Changed repo structure
[mdictionary] / src / mdictionary / 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 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
23
24 #ifndef TRANSLATIONWIDGET_H
25 #define TRANSLATIONWIDGET_H
26
27 #include <QWidget>
28 #include <QModelIndex>
29 #include <QtGui>
30 #include "../backbone/backbone.h"
31 #include <QtXml>
32 #include <QXmlQuery>
33 #include "TranslationTextEdit.h"
34 #include <QPropertyAnimation>
35 #include "../../common/GUIInterface.h"
36
37 //! Displays translation of word found in dictionaries
38 /*!
39     Displays many translations of word, formatted as html.
40 */
41 class TranslationWidget : public QScrollArea {
42     Q_OBJECT
43 public:
44     explicit TranslationWidget(QWidget *parent = 0);
45
46 Q_SIGNALS:
47     void search(QString);
48
49 public Q_SLOTS:
50     //! Show widget.
51     void show();
52
53     //! Requests to show translation of word list passed as parameter.
54     void show(QStringList);
55
56     //! Updates users zoom preferences and sends its to backbone to be saved
57     void updateZoom(qreal);
58
59 protected:
60     #ifdef Q_WS_MAEMO_5
61         void keyPressEvent(QKeyEvent *);
62         void hideEvent(QHideEvent *);
63     #endif
64
65 private Q_SLOTS:
66     void searchSelected();
67     #ifdef Q_WS_MAEMO_5
68         void showButtons();
69     #endif
70
71 private:
72     QString XslConversion(QString translation);
73     QToolButton* zoomInToolButton;
74     QToolButton* zoomOutToolButton;
75     TranslationTextEdit *webkit;
76     QString xslt;
77
78     #ifdef Q_WS_MAEMO_5
79         QToolButton* zoomInButton;
80         QToolButton* zoomOutButton;
81         QToolButton* selectAllButton;
82         QToolButton* copyButton;
83         QToolButton* searchButton;
84         QToolButton* showButtonsButton;
85
86         QPropertyAnimation* zoomInButtonAnimation;
87         QPropertyAnimation* zoomOutButtonAnimation;
88         QPropertyAnimation* copyButtonAnimation;
89         QPropertyAnimation* selectAllButtonAnimation;
90         QPropertyAnimation* searchButtonAnimation;
91         QAnimationGroup* buttonsAnimation;
92
93         void initButtons();
94         bool buttonsInitialized;
95         bool buttonsVisible;
96
97         void grabZoomKeys(bool);
98     #endif
99
100     QVBoxLayout *verticalLayout;
101     QHBoxLayout* horizontalLayout;
102     GUIInterface* guiinterface;
103
104     void initializeUI();
105 };
106
107 #endif // TRANSLATIONWIDGET_H