Add method findImage

Qt QuickControls require an abosolute path to the image
This commit is contained in:
Antonis Tsiapaliokas 2013-08-05 14:00:43 +03:00 committed by Martin Gräßlin
parent 2431da8222
commit fc662d175d
3 changed files with 14 additions and 3 deletions

View file

@ -175,3 +175,8 @@ void EffectView::loadKWinEffects(const QHash<QString, bool> &effectsChanged) {
QDBusConnection::sessionBus().send(messageUnloadEffect);
}
QString EffectView::findImage(const QString &imagePath, int size) {
const QString relativePath("icons/oxygen/" + QString::number(size) + 'x' + QString::number(size) + '/' + imagePath);
const QString fullImagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, relativePath, QStandardPaths::LocateFile);
return fullImagePath;
}

View file

@ -77,6 +77,7 @@ public:
Q_INVOKABLE void effectStatus(const QString &effectName, bool status);
Q_INVOKABLE bool isEnabled(const QString &effectName);
Q_INVOKABLE void syncConfig();
Q_INVOKABLE QString findImage(const QString &imagePath, int size = 128);
private:
QHash<QString, bool> m_effectStatus;

View file

@ -69,7 +69,7 @@ Component {
visible: false
Text {
text: "Author: " + model.AuthorName + "\n" + "License" + model.License
text: "Author: " + model.AuthorName + "\n" + "License: " + model.License
font.bold: true
}
PropertyAnimation {id: animationAbout; target: aboutItem; property: "visible"; to: !aboutItem.visible}
@ -90,7 +90,9 @@ Component {
id: configureButton
anchors.left: effectItem.right
visible: effectConfig.effectUiConfigExists(model.Name)
text: "CONFIGURE EFFECT"
iconSource: engineObject.findImage("actions/configure.png")
width: 50
height: 25
enabled: myCheckBox.checked
onClicked: {
effectConfig.openConfig(model.Name);
@ -100,7 +102,10 @@ Component {
Button {
id: aboutButton
anchors.left: configureButton.right
text: "ABOUT UI BUTTON"
width: 50
height: 25
iconSource: engineObject.findImage("status/dialog-information.png");
onClicked: {
animationAbout.running = true;
animationAboutSpacing.running = true;