mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 23:37:59 +00:00
Merge pull request #14368 from zzandland/revise-apply-button-options
Refactor apply button logics on options dialog
This commit is contained in:
commit
de9b43984a
@ -233,15 +233,8 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||||||
m_ui->hsplitter->setCollapsible(0, false);
|
m_ui->hsplitter->setCollapsible(0, false);
|
||||||
m_ui->hsplitter->setCollapsible(1, false);
|
m_ui->hsplitter->setCollapsible(1, false);
|
||||||
// Get apply button in button box
|
// Get apply button in button box
|
||||||
const QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
|
m_applyButton = m_ui->buttonBox->button(QDialogButtonBox::Apply);
|
||||||
for (QAbstractButton *button : buttons)
|
connect(m_applyButton, &QPushButton::clicked, this, &OptionsDialog::applySettings);
|
||||||
{
|
|
||||||
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
|
|
||||||
{
|
|
||||||
m_applyButton = button;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
m_ui->scanFoldersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
|
m_ui->scanFoldersView->setModel(ScanFoldersModel::instance());
|
||||||
@ -249,7 +242,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||||||
connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton);
|
connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->scanFoldersView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ThisType::handleScanFolderViewSelectionChanged);
|
connect(m_ui->scanFoldersView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ThisType::handleScanFolderViewSelectionChanged);
|
||||||
|
|
||||||
connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &OptionsDialog::applySettings);
|
|
||||||
// Languages supported
|
// Languages supported
|
||||||
initializeLanguageCombo();
|
initializeLanguageCombo();
|
||||||
|
|
||||||
@ -1439,27 +1431,24 @@ void OptionsDialog::on_buttonBox_accepted()
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::applySettings(QAbstractButton *button)
|
void OptionsDialog::applySettings()
|
||||||
{
|
{
|
||||||
if (button == m_applyButton)
|
if (!schedTimesOk())
|
||||||
{
|
{
|
||||||
if (!schedTimesOk())
|
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
{
|
return;
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!webUIAuthenticationOk())
|
|
||||||
{
|
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isAlternativeWebUIPathValid())
|
|
||||||
{
|
|
||||||
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
saveOptions();
|
|
||||||
}
|
}
|
||||||
|
if (!webUIAuthenticationOk())
|
||||||
|
{
|
||||||
|
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isAlternativeWebUIPathValid())
|
||||||
|
{
|
||||||
|
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saveOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::closeEvent(QCloseEvent *e)
|
void OptionsDialog::closeEvent(QCloseEvent *e)
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "base/settingvalue.h"
|
#include "base/settingvalue.h"
|
||||||
|
|
||||||
class QAbstractButton;
|
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
@ -95,7 +94,7 @@ private slots:
|
|||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
void closeEvent(QCloseEvent *e) override;
|
void closeEvent(QCloseEvent *e) override;
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
void applySettings(QAbstractButton *button);
|
void applySettings();
|
||||||
void enableApplyButton();
|
void enableApplyButton();
|
||||||
void toggleComboRatioLimitAct();
|
void toggleComboRatioLimitAct();
|
||||||
void changePage(QListWidgetItem *, QListWidgetItem *);
|
void changePage(QListWidgetItem *, QListWidgetItem *);
|
||||||
@ -181,7 +180,7 @@ private:
|
|||||||
SettingValue<QSize> m_storeDialogSize;
|
SettingValue<QSize> m_storeDialogSize;
|
||||||
SettingValue<QStringList> m_storeHSplitterSize;
|
SettingValue<QStringList> m_storeHSplitterSize;
|
||||||
|
|
||||||
QAbstractButton *m_applyButton;
|
QPushButton *m_applyButton;
|
||||||
|
|
||||||
AdvancedSettings *m_advancedSettings;
|
AdvancedSettings *m_advancedSettings;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user