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 IP2CLoader;
36 class MasterClient;
37 class MasterManager;
38 class Message;
39 class QProgressBar;
40 class QQueryMenuAction;
42 
43 class MainWindow : public QMainWindow
44 {
45  Q_OBJECT
46 
47  public:
48  MainWindow(QApplication* application, int argc, char** argv);
49  ~MainWindow();
50 
51  DockBuddiesList *buddiesList();
52 
59  void initAutoRefreshTimer();
60 
61  void notifyFirstRun();
62 
73  void setDisplayUpdaterProcessFailure(int errorCode);
84  void setDisplayUpdateInstallerError(int errorCode);
89  void setQueryMasterServerEnabled(MasterClient* pClient, bool bEnabled);
90 
91  void stopAutoRefreshTimer();
92 
93  void updateMasterAddresses();
94 
95  public slots:
96  void runGame(const ServerPtr&);
97 
98  protected:
99  friend class DoomseekerConfigurationDialog;
100 
101  static const QString HELP_SITE_URL;
102 
103  void changeEvent(QEvent* event);
104  void checkForUpdates(bool bUserTriggered);
105 
110  void connectEntities();
111 
112  void closeEvent(QCloseEvent* event);
113 
124  void fillQueryMenu(MasterManager* masterManager);
125 
130 
131  bool hasCustomServers() const;
132 
133  QProgressBar* mkStdProgressBarForStatusBar();
134 
135  void initAutoUpdaterWidgets();
136  void initIP2CUpdater();
137  void initIRCDock();
138  void initLogDock();
139  void initMainDock();
140  void initServerDetailsDock();
141  void initServerFilterDock();
142 
147  void initTrayIcon();
148 
156  bool isAnythingToRefresh() const;
157  bool isAnyMasterEnabled() const;
158 
159  QQueryMenuAction* queryMenuActionForMasterClient(MasterClient* pClient);
160 
161  void refreshCustomServers();
162  void setupIcons();
163  void setupToolBar();
164 
170 
171  protected slots:
172  void abortAutoUpdater();
173  void autoRefreshTimer_timeout();
174  void blockRefreshButtons();
179  void checkForUpdatesAuto();
185  void confirmUpdateInstallation();
186  void discardUpdates();
187  void findMissingWADs(const ServerPtr&);
188  void finishedQueryingMaster(MasterClient* master);
189  void getServers();
190  void masterManagerMessages(MasterClient* pSender, const QString& title, const QString& content, bool isError);
191  void masterManagerMessagesImportant(MasterClient* pSender, const Message& objMessage);
192  void menuBuddies();
193  void menuCreateServer();
194  void menuHelpAbout();
195  void menuHelpHelp();
196  void menuIRCOptions();
197  void menuLog();
198  void menuManageDemos();
199  void menuOptionsConfigure();
200  void menuRecordDemo();
201  void menuUpdateIP2C();
202  void menuViewIRC();
203  void menuWadSeeker();
204 
205  void onAutoUpdaterDownloadAndInstallConfirmationRequest();
206  void onAutoUpdaterFileProgress(qint64 bytesReceived, qint64 bytesTotal);
207  void onAutoUpdaterFinish();
208  void onAutoUpdaterOverallProgress(int current, int total, const QString& msg);
209 
210  void quitProgram();
211  void postInitAppStartup();
212  void refreshThreadBeginsWork();
213  void refreshThreadEndsWork();
214  void restartAndInstallUpdatesNow();
215  void serverAddedToList(const ServerPtr&);
216  void showServerJoinCommandLine(const ServerPtr&);
217  void showUpdaterProcessErrorDialog();
218  void showUpdateInstallErrorDialog();
219 
227  void toolBarAction(QAction* pAction);
228  void trayIcon_activated(QSystemTrayIcon::ActivationReason reason);
229  void updateServerFilter(const ServerListFilterInfo& filterInfo);
230 
231  private:
233 
234  void connectIP2CLoader(IP2CLoader* loader);
235 
236  private slots:
237  void ip2cDownloadProgress(qint64 current, qint64 max);
238  void ip2cJobsFinished();
239  void ip2cStartUpdate();
240  void showAndLogStatusMessage(const QString &message);
241  void showServerJoinCommandLineOnBuilderFinished();
242  void showProgramArgsHelp();
243 };
244 
245 #endif
void initTrayIcon()
Definition: mainwindow.cpp:881
void setQueryMasterServerEnabled(MasterClient *pClient, bool bEnabled)
Sets query for selected MasterClient object to enabled or disabled.
Structure describing server filter.
void checkForUpdatesAuto()
Auto triggered updates will display install confirmation only if configured to.
Definition: mainwindow.cpp:453
void updateTrayIconTooltipAndLogTotalRefresh()
Message object used to pass messages throughout the Doomseeker's system.
Definition: message.h:62
void finishConfiguration(DoomseekerConfigurationDialog &, bool)
Definition: mainwindow.cpp:628
void toggleMasterClientEnabled(MasterClient *pClient)
Toggles specified MasterClient object enabled or disabled.
void checkForUpdatesUserTriggered()
User triggered updates will always display install confirmation.
Definition: mainwindow.cpp:459
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.
Definition: mainwindow.cpp:952
void fillQueryMenu(MasterManager *masterManager)
Definition: mainwindow.cpp:547
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:510
Abstract base for all MasterClients.
Definition: masterclient.h:49
void initAutoRefreshTimer()
Definition: mainwindow.cpp:734