kdelibs/plasma/widgets/radiobutton.cpp

90 lines
2.1 KiB
C++
Raw Normal View History

2014-11-13 01:04:59 +02:00
/*
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program 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
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "radiobutton.h"
#include "private/themedwidgetinterface_p.h"
#include "svg.h"
#include <QRadioButton>
2014-11-13 01:04:59 +02:00
namespace Plasma
{
class RadioButtonPrivate : public ThemedWidgetInterface<RadioButton>
{
public:
RadioButtonPrivate(RadioButton *radio)
: ThemedWidgetInterface<RadioButton>(radio)
2014-11-13 01:04:59 +02:00
{
}
};
RadioButton::RadioButton(QGraphicsWidget *parent)
: QGraphicsProxyWidget(parent),
d(new RadioButtonPrivate(this))
2014-11-13 01:04:59 +02:00
{
QRadioButton *native = new QRadioButton();
2014-11-13 01:04:59 +02:00
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
d->setWidget(native);
native->setWindowIcon(QIcon());
native->setAttribute(Qt::WA_NoSystemBackground);
d->initTheming();
}
RadioButton::~RadioButton()
{
delete d;
}
void RadioButton::setText(const QString &text)
{
nativeWidget()->setText(text);
2014-11-13 01:04:59 +02:00
}
QString RadioButton::text() const
{
return nativeWidget()->text();
2014-11-13 01:04:59 +02:00
}
QRadioButton *RadioButton::nativeWidget() const
{
return static_cast<QRadioButton*>(widget());
}
void RadioButton::setChecked(bool checked)
{
nativeWidget()->setChecked(checked);
2014-11-13 01:04:59 +02:00
}
bool RadioButton::isChecked() const
{
return nativeWidget()->isChecked();
2014-11-13 01:04:59 +02:00
}
void RadioButton::changeEvent(QEvent *event)
{
d->changeEvent(event);
QGraphicsProxyWidget::changeEvent(event);
}
} // namespace Plasma
#include "moc_radiobutton.cpp"
2014-11-13 01:04:59 +02:00