Browse Source

Merge pull request #9053 from Chocobo1/optionWheel

Disable certain mouse wheel events in Options dialog
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
c8c7ed4a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/gui/advancedsettings.cpp
  2. 17
      src/gui/advancedsettings.h
  3. 21
      src/gui/optionsdlg.cpp
  4. 8
      src/gui/optionsdlg.h

4
src/gui/advancedsettings.cpp

@ -485,10 +485,6 @@ void AdvancedSettings::loadAdvancedSettings() @@ -485,10 +485,6 @@ void AdvancedSettings::loadAdvancedSettings()
template <typename T>
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);

17
src/gui/advancedsettings.h

@ -31,28 +31,11 @@ @@ -31,28 +31,11 @@
#include <QCheckBox>
#include <QComboBox>
#include <QEvent>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QTableWidget>
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

21
src/gui/optionsdlg.cpp

@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDialogButtonBox>
#include <QEvent>
#include <QFileDialog>
#include <QMessageBox>
#include <QSystemTrayIcon>
@ -50,6 +51,7 @@ @@ -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 @@ @@ -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) @@ -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<QComboBox *>()))
widget->installEventFilter(wheelEventEater);
for (QSpinBox *widget : copyAsConst(findChildren<QSpinBox *>()))
widget->installEventFilter(wheelEventEater);
loadWindowState();
show();
// Have to be called after show(), because splitter width needed

8
src/gui/optionsdlg.h

@ -172,22 +172,20 @@ private: @@ -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<QString> addedScanDirs;
QList<QString> removedScanDirs;
// SSL Cert / key
QByteArray m_sslCert, m_sslKey;
};
#endif

Loading…
Cancel
Save