mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-24 01:08:06 -06:00
committed by
GitHub
parent
41a38428fc
commit
f8a304abdc
@@ -49,6 +49,7 @@ add_library(qbt_gui STATIC
|
||||
executionlogwidget.h
|
||||
fspathedit.h
|
||||
fspathedit_p.h
|
||||
guiapplicationcomponent.h
|
||||
hidabletabwidget.h
|
||||
interfaces/iguiapplication.h
|
||||
ipsubnetwhitelistoptionsdialog.h
|
||||
@@ -131,6 +132,7 @@ add_library(qbt_gui STATIC
|
||||
executionlogwidget.cpp
|
||||
fspathedit.cpp
|
||||
fspathedit_p.cpp
|
||||
guiapplicationcomponent.cpp
|
||||
hidabletabwidget.cpp
|
||||
ipsubnetwhitelistoptionsdialog.cpp
|
||||
lineedit.cpp
|
||||
|
||||
@@ -151,8 +151,9 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
AdvancedSettings::AdvancedSettings(QWidget *parent)
|
||||
AdvancedSettings::AdvancedSettings(IGUIApplication *app, QWidget *parent)
|
||||
: QTableWidget(parent)
|
||||
, GUIApplicationComponent(app)
|
||||
{
|
||||
// column
|
||||
setColumnCount(COL_COUNT);
|
||||
@@ -178,7 +179,7 @@ void AdvancedSettings::saveAdvancedSettings() const
|
||||
|
||||
session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value<BitTorrent::ResumeDataStorageType>());
|
||||
// Physical memory (RAM) usage limit
|
||||
dynamic_cast<IApplication *>(QCoreApplication::instance())->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
|
||||
app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
|
||||
#if defined(Q_OS_WIN)
|
||||
session->setOSMemoryPriority(m_comboBoxOSMemoryPriority.currentData().value<BitTorrent::OSMemoryPriority>());
|
||||
#endif
|
||||
@@ -266,7 +267,7 @@ void AdvancedSettings::saveAdvancedSettings() const
|
||||
// Stop tracker timeout
|
||||
session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value());
|
||||
// Program notification
|
||||
MainWindow *mainWindow = dynamic_cast<IGUIApplication *>(QCoreApplication::instance())->mainWindow();
|
||||
MainWindow *mainWindow = app()->mainWindow();
|
||||
mainWindow->setNotificationsEnabled(m_checkBoxProgramNotifications.isChecked());
|
||||
mainWindow->setTorrentAddedNotificationsEnabled(m_checkBoxTorrentAddedNotifications.isChecked());
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
|
||||
@@ -411,7 +412,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits<int>::max());
|
||||
m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB"));
|
||||
m_spinBoxMemoryWorkingSetLimit.setToolTip(tr("This option is less effective on Linux"));
|
||||
m_spinBoxMemoryWorkingSetLimit.setValue(dynamic_cast<IApplication *>(QCoreApplication::instance())->memoryWorkingSetLimit());
|
||||
m_spinBoxMemoryWorkingSetLimit.setValue(app()->memoryWorkingSetLimit());
|
||||
addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit") + u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set", u"(?)"))
|
||||
, &m_spinBoxMemoryWorkingSetLimit);
|
||||
#if defined(Q_OS_WIN)
|
||||
@@ -670,7 +671,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
, &m_spinBoxStopTrackerTimeout);
|
||||
|
||||
// Program notifications
|
||||
const MainWindow *mainWindow = dynamic_cast<IGUIApplication *>(QCoreApplication::instance())->mainWindow();
|
||||
const MainWindow *mainWindow = app()->mainWindow();
|
||||
m_checkBoxProgramNotifications.setChecked(mainWindow->isNotificationsEnabled());
|
||||
addRow(PROGRAM_NOTIFICATIONS, tr("Display notifications"), &m_checkBoxProgramNotifications);
|
||||
// Torrent added notifications
|
||||
|
||||
@@ -34,13 +34,15 @@
|
||||
#include <QSpinBox>
|
||||
#include <QTableWidget>
|
||||
|
||||
class AdvancedSettings final : public QTableWidget
|
||||
#include "guiapplicationcomponent.h"
|
||||
|
||||
class AdvancedSettings final : public QTableWidget, public GUIApplicationComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(AdvancedSettings)
|
||||
|
||||
public:
|
||||
AdvancedSettings(QWidget *parent);
|
||||
explicit AdvancedSettings(IGUIApplication *app, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void saveAdvancedSettings() const;
|
||||
|
||||
@@ -16,6 +16,7 @@ HEADERS += \
|
||||
$$PWD/executionlogwidget.h \
|
||||
$$PWD/fspathedit.h \
|
||||
$$PWD/fspathedit_p.h \
|
||||
$$PWD/guiapplicationcomponent.h \
|
||||
$$PWD/hidabletabwidget.h \
|
||||
$$PWD/interfaces/iguiapplication.h \
|
||||
$$PWD/ipsubnetwhitelistoptionsdialog.h \
|
||||
@@ -98,6 +99,7 @@ SOURCES += \
|
||||
$$PWD/executionlogwidget.cpp \
|
||||
$$PWD/fspathedit.cpp \
|
||||
$$PWD/fspathedit_p.cpp \
|
||||
$$PWD/guiapplicationcomponent.cpp \
|
||||
$$PWD/hidabletabwidget.cpp \
|
||||
$$PWD/ipsubnetwhitelistoptionsdialog.cpp \
|
||||
$$PWD/lineedit.cpp \
|
||||
|
||||
39
src/gui/guiapplicationcomponent.cpp
Normal file
39
src/gui/guiapplicationcomponent.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "guiapplicationcomponent.h"
|
||||
|
||||
GUIApplicationComponent::GUIApplicationComponent(IGUIApplication *app)
|
||||
: ApplicationComponent(app)
|
||||
{
|
||||
}
|
||||
|
||||
IGUIApplication *GUIApplicationComponent::app() const
|
||||
{
|
||||
return static_cast<IGUIApplication *>(ApplicationComponent::app());
|
||||
}
|
||||
42
src/gui/guiapplicationcomponent.h
Normal file
42
src/gui/guiapplicationcomponent.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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/applicationcomponent.h"
|
||||
#include "interfaces/iguiapplication.h"
|
||||
|
||||
class GUIApplicationComponent : public ApplicationComponent
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(GUIApplicationComponent)
|
||||
|
||||
public:
|
||||
explicit GUIApplicationComponent(IGUIApplication *app);
|
||||
|
||||
IGUIApplication *app() const override;
|
||||
};
|
||||
@@ -39,5 +39,5 @@ class IGUIApplication : public IApplication
|
||||
public:
|
||||
virtual ~IGUIApplication() = default;
|
||||
|
||||
virtual QPointer<MainWindow> mainWindow() = 0;
|
||||
virtual MainWindow *mainWindow() = 0;
|
||||
};
|
||||
|
||||
@@ -138,8 +138,9 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
MainWindow::MainWindow(IGUIApplication *app, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, GUIApplicationComponent(app)
|
||||
, m_ui(new Ui::MainWindow)
|
||||
, m_storeExecutionLogEnabled(EXECUTIONLOG_SETTINGS_KEY(u"Enabled"_qs))
|
||||
, m_storeDownloadTrackerFavicon(SETTINGS_KEY(u"DownloadTrackerFavicon"_qs))
|
||||
@@ -1833,7 +1834,7 @@ void MainWindow::on_actionOptions_triggered()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_options = new OptionsDialog(this);
|
||||
m_options = new OptionsDialog(app(), this);
|
||||
m_options->setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_options->open();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "base/bittorrent/torrent.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "guiapplicationcomponent.h"
|
||||
|
||||
class QCloseEvent;
|
||||
class QFileSystemWatcher;
|
||||
@@ -71,13 +72,13 @@ namespace Ui
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow final : public QMainWindow
|
||||
class MainWindow final : public QMainWindow, public GUIApplicationComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MainWindow)
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
explicit MainWindow(IGUIApplication *app, QWidget *parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
QWidget *currentTabWidget() const;
|
||||
|
||||
@@ -175,8 +175,9 @@ private:
|
||||
};
|
||||
|
||||
// Constructor
|
||||
OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
: QDialog {parent}
|
||||
OptionsDialog::OptionsDialog(IGUIApplication *app, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, GUIApplicationComponent(app)
|
||||
, m_ui {new Ui::OptionsDialog}
|
||||
, m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)}
|
||||
, m_storeHSplitterSize {SETTINGS_KEY(u"HorizontalSplitterSizes"_qs)}
|
||||
@@ -542,7 +543,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
// Tab selection mechanism
|
||||
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
|
||||
// Load Advanced settings
|
||||
m_advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
||||
m_advancedSettings = new AdvancedSettings(app, m_ui->tabAdvancedPage);
|
||||
m_ui->advPageLayout->addWidget(m_advancedSettings);
|
||||
connect(m_advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
@@ -723,14 +724,13 @@ void OptionsDialog::saveOptions()
|
||||
#endif
|
||||
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
||||
|
||||
auto *app = dynamic_cast<IApplication *>(QCoreApplication::instance());
|
||||
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
||||
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
||||
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
|
||||
app->setFileLoggerAge(m_ui->spinFileLogAge->value());
|
||||
app->setFileLoggerAgeType(m_ui->comboFileLogAgeType->currentIndex());
|
||||
app->setFileLoggerDeleteOld(m_ui->checkFileLogDelete->isChecked());
|
||||
app->setFileLoggerEnabled(m_ui->checkFileLog->isChecked());
|
||||
app()->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
|
||||
app()->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
|
||||
app()->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
|
||||
app()->setFileLoggerAge(m_ui->spinFileLogAge->value());
|
||||
app()->setFileLoggerAgeType(m_ui->comboFileLogAgeType->currentIndex());
|
||||
app()->setFileLoggerDeleteOld(m_ui->checkFileLogDelete->isChecked());
|
||||
app()->setFileLoggerEnabled(m_ui->checkFileLog->isChecked());
|
||||
// End Behavior preferences
|
||||
|
||||
RSS::Session::instance()->setRefreshInterval(m_ui->spinRSSRefreshInterval->value());
|
||||
@@ -975,19 +975,18 @@ void OptionsDialog::loadOptions()
|
||||
#endif
|
||||
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
||||
|
||||
const auto *app = dynamic_cast<IApplication *>(QCoreApplication::instance());
|
||||
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
|
||||
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
|
||||
const bool fileLogBackup = app->isFileLoggerBackup();
|
||||
m_ui->checkFileLog->setChecked(app()->isFileLoggerEnabled());
|
||||
m_ui->textFileLogPath->setSelectedPath(app()->fileLoggerPath());
|
||||
const bool fileLogBackup = app()->isFileLoggerBackup();
|
||||
m_ui->checkFileLogBackup->setChecked(fileLogBackup);
|
||||
m_ui->spinFileLogSize->setEnabled(fileLogBackup);
|
||||
const bool fileLogDelete = app->isFileLoggerDeleteOld();
|
||||
const bool fileLogDelete = app()->isFileLoggerDeleteOld();
|
||||
m_ui->checkFileLogDelete->setChecked(fileLogDelete);
|
||||
m_ui->spinFileLogAge->setEnabled(fileLogDelete);
|
||||
m_ui->comboFileLogAgeType->setEnabled(fileLogDelete);
|
||||
m_ui->spinFileLogSize->setValue(app->fileLoggerMaxSize() / 1024);
|
||||
m_ui->spinFileLogAge->setValue(app->fileLoggerAge());
|
||||
m_ui->comboFileLogAgeType->setCurrentIndex(app->fileLoggerAgeType());
|
||||
m_ui->spinFileLogSize->setValue(app()->fileLoggerMaxSize() / 1024);
|
||||
m_ui->spinFileLogAge->setValue(app()->fileLoggerAge());
|
||||
m_ui->comboFileLogAgeType->setCurrentIndex(app()->fileLoggerAgeType());
|
||||
// End Behavior preferences
|
||||
|
||||
m_ui->checkRSSEnable->setChecked(RSS::Session::instance()->isProcessingEnabled());
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "base/pathfwd.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "guiapplicationcomponent.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
@@ -57,7 +58,7 @@ namespace Ui
|
||||
class OptionsDialog;
|
||||
}
|
||||
|
||||
class OptionsDialog final : public QDialog
|
||||
class OptionsDialog final : public QDialog, public GUIApplicationComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(OptionsDialog)
|
||||
@@ -83,8 +84,7 @@ class OptionsDialog final : public QDialog
|
||||
};
|
||||
|
||||
public:
|
||||
// Constructor / Destructor
|
||||
OptionsDialog(QWidget *parent = nullptr);
|
||||
explicit OptionsDialog(IGUIApplication *app, QWidget *parent = nullptr);
|
||||
~OptionsDialog() override;
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user