Merge branch 'gui'
[mdictionary] / trunk / src / base / gui / TranslationWidget.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21 //! \file TranslationWidget.h
22 //! \brief Implements translation widget
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
24
25 #ifndef TRANSLATIONWIDGET_H
26 #define TRANSLATIONWIDGET_H
27
28 #include <QWidget>
29 #include <QModelIndex>
30 #include <QtGui>
31 #include "../backbone/backbone.h"
32 #include "TranslationWidgetAutoResizer.h"
33 #include "TranslationTextEdit.h"
34 #include <QPropertyAnimation>
35
36 //! Displays translation of word found in dictionaries
37 /*!
38     Display many translation of word, formatted as html.
39 */
40 class TranslationWidget : public QScrollArea {
41     Q_OBJECT
42 public:
43     explicit TranslationWidget(QWidget *parent = 0);
44
45 Q_SIGNALS:
46     void updateSize();
47
48     void search(QString);
49
50 public Q_SLOTS:
51     //! Show widget.
52     void show();
53
54     //! Request to show translation of word list passed as parameter.
55     void show(QStringList);
56
57 protected:
58     #ifdef Q_WS_MAEMO_5
59         void keyPressEvent(QKeyEvent *);
60     #endif
61
62 private Q_SLOTS:
63     void searchSelected();
64     #ifdef Q_WS_MAEMO_5
65         void showButtons(bool);
66     #endif
67
68 private:
69     TranslationTextEdit *textEdit;
70     #ifdef Q_WS_MAEMO_5
71         QToolButton* zoomInButton;
72         QToolButton* zoomOutButton;
73         QToolButton* selectAllButton;
74         QToolButton* copyButton;
75         QToolButton* searchButton;
76         QToolButton* showButtonsButton;
77
78         QPropertyAnimation* zoomInButtonAnimation;
79         QPropertyAnimation* zoomOutButtonAnimation;
80         QPropertyAnimation* copyButtonAnimation;
81         QPropertyAnimation* selectAllButtonAnimation;
82         QPropertyAnimation* searchButtonAnimation;
83         QAnimationGroup* buttonsAnimation;
84
85         void initButtons();
86         bool buttonsInitialized;
87         bool buttonsVisible;
88
89         void grabZoomKeys(bool);
90     #endif
91     QVBoxLayout *verticalLayout;
92     QHBoxLayout* horizontalLayout;
93     TranslationWidgetAutoResizer* resizer;
94
95     void initializeUI();
96 };
97
98 #endif // TRANSLATIONWIDGET_H