Skip to content

Commit

Permalink
Filter out the Ctrl-Wheel (text zoom) event
Browse files Browse the repository at this point in the history
To avoid having the user accidentally zooming the text while scrolling
using the mouse wheel, the Ctrl-Wheel event is filtered out.
  • Loading branch information
in3otd committed Jun 26, 2015
1 parent bcb3f65 commit 40e6748
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
22 changes: 19 additions & 3 deletions qucs/qucs/dialogs/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <QTextBrowser>
#include <QLabel>
#include <QPushButton>
#include <QApplication>
#include <QDebug>


Expand Down Expand Up @@ -147,12 +148,12 @@ AboutDialog::AboutDialog(QWidget *parent)
QTabWidget *t = new QTabWidget();
all->addWidget(t);
connect(t, SIGNAL(currentChanged(int)), this, SLOT(currentChangedSlot(int)));


authorsBrowser = new QTextBrowser;
// the Ctrl-Wheel event we would like to filter is handled by the viewport
authorsBrowser->viewport()->installEventFilter(this);
trBrowser = new QTextBrowser;


trBrowser->viewport()->installEventFilter(this);

QString supportText;
// link to home page, help mailing list, IRC ?
Expand All @@ -167,13 +168,15 @@ AboutDialog::AboutDialog(QWidget *parent)
tr("Additional resources") + " : <a href='https://github.com/Qucs/qucs#resources'>https://github.com/Qucs/qucs#resources</a>";

QTextBrowser *supportBrowser = new QTextBrowser;
supportBrowser->viewport()->installEventFilter(this);
supportBrowser->setOpenExternalLinks(true);
supportBrowser->setHtml(supportText);

QString licenseText;
licenseText = "Qucs 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, or (at your option) any later version.<br/><br/>This software 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..<br/><br/> You should have received a copy of the GNU General Public License along with Qucs, see the file COPYING. If not see <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a> or write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,Boston, MA 02110-1301, USA.";

QTextBrowser *licenseBrowser = new QTextBrowser;
licenseBrowser->viewport()->installEventFilter(this);
licenseBrowser->setOpenExternalLinks(true);
licenseBrowser->setHtml(licenseText);

Expand Down Expand Up @@ -240,3 +243,16 @@ void AboutDialog::setTrText() {

trBrowser->setHtml(trText);
}

// event filter to remove the Ctrl-Wheel (text zoom) event
bool AboutDialog::eventFilter(QObject *obj, QEvent *event) {
if ((event->type() == QEvent::Wheel) &&
(QApplication::keyboardModifiers() & Qt::ControlModifier )) {
return true; // eat Ctrl-Wheel event
} else {
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
}


3 changes: 3 additions & 0 deletions qucs/qucs/dialogs/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class AboutDialog : public QDialog {
public:
AboutDialog(QWidget *parent = 0);

protected:
bool eventFilter(QObject *obj, QEvent *ev);

private:
void setAuthorsText(void);
void setTrText(void);
Expand Down

0 comments on commit 40e6748

Please sign in to comment.