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
Select Git revision
  • develop
  • master
  • release-0.1.0
  • release-0.2.0
  • release-0.2.1
  • release-0.3.0
  • release-0.3.1
  • release-0.3.2
  • release-0.4.0
  • release-0.4.1
  • release-0.4.2
  • release-0.4.3
  • release-0.4.4
  • release-0.5.0
  • release-0.5.1
  • release-0.5.2
  • release-0.5.3
  • release-0.5.4
  • release-0.5.5
  • release-0.6.0
  • release-0.6.1
  • release-0.6.2
  • release-0.6.3
  • release-0.6.4
  • release-0.6.5
  • release-0.7.0
  • release-0.7.1
  • release-0.7.2
  • release-0.8.0
  • release-0.8.1
30 results

Target

Select target project
  • akiraohgaki/ocs-manager
  • dfn2/ocs-manager
  • azubieta/ocs-manager
  • rws77/ocs-manager
4 results
Select Git revision
  • develop
  • fix_build
  • master
  • update_dialog
  • release-0.1.0
  • release-0.2.0
  • release-0.2.1
  • release-0.3.0
  • release-0.3.1
  • release-0.3.2
  • release-0.4.0
  • release-0.4.1
  • release-0.4.2
  • release-0.4.3
  • release-0.4.4
  • release-0.5.0
  • release-0.5.1
  • release-0.5.2
  • release-0.5.3
  • release-0.5.4
  • release-0.5.5
  • release-0.6.0
  • release-0.6.1
  • release-0.6.2
  • release-0.6.3
  • release-0.6.4
  • release-0.6.5
  • release-0.7.0
  • release-0.7.1
  • release-0.7.2
  • release-0.8.0
  • release-0.8.1
32 results
Show changes
Commits on Source (372)
Showing
with 1128 additions and 2 deletions
*.pro.user
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-lib
a shared library to handle filemanagement and "apply"
# ocs-manager
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
A tool to handle item installation from OCS provider, file management, and apply themes.
Copyright: 2017-2019, Opendesktop.org
License: GPL-3+
CONFIG += c++11
QT += \
core \
gui \
network \
websockets
HEADERS += \
$${PWD}/src/websockets/websocketserver.h \
$${PWD}/src/handlers/confighandler.h \
$${PWD}/src/handlers/systemhandler.h \
$${PWD}/src/handlers/ocsapihandler.h \
$${PWD}/src/handlers/itemhandler.h \
$${PWD}/src/handlers/updatehandler.h \
$${PWD}/src/handlers/desktopthemehandler.h
SOURCES += \
$${PWD}/src/main.cpp \
$${PWD}/src/websockets/websocketserver.cpp \
$${PWD}/src/handlers/confighandler.cpp \
$${PWD}/src/handlers/systemhandler.cpp \
$${PWD}/src/handlers/ocsapihandler.cpp \
$${PWD}/src/handlers/itemhandler.cpp \
$${PWD}/src/handlers/updatehandler.cpp \
$${PWD}/src/handlers/desktopthemehandler.cpp
RESOURCES += $${PWD}/configs/configs.qrc
INCLUDEPATH += $${PWD}/src
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.8.1",
"organization": "Opendesktop.org",
"domain": "org.opendesktop.ocs-manager",
"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://git.opendesktop.org/akiraohgaki/ocs-manager"
}
<RCC>
<qresource prefix="/configs">
<file>application.json</file>
<file>install_types.json</file>
<file>install_types_alias.json</file>
</qresource>
</RCC>
{
"bin": {
"name": "Software",
"destination": "",
"xdg_destination": "$HOME/.local/bin",
"generic_destination": "$APP_DATA/bin"
},
"downloads": {
"name": "Downloads",
"destination": "",
"xdg_destination": "$XDG_DOWNLOAD_DIR",
"generic_destination": "$APP_DATA/downloads"
},
"documents": {
"name": "Documents",
"destination": "",
"xdg_destination": "$XDG_DOCUMENTS_DIR",
"generic_destination": "$APP_DATA/documents"
},
"pictures": {
"name": "Pictures",
"destination": "",
"xdg_destination": "$XDG_PICTURES_DIR",
"generic_destination": "$APP_DATA/pictures"
},
"music": {
"name": "Music",
"destination": "",
"xdg_destination": "$XDG_MUSIC_DIR",
"generic_destination": "$APP_DATA/music"
},
"videos": {
"name": "Videos",
"destination": "",
"xdg_destination": "$XDG_VIDEOS_DIR",
"generic_destination": "$APP_DATA/videos"
},
"wallpapers": {
"name": "Wallpapers",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/wallpapers",
"generic_destination": "$APP_DATA/wallpapers"
},
"fonts": {
"name": "Fonts",
"destination": "",
"xdg_destination": "$HOME/.fonts",
"generic_destination": "$APP_DATA/fonts"
},
"cursors": {
"name": "Cursors",
"destination": "",
"xdg_destination": "$HOME/.icons",
"generic_destination": "$APP_DATA/cursors"
},
"icons": {
"name": "Icons",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/icons",
"generic_destination": "$APP_DATA/icons"
},
"emoticons": {
"name": "Emoticons",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/emoticons",
"generic_destination": "$APP_DATA/emoticons"
},
"themes": {
"name": "Desktop Themes",
"destination": "",
"xdg_destination": "$HOME/.themes",
"generic_destination": "$APP_DATA/themes"
},
"emerald_themes": {
"name": "Emerald Themes",
"destination": "",
"xdg_destination": "$HOME/.emerald/themes",
"generic_destination": "$APP_DATA/emerald_themes"
},
"enlightenment_themes": {
"name": "Enlightenment Themes",
"destination": "",
"xdg_destination": "$HOME/.e/e/themes",
"generic_destination": "$APP_DATA/enlightenment_themes"
},
"enlightenment_backgrounds": {
"name": "Enlightenment Backgrounds",
"destination": "",
"xdg_destination": "$HOME/.e/e/backgrounds",
"generic_destination": "$APP_DATA/enlightenment_backgrounds"
},
"fluxbox_styles": {
"name": "Fluxbox Styles",
"destination": "",
"xdg_destination": "$HOME/.fluxbox/styles",
"generic_destination": "$APP_DATA/fluxbox_styles"
},
"pekwm_themes": {
"name": "PekWM Themes",
"destination": "",
"xdg_destination": "$HOME/.pekwm/themes",
"generic_destination": "$APP_DATA/pekwm_themes"
},
"icewm_themes": {
"name": "IceWM Themes",
"destination": "",
"xdg_destination": "$HOME/.icewm/themes",
"generic_destination": "$APP_DATA/icewm_themes"
},
"plasma_plasmoids": {
"name": "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_destination": "$XDG_DATA_HOME/plasma/look-and-feel",
"generic_destination": "$APP_DATA/plasma_look_and_feel"
},
"plasma_desktopthemes": {
"name": "Plasma Desktop Themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/plasma/desktoptheme",
"generic_destination": "$APP_DATA/plasma_desktopthemes"
},
"kwin_effects": {
"name": "KWin Effects",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/effects",
"generic_destination": "$APP_DATA/kwin_effects"
},
"kwin_scripts": {
"name": "KWin Scripts",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/scripts",
"generic_destination": "$APP_DATA/kwin_scripts"
},
"kwin_tabbox": {
"name": "KWin Window Switcher",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/kwin/tabbox",
"generic_destination": "$APP_DATA/kwin_tabbox"
},
"aurorae_themes": {
"name": "Aurorae Themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/aurorae/themes",
"generic_destination": "$APP_DATA/aurorae_themes"
},
"dekorator_themes": {
"name": "deKorator Themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/deKorator/themes",
"generic_destination": "$APP_DATA/dekorator_themes"
},
"qtcurve": {
"name": "QtCurve Themes",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/QtCurve",
"generic_destination": "$APP_DATA/qtcurve"
},
"color_schemes": {
"name": "KDE 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_destination": "$XDG_DATA_HOME/gnome-shell/extensions",
"generic_destination": "$APP_DATA/gnome_shell_extensions"
},
"cinnamon_applets": {
"name": "Cinnamon Applets",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/applets",
"generic_destination": "$APP_DATA/cinnamon_applets"
},
"cinnamon_desklets": {
"name": "Cinnamon Desklets",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/desklets",
"generic_destination": "$APP_DATA/cinnamon_desklets"
},
"cinnamon_extensions": {
"name": "Cinnamon Extensions",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/cinnamon/extensions",
"generic_destination": "$APP_DATA/cinnamon_extensions"
},
"nautilus_scripts": {
"name": "Nautilus Scripts",
"destination": "",
"xdg_destination": "$XDG_DATA_HOME/nautilus/scripts",
"generic_destination": "$APP_DATA/nautilus_scripts"
},
"amarok_scripts": {
"name": "Amarok Scripts",
"destination": "",
"xdg_destination": "$KDEHOME/share/apps/amarok/scripts",
"generic_destination": "$APP_DATA/amarok_scripts"
},
"yakuake_skins": {
"name": "Yakuake Skins",
"destination": "",
"xdg_destination": "$KDEHOME/share/apps/yakuake/skins",
"generic_destination": "$APP_DATA/yakuake_skins"
},
"cairo_clock_themes": {
"name": "Cairo-Clock Themes",
"destination": "",
"xdg_destination": "$HOME/.cairo-clock/themes",
"generic_destination": "$APP_DATA/cairo_clock_themes"
},
"books": {
"name": "Books",
"destination": "",
"xdg_destination": "$APP_DATA/books",
"generic_destination": "$APP_DATA/books"
},
"comics": {
"name": "Comics",
"destination": "",
"xdg_destination": "$APP_DATA/comics",
"generic_destination": "$APP_DATA/comics"
}
}
{
"gnome_shell_themes": {
"base": "themes",
"name": "Gnome Shell Themes"
},
"cinnamon_themes": {
"base": "themes",
"name": "Cinnamon Themes"
},
"gtk2_themes": {
"base": "themes",
"name": "GTK2 Themes"
},
"gtk3_themes": {
"base": "themes",
"name": "GTK3 Themes"
},
"metacity_themes": {
"base": "themes",
"name": "Metacity Themes"
},
"xfwm4_themes": {
"base": "themes",
"name": "XFWM4 Themes"
},
"openbox_themes": {
"base": "themes",
"name": "Openbox Themes"
},
"kvantum_themes": {
"base": "themes",
"name": "Kvantum Themes"
},
"compiz_themes": {
"base": "emerald_themes",
"name": "Compiz Themes"
},
"beryl_themes": {
"base": "emerald_themes",
"name": "Beryl Themes"
},
"plasma4_plasmoids": {
"base": "plasma_plasmoids",
"name": "Plasma4 Plasmoids"
},
"plasma5_plasmoids": {
"base": "plasma_plasmoids",
"name": "Plasma5 Plasmoids"
},
"plasma5_look_and_feel": {
"base": "plasma_look_and_feel",
"name": "Plasma5 Look and Feel"
},
"plasma5_desktopthemes": {
"base": "plasma_desktopthemes",
"name": "Plasma5 Desktop Themes"
},
"plasma_color_schemes": {
"base": "color_schemes",
"name": "Plasma Color Schemes"
}
}
#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_;
};
#include "confighandler.h"
#include <QStringList>
#include <QStandardPaths>
#include "qtil_dir.h"
ConfigHandler::ConfigHandler(QObject *parent)
: QObject(parent)
{
appConfig_ = Qtil::Config(":/configs");
importAppConfigApplication();
importAppConfigInstallTypes();
usrConfig_ = Qtil::Config(Qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
}
QJsonObject ConfigHandler::getAppConfigApplication() const
{
return appConfigApplication_;
}
QJsonObject ConfigHandler::getAppConfigInstallTypes() const
{
return appConfigInstallTypes_;
}
QJsonObject ConfigHandler::getUsrConfigApplication() const
{
return usrConfig_.get("application");
}
bool ConfigHandler::setUsrConfigApplication(const QJsonObject &object) const
{
/* object format
{
"update_checked_at": 1483658977219
}
*/
return usrConfig_.set("application", object);
}
QJsonObject ConfigHandler::getUsrConfigProviders() const
{
return usrConfig_.get("providers");
}
bool ConfigHandler::setUsrConfigProviders(const QJsonObject &object) const
{
return usrConfig_.set("providers", object);
}
QJsonObject ConfigHandler::getUsrConfigCategories() const
{
return usrConfig_.get("categories");
}
bool ConfigHandler::setUsrConfigCategories(const QJsonObject &object) const
{
return usrConfig_.set("categories", object);
}
QJsonObject ConfigHandler::getUsrConfigInstalledItems() const
{
return usrConfig_.get("installed_items");
}
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
{
"id": "example",
"location": "https://example.com/ocs/v1/",
"name": "Example",
"icon": "https://example.com/icon.png",
"termsofuse": "https://example.com/termsofuse",
"register": "https://example.com/register",
"_providerfile": "https://example.com/ocs/providers.xml"
}
*/
auto providers = getUsrConfigProviders();
providers[providerKey] = object;
return setUsrConfigProviders(providers);
}
bool ConfigHandler::removeUsrConfigProvidersProvider(const QString &providerKey) const
{
auto providers = getUsrConfigProviders();
providers.remove(providerKey);
return setUsrConfigProviders(providers);
}
bool ConfigHandler::setUsrConfigCategoriesProvider(const QString &providerKey, const QJsonObject &object) const
{
/* object format
{
"1": {
"id": "1",
"name": "Desktop Icons",
"install_type": "icons"
},
"2": {
"id": "2",
"name": "Desktop Themes",
"install_type": "themes"
}
}
*/
auto categories = getUsrConfigCategories();
categories[providerKey] = object;
return setUsrConfigCategories(categories);
}
bool ConfigHandler::removeUsrConfigCategoriesProvider(const QString &providerKey) const
{
auto categories = getUsrConfigCategories();
categories.remove(providerKey);
return setUsrConfigCategories(categories);
}
bool ConfigHandler::setUsrConfigCategoriesInstallType(const QString &providerKey, const QString &categoryKey, const QString &installType) const
{
auto categories = getUsrConfigCategories();
QJsonObject providerCategories;
if (categories.contains(providerKey)) {
providerCategories = categories[providerKey].toObject();
}
QJsonObject providerCategory;
if (providerCategories.contains(categoryKey)) {
providerCategory = providerCategories[categoryKey].toObject();
}
providerCategory["install_type"] = installType;
providerCategories[categoryKey] = providerCategory;
categories[providerKey] = providerCategories;
return setUsrConfigCategories(categories);
}
bool ConfigHandler::setUsrConfigInstalledItemsItem(const QString &itemKey, const QJsonObject &object) const
{
/* object format
{
"url": "http://example.com/downloads/123-1.tar.gz",
"filename": "123-1.tar.gz",
"install_type": "icons",
"provider": "http://example.com/ocs/v1/",
"content_id": "123",
"files": [
"iconset-light",
"iconset-dark"
],
"installed_at": 1483658977219
}
*/
auto installedItems = getUsrConfigInstalledItems();
installedItems[itemKey] = object;
return setUsrConfigInstalledItems(installedItems);
}
bool ConfigHandler::removeUsrConfigInstalledItemsItem(const QString &itemKey) const
{
auto installedItems = getUsrConfigInstalledItems();
installedItems.remove(itemKey);
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");
}
void ConfigHandler::importAppConfigInstallTypes()
{
auto installTypes = appConfig_.get("install_types");
for (const auto &key : installTypes.keys()) {
auto installtype = installTypes[key].toObject();
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");
for (const auto &key : installTypesAlias.keys()) {
auto installTypeAlias = installTypesAlias[key].toObject();
auto baseKey = installTypeAlias["base"].toString();
if (installTypes.contains(baseKey)) {
auto installType = installTypes[baseKey].toObject();
installType["base"] = baseKey;
installType["name"] = installTypeAlias["name"].toString();
installTypes[key] = installType;
}
}
appConfigInstallTypes_ = installTypes;
}
QString ConfigHandler::convertPathString(const QString &path) const
{
auto newPath = path;
if (newPath.contains("$HOME")) {
newPath.replace("$HOME", Qtil::Dir::homePath());
}
else if (newPath.contains("$XDG_DOCUMENTS_DIR")) {
newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
}
else if (newPath.contains("$XDG_DOWNLOAD_DIR")) {
newPath.replace("$XDG_DOWNLOAD_DIR", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
}
else if (newPath.contains("$XDG_PICTURES_DIR")) {
newPath.replace("$XDG_PICTURES_DIR", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
}
else if (newPath.contains("$XDG_MUSIC_DIR")) {
newPath.replace("$XDG_MUSIC_DIR", QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
}
else if (newPath.contains("$XDG_VIDEOS_DIR")) {
newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
}
else if (newPath.contains("$XDG_DATA_HOME")) {
newPath.replace("$XDG_DATA_HOME", Qtil::Dir::genericDataPath());
}
else if (newPath.contains("$KDEHOME")) {
newPath.replace("$KDEHOME", Qtil::Dir::kdehomePath());
}
else if (newPath.contains("$APP_DATA")) {
newPath.replace("$APP_DATA", Qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
}
return newPath;
}
#pragma once
#include <QObject>
#include <QJsonObject>
#include "qtil_config.h"
class ConfigHandler : public QObject
{
Q_OBJECT
public:
explicit ConfigHandler(QObject *parent = nullptr);
public slots:
QJsonObject getAppConfigApplication() const;
QJsonObject getAppConfigInstallTypes() const;
QJsonObject getUsrConfigApplication() const;
bool setUsrConfigApplication(const QJsonObject &object) const;
QJsonObject getUsrConfigProviders() const;
bool setUsrConfigProviders(const QJsonObject &object) const;
QJsonObject getUsrConfigCategories() const;
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;
bool setUsrConfigCategoriesProvider(const QString &providerKey, const QJsonObject &object) const;
bool removeUsrConfigCategoriesProvider(const QString &providerKey) const;
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;
Qtil::Config appConfig_;
Qtil::Config usrConfig_;
QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_;
};