Russian translation. Gui fix.
[qstardict] / qstardict / mainwindow.h
1 /*****************************************************************************
2  * mainwindow.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 MAINWINDOW_H
21 #define MAINWINDOW_H
22
23 #include "ui_mainwindow.h"
24
25 class QMenu;
26 class QCloseEvent;
27
28 namespace QStarDict {
29
30 class DictCore;
31 class SettingsDialog;
32
33 /**
34  * The main window of QStarDict.
35  */
36 class MainWindow: public QMainWindow, private Ui::MainWindow
37 {
38     Q_OBJECT
39
40     public:
41         /**
42          * Create new MainWindow.
43          */
44         MainWindow(QWidget *parent = 0);
45         /**
46          * Destructor.
47          */
48         ~MainWindow();
49
50         /**
51          * Return true if instant search is on, otherwise false.
52          */
53         bool isInstantSearch() const
54         { return m_instantSearch; }
55         /**
56          * Set instant search mode. If instantSearch is true
57          * translation will be shown when typing, otherwise only when
58          * "Search" button clicked.
59          */
60         void setInstantSearch(bool instantSearch);
61
62         /**
63          * Set the dictionary.
64          */
65         void setDict(DictCore *dict);
66
67         /**
68          * Return the dictionary.
69          */
70         DictCore *dict() const
71         { return m_dict; }
72
73         /**
74          * Set default style sheet for translations.
75          */
76         void setDefaultStyleSheet(const QString &css)
77         { translationView->setDefaultStyleSheet(css); }
78
79         /**
80          * Return default style sheet.
81          */
82         QString defaultStyleSheet() const
83         { return translationView->defaultStyleSheet(); }
84
85         void reload();
86
87         void saveSettings();
88
89     public slots:
90         /**
91          * Show translation of word.
92          */
93         void showTranslation(const QString &word);
94
95     protected:
96         void timerEvent(QTimerEvent *event);
97         void keyPressEvent(QKeyEvent *event);
98         void closeEvent(QCloseEvent *event);
99
100     private slots:
101         void on_actionAbout_triggered();
102         void on_actionSettings_triggered();
103         void on_actionHelp_triggered();
104         void on_queryButton_clicked();
105         void on_actionToolBar_toggled(bool CheckedState);
106
107         void wordsListItemActivated(QListWidgetItem *item);
108         void wordTranslated(const QString &word);
109         void queryEdited(const QString &);
110
111     private:
112         void createConnections();
113         void loadSettings();
114
115         DictCore *m_dict;
116         bool m_instantSearch;
117         int m_queryTimer;
118 };
119
120 }
121
122 #endif // MAINWINDOW_H
123
124 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc
125