28#include "private/themedwidgetinterface_p.h"
35class CheckBoxPrivate :
public ThemedWidgetInterface<CheckBox>
38 CheckBoxPrivate(CheckBox *c)
39 : ThemedWidgetInterface<CheckBox>(c),
51 if (imagePath.isEmpty()) {
57 KMimeType::Ptr mime = KMimeType::findByPath(absImagePath);
58 QPixmap pm(q->size().toSize());
60 if (mime->is(
"image/svg+xml") || mime->is(
"image/svg+xml-compressed")) {
61 if (!svg || svg->imagePath() != imagePath) {
64 svg->setImagePath(imagePath);
65 QObject::connect(svg, SIGNAL(repaintNeeded()), q, SLOT(setPixmap()));
69 svg->paint(&p, pm.rect());
73 pm = QPixmap(absImagePath);
76 static_cast<QCheckBox*
>(q->widget())->setIcon(QIcon(pm));
86 d(new CheckBoxPrivate(this))
88 QCheckBox *native =
new QCheckBox;
89 connect(native, SIGNAL(
toggled(
bool)),
this, SIGNAL(
toggled(
bool)));
91 native->setWindowIcon(QIcon());
92 native->setAttribute(Qt::WA_NoSystemBackground);
102void CheckBox::setText(
const QString &text)
107QString CheckBox::text()
const
109 return static_cast<QCheckBox*
>(widget())->
text();
112void CheckBox::setImage(
const QString &path)
114 if (d->imagePath == path) {
122 bool absolutePath = !path.isEmpty() &&
124 !QDir::isRelativePath(path)
126 (path[0] ==
'/' || path.startsWith(QLatin1String(
":/")))
131 d->absImagePath = path;
140QString CheckBox::image()
const
145void CheckBox::setStyleSheet(
const QString &stylesheet)
147 widget()->setStyleSheet(stylesheet);
150QString CheckBox::styleSheet()
152 return widget()->styleSheet();
155QCheckBox *CheckBox::nativeWidget()
const
157 return static_cast<QCheckBox*
>(widget());
160void CheckBox::resizeEvent(QGraphicsSceneResizeEvent *event)
163 QGraphicsProxyWidget::resizeEvent(event);
166void CheckBox::setChecked(
bool checked)
171bool CheckBox::isChecked()
const
173 return static_cast<QCheckBox*
>(widget())->
isChecked();
176void CheckBox::changeEvent(QEvent *event)
178 d->changeEvent(event);
179 QGraphicsProxyWidget::changeEvent(event);
184#include <checkbox.moc>
void setText(const QString &text)
Sets the display text for this CheckBox.
void setChecked(bool checked)
Sets the checked state.
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.