From 0b050e2a303d31783f02abf8e35a13aceff0482f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 4 Jun 2018 21:07:55 +0800 Subject: [PATCH 1/2] Remove duplicate private sections in class And group related methods & variables together. --- src/gui/optionsdlg.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/optionsdlg.h b/src/gui/optionsdlg.h index 300a705e9..a9ca71217 100644 --- a/src/gui/optionsdlg.h +++ b/src/gui/optionsdlg.h @@ -172,22 +172,20 @@ private: bool isWebUiEnabled() const; QString webUiUsername() const; QString webUiPassword() const; - -private: + // WebUI SSL Cert / key bool setSslKey(const QByteArray &key); bool setSslCertificate(const QByteArray &cert); bool schedTimesOk(); bool webUIAuthenticationOk(); -private: + QByteArray m_sslCert, m_sslKey; + Ui::OptionsDialog *m_ui; QButtonGroup choiceLanguage; QAbstractButton *applyButton; AdvancedSettings *advancedSettings; QList addedScanDirs; QList removedScanDirs; - // SSL Cert / key - QByteArray m_sslCert, m_sslKey; }; #endif From 96819f3798fa48678371cff987352deeafe3d47c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 5 Jun 2018 00:28:33 +0800 Subject: [PATCH 2/2] Disable certain mouse wheel events in Options dialog The mouse wheel events for QComboBox & QSpinBox widgets in Options dialog are filtered out. --- src/gui/advancedsettings.cpp | 4 ---- src/gui/advancedsettings.h | 17 ----------------- src/gui/optionsdlg.cpp | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index baa4dc939..b5733145e 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -485,10 +485,6 @@ void AdvancedSettings::loadAdvancedSettings() template void AdvancedSettings::addRow(int row, const QString &rowText, T* widget) { - // ignore mouse wheel event - static WheelEventEater filter; - widget->installEventFilter(&filter); - setItem(row, PROPERTY, new QTableWidgetItem(rowText)); setCellWidget(row, VALUE, widget); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 8c1893c00..50c9c1a56 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -31,28 +31,11 @@ #include #include -#include #include #include #include #include -class WheelEventEater: public QObject -{ - Q_OBJECT - -private: - bool eventFilter(QObject *obj, QEvent *event) - { - switch (event->type()) { - case QEvent::Wheel: - return true; - default: - return QObject::eventFilter(obj, event); - } - } -}; - class AdvancedSettings: public QTableWidget { Q_OBJECT diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index d0ac39d87..323aae22f 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include "app/application.h" #include "base/bittorrent/session.h" +#include "base/global.h" #include "base/net/dnsupdater.h" #include "base/net/portforwarder.h" #include "base/net/proxyconfigurationmanager.h" @@ -72,6 +74,18 @@ #include "ui_optionsdlg.h" +class WheelEventEater : public QObject +{ +public: + using QObject::QObject; + +private: + bool eventFilter(QObject *, QEvent *event) override + { + return (event->type() == QEvent::Wheel); + } +}; + // Constructor OptionsDialog::OptionsDialog(QWidget *parent) : QDialog(parent) @@ -425,6 +439,13 @@ OptionsDialog::OptionsDialog(QWidget *parent) m_ui->textTempPath->setDialogCaption(tr("Choose a save directory")); m_ui->textTempPath->setMode(FileSystemPathEdit::Mode::DirectorySave); + // disable mouse wheel event on widgets to avoid mis-selection + WheelEventEater *wheelEventEater = new WheelEventEater(this); + for (QComboBox *widget : copyAsConst(findChildren())) + widget->installEventFilter(wheelEventEater); + for (QSpinBox *widget : copyAsConst(findChildren())) + widget->installEventFilter(wheelEventEater); + loadWindowState(); show(); // Have to be called after show(), because splitter width needed