752abd341f25375ee6406964a7fb9f70101e7d82
[qstardict] / qstardict / application.h
1 /*****************************************************************************
2  * application.h - QStarDict, a StarDict clone written using Qt              *
3  * Copyright (C) 2008 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 APPLICATION_H
21 #define APPLICATION_H
22
23 #include <QApplication>
24
25 #ifdef QSTARDICT_WITH_TRANSLATIONS
26 class QTranslator;
27 #endif // QSTARDICT_WITH_TRANSLATIONS
28
29 namespace QStarDict
30 {
31 class DictCore;
32 class MainWindow;
33 class PopupWindow;
34 class Speaker;
35 #ifndef MAEMO
36 class TrayIcon;
37 #endif // MAEMO
38 #ifdef QSTARDICT_WITH_DBUS
39 class DBusAdaptor;
40 #endif // QSTARDICT_WITH_DBUS
41
42 /**
43  * Main application class.
44  */
45 class Application: public QApplication
46 {
47     Q_OBJECT
48
49     public:
50         /**
51          * Construct new QStarDict application.
52          */
53         Application(int &argc, char **argv);
54
55         /**
56          * Destructor.
57          */
58         ~Application();
59
60         /**
61          * Enter the main event loop and wait until exit().
62          */
63         int exec();
64
65         /**
66          * Returns a pointer to the application's QStarDict::Application instance.
67          */
68         static Application *instance()
69         { return qobject_cast<Application*>(QCoreApplication::instance()); }
70
71         /**
72          * Returns a pointer to the DictCore instance.
73          */
74         DictCore *dictCore()
75         { return m_dictCore; }
76         /**
77          * Returns a pointer to the application's main window.
78          */
79         MainWindow *mainWindow()
80         { return m_mainWindow; }
81
82         /**
83          * Returns a pointer to the application's popup window.
84          */
85         PopupWindow *popupWindow()
86         { return m_popupWindow; }
87
88         /**
89          * Returns a pointer to the application's speacker.
90          */
91         Speaker *speaker()
92         { return m_speaker; }
93
94         /**
95          * Returns a pointer to the tray icon.
96          */
97         #ifndef MAEMO
98         TrayIcon *trayIcon()
99         { return m_trayIcon; }
100         #endif // MAEMO
101 #ifdef QSTARDICT_WITH_DBUS
102         /**
103          * Returns a pointer to the DBusAdaptor instance.
104          */
105         DBusAdaptor *dbusAdaptor()
106         { return m_dbusAdaptor; }
107 #endif // QSTARDICT_WITH_DBUS
108     private:
109 #ifdef QSTARDICT_WITH_TRANSLATIONS
110         QTranslator *m_translator;
111         QTranslator *m_qtTranslator;
112 #endif // QSTARDICT_WITH_TRANSLATIONS
113         DictCore *m_dictCore;
114         MainWindow *m_mainWindow;
115         PopupWindow *m_popupWindow;
116         Speaker *m_speaker;
117         #ifndef MAEMO
118         TrayIcon *m_trayIcon;
119         #endif // MAEMO
120 #ifdef QSTARDICT_WITH_DBUS
121         DBusAdaptor *m_dbusAdaptor;
122 #endif // QSTARDICT_WITH_DBUS
123
124         QString commandLineText();
125 };
126
127 }
128
129 #endif // APPLICATION_H
130
131 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent
132