qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
genericsettings.cpp
Go to the documentation of this file.
1 /*
2  Copyright © 2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "genericsettings.h"
21 #include "src/widget/gui.h"
22 
23 #include <QCheckBox>
24 #include <QComboBox>
25 #include <QEvent>
26 #include <QSpinBox>
27 
35 GenericForm::GenericForm(const QPixmap& icon)
36  : formIcon(icon)
37 {
39 }
40 
42 {
43  return formIcon;
44 }
45 
55 {
56  for (QComboBox* cb : findChildren<QComboBox*>()) {
57  cb->installEventFilter(this);
58  cb->setFocusPolicy(Qt::StrongFocus);
59  }
60 
61  for (QSpinBox* sp : findChildren<QSpinBox*>()) {
62  sp->installEventFilter(this);
63  sp->setFocusPolicy(Qt::WheelFocus);
64  }
65 
66  for (QCheckBox* cb : findChildren<QCheckBox*>()) // this one is to allow scrolling on checkboxes
67  cb->installEventFilter(this);
68 }
69 
76 bool GenericForm::eventFilter(QObject* o, QEvent* e)
77 {
78  if ((e->type() == QEvent::Wheel)
79  && (qobject_cast<QComboBox*>(o) || qobject_cast<QAbstractSpinBox*>(o)
80  || qobject_cast<QCheckBox*>(o))) {
81  e->ignore();
82  return true;
83  }
84 
85  return QWidget::eventFilter(o, e);
86 }
GenericForm::GenericForm
GenericForm(const QPixmap &icon)
Definition: genericsettings.cpp:35
GUI::getInstance
static GUI & getInstance()
Returns the singleton instance.
Definition: gui.cpp:56
genericsettings.h
GenericForm::reloadTheme
virtual void reloadTheme()
Definition: genericsettings.h:37
GenericForm::eventFilter
bool eventFilter(QObject *o, QEvent *e) final
Ignore scroll on different controls.
Definition: genericsettings.cpp:76
GUI::themeReload
void themeReload()
GenericForm::getFormIcon
QPixmap getFormIcon()
Definition: genericsettings.cpp:41
GenericForm::formIcon
QPixmap formIcon
Definition: genericsettings.h:44
gui.h
GenericForm::eventsInit
void eventsInit()
Prevent stealing mouse wheel scroll.
Definition: genericsettings.cpp:54