mainwindow.h
1 //------------------------------------------------------------------------------
2 // mainwindow.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (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
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __MAINWINDOW_H_
25 #define __MAINWINDOW_H_
26 
27 #include "serverapi/serverptr.h"
28 #include "dptr.h"
29 
30 #include <QMainWindow>
31 #include <QSystemTrayIcon>
32 
33 class DockBuddiesList;
35 class EnginePlugin;
36 class IP2CLoader;
37 class MasterClient;
38 class MasterManager;
39 class Message;
40 class QProgressBar;
41 class QueryMenuAction;
43 struct ServerListCount;
44 
45 class MainWindow : public QMainWindow
46 {
47  Q_OBJECT
48 
49  public:
50  MainWindow(QApplication* application, int argc, char** argv);
51  ~MainWindow();
52 
53  DockBuddiesList *buddiesList();
54 
61  void initAutoRefreshTimer();
62 
63  void notifyFirstRun();
64 
75  void setDisplayUpdaterProcessFailure(int errorCode);
86  void setDisplayUpdateInstallerError(int errorCode);
91  void setQueryPluginEnabled(const EnginePlugin* pClient, bool bEnabled);
92 
93  void stopAutoRefreshTimer();
94 
95  void updateMasterAddresses();
96 
97  public slots:
98  void runGame(const ServerPtr&);
99  void showInstallFreedoomDialog();
100 
101  protected:
102  friend class DoomseekerConfigurationDialog;
103 
104  static const QString HELP_SITE_URL;
105 
106  void changeEvent(QEvent* event);
107  void checkForUpdates(bool bUserTriggered);
108 
113  void connectEntities();
114 
115  void closeEvent(QCloseEvent* event);
116 
127  void fillQueryMenu(MasterManager* masterManager);
128 
133 
134  bool hasCustomServers() const;
135 
136  QProgressBar* mkStdProgressBarForStatusBar();
137 
138  void initAutoUpdaterWidgets();
139  void initIP2CUpdater();
140  void initIRCDock();
141  void initLogDock();
142  void initMainDock();
143  void initServerDetailsDock();
144  void initServerFilterDock();
145 
150  void initTrayIcon();
151 
159  bool isAnythingToRefresh() const;
160  bool isAnyMasterEnabled() const;
161 
162  QueryMenuAction* queryMenuActionForPlugin(const EnginePlugin *plugin);
163 
164  void refreshCustomServers();
165  void refreshLanServers();
166  void showEvent(QShowEvent *event);
167  void setupIcons();
168  void setupToolBar();
169  ServerListCount sumServerListCount() const;
170 
171  void updateTrayIconTooltip(const ServerListCount &count);
172  void updateTrayIconTooltipAndLogTotalRefresh();
173 
174  protected slots:
175  void abortAutoUpdater();
176  void autoRefreshTimer_timeout();
177  void blockRefreshButtons();
182  void checkForUpdatesAuto();
188  void confirmUpdateInstallation();
189  void discardUpdates();
190  void findMissingWADs(const ServerPtr&);
191  void finishedQueryingMaster(MasterClient* master);
192  void getServers();
193  void masterManagerMessages(MasterClient* pSender, const QString& title, const QString& content, bool isError);
194  void masterManagerMessagesImportant(MasterClient* pSender, const Message& objMessage);
195  void menuBuddies();
196  void menuCreateServer();
197  void menuHelpAbout();
198  void menuHelpHelp();
199  void menuIRCOptions();
200  void menuLog();
201  void menuManageDemos();
202  void menuOptionsConfigure();
203  void menuRecordDemo();
204  void menuUpdateIP2C();
205  void menuViewIRC();
206  void menuWadSeeker();
207 
208  void onAutoUpdaterDownloadAndInstallConfirmationRequest();
209  void onAutoUpdaterFileProgress(qint64 bytesReceived, qint64 bytesTotal);
210  void onAutoUpdaterFinish();
211  void onAutoUpdaterOverallProgress(int current, int total, const QString& msg);
212 
213  void quitProgram();
214  void postInitAppStartup();
215  void refreshThreadBeginsWork();
216  void refreshThreadEndsWork();
217  void restartAndInstallUpdatesNow();
218  void serverAddedToList(const ServerPtr&);
219  void showServerJoinCommandLine(const ServerPtr&);
220  void showUpdaterProcessErrorDialog();
221  void showUpdateInstallErrorDialog();
222 
227  void togglePluginQueryEnabled(const EnginePlugin* plugin);
228  void toolBarAction(QAction* pAction);
229  void trayIcon_activated(QSystemTrayIcon::ActivationReason reason);
230  void updateServerFilter(const ServerListFilterInfo& filterInfo);
231  void updateRefreshProgress();
232 
233  private:
235 
236  void connectIP2CLoader(IP2CLoader* loader);
237  void fixIconsDpi();
238 
239  private slots:
240  void ip2cDownloadProgress(qint64 current, qint64 max);
241  void ip2cJobsFinished();
242  void ip2cStartUpdate();
243  void showAndLogStatusMessage(const QString &message);
244  void showServerJoinCommandLineOnBuilderFinished();
245  void showProgramArgsHelp();
246 };
247 
248 #endif
void initTrayIcon()
Definition: mainwindow.cpp:932
Structure describing server filter.
void checkForUpdatesAuto()
Auto triggered updates will display install confirmation only if configured to.
Definition: mainwindow.cpp:479
void togglePluginQueryEnabled(const EnginePlugin *plugin)
Message object used to pass messages throughout the Doomseeker&#39;s system.
Definition: message.h:63
void finishConfiguration(DoomseekerConfigurationDialog &, bool)
Definition: mainwindow.cpp:672
void setQueryPluginEnabled(const EnginePlugin *pClient, bool bEnabled)
Sets query for selected MasterClient object to enabled or disabled.
void checkForUpdatesUserTriggered()
User triggered updates will always display install confirmation.
Definition: mainwindow.cpp:485
void setDisplayUpdaterProcessFailure(int errorCode)
This should be set if program was started with "--update-failed" argument.
bool isAnythingToRefresh() const
Will check if refresh operation has any sense.
void fillQueryMenu(MasterManager *masterManager)
Definition: mainwindow.cpp:573
Manager class for a number of MasterClient instances.
Definition: mastermanager.h:38
void setDisplayUpdateInstallerError(int errorCode)
If set then MainWindow will display the reason for updater failure.
void connectEntities()
Definition: mainwindow.cpp:536
Abstract base for all MasterClients.
Definition: masterclient.h:49
void initAutoRefreshTimer()
Definition: mainwindow.cpp:785