mainwindow.h
1 //------------------------------------------------------------------------------
2 // mainwindow.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; 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 "dptr.h"
28 #include "serverapi/serverptr.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);
51  ~MainWindow() override;
52 
53  DockBuddiesList *buddiesList();
54 
61  void initAutoRefreshTimer();
62 
63  bool isEffectivelyActiveWindow() const;
64 
65  void notifyFirstRun();
66 
77  void setDisplayUpdaterProcessFailure(int errorCode);
88  void setDisplayUpdateInstallerError(int errorCode);
93  void setQueryPluginEnabled(const EnginePlugin *pClient, bool bEnabled);
94 
95  void stopAutoRefreshTimer();
96 
97  void updateMasterAddresses();
98 
99 public slots:
100  void runGame(const ServerPtr &);
101  void showInstallFreedoomDialog();
102  void updateDynamicAppearance();
103 
104 protected:
105  friend class DoomseekerConfigurationDialog;
106 
107  static const QString HELP_SITE_URL;
108 
109  void changeEvent(QEvent *event) override;
110  void checkForUpdates(bool bUserTriggered);
111 
116  void connectEntities();
117 
118  void closeEvent(QCloseEvent *event) override;
119 
130  void fillQueryMenu(MasterManager *masterManager);
131 
136 
137  bool hasCustomServers() const;
138 
139  QProgressBar *mkStdProgressBarForStatusBar();
140 
141  void initAutoUpdaterWidgets();
142  void initIP2CUpdater();
143  void initIRCDock();
144  void initLogDock();
145  void initMainDock();
146  void initServerDetailsDock();
147  void initServerFilterDock();
148 
153  void initTrayIcon();
154 
162  bool isAnythingToRefresh() const;
163  bool isAnyMasterEnabled() const;
164 
165  QueryMenuAction *queryMenuActionForPlugin(const EnginePlugin *plugin);
166 
167  void refreshCustomServers();
168  void refreshServersOnList();
169  void showEvent(QShowEvent *event) override;
170  void setupIcons();
171  void setupToolBar();
172  ServerListCount sumServerListCount() const;
173 
174  void updateTrayIconTooltip(const ServerListCount &count);
175  void updateTrayIconTooltipAndLogTotalRefresh();
176 
177 protected slots:
178  void abortAutoUpdater();
179  void autoRefreshTimer_timeout();
180  void blockRefreshButtons();
185  void checkForUpdatesAuto();
191  void confirmUpdateInstallation();
192  void discardUpdates();
193  void findMissingWADs(const ServerPtr &);
194  void finishedQueryingMaster(MasterClient *master);
195  void getServers();
196  void masterManagerMessages(MasterClient *pSender, const QString &title, const QString &content, bool isError);
197  void masterManagerMessagesImportant(MasterClient *pSender, const Message &objMessage);
198  void menuBuddies();
199  void menuCreateServer();
200  void menuHelpAbout();
201  void menuHelpHelp();
202  void menuIRCOptions();
203  void menuLog();
204  void menuManageDemos();
205  void menuOptionsConfigure();
206  void menuRecordDemo();
207  void menuUpdateIP2C();
208  void menuViewIRC();
209  void menuWadSeeker();
210 
211  void onAutoUpdaterDownloadAndInstallConfirmationRequest();
212  void onAutoUpdaterFileProgress(qint64 bytesReceived, qint64 bytesTotal);
213  void onAutoUpdaterFinish();
214  void onAutoUpdaterOverallProgress(int current, int total, const QString &msg);
215 
216  void quitProgram();
217  void postInitAppStartup();
218  void refreshThreadBeginsWork();
219  void refreshThreadEndsWork();
220  void restartAndInstallUpdatesNow();
221  void serverAddedToList(const ServerPtr &);
222  void showServerJoinCommandLine(const ServerPtr &);
223  void showUpdaterProcessErrorDialog();
224  void showUpdateInstallErrorDialog();
225 
230  void togglePluginQueryEnabled(const EnginePlugin *plugin);
231  void toolBarAction(QAction *pAction);
232  void trayIcon_activated(QSystemTrayIcon::ActivationReason reason);
233  void updateServerFilter(const ServerListFilterInfo &filterInfo);
234  void updateRefreshProgress();
235 
236 private:
238 
239  void connectIP2CLoader();
240  void fixIconsDpi();
241 
242 private slots:
243  void ip2cDownloadProgress(qint64 current, qint64 max);
244  void ip2cJobsFinished();
245  void ip2cStartUpdate();
246  void showAndLogStatusMessage(const QString &message);
247  void showServerJoinCommandLineOnBuilderFinished();
248  void showProgramArgsHelp();
249 };
250 
251 #endif