Skip to content
Snippets Groups Projects
Commit 80a273e8 authored by akiraohgaki's avatar akiraohgaki Committed by GitHub
Browse files

Merge pull request #10 from opendesktop/develop

Develop
parents 9298f80c 6474759a
No related branches found
No related tags found
No related merge requests found
...@@ -32,11 +32,15 @@ unix:!ios:!android { ...@@ -32,11 +32,15 @@ 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/cinnamontheme.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/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::applyAsMetacityTheme() const
{
return setConfig("org.cinnamon.desktop.wm.preferences", "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 applyAsMetacityTheme() const;
bool applyAsCinnamonTheme() const;
private:
bool setConfig(const QString &schema, const QString &key, const QString &value) const;
QString path_;
QString themeName_;
};
#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,8 @@ ...@@ -8,6 +8,8 @@
#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/cinnamontheme.h"
#include "desktopthemes/matetheme.h"
#endif #endif
DesktopThemeHandler::DesktopThemeHandler(QObject *parent) DesktopThemeHandler::DesktopThemeHandler(QObject *parent)
...@@ -38,6 +40,12 @@ QString DesktopThemeHandler::desktopEnvironment() const ...@@ -38,6 +40,12 @@ QString DesktopThemeHandler::desktopEnvironment() const
else if (currentDesktop.contains("xfce")) { else if (currentDesktop.contains("xfce")) {
desktop = "xfce"; desktop = "xfce";
} }
else if (currentDesktop.contains("cinnamon")) {
desktop = "cinnamon";
}
else if (currentDesktop.contains("mate")) {
desktop = "mate";
}
return desktop; return desktop;
} }
...@@ -69,6 +77,21 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const ...@@ -69,6 +77,21 @@ bool DesktopThemeHandler::isApplicableType(const QString &installType) const
<< "gtk2_themes" << "gtk2_themes"
<< "xfwm4_themes"; << "xfwm4_themes";
} }
else if (desktop == "cinnamon") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk3_themes"
<< "metacity_themes"
<< "cinnamon_themes";
}
else if (desktop == "mate") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk2_themes"
<< "metacity_themes";
}
return applicableTypes.contains(installType); return applicableTypes.contains(installType);
} }
...@@ -133,6 +156,45 @@ bool DesktopThemeHandler::applyTheme(const QString &path, const QString &install ...@@ -133,6 +156,45 @@ bool DesktopThemeHandler::applyTheme(const QString &path, const QString &install
return xfceTheme.applyAsXfwm4Theme(); 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 == "metacity_themes") {
return cinnamonTheme.applyAsMetacityTheme();
}
else if (installType == "cinnamon_themes") {
return cinnamonTheme.applyAsCinnamonTheme();
}
}
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