Prevent WebUI tables from being highlighted
[qBittorrent.git] / src / app / application.h
bloba36d72721d053c42d64275a245e064ec53f552a8
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
30 #ifndef APPLICATION_H
31 #define APPLICATION_H
33 #include <QPointer>
34 #include <QStringList>
35 #include <QTranslator>
37 #ifndef DISABLE_GUI
38 #include "qtsingleapplication.h"
39 typedef QtSingleApplication BaseApplication;
40 class MainWindow;
42 #ifdef Q_OS_WIN
43 class QSessionManager;
44 #endif // Q_OS_WIN
46 #else
47 #include "qtsinglecoreapplication.h"
48 typedef QtSingleCoreApplication BaseApplication;
49 #endif // DISABLE_GUI
51 #include "base/utils/misc.h"
52 #include "cmdoptions.h"
54 #ifndef DISABLE_WEBUI
55 class WebUI;
56 #endif
58 class FileLogger;
60 namespace BitTorrent
62 class TorrentHandle;
65 namespace RSS
67 class Session;
68 class AutoDownloader;
71 class Application : public BaseApplication
73 Q_OBJECT
74 Q_DISABLE_COPY(Application)
76 public:
77 Application(const QString &id, int &argc, char **argv);
78 ~Application() override;
80 #if (defined(Q_OS_WIN) && !defined(DISABLE_GUI))
81 bool isRunning();
82 #endif
83 int exec(const QStringList &params);
84 bool sendParams(const QStringList &params);
86 #ifndef DISABLE_GUI
87 QPointer<MainWindow> mainWindow();
88 #endif
90 const QBtCommandLineParameters &commandLineArgs() const;
92 // FileLogger properties
93 bool isFileLoggerEnabled() const;
94 void setFileLoggerEnabled(bool value);
95 QString fileLoggerPath() const;
96 void setFileLoggerPath(const QString &path);
97 bool isFileLoggerBackup() const;
98 void setFileLoggerBackup(bool value);
99 bool isFileLoggerDeleteOld() const;
100 void setFileLoggerDeleteOld(bool value);
101 int fileLoggerMaxSize() const;
102 void setFileLoggerMaxSize(const int bytes);
103 int fileLoggerAge() const;
104 void setFileLoggerAge(const int value);
105 int fileLoggerAgeType() const;
106 void setFileLoggerAgeType(const int value);
108 protected:
109 #ifndef DISABLE_GUI
110 #ifdef Q_OS_MAC
111 bool event(QEvent *) override;
112 #endif
113 bool notify(QObject *receiver, QEvent *event) override;
114 #endif
116 private slots:
117 void processMessage(const QString &message);
118 void torrentFinished(BitTorrent::TorrentHandle *const torrent);
119 void allTorrentsFinished();
120 void cleanup();
121 #if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
122 void shutdownCleanup(QSessionManager &manager);
123 #endif
125 private:
126 bool m_running;
127 ShutdownDialogAction m_shutdownAct;
128 QBtCommandLineParameters m_commandLineArgs;
130 #ifndef DISABLE_GUI
131 QPointer<MainWindow> m_window;
132 #endif
134 #ifndef DISABLE_WEBUI
135 WebUI *m_webui;
136 #endif
138 // FileLog
139 QPointer<FileLogger> m_fileLogger;
141 QTranslator m_qtTranslator;
142 QTranslator m_translator;
143 QStringList m_paramsQueue;
145 void initializeTranslation();
146 void processParams(const QStringList &params);
147 void runExternalProgram(const BitTorrent::TorrentHandle *torrent) const;
148 void sendNotificationEmail(const BitTorrent::TorrentHandle *torrent);
149 void validateCommandLineParameters();
152 #endif // APPLICATION_H