Skip to content
Snippets Groups Projects
Commit d30cb4e5 authored by akiraohgaki's avatar akiraohgaki
Browse files

Add GnomeTheme class

parent cd0f7f8c
Branches
Tags
No related merge requests found
#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);
}
#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_;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment