Sync translations from Transifex and run lupdate
[qBittorrent.git] / src / app / application.h
blob1edf83e3f1e6e7cdf010e1cfc87eaa7d122722ed
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2015, 2019 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 #pragma once
32 #include <QPointer>
33 #include <QStringList>
34 #include <QTranslator>
36 #ifndef DISABLE_GUI
37 #include <QApplication>
38 using BaseApplication = QApplication;
39 class MainWindow;
41 #ifdef Q_OS_WIN
42 class QSessionManager;
43 #endif // Q_OS_WIN
45 #else
46 #include <QCoreApplication>
47 using BaseApplication = QCoreApplication;
48 #endif // DISABLE_GUI
50 #include "base/path.h"
51 #include "base/settingvalue.h"
52 #include "base/types.h"
53 #include "cmdoptions.h"
55 #ifndef DISABLE_WEBUI
56 class WebUI;
57 #endif
59 class ApplicationInstanceManager;
60 class FileLogger;
62 namespace BitTorrent
64 class Torrent;
67 namespace RSS
69 class Session;
70 class AutoDownloader;
73 class Application final : public BaseApplication
75 Q_OBJECT
76 Q_DISABLE_COPY_MOVE(Application)
78 public:
79 Application(int &argc, char **argv);
80 ~Application() override;
82 bool isRunning();
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 #ifdef Q_OS_WIN
93 int memoryWorkingSetLimit() const;
94 void setMemoryWorkingSetLimit(int size);
95 #endif
97 // FileLogger properties
98 bool isFileLoggerEnabled() const;
99 void setFileLoggerEnabled(bool value);
100 Path fileLoggerPath() const;
101 void setFileLoggerPath(const Path &path);
102 bool isFileLoggerBackup() const;
103 void setFileLoggerBackup(bool value);
104 bool isFileLoggerDeleteOld() const;
105 void setFileLoggerDeleteOld(bool value);
106 int fileLoggerMaxSize() const;
107 void setFileLoggerMaxSize(int bytes);
108 int fileLoggerAge() const;
109 void setFileLoggerAge(int value);
110 int fileLoggerAgeType() const;
111 void setFileLoggerAgeType(int value);
113 protected:
114 #ifndef DISABLE_GUI
115 #ifdef Q_OS_MACOS
116 bool event(QEvent *) override;
117 #endif
118 #endif
120 private slots:
121 void processMessage(const QString &message);
122 void torrentFinished(BitTorrent::Torrent *const torrent);
123 void allTorrentsFinished();
124 void cleanup();
125 #if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
126 void shutdownCleanup(QSessionManager &manager);
127 #endif
129 private:
130 #ifdef Q_OS_WIN
131 void applyMemoryWorkingSetLimit();
132 #endif
133 void initializeTranslation();
134 void processParams(const QStringList &params);
135 void runExternalProgram(const BitTorrent::Torrent *torrent) const;
136 void sendNotificationEmail(const BitTorrent::Torrent *torrent);
138 ApplicationInstanceManager *m_instanceManager = nullptr;
139 bool m_running;
140 ShutdownDialogAction m_shutdownAct;
141 QBtCommandLineParameters m_commandLineArgs;
143 #ifndef DISABLE_GUI
144 QPointer<MainWindow> m_window;
145 #endif
147 #ifndef DISABLE_WEBUI
148 WebUI *m_webui = nullptr;
149 #endif
151 // FileLog
152 QPointer<FileLogger> m_fileLogger;
154 QTranslator m_qtTranslator;
155 QTranslator m_translator;
156 QStringList m_paramsQueue;
158 #ifdef Q_OS_WIN
159 SettingValue<int> m_storeMemoryWorkingSetLimit;
160 #endif
161 SettingValue<bool> m_storeFileLoggerEnabled;
162 SettingValue<bool> m_storeFileLoggerBackup;
163 SettingValue<bool> m_storeFileLoggerDeleteOld;
164 SettingValue<int> m_storeFileLoggerMaxSize;
165 SettingValue<int> m_storeFileLoggerAge;
166 SettingValue<int> m_storeFileLoggerAgeType;
167 SettingValue<Path> m_storeFileLoggerPath;