Russian translation. Gui fix.
[qstardict] / qstardict / dictwidget.h
1 /*****************************************************************************
2  * dictwidget.h - QStarDict, a StarDict clone written with using Qt          *
3  * Copyright (C) 2007 Alexander Rodin                                        *
4  *                                                                           *
5  * This program 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 2 of the License, or         *
8  * (at your option) any later version.                                       *
9  *                                                                           *
10  * This program 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 along   *
16  * with this program; if not, write to the Free Software Foundation, Inc.,   *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.               *
18  *****************************************************************************/
19
20 #ifndef DICTWIDGET_H
21 #define DICTWIDGET_H
22
23 #include <QFrame>
24
25 #include "dictcore.h"
26 #include "dictbrowser.h"
27
28 class QToolBar;
29 class QAction;
30
31 namespace QStarDict
32 {
33
34 /**
35  * The DictBrowser widget provides view of translations from given dictionary.
36  */
37 class DictWidget: public QFrame
38 {
39     Q_OBJECT
40
41     public:
42         /**
43          * Construct empty DictWidget.
44          */
45         DictWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
46
47         /**
48          * Set source dictionary.
49          * Warning: DictWidget will copy only a pointer to dict. So set dictionaries
50          * allocated from heap and don't destroy it befor DictWidget.
51          */
52         void setDict(DictCore *dict)
53         { m_translationView->setDict(dict); }
54         /**
55          * Return pointer to dictionary.
56          */
57         const DictCore* dict() const
58         { return m_translationView->dict(); }
59         /**
60          * Clear translation text.
61          */
62         void clear()
63         { m_translationView->clear(); }
64
65         /**
66          * Clear history.
67          */
68         void clearHistory()
69         { m_translationView->clearHistory(); }
70         
71         /**
72          * Show translation of str.
73          */
74         void translate(const QString &str);
75         /**
76          * Return last translated word.
77          */
78         QString translatedWord() const
79         { return m_translationView->source().toString(QUrl::RemoveScheme); }
80
81         /**
82          * Return toolbar.
83          */
84         QToolBar *toolBar()
85         { return m_toolBar; }
86
87         void setDefaultStyleSheet(const QString &css);
88
89         QString defaultStyleSheet() const
90         { return m_translationView->document()->defaultStyleSheet(); }
91         
92         void reload()
93         { m_translationView->reload(); }
94
95         void toggleToolBar(bool CheckedState);
96
97     signals:
98         /**
99          * Emits when translated word is shown.
100          */
101         void wordTranslated(const QString &word);
102
103     private slots:
104         void on_translationView_sourceChanged(const QUrl &name);
105         void saveToFile();
106         void speak();
107         #ifndef MAEMO
108         void print();
109         #endif // MAEMO
110
111     private:
112         DictBrowser *m_translationView;
113         QToolBar *m_toolBar;
114 };
115
116 }
117
118 #endif // DICTWIDGET_H
119
120 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc
121