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
Loading items

Target

Select target project
0 results Searching
Select Git revision
Loading items
Show changes

Commits on Source 331

231 additional commits have been omitted to prevent performance issues.
48 files
+ 2013
637
Compare changes
  • Side-by-side
  • Inline

Files

+4 −1
Original line number Diff line number Diff line
*.pro.user
lib/qtlib/
build_*/
lib/qtil/
lib/AppImageUpdate/
lib/AppImageUpdate-prebuilt/

.gitlab-ci.yml

0 → 100644
+15 −0
Original line number Diff line number Diff line
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
+2 −16
Original line number Diff line number Diff line
# 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
+25 −3
Original line number Diff line number Diff line
CONFIG += c++11

QT += \
    core \
    gui \
@@ -9,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 \
@@ -17,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
}
Original line number Diff line number Diff line
{
    "id": "ocs-manager",
    "name": "ocs-manager",
    "version": "0.1.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"
}
Original line number Diff line number Diff line
{
    "bin": {
        "name": "Softwares",
        "destination": "$HOME/.local/bin",
        "name": "Software",
        "destination": "",
        "xdg_destination": "$HOME/.local/bin",
        "generic_destination": "$APP_DATA/bin"
    },
    "downloads": {
        "name": "Downloads",
        "destination": "$HOME/Downloads",
        "destination": "",
        "xdg_destination": "$XDG_DOWNLOAD_DIR",
        "generic_destination": "$APP_DATA/downloads"
    },
    "documents": {
        "name": "Documents",
        "destination": "$HOME/Documents",
        "destination": "",
        "xdg_destination": "$XDG_DOCUMENTS_DIR",
        "generic_destination": "$APP_DATA/documents"
    },
    "pictures": {
        "name": "Pictures",
        "destination": "$HOME/Pictures",
        "destination": "",
        "xdg_destination": "$XDG_PICTURES_DIR",
        "generic_destination": "$APP_DATA/pictures"
    },
    "music": {
        "name": "Music",
        "destination": "$HOME/Music",
        "destination": "",
        "xdg_destination": "$XDG_MUSIC_DIR",
        "generic_destination": "$APP_DATA/music"
    },
    "videos": {
        "name": "Videos",
        "destination": "$HOME/Videos",
        "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"
    }
}
+46 −0
Original line number Diff line number Diff line
#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);
}
+24 −0
Original line number Diff line number Diff line
#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_;
};
+41 −0
Original line number Diff line number Diff line
#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);
}
+23 −0
Original line number Diff line number Diff line
#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_;
};
+125 −0
Original line number Diff line number Diff line
#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;
}
+23 −0
Original line number Diff line number Diff line
#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_;
};
+41 −0
Original line number Diff line number Diff line
#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);
}
+23 −0
Original line number Diff line number Diff line
#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_;
};
+53 −0
Original line number Diff line number Diff line
#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;
}
+23 −0
Original line number Diff line number Diff line
#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_;
};
Original line number Diff line number Diff line
#include "confighandler.h"

#include <QStringList>
#include <QStandardPaths>

#include "qtlib_dir.h"
#include "qtil_dir.h"

ConfigHandler::ConfigHandler(QObject *parent)
    : QObject(parent)
{
    appConfig_ = qtlib::Config(":/configs");
    usrConfig_ = qtlib::Config(qtlib::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
    appConfig_ = Qtil::Config(":/configs");
    importAppConfigApplication();
    importAppConfigInstallTypes();
    usrConfig_ = Qtil::Config(Qtil::Dir::genericConfigPath() + "/" + getAppConfigApplication()["id"].toString());
}

QJsonObject ConfigHandler::getAppConfigApplication()
QJsonObject ConfigHandler::getAppConfigApplication() const
{
    if (appConfigApplication_.isEmpty()) {
        appConfigApplication_ = appConfig_.get("application");
    }
    return appConfigApplication_;
}

QJsonObject ConfigHandler::getAppConfigInstallTypes()
QJsonObject ConfigHandler::getAppConfigInstallTypes() const
{
    if (appConfigInstallTypes_.isEmpty()) {
        QJsonObject installTypes = appConfig_.get("install_types");
        foreach (const QString &key, installTypes.keys()) {
            QJsonObject installtype = installTypes[key].toObject();
            installtype["destination"] = convertPathString(installtype["destination"].toString());
            installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString());
            installTypes[key] = installtype;
        }
        QJsonObject installTypesAlias = appConfig_.get("install_types_alias");
        foreach (const QString &key, installTypesAlias.keys()) {
            QJsonObject installTypeAlias = installTypesAlias[key].toObject();
            QString baseKey = installTypeAlias["base"].toString();
            if (installTypes.contains(baseKey)) {
                QJsonObject installType = installTypes[baseKey].toObject();
                installType["base"] = baseKey;
                installType["name"] = installTypeAlias["name"].toString();
                installTypes[key] = installType;
            }
        }
        appConfigInstallTypes_ = installTypes;
    }
    return appConfigInstallTypes_;
}

QJsonObject ConfigHandler::getUsrConfigApplication()
QJsonObject ConfigHandler::getUsrConfigApplication() const
{
    return usrConfig_.get("application");
}

bool ConfigHandler::setUsrConfigApplication(const QJsonObject &object)
bool ConfigHandler::setUsrConfigApplication(const QJsonObject &object) const
{
    /* object format
    {
        "update_checked_at": 1483658977219
    }
    */
    return usrConfig_.set("application", object);
}

QJsonObject ConfigHandler::getUsrConfigProviders()
QJsonObject ConfigHandler::getUsrConfigProviders() const
{
    return usrConfig_.get("providers");
}

bool ConfigHandler::setUsrConfigProviders(const QJsonObject &object)
bool ConfigHandler::setUsrConfigProviders(const QJsonObject &object) const
{
    return usrConfig_.set("providers", object);
}

QJsonObject ConfigHandler::getUsrConfigCategories()
QJsonObject ConfigHandler::getUsrConfigCategories() const
{
    return usrConfig_.get("categories");
}

bool ConfigHandler::setUsrConfigCategories(const QJsonObject &object)
bool ConfigHandler::setUsrConfigCategories(const QJsonObject &object) const
{
    return usrConfig_.set("categories", object);
}

QJsonObject ConfigHandler::getUsrConfigInstalledItems()
QJsonObject ConfigHandler::getUsrConfigInstalledItems() const
{
    return usrConfig_.get("installed_items");
}

bool ConfigHandler::setUsrConfigInstalledItems(const QJsonObject &object)
bool ConfigHandler::setUsrConfigInstalledItems(const QJsonObject &object) const
{
    return usrConfig_.set("installed_items", object);
}

bool ConfigHandler::setUsrConfigProvidersProvider(const QString &providerKey, const QJsonObject &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
    {
@@ -98,19 +92,19 @@ bool ConfigHandler::setUsrConfigProvidersProvider(const QString &providerKey, co
        "_providerfile": "https://example.com/ocs/providers.xml"
    }
    */
    QJsonObject providers = getUsrConfigProviders();
    auto providers = getUsrConfigProviders();
    providers[providerKey] = object;
    return setUsrConfigProviders(providers);
}

bool ConfigHandler::removeUsrConfigProvidersProvider(const QString &providerKey)
bool ConfigHandler::removeUsrConfigProvidersProvider(const QString &providerKey) const
{
    QJsonObject providers = getUsrConfigProviders();
    auto providers = getUsrConfigProviders();
    providers.remove(providerKey);
    return setUsrConfigProviders(providers);
}

bool ConfigHandler::setUsrConfigCategoriesProvider(const QString &providerKey, const QJsonObject &object)
bool ConfigHandler::setUsrConfigCategoriesProvider(const QString &providerKey, const QJsonObject &object) const
{
    /* object format
    {
@@ -126,21 +120,21 @@ bool ConfigHandler::setUsrConfigCategoriesProvider(const QString &providerKey, c
        }
    }
    */
    QJsonObject categories = getUsrConfigCategories();
    auto categories = getUsrConfigCategories();
    categories[providerKey] = object;
    return setUsrConfigCategories(categories);
}

bool ConfigHandler::removeUsrConfigCategoriesProvider(const QString &providerKey)
bool ConfigHandler::removeUsrConfigCategoriesProvider(const QString &providerKey) const
{
    QJsonObject categories = getUsrConfigCategories();
    auto categories = getUsrConfigCategories();
    categories.remove(providerKey);
    return setUsrConfigCategories(categories);
}

bool ConfigHandler::setUsrConfigCategoriesInstallType(const QString &providerKey, const QString &categoryKey, const QString &installType)
bool ConfigHandler::setUsrConfigCategoriesInstallType(const QString &providerKey, const QString &categoryKey, const QString &installType) const
{
    QJsonObject categories = getUsrConfigCategories();
    auto categories = getUsrConfigCategories();
    QJsonObject providerCategories;
    if (categories.contains(providerKey)) {
        providerCategories = categories[providerKey].toObject();
@@ -155,7 +149,7 @@ bool ConfigHandler::setUsrConfigCategoriesInstallType(const QString &providerKey
    return setUsrConfigCategories(categories);
}

bool ConfigHandler::setUsrConfigInstalledItemsItem(const QString &itemKey, const QJsonObject &object)
bool ConfigHandler::setUsrConfigInstalledItemsItem(const QString &itemKey, const QJsonObject &object) const
{
    /* object format
    {
@@ -171,32 +165,102 @@ bool ConfigHandler::setUsrConfigInstalledItemsItem(const QString &itemKey, const
        "installed_at": 1483658977219
    }
    */
    QJsonObject installedItems = getUsrConfigInstalledItems();
    auto installedItems = getUsrConfigInstalledItems();
    installedItems[itemKey] = object;
    return setUsrConfigInstalledItems(installedItems);
}

bool ConfigHandler::removeUsrConfigInstalledItemsItem(const QString &itemKey)
bool ConfigHandler::removeUsrConfigInstalledItemsItem(const QString &itemKey) const
{
    QJsonObject installedItems = getUsrConfigInstalledItems();
    auto installedItems = getUsrConfigInstalledItems();
    installedItems.remove(itemKey);
    return setUsrConfigInstalledItems(installedItems);
}

QString ConfigHandler::convertPathString(const QString &path)
bool ConfigHandler::setUsrConfigUpdateAvailableItemsItem(const QString &itemKey, const QJsonObject &object) const
{
    /* object format
    {
    QString newPath = path;
        "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", 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));
    }
    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", 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;
}
Original line number Diff line number Diff line
@@ -3,41 +3,47 @@
#include <QObject>
#include <QJsonObject>

#include "qtlib_config.h"
#include "qtil_config.h"

class ConfigHandler : public QObject
{
    Q_OBJECT

public:
    explicit ConfigHandler(QObject *parent = 0);
    explicit ConfigHandler(QObject *parent = nullptr);

public slots:
    QJsonObject getAppConfigApplication();
    QJsonObject getAppConfigInstallTypes();

    QJsonObject getUsrConfigApplication();
    bool setUsrConfigApplication(const QJsonObject &object);
    QJsonObject getUsrConfigProviders();
    bool setUsrConfigProviders(const QJsonObject &object);
    QJsonObject getUsrConfigCategories();
    bool setUsrConfigCategories(const QJsonObject &object);
    QJsonObject getUsrConfigInstalledItems();
    bool setUsrConfigInstalledItems(const QJsonObject &object);

    bool setUsrConfigProvidersProvider(const QString &providerKey, const QJsonObject &object);
    bool removeUsrConfigProvidersProvider(const QString &providerKey);
    bool setUsrConfigCategoriesProvider(const QString &providerKey, const QJsonObject &object);
    bool removeUsrConfigCategoriesProvider(const QString &providerKey);
    bool setUsrConfigCategoriesInstallType(const QString &providerKey, const QString &categoryKey, const QString &installType);
    bool setUsrConfigInstalledItemsItem(const QString &itemKey, const QJsonObject &object);
    bool removeUsrConfigInstalledItemsItem(const QString &itemKey);
    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:
    QString convertPathString(const QString &path);
    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_;
};
+202 −0
Original line number Diff line number Diff line
#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 (QFi