diff --git a/app/src/desktopthemes/gnometheme.cpp b/app/src/desktopthemes/gnometheme.cpp new file mode 100644 index 0000000000000000000000000000000000000000..118efc1437cf0a32fc7fe0c38e63630f7c673fc3 --- /dev/null +++ b/app/src/desktopthemes/gnometheme.cpp @@ -0,0 +1,41 @@ +#include "gnometheme.h" + +#include <QStringList> +#include <QDir> +#include <QProcess> + +GnomeTheme::GnomeTheme(const QString &path, QObject *parent) + : QObject(parent), path_(path) +{ + themeName_ = QDir(path_).dirName(); +} + +bool GnomeTheme::applyAsWallpaper() const +{ + return setConfig("org.gnome.desktop.background", "picture-uri", "file://" + path_); +} + +bool GnomeTheme::applyAsIcon() const +{ + return setConfig("org.gnome.desktop.interface", "icon-theme", themeName_); +} + +bool GnomeTheme::applyAsCursor() const +{ + return setConfig("org.gnome.desktop.interface", "cursor-theme", themeName_); +} + +bool GnomeTheme::applyAsGtk3Theme() const +{ + return setConfig("org.gnome.desktop.interface", "gtk-theme", themeName_); +} + +bool GnomeTheme::applyAsGnomeShellTheme() const +{ + return setConfig("org.gnome.shell.extensions.user-theme", "name", themeName_); +} + +bool GnomeTheme::setConfig(const QString &schema, const QString &key, const QString &value) const +{ + return QProcess::startDetached("gsettings", QStringList() << "set" << schema << key << value); +} diff --git a/app/src/desktopthemes/gnometheme.h b/app/src/desktopthemes/gnometheme.h new file mode 100644 index 0000000000000000000000000000000000000000..c27e7fea22fa9e50733900cfd207bcfd3b763485 --- /dev/null +++ b/app/src/desktopthemes/gnometheme.h @@ -0,0 +1,23 @@ +#pragma once + +#include <QObject> + +class GnomeTheme : public QObject +{ + Q_OBJECT + +public: + explicit GnomeTheme(const QString &path, QObject *parent = nullptr); + + bool applyAsWallpaper() const; + bool applyAsIcon() const; + bool applyAsCursor() const; + bool applyAsGtk3Theme() const; + bool applyAsGnomeShellTheme() const; + +private: + bool setConfig(const QString &schema, const QString &key, const QString &value) const; + + QString path_; + QString themeName_; +};