26 #include <kmimetype.h> 28 #include "private/themedwidgetinterface_p.h" 35 class 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);
104 static_cast<QCheckBox*>(widget())->setText(
text);
109 return static_cast<QCheckBox*>(widget())->text();
114 if (d->imagePath == path) {
122 bool absolutePath = !path.isEmpty() &&
124 !QDir::isRelativePath(path)
126 (path[0] ==
'/' || path.startsWith(QLatin1String(
":/")))
131 d->absImagePath = path;
147 widget()->setStyleSheet(stylesheet);
152 return widget()->styleSheet();
157 return static_cast<QCheckBox*>(widget());
163 QGraphicsProxyWidget::resizeEvent(event);
168 static_cast<QCheckBox*>(widget())->setChecked(
checked);
173 return static_cast<QCheckBox*>(widget())->isChecked();
178 d->changeEvent(event);
179 QGraphicsProxyWidget::changeEvent(event);
184 #include <checkbox.moc> Q_INVOKABLE QString imagePath(const QString &name) const
Retrieve the path for an SVG image in the current theme.
void setText(const QString &text)
Sets the display text for this CheckBox.
Namespace for everything in libplasma.
void setImage(const QString &path)
Sets the path to an image to display.
QCheckBox * nativeWidget() const
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this CheckBox.
void resizeEvent(QGraphicsSceneResizeEvent *event)
static Theme * defaultTheme()
Singleton pattern accessor.
void changeEvent(QEvent *event)
CheckBox(QGraphicsWidget *parent=0)
void setChecked(bool checked)
Sets the checked state.