5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "genericpanel.h"
27 #include <QGridLayout>
28 #include <QSpacerItem>
30 GenericPanel::GenericPanel(QWidget
* parent
, ModelData
* model
, GeneralSettings
& generalSettings
, Firmware
* firmware
):
33 generalSettings(generalSettings
),
39 GenericPanel::~GenericPanel()
43 void GenericPanel::update()
47 void GenericPanel::addLabel(QGridLayout
*gridLayout
, const QString
&text
, int col
, bool minimize
)
49 QLabel
*label
= new QLabel(this);
50 label
->setFrameShape(QFrame::Panel
);
51 label
->setFrameShadow(QFrame::Raised
);
52 label
->setMidLineWidth(0);
53 label
->setAlignment(Qt::AlignCenter
);
57 label
->setMinimumWidth(100);
58 gridLayout
->addWidget(label
, 0, col
, 1, 1);
61 void GenericPanel::addEmptyLabel(QGridLayout
* gridLayout
, int col
)
63 QLabel
*label
= new QLabel(this);
65 gridLayout
->addWidget(label
, 0, col
, 1, 1);
68 void GenericPanel::addHSpring(QGridLayout
* gridLayout
, int col
, int row
)
70 QSpacerItem
* spacer
= new QSpacerItem(0, 0, QSizePolicy::Expanding
, QSizePolicy::Minimum
);
71 gridLayout
->addItem(spacer
, row
, col
);
74 void GenericPanel::addVSpring(QGridLayout
* gridLayout
, int col
, int row
)
76 QSpacerItem
* spacer
= new QSpacerItem(0, 0, QSizePolicy::Minimum
, QSizePolicy::Expanding
);
77 gridLayout
->addItem(spacer
, row
, col
);
80 void GenericPanel::addDoubleSpring(QGridLayout
* gridLayout
, int col
, int row
)
82 QSpacerItem
* spacer
= new QSpacerItem(0, 0, QSizePolicy::Expanding
, QSizePolicy::Expanding
);
83 gridLayout
->addItem(spacer
, row
, col
);
86 bool GenericPanel::eventFilter(QObject
*object
, QEvent
* event
)
88 QWidget
* widget
= qobject_cast
<QWidget
*>(object
);
90 if (event
->type() == QEvent::Wheel
) {
91 if (widget
->focusPolicy() == Qt::WheelFocus
) {
100 else if (event
->type() == QEvent::FocusIn
) {
101 widget
->setFocusPolicy(Qt::WheelFocus
);
103 else if (event
->type() == QEvent::FocusOut
) {
104 widget
->setFocusPolicy(Qt::StrongFocus
);
107 return QWidget::eventFilter(object
, event
);
110 void GenericPanel::setFocusFilter(QWidget
* w
)
112 w
->installEventFilter(this);
113 w
->setFocusPolicy(Qt::StrongFocus
);
116 void GenericPanel::disableMouseScrolling()
118 foreach(QWidget
* cb
, findChildren
<QComboBox
*>())
121 foreach(QWidget
* sb
, findChildren
<QAbstractSpinBox
*>())
124 foreach(QWidget
* slider
, findChildren
<QSlider
*>())
125 setFocusFilter(slider
);
127 foreach(QWidget
* te
, findChildren
<TimerEdit
*>())