Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • akiraohgaki/ocs-manager
  • dfn2/ocs-manager
  • azubieta/ocs-manager
  • rws77/ocs-manager
4 results
Show changes
Commits on Source (321)
Showing
with 823 additions and 75 deletions
*.pro.user
lib/qtlib/
build_*/
lib/qtil/
lib/AppImageUpdate/
lib/AppImageUpdate-prebuilt/
stages:
- build
appimage:
stage: build
image: ubuntu:14.04
only:
- master
- /^release\-.+/
script:
- ./scripts/package appimage
artifacts:
paths:
- build_*/ocs-manager*.AppImage
expire_in: 2 days
# ocs-manager
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Build Status](https://travis-ci.org/opendesktop/ocs-manager.svg?branch=master)](https://travis-ci.org/opendesktop/ocs-manager)
A tool to handle filemanagement and "apply".
A tool to handle item installation from OCS provider, file management, and apply themes.
Copyright: 2017, Opendesktop.org
Copyright: 2017-2019, Opendesktop.org
License: GPL-3+
### Package depends
* libqt5gui5
* libqt5websockets5
* libqt5dbus5
### Package depends (build)
* build-essential
* qt5-default
* libqt5websockets5-dev
......@@ -11,7 +11,9 @@ HEADERS += \
$${PWD}/src/handlers/confighandler.h \
$${PWD}/src/handlers/systemhandler.h \
$${PWD}/src/handlers/ocsapihandler.h \
$${PWD}/src/handlers/itemhandler.h
$${PWD}/src/handlers/itemhandler.h \
$${PWD}/src/handlers/updatehandler.h \
$${PWD}/src/handlers/desktopthemehandler.h
SOURCES += \
$${PWD}/src/main.cpp \
......@@ -19,12 +21,30 @@ SOURCES += \
$${PWD}/src/handlers/confighandler.cpp \
$${PWD}/src/handlers/systemhandler.cpp \
$${PWD}/src/handlers/ocsapihandler.cpp \
$${PWD}/src/handlers/itemhandler.cpp
$${PWD}/src/handlers/itemhandler.cpp \
$${PWD}/src/handlers/updatehandler.cpp \
$${PWD}/src/handlers/desktopthemehandler.cpp
RESOURCES += $${PWD}/configs/configs.qrc
INCLUDEPATH += $${PWD}/src
unix:!ios:!android {
contains(DEFINES, APP_DESKTOP) {
QT += dbus
HEADERS += \
$${PWD}/src/updaters/appimageupdater.h \
$${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 += \
$${PWD}/src/updaters/appimageupdater.cpp \
$${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
}
{
"id": "ocs-manager",
"name": "ocs-manager",
"version": "0.2.0",
"version": "0.8.1",
"organization": "Opendesktop.org",
"domain": "org.opendesktop.ocs-manager",
"icon": "",
"description": "A tool to handle filemanagement and apply.",
"icon": ":/desktop/ocs-manager.svg",
"description": "A tool to handle item installation from OCS provider, file management, and apply themes.",
"license": "GPL-3+",
"author": "Opendesktop.org",
"contact": "contact@opendesktop.org",
"homepage": "https://github.com/opendesktop/ocs-manager"
"homepage": "https://git.opendesktop.org/akiraohgaki/ocs-manager"
}
{
"bin": {
"name": "Softwares",
"destination": "$HOME/.local/bin",
"name": "Software",
"destination": "",
"xdg_destination": "$HOME/.local/bin",
"generic_destination": "$APP_DATA/bin"
},
"downloads": {
"name": "Downloads",
"destination": "$XDG_DOWNLOAD_DIR",
"destination": "",
"xdg_destination": "$XDG_DOWNLOAD_DIR",
"generic_destination": "$APP_DATA/downloads"
},
"documents": {
"name": "Documents",
"destination": "$XDG_DOCUMENTS_DIR",
"destination": "",
"xdg_destination": "$XDG_DOCUMENTS_DIR",
"generic_destination": "$APP_DATA/documents"
},
"pictures": {
"name": "Pictures",
"destination": "$XDG_PICTURES_DIR",
"destination": "",
"xdg_destination": "$XDG_PICTURES_DIR",
"generic_destination": "$APP_DATA/pictures"
},
"music": {
"name": "Music",
"destination": "$XDG_MUSIC_DIR",
"destination": "",
"xdg_destination": "$XDG_MUSIC_DIR",
"generic_destination": "$APP_DATA/music"
},
"videos": {
"name": "Videos",
"destination": "$XDG_VIDEOS_DIR",
"destination": "",
"xdg_destination": "$XDG_VIDEOS_DIR",
"generic_destination": "$APP_DATA/videos"
},
"wallpapers": {
"name": "Wallpapers",
"destination": "$XDG_DATA_HOME/wallpapers",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/wallpapers",
"generic_destination": "$APP_DATA/wallpapers"
},
"fonts": {
"name": "Fonts",
"destination": "$HOME/.fonts",
"destination": "",
"xdg_destination": "$HOME/.fonts",
"generic_destination": "$APP_DATA/fonts"
},
"cursors": {
"name": "Cursors",
"destination": "$HOME/.icons",
"destination": "",
"xdg_destination": "$HOME/.icons",
"generic_destination": "$APP_DATA/cursors"
},
"icons": {
"name": "Icons",
"destination": "$XDG_DATA_HOME/icons",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/icons",
"generic_destination": "$APP_DATA/icons"
},
"emoticons": {
"name": "Emoticons",
"destination": "$XDG_DATA_HOME/emoticons",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/emoticons",
"generic_destination": "$APP_DATA/emoticons"
},
"themes": {
"name": "Desktop Themes",
"destination": "$HOME/.themes",
"destination": "",
"xdg_destination": "$HOME/.themes",
"generic_destination": "$APP_DATA/themes"
},
"emerald_themes": {
"name": "Emerald Themes",
"destination": "$HOME/.emerald/themes",
"destination": "",
"xdg_destination": "$HOME/.emerald/themes",
"generic_destination": "$APP_DATA/emerald_themes"
},
"enlightenment_themes": {
"name": "Enlightenment Themes",
"destination": "$HOME/.e/e/themes",
"destination": "",
"xdg_destination": "$HOME/.e/e/themes",
"generic_destination": "$APP_DATA/enlightenment_themes"
},
"enlightenment_backgrounds": {
"name": "Enlightenment Backgrounds",
"destination": "$HOME/.e/e/backgrounds",
"destination": "",
"xdg_destination": "$HOME/.e/e/backgrounds",
"generic_destination": "$APP_DATA/enlightenment_backgrounds"
},
"fluxbox_styles": {
"name": "Fluxbox Styles",
"destination": "$HOME/.fluxbox/styles",
"destination": "",
"xdg_destination": "$HOME/.fluxbox/styles",
"generic_destination": "$APP_DATA/fluxbox_styles"
},
"pekwm_themes": {
"name": "PekWM Themes",
"destination": "$HOME/.pekwm/themes",
"destination": "",
"xdg_destination": "$HOME/.pekwm/themes",
"generic_destination": "$APP_DATA/pekwm_themes"
},
"icewm_themes": {
"name": "IceWM Themes",
"destination": "$HOME/.icewm/themes",
"destination": "",
"xdg_destination": "$HOME/.icewm/themes",
"generic_destination": "$APP_DATA/icewm_themes"
},
"plasma_plasmoids": {
"name": "Plasma Plasmoids",
"destination": "$XDG_DATA_HOME/plasma/plasmoids",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/plasma/plasmoids",
"generic_destination": "$APP_DATA/plasma_plasmoids"
},
"plasma_look_and_feel": {
"name": "Plasma Look and Feel",
"destination": "$XDG_DATA_HOME/plasma/look-and-feel",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/plasma/look-and-feel",
"generic_destination": "$APP_DATA/plasma_look_and_feel"
},
"plasma_desktopthemes": {
"name": "Plasma Desktop Themes",
"destination": "$XDG_DATA_HOME/plasma/desktoptheme",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/plasma/desktoptheme",
"generic_destination": "$APP_DATA/plasma_desktopthemes"
},
"kwin_effects": {
"name": "KWin Effects",
"destination": "$XDG_DATA_HOME/kwin/effects",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/effects",
"generic_destination": "$APP_DATA/kwin_effects"
},
"kwin_scripts": {
"name": "KWin Scripts",
"destination": "$XDG_DATA_HOME/kwin/scripts",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/scripts",
"generic_destination": "$APP_DATA/kwin_scripts"
},
"kwin_tabbox": {
"name": "KWin Window Switcher",
"destination": "$XDG_DATA_HOME/kwin/tabbox",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/tabbox",
"generic_destination": "$APP_DATA/kwin_tabbox"
},
"aurorae_themes": {
"name": "Aurorae Themes",
"destination": "$XDG_DATA_HOME/aurorae/themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/aurorae/themes",
"generic_destination": "$APP_DATA/aurorae_themes"
},
"dekorator_themes": {
"name": "deKorator Themes",
"destination": "$XDG_DATA_HOME/deKorator/themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/deKorator/themes",
"generic_destination": "$APP_DATA/dekorator_themes"
},
"qtcurve": {
"name": "QtCurve Themes",
"destination": "$XDG_DATA_HOME/QtCurve",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/QtCurve",
"generic_destination": "$APP_DATA/qtcurve"
},
"color_schemes": {
"name": "KDE Color Schemes",
"destination": "$XDG_DATA_HOME/color-schemes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/color-schemes",
"generic_destination": "$APP_DATA/color_schemes"
},
"gnome_shell_extensions": {
"name": "Gnome Shell Extensions",
"destination": "$XDG_DATA_HOME/gnome-shell/extensions",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/gnome-shell/extensions",
"generic_destination": "$APP_DATA/gnome_shell_extensions"
},
"cinnamon_applets": {
"name": "Cinnamon Applets",
"destination": "$XDG_DATA_HOME/cinnamon/applets",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/applets",
"generic_destination": "$APP_DATA/cinnamon_applets"
},
"cinnamon_desklets": {
"name": "Cinnamon Desklets",
"destination": "$XDG_DATA_HOME/cinnamon/desklets",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/desklets",
"generic_destination": "$APP_DATA/cinnamon_desklets"
},
"cinnamon_extensions": {
"name": "Cinnamon Extensions",
"destination": "$XDG_DATA_HOME/cinnamon/extensions",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/extensions",
"generic_destination": "$APP_DATA/cinnamon_extensions"
},
"nautilus_scripts": {
"name": "Nautilus Scripts",
"destination": "$XDG_DATA_HOME/nautilus/scripts",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/nautilus/scripts",
"generic_destination": "$APP_DATA/nautilus_scripts"
},
"amarok_scripts": {
"name": "Amarok Scripts",
"destination": "$KDEHOME/share/apps/amarok/scripts",
"destination": "",
"xdg_destination": "$KDEHOME/share/apps/amarok/scripts",
"generic_destination": "$APP_DATA/amarok_scripts"
},
"yakuake_skins": {
"name": "Yakuake Skins",
"destination": "$KDEHOME/share/apps/yakuake/skins",
"destination": "",
"xdg_destination": "$KDEHOME/share/apps/yakuake/skins",
"generic_destination": "$APP_DATA/yakuake_skins"
},
"cairo_clock_themes": {
"name": "Cairo-Clock Themes",
"destination": "$HOME/.cairo-clock/themes",
"destination": "",
"xdg_destination": "$HOME/.cairo-clock/themes",
"generic_destination": "$APP_DATA/cairo_clock_themes"
},
"books": {
"name": "Books",
"destination": "$APP_DATA/books",
"destination": "",
"xdg_destination": "$APP_DATA/books",
"generic_destination": "$APP_DATA/books"
},
"comics": {
"name": "Comics",
"destination": "$APP_DATA/comics",
"destination": "",
"xdg_destination": "$APP_DATA/comics",
"generic_destination": "$APP_DATA/comics"
}
}
#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 "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_;
};
#include "kdetheme.h"
#include <QVariantList>
#include <QTextStream>
#include <QDir>
#include <QProcess>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDebug>
KdeTheme::KdeTheme(const QString &path, QObject *parent)
: QObject(parent), path_(path)
{
themeName_ = QDir(path_).dirName();
}
bool KdeTheme::applyAsWallpaper() const
{
QString script;
QTextStream out(&script);
out << "for (var key in desktops()) {"
<< "var d = desktops()[key];"
<< "d.wallpaperPlugin = 'org.kde.image';"
<< "d.currentConfigGroup = ['Wallpaper', 'org.kde.image', 'General'];"
<< "d.writeConfig('Image', 'file://" + path_ + "');"
<< "}";
return evaluateScript(script);
}
bool KdeTheme::applyAsIcon() const
{
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('kdeglobals');"
<< "c.group = 'Icons';"
<< "c.writeEntry('Theme', '" + themeName_ + "');";
if (evaluateScript(script)) {
auto iconChanged = QDBusMessage::createSignal("/KIconLoader", "org.kde.KIconLoader", "iconChanged");
iconChanged.setArguments(QVariantList() << QVariant(qint32(0)));
QDBusConnection::sessionBus().send(iconChanged);
auto notifyChange = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange");
notifyChange.setArguments(QVariantList() << QVariant(qint32(4)) << QVariant(qint32(0)));
QDBusConnection::sessionBus().send(notifyChange);
return true;
}
return false;
}
bool KdeTheme::applyAsCursor() const
{
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('kcminputrc');"
<< "c.group = 'Mouse';"
<< "c.writeEntry('cursorTheme', '" + themeName_ + "');";
if (evaluateScript(script)) {
QProcess::startDetached("sh -c \"echo 'Xcursor.theme: " + themeName_ + "' | xrdb -merge\"");
auto setLaunchEnv = QDBusMessage::createMethodCall("org.kde.klauncher5", "/KLauncher", "org.kde.KLauncher", "setLaunchEnv");
setLaunchEnv.setArguments(QVariantList() << QVariant(QString("XCURSOR_THEME")) << QVariant(themeName_));
QDBusConnection::sessionBus().call(setLaunchEnv);
auto notifyChange = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange");
notifyChange.setArguments(QVariantList() << QVariant(qint32(5)) << QVariant(qint32(0)));
QDBusConnection::sessionBus().send(notifyChange);
QProcess::startDetached("kwin --replace");
QProcess::startDetached("kquitapp5 plasmashell");
QProcess::startDetached("sh -c \"XCURSOR_THEME='" + themeName_ + "' kstart5 plasmashell\"");
return true;
}
return false;
}
bool KdeTheme::applyAsPlasma5Desktoptheme() const
{
QString script;
QTextStream out(&script);
out << "var c = ConfigFile('plasmarc');"
<< "c.group = 'Theme';"
<< "c.writeEntry('name', '" + themeName_ + "');";
if (evaluateScript(script)) {
QProcess::startDetached("kquitapp5 plasmashell");
QProcess::startDetached("kstart5 plasmashell");
return true;
}
return false;
}
bool KdeTheme::applyAsAuroraeTheme() const
{
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_ + "');";
if (evaluateScript(script)) {
auto reloadConfig = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
QDBusConnection::sessionBus().send(reloadConfig);
return true;
}
return false;
}
bool KdeTheme::evaluateScript(const QString &script) const
{
auto message = QDBusMessage::createMethodCall("org.kde.plasmashell", "/PlasmaShell", "org.kde.PlasmaShell", "evaluateScript");
message.setArguments(QVariantList() << QVariant(script));
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
return true;
}
#pragma once
#include <QObject>
class KdeTheme : public QObject
{
Q_OBJECT
public:
explicit KdeTheme(const QString &path, QObject *parent = nullptr);
bool applyAsWallpaper() const;
bool applyAsIcon() const;
bool applyAsCursor() const;
bool applyAsPlasma5Desktoptheme() const;
bool applyAsAuroraeTheme() const;
private:
bool evaluateScript(const QString &script) 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_;
};
#include "xfcetheme.h"
#include <QVariantList>
#include <QDir>
#include <QProcess>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusVariant>
#include <QDebug>
XfceTheme::XfceTheme(const QString &path, QObject *parent)
: QObject(parent), path_(path)
{
themeName_ = QDir(path_).dirName();
}
bool XfceTheme::applyAsWallpaper() const
{
return setConfig("xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", path_);
}
bool XfceTheme::applyAsIcon() const
{
return setConfig("xsettings", "/Net/IconThemeName", themeName_);
}
bool XfceTheme::applyAsCursor() const
{
return setConfig("xsettings", "/Gtk/CursorThemeName", themeName_);
}
bool XfceTheme::applyAsGtk2Theme() const
{
return setConfig("xsettings", "/Net/ThemeName", themeName_);
}
bool XfceTheme::applyAsXfwm4Theme() const
{
return setConfig("xfwm4", "/general/theme", themeName_);
}
bool XfceTheme::setConfig(const QString &channel, const QString &property, const QString &value) const
{
auto message = QDBusMessage::createMethodCall("org.xfce.Xfconf", "/org/xfce/Xfconf", "org.xfce.Xfconf", "SetProperty");
message.setArguments(QVariantList() << QVariant(channel) << QVariant(property) << QVariant::fromValue(QDBusVariant(value)));
auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << reply.errorMessage();
return false;
}
return true;
}
#pragma once
#include <QObject>
class XfceTheme : public QObject
{
Q_OBJECT
public:
explicit XfceTheme(const QString &path, QObject *parent = nullptr);
bool applyAsWallpaper() const;
bool applyAsIcon() const;
bool applyAsCursor() const;
bool applyAsGtk2Theme() const;
bool applyAsXfwm4Theme() const;
private:
bool setConfig(const QString &channel, const QString &property, const QString &value) const;
QString path_;
QString themeName_;
};
......@@ -3,15 +3,15 @@
#include <QStringList>
#include <QStandardPaths>
#include "qtlib_dir.h"
#include "qtil_dir.h"
ConfigHandler::ConfigHandler(QObject *parent)
: QObject(parent)
{
appConfig_ = qtlib::Config(":/configs");
appConfig_ = Qtil::Config(":/configs");
importAppConfigApplication();
importAppConfigInstallTypes();
usrConfig_ = qtlib::Config(qtlib::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
usrConfig_ = Qtil::Config(Qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
}
QJsonObject ConfigHandler::getAppConfigApplication() const
......@@ -31,6 +31,11 @@ QJsonObject ConfigHandler::getUsrConfigApplication() const
bool ConfigHandler::setUsrConfigApplication(const QJsonObject &object) const
{
/* object format
{
"update_checked_at": 1483658977219
}
*/
return usrConfig_.set("application", object);
}
......@@ -64,6 +69,16 @@ bool ConfigHandler::setUsrConfigInstalledItems(const QJsonObject &object) const
return usrConfig_.set("installed_items", object);
}
QJsonObject ConfigHandler::getUsrConfigUpdateAvailableItems() const
{
return usrConfig_.get("update_available_items");
}
bool ConfigHandler::setUsrConfigUpdateAvailableItems(const QJsonObject &object) const
{
return usrConfig_.set("update_available_items", object);
}
bool ConfigHandler::setUsrConfigProvidersProvider(const QString &providerKey, const QJsonObject &object) const
{
/* object format
......@@ -162,6 +177,26 @@ bool ConfigHandler::removeUsrConfigInstalledItemsItem(const QString &itemKey) co
return setUsrConfigInstalledItems(installedItems);
}
bool ConfigHandler::setUsrConfigUpdateAvailableItemsItem(const QString &itemKey, const QJsonObject &object) const
{
/* object format
{
"installed_item": "http://example.com/downloads/example.AppImage",
"update_method": "appimageupdate"
}
*/
auto updateAvailableItems = getUsrConfigUpdateAvailableItems();
updateAvailableItems[itemKey] = object;
return setUsrConfigUpdateAvailableItems(updateAvailableItems);
}
bool ConfigHandler::removeUsrConfigUpdateAvailableItemsItem(const QString &itemKey) const
{
auto updateAvailableItems = getUsrConfigUpdateAvailableItems();
updateAvailableItems.remove(itemKey);
return setUsrConfigUpdateAvailableItems(updateAvailableItems);
}
void ConfigHandler::importAppConfigApplication()
{
appConfigApplication_ = appConfig_.get("application");
......@@ -172,8 +207,15 @@ void ConfigHandler::importAppConfigInstallTypes()
auto installTypes = appConfig_.get("install_types");
for (const auto &key : installTypes.keys()) {
auto installtype = installTypes[key].toObject();
installtype["destination"] = convertPathString(installtype["destination"].toString());
installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString());
auto xdgDestination = convertPathString(installtype["xdg_destination"].toString());
auto genericDestination = convertPathString(installtype["generic_destination"].toString());
installtype["xdg_destination"] = xdgDestination;
installtype["generic_destination"] = genericDestination;
#ifdef APP_DESKTOP
installtype["destination"] = xdgDestination;
#else
installtype["destination"] = genericDestination;
#endif
installTypes[key] = installtype;
}
auto installTypesAlias = appConfig_.get("install_types_alias");
......@@ -194,7 +236,7 @@ QString ConfigHandler::convertPathString(const QString &path) const
{
auto newPath = path;
if (newPath.contains("$HOME")) {
newPath.replace("$HOME", qtlib::Dir::homePath());
newPath.replace("$HOME", Qtil::Dir::homePath());
}
else if (newPath.contains("$XDG_DOCUMENTS_DIR")) {
newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
......@@ -212,13 +254,13 @@ QString ConfigHandler::convertPathString(const QString &path) const
newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
}
else if (newPath.contains("$XDG_DATA_HOME")) {
newPath.replace("$XDG_DATA_HOME", qtlib::Dir::genericDataPath());
newPath.replace("$XDG_DATA_HOME", Qtil::Dir::genericDataPath());
}
else if (newPath.contains("$KDEHOME")) {
newPath.replace("$KDEHOME", qtlib::Dir::kdehomePath());
newPath.replace("$KDEHOME", Qtil::Dir::kdehomePath());
}
else if (newPath.contains("$APP_DATA")) {
newPath.replace("$APP_DATA", qtlib::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
newPath.replace("$APP_DATA", Qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
}
return newPath;
}
......@@ -3,7 +3,7 @@
#include <QObject>
#include <QJsonObject>
#include "qtlib_config.h"
#include "qtil_config.h"
class ConfigHandler : public QObject
{
......@@ -24,6 +24,8 @@ public slots:
bool setUsrConfigCategories(const QJsonObject &object) const;
QJsonObject getUsrConfigInstalledItems() const;
bool setUsrConfigInstalledItems(const QJsonObject &object) const;
QJsonObject getUsrConfigUpdateAvailableItems() const;
bool setUsrConfigUpdateAvailableItems(const QJsonObject &object) const;
bool setUsrConfigProvidersProvider(const QString &providerKey, const QJsonObject &object) const;
bool removeUsrConfigProvidersProvider(const QString &providerKey) const;
......@@ -32,14 +34,16 @@ public slots:
bool setUsrConfigCategoriesInstallType(const QString &providerKey, const QString &categoryKey, const QString &installType) const;
bool setUsrConfigInstalledItemsItem(const QString &itemKey, const QJsonObject &object) const;
bool removeUsrConfigInstalledItemsItem(const QString &itemKey) const;
bool setUsrConfigUpdateAvailableItemsItem(const QString &itemKey, const QJsonObject &object) const;
bool removeUsrConfigUpdateAvailableItemsItem(const QString &itemKey) const;
private:
void importAppConfigApplication();
void importAppConfigInstallTypes();
QString convertPathString(const QString &path) const;
qtlib::Config appConfig_;
qtlib::Config usrConfig_;
Qtil::Config appConfig_;
Qtil::Config usrConfig_;
QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_;
};
#include "desktopthemehandler.h"
#include <QStringList>
#ifdef APP_DESKTOP
#include <QFileInfo>
#include "desktopthemes/kdetheme.h"
#include "desktopthemes/gnometheme.h"
#include "desktopthemes/xfcetheme.h"
#include "desktopthemes/cinnamontheme.h"
#include "desktopthemes/matetheme.h"
#endif
DesktopThemeHandler::DesktopThemeHandler(QObject *parent)
: QObject(parent)
{}
QString DesktopThemeHandler::desktopEnvironment() const
{
QString desktop;
QString currentDesktop;
if (!qgetenv("XDG_CURRENT_DESKTOP").isEmpty()) {
currentDesktop = QString::fromLocal8Bit(qgetenv("XDG_CURRENT_DESKTOP").constData()).toLower();
}
else if (!qgetenv("XDG_SESSION_DESKTOP").isEmpty()) {
currentDesktop = QString::fromLocal8Bit(qgetenv("XDG_SESSION_DESKTOP").constData()).toLower();
}
else if (!qgetenv("DESKTOP_SESSION").isEmpty()) {
currentDesktop = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION").constData()).toLower();
}
if (currentDesktop.contains("kde") || currentDesktop.contains("plasma")) {
desktop = "kde";
}
else if (currentDesktop.contains("gnome") || currentDesktop.contains("unity")) {
desktop = "gnome";
}
else if (currentDesktop.contains("xfce")) {
desktop = "xfce";
}
else if (currentDesktop.contains("cinnamon")) {
desktop = "cinnamon";
}
else if (currentDesktop.contains("mate")) {
desktop = "mate";
}
return desktop;
}
bool DesktopThemeHandler::isApplicableType(const QString &installType) const
{
auto desktop = desktopEnvironment();
QStringList applicableTypes;
if (desktop == "kde") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "plasma5_desktopthemes"
<< "aurorae_themes";
}
else if (desktop == "gnome") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk3_themes"
<< "gnome_shell_themes";
}
else if (desktop == "xfce") {
applicableTypes << "wallpapers"
<< "icons"
<< "cursors"
<< "gtk2_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);
}
bool DesktopThemeHandler::applyTheme(const QString &path, const QString &installType) const
{
#ifdef APP_DESKTOP
if (QFileInfo::exists(path) && isApplicableType(installType)) {
auto desktop = desktopEnvironment();
if (desktop == "kde") {
KdeTheme kdeTheme(path);
if (installType == "wallpapers") {
return kdeTheme.applyAsWallpaper();
}
else if (installType == "icons") {
return kdeTheme.applyAsIcon();
}
else if (installType == "cursors") {
return kdeTheme.applyAsCursor();
}
else if (installType == "plasma5_desktopthemes") {
return kdeTheme.applyAsPlasma5Desktoptheme();
}
else if (installType == "aurorae_themes") {
return kdeTheme.applyAsAuroraeTheme();
}
}
else if (desktop == "gnome") {
GnomeTheme gnomeTheme(path);
if (installType == "wallpapers") {
return gnomeTheme.applyAsWallpaper();
}
else if (installType == "icons") {
return gnomeTheme.applyAsIcon();
}
else if (installType == "cursors") {
return gnomeTheme.applyAsCursor();
}
else if (installType == "gtk3_themes") {
return gnomeTheme.applyAsGtk3Theme();
}
else if (installType == "gnome_shell_themes") {
return gnomeTheme.applyAsGnomeShellTheme();
}
}
else if (desktop == "xfce") {
XfceTheme xfceTheme(path);
if (installType == "wallpapers") {
return xfceTheme.applyAsWallpaper();
}
else if (installType == "icons") {
return xfceTheme.applyAsIcon();
}
else if (installType == "cursors") {
return xfceTheme.applyAsCursor();
}
else if (installType == "gtk2_themes") {
return xfceTheme.applyAsGtk2Theme();
}
else if (installType == "xfwm4_themes") {
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();
}
}
}
#endif
return false;
}
#pragma once
#include <QObject>
class DesktopThemeHandler : public QObject
{
Q_OBJECT
public:
explicit DesktopThemeHandler(QObject *parent = nullptr);
public slots:
QString desktopEnvironment() const;
bool isApplicableType(const QString &installType) const;
bool applyTheme(const QString &path, const QString &installType) const;
};