mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
parent
dc22109fa7
commit
a2b85ba1fd
@ -29,8 +29,6 @@
|
|||||||
|
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
@ -82,7 +80,6 @@
|
|||||||
#include "base/torrentfileswatcher.h"
|
#include "base/torrentfileswatcher.h"
|
||||||
#include "base/utils/compare.h"
|
#include "base/utils/compare.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/path.h"
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/version.h"
|
#include "base/version.h"
|
||||||
#include "applicationinstancemanager.h"
|
#include "applicationinstancemanager.h"
|
||||||
@ -90,10 +87,10 @@
|
|||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include "gui/addnewtorrentdialog.h"
|
#include "gui/addnewtorrentdialog.h"
|
||||||
#include "gui/uithememanager.h"
|
|
||||||
#include "gui/utils.h"
|
|
||||||
#include "gui/mainwindow.h"
|
#include "gui/mainwindow.h"
|
||||||
#include "gui/shutdownconfirmdialog.h"
|
#include "gui/shutdownconfirmdialog.h"
|
||||||
|
#include "gui/uithememanager.h"
|
||||||
|
#include "gui/utils.h"
|
||||||
#endif // DISABLE_GUI
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
#ifndef DISABLE_WEBUI
|
#ifndef DISABLE_WEBUI
|
||||||
@ -121,12 +118,8 @@ namespace
|
|||||||
|
|
||||||
Application::Application(int &argc, char **argv)
|
Application::Application(int &argc, char **argv)
|
||||||
: BaseApplication(argc, argv)
|
: BaseApplication(argc, argv)
|
||||||
, m_running(false)
|
|
||||||
, m_shutdownAct(ShutdownDialogAction::Exit)
|
, m_shutdownAct(ShutdownDialogAction::Exit)
|
||||||
, m_commandLineArgs(parseCommandLine(this->arguments()))
|
, m_commandLineArgs(parseCommandLine(this->arguments()))
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
, m_storeMemoryWorkingSetLimit(SETTINGS_KEY(u"MemoryWorkingSetLimit"_qs))
|
|
||||||
#endif
|
|
||||||
, m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_qs))
|
, m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_qs))
|
||||||
, m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_qs))
|
, m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_qs))
|
||||||
, m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_qs))
|
, m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_qs))
|
||||||
@ -134,6 +127,9 @@ Application::Application(int &argc, char **argv)
|
|||||||
, m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY(u"Age"_qs))
|
, m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY(u"Age"_qs))
|
||||||
, m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY(u"AgeType"_qs))
|
, m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY(u"AgeType"_qs))
|
||||||
, m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY(u"Path"_qs))
|
, m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY(u"Path"_qs))
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
, m_storeMemoryWorkingSetLimit(SETTINGS_KEY(u"MemoryWorkingSetLimit"_qs))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Log::Msg>("Log::Msg");
|
qRegisterMetaType<Log::Msg>("Log::Msg");
|
||||||
qRegisterMetaType<Log::Peer>("Log::Peer");
|
qRegisterMetaType<Log::Peer>("Log::Peer");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2022 Mike Tzou (Chocobo1)
|
||||||
* Copyright (C) 2015, 2019 Vladimir Golovnev <glassez@yandex.ru>
|
* Copyright (C) 2015, 2019 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
* Copyright (C) 2006 Christophe Dumez
|
* Copyright (C) 2006 Christophe Dumez
|
||||||
*
|
*
|
||||||
@ -29,31 +30,24 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
using BaseApplication = QApplication;
|
#endif
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
class QSessionManager;
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <QCoreApplication>
|
|
||||||
using BaseApplication = QCoreApplication;
|
|
||||||
#endif // DISABLE_GUI
|
|
||||||
|
|
||||||
|
#include "base/interfaces/iapplication.h"
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
#include "base/settingvalue.h"
|
#include "base/settingvalue.h"
|
||||||
#include "base/types.h"
|
#include "base/types.h"
|
||||||
#include "cmdoptions.h"
|
#include "cmdoptions.h"
|
||||||
|
|
||||||
#ifndef DISABLE_WEBUI
|
#ifndef DISABLE_GUI
|
||||||
class WebUI;
|
#include "gui/interfaces/iguiapplication.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ApplicationInstanceManager;
|
class ApplicationInstanceManager;
|
||||||
@ -70,7 +64,25 @@ namespace RSS
|
|||||||
class AutoDownloader;
|
class AutoDownloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Application final : public BaseApplication
|
#ifndef DISABLE_GUI
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
using BaseApplication = QApplication;
|
||||||
|
using BaseIApplication = IGUIApplication;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
class QSessionManager;
|
||||||
|
#endif
|
||||||
|
#else // DISABLE_GUI
|
||||||
|
using BaseApplication = QCoreApplication;
|
||||||
|
using BaseIApplication = IApplication;
|
||||||
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
|
#ifndef DISABLE_WEBUI
|
||||||
|
class WebUI;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class Application final : public BaseApplication, public BaseIApplication
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY_MOVE(Application)
|
Q_DISABLE_COPY_MOVE(Application)
|
||||||
@ -79,42 +91,35 @@ public:
|
|||||||
Application(int &argc, char **argv);
|
Application(int &argc, char **argv);
|
||||||
~Application() override;
|
~Application() override;
|
||||||
|
|
||||||
bool isRunning();
|
|
||||||
int exec(const QStringList ¶ms);
|
int exec(const QStringList ¶ms);
|
||||||
|
|
||||||
|
bool isRunning();
|
||||||
bool sendParams(const QStringList ¶ms);
|
bool sendParams(const QStringList ¶ms);
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
|
||||||
QPointer<MainWindow> mainWindow();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const QBtCommandLineParameters &commandLineArgs() const;
|
const QBtCommandLineParameters &commandLineArgs() const;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
int memoryWorkingSetLimit() const;
|
|
||||||
void setMemoryWorkingSetLimit(int size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// FileLogger properties
|
// FileLogger properties
|
||||||
bool isFileLoggerEnabled() const;
|
bool isFileLoggerEnabled() const override;
|
||||||
void setFileLoggerEnabled(bool value);
|
void setFileLoggerEnabled(bool value) override;
|
||||||
Path fileLoggerPath() const;
|
Path fileLoggerPath() const override;
|
||||||
void setFileLoggerPath(const Path &path);
|
void setFileLoggerPath(const Path &path) override;
|
||||||
bool isFileLoggerBackup() const;
|
bool isFileLoggerBackup() const override;
|
||||||
void setFileLoggerBackup(bool value);
|
void setFileLoggerBackup(bool value) override;
|
||||||
bool isFileLoggerDeleteOld() const;
|
bool isFileLoggerDeleteOld() const override;
|
||||||
void setFileLoggerDeleteOld(bool value);
|
void setFileLoggerDeleteOld(bool value) override;
|
||||||
int fileLoggerMaxSize() const;
|
int fileLoggerMaxSize() const override;
|
||||||
void setFileLoggerMaxSize(int bytes);
|
void setFileLoggerMaxSize(int bytes) override;
|
||||||
int fileLoggerAge() const;
|
int fileLoggerAge() const override;
|
||||||
void setFileLoggerAge(int value);
|
void setFileLoggerAge(int value) override;
|
||||||
int fileLoggerAgeType() const;
|
int fileLoggerAgeType() const override;
|
||||||
void setFileLoggerAgeType(int value);
|
void setFileLoggerAgeType(int value) override;
|
||||||
|
|
||||||
protected:
|
#ifdef Q_OS_WIN
|
||||||
#ifndef DISABLE_GUI
|
int memoryWorkingSetLimit() const override;
|
||||||
#ifdef Q_OS_MACOS
|
void setMemoryWorkingSetLimit(int size) override;
|
||||||
bool event(QEvent *) override;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_GUI
|
||||||
|
QPointer<MainWindow> mainWindow() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -122,31 +127,30 @@ private slots:
|
|||||||
void torrentFinished(BitTorrent::Torrent *const torrent);
|
void torrentFinished(BitTorrent::Torrent *const torrent);
|
||||||
void allTorrentsFinished();
|
void allTorrentsFinished();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
#if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
|
#if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
|
||||||
void shutdownCleanup(QSessionManager &manager);
|
void shutdownCleanup(QSessionManager &manager);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
void applyMemoryWorkingSetLimit();
|
|
||||||
#endif
|
|
||||||
void initializeTranslation();
|
void initializeTranslation();
|
||||||
void processParams(const QStringList ¶ms);
|
void processParams(const QStringList ¶ms);
|
||||||
void runExternalProgram(const BitTorrent::Torrent *torrent) const;
|
void runExternalProgram(const BitTorrent::Torrent *torrent) const;
|
||||||
void sendNotificationEmail(const BitTorrent::Torrent *torrent);
|
void sendNotificationEmail(const BitTorrent::Torrent *torrent);
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
ApplicationInstanceManager *m_instanceManager = nullptr;
|
void applyMemoryWorkingSetLimit();
|
||||||
bool m_running;
|
#endif
|
||||||
ShutdownDialogAction m_shutdownAct;
|
|
||||||
QBtCommandLineParameters m_commandLineArgs;
|
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
QPointer<MainWindow> m_window;
|
#ifdef Q_OS_MACOS
|
||||||
|
bool event(QEvent *) override;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_WEBUI
|
ApplicationInstanceManager *m_instanceManager = nullptr;
|
||||||
WebUI *m_webui = nullptr;
|
bool m_running = false;
|
||||||
#endif
|
ShutdownDialogAction m_shutdownAct;
|
||||||
|
QBtCommandLineParameters m_commandLineArgs;
|
||||||
|
|
||||||
// FileLog
|
// FileLog
|
||||||
QPointer<FileLogger> m_fileLogger;
|
QPointer<FileLogger> m_fileLogger;
|
||||||
@ -155,9 +159,6 @@ private:
|
|||||||
QTranslator m_translator;
|
QTranslator m_translator;
|
||||||
QStringList m_paramsQueue;
|
QStringList m_paramsQueue;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
SettingValue<int> m_storeMemoryWorkingSetLimit;
|
|
||||||
#endif
|
|
||||||
SettingValue<bool> m_storeFileLoggerEnabled;
|
SettingValue<bool> m_storeFileLoggerEnabled;
|
||||||
SettingValue<bool> m_storeFileLoggerBackup;
|
SettingValue<bool> m_storeFileLoggerBackup;
|
||||||
SettingValue<bool> m_storeFileLoggerDeleteOld;
|
SettingValue<bool> m_storeFileLoggerDeleteOld;
|
||||||
@ -165,4 +166,15 @@ private:
|
|||||||
SettingValue<int> m_storeFileLoggerAge;
|
SettingValue<int> m_storeFileLoggerAge;
|
||||||
SettingValue<int> m_storeFileLoggerAgeType;
|
SettingValue<int> m_storeFileLoggerAgeType;
|
||||||
SettingValue<Path> m_storeFileLoggerPath;
|
SettingValue<Path> m_storeFileLoggerPath;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
SettingValue<int> m_storeMemoryWorkingSetLimit;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_GUI
|
||||||
|
QPointer<MainWindow> m_window;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_WEBUI
|
||||||
|
WebUI *m_webui = nullptr;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -51,6 +51,7 @@ add_library(qbt_base STATIC
|
|||||||
http/types.h
|
http/types.h
|
||||||
iconprovider.h
|
iconprovider.h
|
||||||
indexrange.h
|
indexrange.h
|
||||||
|
interfaces/iapplication.h
|
||||||
interfaces/istringable.h
|
interfaces/istringable.h
|
||||||
logger.h
|
logger.h
|
||||||
net/dnsupdater.h
|
net/dnsupdater.h
|
||||||
|
@ -50,6 +50,7 @@ HEADERS += \
|
|||||||
$$PWD/http/types.h \
|
$$PWD/http/types.h \
|
||||||
$$PWD/iconprovider.h \
|
$$PWD/iconprovider.h \
|
||||||
$$PWD/indexrange.h \
|
$$PWD/indexrange.h \
|
||||||
|
$$PWD/interfaces/iapplication.h \
|
||||||
$$PWD/interfaces/istringable.h \
|
$$PWD/interfaces/istringable.h \
|
||||||
$$PWD/logger.h \
|
$$PWD/logger.h \
|
||||||
$$PWD/net/dnsupdater.h \
|
$$PWD/net/dnsupdater.h \
|
||||||
|
65
src/base/interfaces/iapplication.h
Normal file
65
src/base/interfaces/iapplication.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2022 Mike Tzou (Chocobo1)
|
||||||
|
* Copyright (C) 2015, 2019 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
|
* Copyright (C) 2006 Christophe Dumez
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
class Path;
|
||||||
|
struct QBtCommandLineParameters;
|
||||||
|
|
||||||
|
class IApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IApplication() = default;
|
||||||
|
|
||||||
|
// FileLogger properties
|
||||||
|
virtual bool isFileLoggerEnabled() const = 0;
|
||||||
|
virtual void setFileLoggerEnabled(bool value) = 0;
|
||||||
|
virtual Path fileLoggerPath() const = 0;
|
||||||
|
virtual void setFileLoggerPath(const Path &path) = 0;
|
||||||
|
virtual bool isFileLoggerBackup() const = 0;
|
||||||
|
virtual void setFileLoggerBackup(bool value) = 0;
|
||||||
|
virtual bool isFileLoggerDeleteOld() const = 0;
|
||||||
|
virtual void setFileLoggerDeleteOld(bool value) = 0;
|
||||||
|
virtual int fileLoggerMaxSize() const = 0;
|
||||||
|
virtual void setFileLoggerMaxSize(int bytes) = 0;
|
||||||
|
virtual int fileLoggerAge() const = 0;
|
||||||
|
virtual void setFileLoggerAge(int value) = 0;
|
||||||
|
virtual int fileLoggerAgeType() const = 0;
|
||||||
|
virtual void setFileLoggerAgeType(int value) = 0;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
virtual int memoryWorkingSetLimit() const = 0;
|
||||||
|
virtual void setMemoryWorkingSetLimit(int size) = 0;
|
||||||
|
#endif
|
||||||
|
};
|
@ -50,6 +50,7 @@ add_library(qbt_gui STATIC
|
|||||||
fspathedit.h
|
fspathedit.h
|
||||||
fspathedit_p.h
|
fspathedit_p.h
|
||||||
hidabletabwidget.h
|
hidabletabwidget.h
|
||||||
|
interfaces/iguiapplication.h
|
||||||
ipsubnetwhitelistoptionsdialog.h
|
ipsubnetwhitelistoptionsdialog.h
|
||||||
lineedit.h
|
lineedit.h
|
||||||
log/logfiltermodel.h
|
log/logfiltermodel.h
|
||||||
|
@ -39,9 +39,9 @@
|
|||||||
#include "base/global.h"
|
#include "base/global.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
#include "app/application.h"
|
|
||||||
#include "gui/addnewtorrentdialog.h"
|
#include "gui/addnewtorrentdialog.h"
|
||||||
#include "gui/mainwindow.h"
|
#include "gui/mainwindow.h"
|
||||||
|
#include "interfaces/iguiapplication.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -200,7 +200,7 @@ void AdvancedSettings::saveAdvancedSettings()
|
|||||||
}
|
}
|
||||||
session->setOSMemoryPriority(prio);
|
session->setOSMemoryPriority(prio);
|
||||||
|
|
||||||
static_cast<Application *>(QCoreApplication::instance())->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
|
dynamic_cast<IApplication *>(QCoreApplication::instance())->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
|
||||||
#endif
|
#endif
|
||||||
// Async IO threads
|
// Async IO threads
|
||||||
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
|
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
|
||||||
@ -292,7 +292,7 @@ void AdvancedSettings::saveAdvancedSettings()
|
|||||||
// Stop tracker timeout
|
// Stop tracker timeout
|
||||||
session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value());
|
session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value());
|
||||||
// Program notification
|
// Program notification
|
||||||
MainWindow *const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
|
MainWindow *mainWindow = dynamic_cast<IGUIApplication *>(QCoreApplication::instance())->mainWindow();
|
||||||
mainWindow->setNotificationsEnabled(m_checkBoxProgramNotifications.isChecked());
|
mainWindow->setNotificationsEnabled(m_checkBoxProgramNotifications.isChecked());
|
||||||
mainWindow->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications.isChecked());
|
mainWindow->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications.isChecked());
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
|
||||||
@ -449,7 +449,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||||||
m_spinBoxMemoryWorkingSetLimit.setMinimum(1);
|
m_spinBoxMemoryWorkingSetLimit.setMinimum(1);
|
||||||
m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits<int>::max());
|
m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits<int>::max());
|
||||||
m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB"));
|
m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB"));
|
||||||
m_spinBoxMemoryWorkingSetLimit.setValue(static_cast<Application *>(QCoreApplication::instance())->memoryWorkingSetLimit());
|
m_spinBoxMemoryWorkingSetLimit.setValue(dynamic_cast<IApplication *>(QCoreApplication::instance())->memoryWorkingSetLimit());
|
||||||
|
|
||||||
addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit")
|
addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit")
|
||||||
+ u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set", u"(?)"))
|
+ u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set", u"(?)"))
|
||||||
@ -694,7 +694,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||||||
, &m_spinBoxStopTrackerTimeout);
|
, &m_spinBoxStopTrackerTimeout);
|
||||||
|
|
||||||
// Program notifications
|
// Program notifications
|
||||||
const MainWindow *const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
|
const MainWindow *mainWindow = dynamic_cast<IGUIApplication *>(QCoreApplication::instance())->mainWindow();
|
||||||
m_checkBoxProgramNotifications.setChecked(mainWindow->isNotificationsEnabled());
|
m_checkBoxProgramNotifications.setChecked(mainWindow->isNotificationsEnabled());
|
||||||
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &m_checkBoxProgramNotifications);
|
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &m_checkBoxProgramNotifications);
|
||||||
// Torrent added notifications
|
// Torrent added notifications
|
||||||
|
@ -17,6 +17,7 @@ HEADERS += \
|
|||||||
$$PWD/fspathedit.h \
|
$$PWD/fspathedit.h \
|
||||||
$$PWD/fspathedit_p.h \
|
$$PWD/fspathedit_p.h \
|
||||||
$$PWD/hidabletabwidget.h \
|
$$PWD/hidabletabwidget.h \
|
||||||
|
$$PWD/interfaces/iguiapplication.h \
|
||||||
$$PWD/ipsubnetwhitelistoptionsdialog.h \
|
$$PWD/ipsubnetwhitelistoptionsdialog.h \
|
||||||
$$PWD/lineedit.h \
|
$$PWD/lineedit.h \
|
||||||
$$PWD/log/logfiltermodel.h \
|
$$PWD/log/logfiltermodel.h \
|
||||||
|
43
src/gui/interfaces/iguiapplication.h
Normal file
43
src/gui/interfaces/iguiapplication.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2022 Mike Tzou (Chocobo1)
|
||||||
|
* Copyright (C) 2015, 2019 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
|
* Copyright (C) 2006 Christophe Dumez
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/interfaces/iapplication.h"
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class IGUIApplication : public IApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IGUIApplication() = default;
|
||||||
|
|
||||||
|
virtual QPointer<MainWindow> mainWindow() = 0;
|
||||||
|
};
|
@ -61,8 +61,8 @@
|
|||||||
#include "base/utils/random.h"
|
#include "base/utils/random.h"
|
||||||
#include "addnewtorrentdialog.h"
|
#include "addnewtorrentdialog.h"
|
||||||
#include "advancedsettings.h"
|
#include "advancedsettings.h"
|
||||||
#include "app/application.h"
|
|
||||||
#include "banlistoptionsdialog.h"
|
#include "banlistoptionsdialog.h"
|
||||||
|
#include "interfaces/iguiapplication.h"
|
||||||
#include "ipsubnetwhitelistoptionsdialog.h"
|
#include "ipsubnetwhitelistoptionsdialog.h"
|
||||||
#include "rss/automatedrssdownloader.h"
|
#include "rss/automatedrssdownloader.h"
|
||||||
#include "ui_optionsdialog.h"
|
#include "ui_optionsdialog.h"
|
||||||
@ -719,7 +719,7 @@ void OptionsDialog::saveOptions()
|
|||||||
#endif
|
#endif
|
||||||
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
||||||
|
|
||||||
auto *const app = static_cast<Application *>(QCoreApplication::instance());
|
auto *app = dynamic_cast<IApplication *>(QCoreApplication::instance());
|
||||||
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
||||||
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
||||||
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
|
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
|
||||||
@ -969,7 +969,7 @@ void OptionsDialog::loadOptions()
|
|||||||
#endif
|
#endif
|
||||||
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
||||||
|
|
||||||
const Application *const app = static_cast<Application*>(QCoreApplication::instance());
|
const auto *app = dynamic_cast<IApplication *>(QCoreApplication::instance());
|
||||||
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
||||||
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
||||||
const bool fileLogBackup = app->isFileLoggerBackup();
|
const bool fileLogBackup = app->isFileLoggerBackup();
|
||||||
|
Loading…
Reference in New Issue
Block a user