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 #ifndef RADIOKEYWIDGET_H
22 #define RADIOKEYWIDGET_H
24 #include "radiouiaction.h"
25 #include "radiowidget.h"
27 class RadioKeyWidget
: public RadioWidget
33 explicit RadioKeyWidget(const QPolygon
& polygon
, const QString
&image
, RadioUiAction
* action
= NULL
, QWidget
* parent
= NULL
, Qt::WindowFlags f
= Qt::WindowFlags()):
34 RadioWidget(action
, parent
, f
),
38 m_type
= RADIO_WIDGET_KEY
;
40 hide(); // we're a "virtual" button for now
41 setSizePolicy(QSizePolicy::Ignored
, QSizePolicy::Ignored
);
44 virtual void setAction(RadioUiAction
* action
)
47 disconnect(m_action
, 0, this, 0);
48 RadioWidget::setAction(action
);
50 connect(m_action
, &RadioUiAction::toggled
, this, &RadioKeyWidget::onActionToggled
);
53 virtual int getValue() const
55 return (m_action
&& m_action
->isActive()) ? 1 : 0;
60 m_action
->trigger(true);
65 m_action
->trigger(false);
68 void toggle(bool down
)
76 bool contains(const QPoint
& point
)
78 return polygon
.containsPoint(point
, Qt::OddEvenFill
);
83 void imageChanged(const QString image
);
87 virtual void onActionToggled(int index
, bool active
)
89 RadioWidget::onActionToggled(index
, active
);
90 emit
imageChanged(active
? imgFile
: "");
98 #endif // RADIOKEYWIDGET_H