24#include <QRadioButton>
28#include "private/themedwidgetinterface_p.h"
35class RadioButtonPrivate :
public ThemedWidgetInterface<RadioButton>
38 RadioButtonPrivate(RadioButton *radio)
39 : ThemedWidgetInterface<RadioButton>(radio),
49 void setPixmap(RadioButton *q)
51 if (imagePath.isEmpty()) {
55 KMimeType::Ptr mime = KMimeType::findByPath(absImagePath);
56 QPixmap pm(q->size().toSize());
58 if (mime->is(
"image/svg+xml")) {
61 svg->paint(&p, pm.rect());
63 pm = QPixmap(absImagePath);
66 static_cast<QRadioButton*
>(q->widget())->setIcon(QIcon(pm));
76 d(new RadioButtonPrivate(this))
78 QRadioButton *native =
new QRadioButton;
79 connect(native, SIGNAL(
toggled(
bool)),
this, SIGNAL(
toggled(
bool)));
81 native->setWindowIcon(QIcon());
82 native->setAttribute(Qt::WA_NoSystemBackground);
86RadioButton::~RadioButton()
91void RadioButton::setText(
const QString &text)
93 static_cast<QRadioButton*
>(widget())->
setText(
text);
96QString RadioButton::text()
const
98 return static_cast<QRadioButton*
>(widget())->
text();
101void RadioButton::setImage(
const QString &path)
103 if (d->imagePath == path) {
111 bool absolutePath = !path.isEmpty() &&
113 !QDir::isRelativePath(path)
115 (path[0] ==
'/' || path.startsWith(QLatin1String(
":/")))
120 d->absImagePath = path;
129QString RadioButton::image()
const
134void RadioButton::setStyleSheet(
const QString &stylesheet)
136 widget()->setStyleSheet(stylesheet);
139QString RadioButton::styleSheet()
141 return widget()->styleSheet();
144QRadioButton *RadioButton::nativeWidget()
const
146 return static_cast<QRadioButton*
>(widget());
149void RadioButton::resizeEvent(QGraphicsSceneResizeEvent *event)
152 QGraphicsProxyWidget::resizeEvent(event);
155void RadioButton::setChecked(
bool checked)
160bool RadioButton::isChecked()
const
162 return static_cast<QRadioButton*
>(widget())->
isChecked();
165void RadioButton::changeEvent(QEvent *event)
167 d->changeEvent(event);
168 QGraphicsProxyWidget::changeEvent(event);
173#include <radiobutton.moc>
Q_INVOKABLE QString imagePath(const QString &name) const
Retrieve the path for an SVG image in the current theme.
static Theme * defaultTheme()
Singleton pattern accessor.
Namespace for everything in libplasma.