1 /*******************************************************************************
3 This file is part of mDictionary.
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.
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.
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/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
21 //! \file MainWindow.h
22 //! \brief Implements interface for GUI
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
28 #include <QMainWindow>
29 #include "../../includes/GUIInterface.h"
30 #include "../../includes/settings.h"
31 #include "../backbone/backbone.h"
32 #include "TranslationWidget.h"
33 #include "WordListWidget.h"
34 #include "SearchBarWidget.h"
35 #include "MenuWidget.h"
36 #include "DictManagerWidget.h"
37 #include "SettingsWidget.h"
38 #include "HistoryListDialog.h"
39 #include "BookmarksWidget.h"
40 #include "WelcomeScreenWidget.h"
41 #include "AboutWidget.h"
47 //! Implements interface for GUI
49 Create all of GUI subcomponents, and connects all GUI interface signals with
50 suitable backbone signals and slots. Only this class has direct access to
51 backbone object. It manages all request of subcomponents e. g. searching of
52 given word, displaying history, removing dictionary.
53 It also provide data from backbone to subcomponents e. g. result of search.
55 class MainWindow : public GUIInterface
62 \param backbone object which will doing all searches and returns data
63 \param parent parent widget of this window
66 explicit MainWindow(Backbone* backbone, QWidget *parent = 0);
69 //! Returns all loaded dictionaries with infromation about that they are
72 \return Hash of pointers to dictionary and boolean flag indicating if
75 QHash<CommonDictInterface*, bool> getDictionaries();
77 //! Returns all loaded plugins
79 \return List of pointers to plugins
81 QList<CommonDictInterface*> getPlugins();
83 //! Indicates if GUI is in exact search mode.
84 /*! When GUI is in exact search mode it search for word, and
85 if find exacly matching translation it directly displays it, whithout
86 displaying matching word list. This mode is used for browsing search
87 history and search words from application arguments.
88 \returns flag indicating if GUI is in exact search mode
92 //! Sets GUI exact search mode.
93 /*! When GUI is in exact search mode it search for word, and
94 if find exacly matching translation it directly displays it, whithout
95 displaying matching word list. This mode is used for browsing search
96 history and search words from application arguments.
97 \param exactSearch flag indicating if GUI will be in exact search mode
100 void setExactSearch(bool);
102 Settings* settings();
104 void setSettings(Settings*);
108 //! Search in exact mode for given word
110 GUI will be automaticaly set into exact search mode, and after search or
111 break will be unset from exact search mode.
112 \param word which will be searched in dictionaries
114 void searchExact(QString);
117 //! Gets word list from backbone and prepares received list to display
119 Checks if received list is empty, in that case displays suitable
120 information. If GUI is in exact search mode it will search for exact
121 word in received list, and if word is found it will emit signal to
122 display it's translation. Otherwise it will display list of matching
123 words and show suitable information.
125 \sa showTranslation()
127 void wordListReady();
129 //! Gets translation strings from backbone and emit signal to display them
130 void translationsReady();
132 //! Adds to history key words from given translations
134 By default this slot is connected to signal searchTranslations, and
135 passed translation list contains only translation with the same key, so
136 only one word is added to history.
137 \param list of translations with key words
138 \sa searchTranslations()
140 void addToHistory(QList<Translation*>);
142 //! Shows history dialog
145 //! Shows translation of next word in history
147 It will work only if there is available next word in history.
148 Translation of word is searched with searchExact() function
153 //! Shows translation of previous word in history
155 It will work only if there is available previous word in history.
156 Translation of word is searched with searchExact() function
162 //! Sets string for which current search is ongoing, is used to find exact
163 //! word when GUI is in search exact mode.
164 void setSearchString(QString);
166 //! Disables menu when search is ongoing
172 //! When user break searching it make sure that exact search mode will be
174 void breakSearching();
177 void showAllBookmarks();
181 /*! When user wants to close application, we first sends signal to stop all
184 void closeEvent(QCloseEvent *);
194 SearchBarWidget* searchBarWidget;
195 QWidget* translationWidget;
196 QWidget* wordListWidget;
197 MenuWidget* menuWidget;
199 DictManagerWidget* dictManagerWidget;
200 SettingsWidget* settingsWidget;
201 BookmarksWidget* bookmarksWidget;
202 QWidget* welcomeScreenWidget;
203 AboutWidget* aboutWidget;
207 QAction* dictionariesAction;
208 QAction* bookmarksAction;
209 QAction* settingsAction;
210 QAction* aboutAction;
214 QString searchString;
217 void connectBackbone();
218 void connectSearchBar();
219 void connectWordList();
220 void connectTranslationWidget();
221 void connectDictManager();
223 void connectBookmarksWidget();
226 #endif // MAINWINDOW_H