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

Merge pull request #6 from opendesktop/develop

Develop
parents 4e51020b e819ab6e
No related branches found
No related tags found
No related merge requests found
...@@ -96,7 +96,11 @@ bool SystemHandler::isApplicableType(const QString &installType) const ...@@ -96,7 +96,11 @@ bool SystemHandler::isApplicableType(const QString &installType) const
QStringList applicableTypes; QStringList applicableTypes;
if (desktop == "kde") { if (desktop == "kde") {
applicableTypes << "wallpapers"; applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "plasma_desktopthemes"
<< "aurorae_themes";
} }
else if (desktop == "gnome") { else if (desktop == "gnome") {
applicableTypes << "wallpapers" applicableTypes << "wallpapers"
...@@ -122,6 +126,18 @@ bool SystemHandler::applyFile(const QString &path, const QString &installType) c ...@@ -122,6 +126,18 @@ bool SystemHandler::applyFile(const QString &path, const QString &installType) c
if (installType == "wallpapers") { if (installType == "wallpapers") {
return applyKdeWallpaper(path); return applyKdeWallpaper(path);
} }
else if (installType == "icons") {
return applyKdeIcon(path);
}
else if (installType == "cursors") {
return applyKdeCursor(path);
}
else if (installType == "plasma_desktopthemes") {
return applyKdePlasmaDesktoptheme(path);
}
else if (installType == "aurorae_themes") {
return applyKdeAuroraeTheme(path);
}
} }
else if (desktop == "gnome") { else if (desktop == "gnome") {
if (installType == "wallpapers") { if (installType == "wallpapers") {
...@@ -179,6 +195,116 @@ bool SystemHandler::applyKdeWallpaper(const QString &path) const ...@@ -179,6 +195,116 @@ bool SystemHandler::applyKdeWallpaper(const QString &path) const
return true; return true;
} }
bool SystemHandler::applyKdeIcon(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('kdeglobals');"
<< "c.group = 'Icons';"
<< "c.writeEntry('Theme', '" + themeName + "');";
QVariantList arguments;
arguments << QVariant(script);
message.setArguments(arguments);
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
QProcess::startDetached("kquitapp5 plasmashell");
QProcess::startDetached("kstart5 plasmashell");
return true;
}
bool SystemHandler::applyKdeCursor(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('kcminputrc');"
<< "c.group = 'Mouse';"
<< "c.writeEntry('cursorTheme', '" + themeName + "');";
QVariantList arguments;
arguments << QVariant(script);
message.setArguments(arguments);
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
return true;
}
bool SystemHandler::applyKdePlasmaDesktoptheme(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('plasmarc');"
<< "c.group = 'Theme';"
<< "c.writeEntry('name', '" + themeName + "');";
QVariantList arguments;
arguments << QVariant(script);
message.setArguments(arguments);
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
QProcess::startDetached("kquitapp5 plasmashell");
QProcess::startDetached("kstart5 plasmashell");
return true;
}
bool SystemHandler::applyKdeAuroraeTheme(const QString &path) const
{
auto themeName = QFileInfo(path).fileName();
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('kwinrc');"
<< "c.group = 'org.kde.kdecoration2';"
<< "c.writeEntry('library', 'org.kde.kwin.aurorae');"
<< "c.writeEntry('theme', '__aurorae__svg__" + themeName + "');";
QVariantList arguments;
arguments << QVariant(script);
message.setArguments(arguments);
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
auto refreshMessage = QDBusMessage::createMethodCall("org.kde.KWin", "/KWin", "org.kde.KWin", "reconfigure");
QDBusConnection::sessionBus().call(refreshMessage);
return true;
}
bool SystemHandler::applyGnomeWallpaper(const QString &path) const bool SystemHandler::applyGnomeWallpaper(const QString &path) const
{ {
QStringList arguments{"set", "org.gnome.desktop.background", "picture-uri", "file://" + path}; QStringList arguments{"set", "org.gnome.desktop.background", "picture-uri", "file://" + path};
......
...@@ -24,6 +24,10 @@ public slots: ...@@ -24,6 +24,10 @@ public slots:
private: private:
#ifdef QTLIB_UNIX #ifdef QTLIB_UNIX
bool applyKdeWallpaper(const QString &path) const; bool applyKdeWallpaper(const QString &path) const;
bool applyKdeIcon(const QString &path) const;
bool applyKdeCursor(const QString &path) const;
bool applyKdePlasmaDesktoptheme(const QString &path) const;
bool applyKdeAuroraeTheme(const QString &path) const;
bool applyGnomeWallpaper(const QString &path) const; bool applyGnomeWallpaper(const QString &path) const;
bool applyGnomeIcon(const QString &path) const; bool applyGnomeIcon(const QString &path) const;
......
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