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

Apply themes with Cinnamon

parent b830e8f1
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ unix:!ios:!android {
$${PWD}/src/desktopthemes/kdetheme.h \
$${PWD}/src/desktopthemes/gnometheme.h \
$${PWD}/src/desktopthemes/xfcetheme.h \
$${PWD}/src/desktopthemes/cinnamontheme.h \
$${PWD}/src/desktopthemes/matetheme.h
SOURCES += \
......@@ -40,5 +41,6 @@ unix:!ios:!android {
$${PWD}/src/desktopthemes/kdetheme.cpp \
$${PWD}/src/desktopthemes/gnometheme.cpp \
$${PWD}/src/desktopthemes/xfcetheme.cpp \
$${PWD}/src/desktopthemes/cinnamontheme.cpp \
$${PWD}/src/desktopthemes/matetheme.cpp
}
#include "cinnamontheme.h"
#include <QStringList>
#include <QDir>
#include <QProcess>
CinnamonTheme::CinnamonTheme(const QString &path, QObject *parent)
: QObject(parent), path_(path)
{
themeName_ = QDir(path_).dirName();
}
bool CinnamonTheme::applyAsWallpaper() const
{
return setConfig("org.cinnamon.desktop.background", "picture-uri", "file://" + path_);
}
bool CinnamonTheme::applyAsIcon() const
{
return setConfig("org.cinnamon.desktop.interface", "icon-theme", themeName_);
}
bool CinnamonTheme::applyAsCursor() const
{
return setConfig("org.cinnamon.desktop.interface", "cursor-theme", themeName_);
}
bool CinnamonTheme::applyAsGtk3Theme() const
{
return setConfig("org.cinnamon.desktop.interface", "gtk-theme", themeName_);
}
bool CinnamonTheme::applyAsCinnamonTheme() const
{
return setConfig("org.cinnamon.theme", "name", themeName_);
}
bool CinnamonTheme::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 CinnamonTheme : public QObject
{
Q_OBJECT
public:
explicit CinnamonTheme(const QString &path, QObject *parent = nullptr);
bool applyAsWallpaper() const;
bool applyAsIcon() const;
bool applyAsCursor() const;
bool applyAsGtk3Theme() const;
bool applyAsCinnamonTheme() const;
private:
bool setConfig(const QString &schema, const QString &key, const QString &value) const;
QString path_;
QString themeName_;
};
......@@ -8,6 +8,7 @@
#include "desktopthemes/kdetheme.h"
#include "desktopthemes/gnometheme.h"
#include "desktopthemes/xfcetheme.h"
#include "desktopthemes/cinnamontheme.h"
#include "desktopthemes/matetheme.h"
#endif
......@@ -39,6 +40,9 @@ QString DesktopThemeHandler::desktopEnvironment() const
else if (currentDesktop.contains("xfce")) {
desktop = "xfce";
}
else if (currentDesktop.contains("cinnamon")) {
desktop = "cinnamon";
}
else if (currentDesktop.contains("mate")) {
desktop = "mate";
}
......@@ -73,6 +77,13 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const
<< "gtk2_themes"
<< "xfwm4_themes";
}
else if (desktop == "cinnamon") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk3_themes"
<< "cinnamon_themes";
}
else if (desktop == "mate") {
applicableTypes << "wallpapers"
<< "icons"
......@@ -144,6 +155,24 @@ bool DesktopThemeHandler::applyTheme(const QString &path, const QString &install
return xfceTheme.applyAsXfwm4Theme();
}
}
else if (desktop == "cinnamon") {
CinnamonTheme cinnamonTheme(path);
if (installType == "wallpapers") {
return cinnamonTheme.applyAsWallpaper();
}
else if (installType == "icons") {
return cinnamonTheme.applyAsIcon();
}
else if (installType == "cursors") {
return cinnamonTheme.applyAsCursor();
}
else if (installType == "gtk3_themes") {
return cinnamonTheme.applyAsGtk3Theme();
}
else if (installType == "gnome_shell_themes") {
return cinnamonTheme.applyAsCinnamonTheme();
}
}
else if (desktop == "mate") {
MateTheme mateTheme(path);
if (installType == "wallpapers") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment