From c8d6e8bd9ded24416bb45fa992b33b69696b65c5 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Wed, 28 Jun 2017 10:04:36 +0900 Subject: [PATCH] Add function to set property with xfconf --- app/src/handlers/systemhandler.cpp | 15 +++++++-------- app/src/handlers/systemhandler.h | 5 +++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/handlers/systemhandler.cpp b/app/src/handlers/systemhandler.cpp index cb1f913..a5c3d10 100644 --- a/app/src/handlers/systemhandler.cpp +++ b/app/src/handlers/systemhandler.cpp @@ -8,7 +8,6 @@ #include <QProcess> #include <QDBusMessage> #include <QDBusConnection> -#include <QDBusVariant> #include <QDebug> #endif @@ -297,15 +296,10 @@ bool SystemHandler::applyGnomeGnomeShellTheme(const QString &path) const return QProcess::startDetached("gsettings", arguments); } -bool SystemHandler::applyXfceWallpaper(const QString &path) const +bool SystemHandler::setPropertyWithXfconf(const QString &channel, const QString &property, const QDBusVariant &value) const { - QString channelValue = "xfce4-desktop"; - //QString propertyValue = "/backdrop/screen0/monitor0/image-path"; - QString propertyValue = "/backdrop/screen0/monitor0/workspace0/last-image"; - QDBusVariant valueValue(path); - auto message = QDBusMessage::createMethodCall("org.xfce.Xfconf", "/org/xfce/Xfconf", "org.xfce.Xfconf", "SetProperty"); - message.setArguments(QVariantList() << QVariant(channelValue) << QVariant(propertyValue) << QVariant::fromValue(valueValue)); + message.setArguments(QVariantList() << QVariant(channel) << QVariant(property) << QVariant::fromValue(value)); auto reply = QDBusConnection::sessionBus().call(message); if (reply.type() == QDBusMessage::ErrorMessage) { @@ -314,4 +308,9 @@ bool SystemHandler::applyXfceWallpaper(const QString &path) const } return true; } + +bool SystemHandler::applyXfceWallpaper(const QString &path) const +{ + return setPropertyWithXfconf("xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", QDBusVariant(path)); +} #endif diff --git a/app/src/handlers/systemhandler.h b/app/src/handlers/systemhandler.h index 06cd247..1d61714 100644 --- a/app/src/handlers/systemhandler.h +++ b/app/src/handlers/systemhandler.h @@ -2,6 +2,10 @@ #include <QObject> +#ifdef QTLIB_UNIX +#include <QDBusVariant> +#endif + class SystemHandler : public QObject { Q_OBJECT @@ -36,6 +40,7 @@ private: bool applyGnomeGtk3Theme(const QString &path) const; bool applyGnomeGnomeShellTheme(const QString &path) const; + bool setPropertyWithXfconf(const QString &channel, const QString &property, const QDBusVariant &value) const; bool applyXfceWallpaper(const QString &path) const; #endif }; -- GitLab