Add system module
parent
01ac677dae
commit
4f74b09192
@ -0,0 +1,19 @@
|
|||||||
|
set(SCREEN_SRCS
|
||||||
|
wallpaper.cpp
|
||||||
|
wallpaper.h
|
||||||
|
plugin.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(Qt5 REQUIRED COMPONENTS DBus)
|
||||||
|
|
||||||
|
add_library(cutefishsystem_qmlplugins SHARED ${SCREEN_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries (cutefishsystem_qmlplugins
|
||||||
|
Qt5::Core
|
||||||
|
Qt5::Quick
|
||||||
|
Qt5::Gui
|
||||||
|
Qt5::DBus
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS cutefishsystem_qmlplugins DESTINATION ${INSTALL_QMLDIR}/Cutefish/System)
|
||||||
|
install(FILES qmldir DESTINATION ${INSTALL_QMLDIR}/Cutefish/System)
|
@ -0,0 +1,17 @@
|
|||||||
|
#include <QQmlExtensionPlugin>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
#include "wallpaper.h"
|
||||||
|
|
||||||
|
class QmlPlugins : public QQmlExtensionPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||||
|
|
||||||
|
public:
|
||||||
|
void registerTypes(const char * uri) override {
|
||||||
|
qmlRegisterType<Wallpaper>(uri, 1, 0, "Wallpaper");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "plugin.moc"
|
@ -0,0 +1,3 @@
|
|||||||
|
module Cutefish.System
|
||||||
|
|
||||||
|
plugin cutefishsystem_qmlplugins
|
@ -0,0 +1,24 @@
|
|||||||
|
#include "wallpaper.h"
|
||||||
|
|
||||||
|
Wallpaper::Wallpaper(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_interface("org.cutefish.Settings",
|
||||||
|
"/Theme", "org.cutefish.Theme",
|
||||||
|
QDBusConnection::sessionBus(), this)
|
||||||
|
{
|
||||||
|
if (m_interface.isValid()) {
|
||||||
|
connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onPathChanged(QString)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Wallpaper::path() const
|
||||||
|
{
|
||||||
|
return m_interface.property("wallpaper").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wallpaper::onPathChanged(QString path)
|
||||||
|
{
|
||||||
|
Q_UNUSED(path);
|
||||||
|
|
||||||
|
emit pathChanged();
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef WALLPAPER_H
|
||||||
|
#define WALLPAPER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
|
||||||
|
class Wallpaper : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString path READ path NOTIFY pathChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Wallpaper(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
QString path() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pathChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onPathChanged(QString path);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDBusInterface m_interface;
|
||||||
|
QString m_wallpaper;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WALLPAPER_H
|
Loading…
Reference in New Issue