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

Apply themes with Mate

wallpaper, icon, cursor, gtk2 theme, metacity theme
parent 69fa86f2
No related branches found
No related tags found
No related merge requests found
...@@ -32,11 +32,13 @@ unix:!ios:!android { ...@@ -32,11 +32,13 @@ unix:!ios:!android {
$${PWD}/src/handlers/desktopthemehandler.h \ $${PWD}/src/handlers/desktopthemehandler.h \
$${PWD}/src/desktopthemes/kdetheme.h \ $${PWD}/src/desktopthemes/kdetheme.h \
$${PWD}/src/desktopthemes/gnometheme.h \ $${PWD}/src/desktopthemes/gnometheme.h \
$${PWD}/src/desktopthemes/xfcetheme.h $${PWD}/src/desktopthemes/xfcetheme.h \
$${PWD}/src/desktopthemes/matetheme.h
SOURCES += \ SOURCES += \
$${PWD}/src/handlers/desktopthemehandler.cpp \ $${PWD}/src/handlers/desktopthemehandler.cpp \
$${PWD}/src/desktopthemes/kdetheme.cpp \ $${PWD}/src/desktopthemes/kdetheme.cpp \
$${PWD}/src/desktopthemes/gnometheme.cpp \ $${PWD}/src/desktopthemes/gnometheme.cpp \
$${PWD}/src/desktopthemes/xfcetheme.cpp $${PWD}/src/desktopthemes/xfcetheme.cpp \
$${PWD}/src/desktopthemes/matetheme.cpp
} }
#include "matetheme.h"
#include <QStringList>
#include <QDir>
#include <QProcess>
MateTheme::MateTheme(const QString &path, QObject *parent)
: QObject(parent), path_(path)
{
themeName_ = QDir(path_).dirName();
}
bool MateTheme::applyAsWallpaper() const
{
return setConfig("org.mate.background", "picture-filename", path_);
}
bool MateTheme::applyAsIcon() const
{
return setConfig("org.mate.interface", "icon-theme", themeName_);
}
bool MateTheme::applyAsCursor() const
{
return setConfig("org.mate.peripherals-mouse", "cursor-theme", themeName_);
}
bool MateTheme::applyAsGtk2Theme() const
{
return setConfig("org.mate.interface", "gtk-theme", themeName_);
}
bool MateTheme::applyAsMetacityTheme() const
{
return setConfig("org.mate.Marco.general", "theme", themeName_);
}
bool MateTheme::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 MateTheme : public QObject
{
Q_OBJECT
public:
explicit MateTheme(const QString &path, QObject *parent = nullptr);
bool applyAsWallpaper() const;
bool applyAsIcon() const;
bool applyAsCursor() const;
bool applyAsGtk2Theme() const;
bool applyAsMetacityTheme() const;
private:
bool setConfig(const QString &schema, const QString &key, const QString &value) const;
QString path_;
QString themeName_;
};
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "desktopthemes/kdetheme.h" #include "desktopthemes/kdetheme.h"
#include "desktopthemes/gnometheme.h" #include "desktopthemes/gnometheme.h"
#include "desktopthemes/xfcetheme.h" #include "desktopthemes/xfcetheme.h"
#include "desktopthemes/matetheme.h"
#endif #endif
DesktopThemeHandler::DesktopThemeHandler(QObject *parent) DesktopThemeHandler::DesktopThemeHandler(QObject *parent)
...@@ -38,6 +39,9 @@ QString DesktopThemeHandler::desktopEnvironment() const ...@@ -38,6 +39,9 @@ QString DesktopThemeHandler::desktopEnvironment() const
else if (currentDesktop.contains("xfce")) { else if (currentDesktop.contains("xfce")) {
desktop = "xfce"; desktop = "xfce";
} }
else if (currentDesktop.contains("mate")) {
desktop = "mate";
}
return desktop; return desktop;
} }
...@@ -69,6 +73,13 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const ...@@ -69,6 +73,13 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const
<< "gtk2_themes" << "gtk2_themes"
<< "xfwm4_themes"; << "xfwm4_themes";
} }
else if (desktop == "mate") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk2_themes"
<< "metacity_themes";
}
return applicableTypes.contains(installType); return applicableTypes.contains(installType);
} }
...@@ -133,6 +144,24 @@ bool DesktopThemeHandler::applyTheme(const QString &path, const QString &install ...@@ -133,6 +144,24 @@ bool DesktopThemeHandler::applyTheme(const QString &path, const QString &install
return xfceTheme.applyAsXfwm4Theme(); return xfceTheme.applyAsXfwm4Theme();
} }
} }
else if (desktop == "mate") {
MateTheme mateTheme(path);
if (installType == "wallpapers") {
return mateTheme.applyAsWallpaper();
}
else if (installType == "icons") {
return mateTheme.applyAsIcon();
}
else if (installType == "cursors") {
return mateTheme.applyAsCursor();
}
else if (installType == "gtk2_themes") {
return mateTheme.applyAsGtk2Theme();
}
else if (installType == "metacity_themes") {
return mateTheme.applyAsMetacityTheme();
}
}
} }
return false; return false;
......
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