refactor(appearance): split the library from its QML plugin

main
reionwong 3 weeks ago
parent 7387a0f734
commit 164de9c9f6

@ -25,24 +25,6 @@ find_package(Qt6 REQUIRED COMPONENTS
Qml
)
qt_policy(SET QTP0001 NEW)
function(cutefish_install_qml_module target)
qt_query_qml_module("${target}"
TARGET_PATH module_path
QMLDIR module_qmldir
TYPEINFO module_qmltypes
)
set(module_install_dir "${INSTALL_QMLDIR}/${module_path}")
install(TARGETS "${target}" DESTINATION "${module_install_dir}")
install(FILES "${module_qmldir}" DESTINATION "${module_install_dir}")
if(module_qmltypes)
install(FILES "${module_qmltypes}" DESTINATION "${module_install_dir}")
endif()
endfunction()
# Get the installation directory from Qt 6
find_program(QT_PATHS_EXECUTABLE NAMES qtpaths6 REQUIRED)
@ -55,6 +37,8 @@ if(INSTALL_QMLDIR)
else()
message(FATAL_ERROR "qml directory cannot be detected.")
endif()
include(CutefishFrameworkQml)
# -------------------------------------------
add_subdirectory(applications)

@ -28,6 +28,7 @@ qt_add_qml_module(cutefish-framework-accounts
PLUGIN_TARGET cutefish-framework-accounts
CLASS_NAME QmlPlugins
NO_GENERATE_PLUGIN_SOURCE
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Accounts"
)

@ -1,29 +1,62 @@
set(CUTEFISH_APPEARANCE_SOURCES
appearance.cpp
appearance.h
wallpaper.cpp
wallpaper.h
plugin.cpp
)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick DBus)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml DBus)
include(GNUInstallDirs)
if(NOT COMMAND cutefish_install_qml_module)
include("${CMAKE_CURRENT_LIST_DIR}/../cmake/CutefishFrameworkQml.cmake")
endif()
add_library(cutefish-framework-appearance SHARED ${CUTEFISH_APPEARANCE_SOURCES})
add_library(Cutefish::Appearance ALIAS cutefish-framework-appearance)
qt_add_qml_module(cutefish-framework-appearance
URI Cutefish.Appearance
VERSION 1.0
PLUGIN_TARGET cutefish-framework-appearance
CLASS_NAME QmlPlugins
NO_GENERATE_PLUGIN_SOURCE
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Appearance"
target_include_directories(cutefish-framework-appearance
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Cutefish>
)
add_library(Cutefish::Appearance ALIAS cutefish-framework-appearance)
target_link_libraries(cutefish-framework-appearance PUBLIC
Qt6::Core
Qt6::Quick
Qt6::Gui
Qt6::DBus
)
cutefish_install_qml_module(cutefish-framework-appearance)
# Consumers pull this directory in with add_subdirectory to link the library;
# only the framework's own build ships it and the QML module, so their packages
# do not fight over the same files.
if(PROJECT_NAME STREQUAL "CutefishFramework")
install(TARGETS cutefish-framework-appearance
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES appearance.h wallpaper.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Cutefish)
# qmltyperegistrar resolves the QML_FOREIGN types out of this file.
qt_extract_metatypes(cutefish-framework-appearance)
# The QML module is a plugin of its own so the module registration ships in
# exactly one library, even in a process that also links the one above.
qt_add_qml_module(cutefish-framework-appearance-qml
URI Cutefish.Appearance
VERSION 1.0
PLUGIN_TARGET cutefish-framework-appearance-qml
CLASS_NAME AppearanceQmlPlugin
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Appearance"
SOURCES
qmlregistration.cpp
qmlregistration.h
)
target_link_libraries(cutefish-framework-appearance-qml PRIVATE
Cutefish::Appearance
Qt6::Qml
)
cutefish_install_qml_module(cutefish-framework-appearance-qml)
endif()

@ -0,0 +1,254 @@
#include "appearance.h"
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusServiceWatcher>
namespace
{
constexpr auto Service = "com.cutefish.Services";
constexpr auto ObjectPath = "/com/cutefish/Services/Appearance";
constexpr auto Interface = "com.cutefish.Services.Appearance";
}
Appearance::Appearance(QObject *parent)
: QObject(parent)
, m_interface(nullptr)
{
auto *watcher = new QDBusServiceWatcher(QString::fromLatin1(Service),
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration,
this);
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &Appearance::init);
init();
}
void Appearance::init()
{
delete m_interface;
m_interface = new QDBusInterface(QString::fromLatin1(Service),
QString::fromLatin1(ObjectPath),
QString::fromLatin1(Interface),
QDBusConnection::sessionBus(),
this);
if (!m_interface->isValid())
return;
connect(m_interface, SIGNAL(darkModeChanged(bool)), this, SLOT(onDarkModeChanged(bool)));
connect(m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString)));
connect(m_interface, SIGNAL(accentColorChanged(int)), this, SLOT(onAccentColorChanged(int)));
connect(m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SLOT(onDarkModeDimsWallpaperChanged()));
connect(m_interface, SIGNAL(blurEnabledChanged()), this, SLOT(onBlurEnabledChanged()));
connect(m_interface, SIGNAL(systemFontPointSizeChanged()), this, SLOT(onFontPointSizeChanged()));
connect(m_interface, SIGNAL(systemFontChanged()), this, SLOT(onFontFamilyChanged()));
connect(m_interface, SIGNAL(backgroundTypeChanged()), this, SLOT(onBackgroundTypeChanged()));
connect(m_interface, SIGNAL(backgroundColorChanged()), this, SLOT(onBackgroundColorChanged()));
connect(m_interface, SIGNAL(backgroundVisibleChanged()), this, SLOT(onBackgroundVisibleChanged()));
emit darkModeChanged();
emit wallpaperChanged();
emit accentColorIndexChanged();
emit dimsWallpaperChanged();
emit blurEnabledChanged();
emit fontPointSizeChanged();
emit fontFamilyChanged();
emit fixedFontFamilyChanged();
emit backgroundTypeChanged();
emit backgroundColorChanged();
emit backgroundVisibleChanged();
}
QVariant Appearance::serviceProperty(const char *name) const
{
return m_interface && m_interface->isValid() ? m_interface->property(name) : QVariant();
}
void Appearance::callService(const char *method)
{
if (m_interface && m_interface->isValid())
m_interface->call(method);
}
void Appearance::callService(const char *method, const QVariant &value)
{
if (m_interface && m_interface->isValid())
m_interface->call(method, value);
}
bool Appearance::darkMode() const
{
return serviceProperty("isDarkMode").toBool();
}
void Appearance::switchDarkMode(bool darkMode)
{
callService("setDarkMode", darkMode);
}
bool Appearance::dimsWallpaper() const
{
return serviceProperty("darkModeDimsWallpaer").toBool();
}
void Appearance::setDimsWallpaper(bool value)
{
callService("setDarkModeDimsWallpaer", value);
}
bool Appearance::blurEnabled() const
{
return serviceProperty("blurEnabled").toBool();
}
void Appearance::setBlurEnabled(bool value)
{
callService("setBlurEnabled", value);
}
int Appearance::accentColorIndex() const
{
return serviceProperty("accentColor").toInt();
}
void Appearance::setAccentColor(int accentColor)
{
callService("setAccentColor", accentColor);
}
qreal Appearance::fontPointSize() const
{
return serviceProperty("systemFontPointSize").toReal();
}
void Appearance::setFontPointSize(qreal fontPointSize)
{
callService("setSystemFontPointSize", fontPointSize);
}
QString Appearance::fontFamily() const
{
return serviceProperty("systemFont").toString();
}
void Appearance::setFontFamily(const QString &name)
{
if (!name.isEmpty())
callService("setSystemFont", name);
}
QString Appearance::fixedFontFamily() const
{
return serviceProperty("systemFixedFont").toString();
}
// com.cutefish.Services.Appearance has no systemFixedFontChanged signal, so
// the change is announced here.
void Appearance::setFixedFontFamily(const QString &name)
{
if (!name.isEmpty()) {
callService("setSystemFixedFont", name);
emit fixedFontFamilyChanged();
}
}
QString Appearance::wallpaper() const
{
return serviceProperty("wallpaper").toString();
}
void Appearance::setWallpaper(const QString &path)
{
if (!path.isEmpty())
callService("setWallpaper", path);
}
int Appearance::backgroundType() const
{
return serviceProperty("backgroundType").toInt();
}
void Appearance::setBackgroundType(int type)
{
callService("setBackgroundType", type);
}
QString Appearance::backgroundColor() const
{
return serviceProperty("backgroundColor").toString();
}
void Appearance::setBackgroundColor(const QString &color)
{
callService("setBackgroundColor", color);
}
bool Appearance::backgroundVisible() const
{
return serviceProperty("backgroundVisible").toBool();
}
void Appearance::setCursorTheme(const QString &theme)
{
if (!theme.isEmpty())
callService("setCursorTheme", theme);
}
void Appearance::applyFontSettings()
{
callService("applyFontSettings");
}
void Appearance::onDarkModeChanged(bool darkMode)
{
Q_UNUSED(darkMode);
emit darkModeChanged();
}
void Appearance::onWallpaperChanged(const QString &path)
{
Q_UNUSED(path);
emit wallpaperChanged();
}
void Appearance::onAccentColorChanged(int accentColor)
{
Q_UNUSED(accentColor);
emit accentColorIndexChanged();
}
void Appearance::onDarkModeDimsWallpaperChanged()
{
emit dimsWallpaperChanged();
}
void Appearance::onBlurEnabledChanged()
{
emit blurEnabledChanged();
}
void Appearance::onFontPointSizeChanged()
{
emit fontPointSizeChanged();
}
void Appearance::onFontFamilyChanged()
{
emit fontFamilyChanged();
}
void Appearance::onBackgroundTypeChanged()
{
emit backgroundTypeChanged();
}
void Appearance::onBackgroundColorChanged()
{
emit backgroundColorChanged();
}
void Appearance::onBackgroundVisibleChanged()
{
emit backgroundVisibleChanged();
}

@ -0,0 +1,97 @@
#ifndef CUTEFISH_APPEARANCE_H
#define CUTEFISH_APPEARANCE_H
#include <QObject>
#include <QString>
#include <QVariant>
class QDBusInterface;
class Appearance : public QObject
{
Q_OBJECT
Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper WRITE setDimsWallpaper NOTIFY dimsWallpaperChanged)
Q_PROPERTY(bool blurEnabled READ blurEnabled WRITE setBlurEnabled NOTIFY blurEnabledChanged)
Q_PROPERTY(int accentColorIndex READ accentColorIndex NOTIFY accentColorIndexChanged)
Q_PROPERTY(qreal fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY fontPointSizeChanged)
Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged)
Q_PROPERTY(QString wallpaper READ wallpaper WRITE setWallpaper NOTIFY wallpaperChanged)
Q_PROPERTY(int backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
Q_PROPERTY(QString backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
Q_PROPERTY(bool backgroundVisible READ backgroundVisible NOTIFY backgroundVisibleChanged)
public:
explicit Appearance(QObject *parent = nullptr);
bool darkMode() const;
Q_INVOKABLE void switchDarkMode(bool darkMode);
bool dimsWallpaper() const;
Q_INVOKABLE void setDimsWallpaper(bool value);
bool blurEnabled() const;
Q_INVOKABLE void setBlurEnabled(bool value);
int accentColorIndex() const;
Q_INVOKABLE void setAccentColor(int accentColor);
qreal fontPointSize() const;
Q_INVOKABLE void setFontPointSize(qreal fontPointSize);
QString fontFamily() const;
Q_INVOKABLE void setFontFamily(const QString &name);
QString fixedFontFamily() const;
Q_INVOKABLE void setFixedFontFamily(const QString &name);
QString wallpaper() const;
Q_INVOKABLE void setWallpaper(const QString &path);
int backgroundType() const;
Q_INVOKABLE void setBackgroundType(int type);
QString backgroundColor() const;
Q_INVOKABLE void setBackgroundColor(const QString &color);
bool backgroundVisible() const;
Q_INVOKABLE void setCursorTheme(const QString &theme);
Q_INVOKABLE void applyFontSettings();
signals:
void darkModeChanged();
void dimsWallpaperChanged();
void blurEnabledChanged();
void accentColorIndexChanged();
void fontPointSizeChanged();
void fontFamilyChanged();
void fixedFontFamilyChanged();
void wallpaperChanged();
void backgroundTypeChanged();
void backgroundColorChanged();
void backgroundVisibleChanged();
private slots:
void init();
void onDarkModeChanged(bool darkMode);
void onWallpaperChanged(const QString &path);
void onAccentColorChanged(int accentColor);
void onDarkModeDimsWallpaperChanged();
void onBlurEnabledChanged();
void onFontPointSizeChanged();
void onFontFamilyChanged();
void onBackgroundTypeChanged();
void onBackgroundColorChanged();
void onBackgroundVisibleChanged();
private:
QVariant serviceProperty(const char *name) const;
void callService(const char *method);
void callService(const char *method, const QVariant &value);
QDBusInterface *m_interface;
};
#endif // CUTEFISH_APPEARANCE_H

@ -1,17 +0,0 @@
#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 @@
#include "qmlregistration.h"

@ -0,0 +1,29 @@
#ifndef CUTEFISH_APPEARANCE_QMLREGISTRATION_H
#define CUTEFISH_APPEARANCE_QMLREGISTRATION_H
#include <QtQml/qqmlregistration.h>
#include "appearance.h"
#include "wallpaper.h"
// The types themselves live in libcutefish-framework-appearance, which settings
// and FishUI link against. Registering Cutefish.Appearance from a separate
// plugin keeps the module registration in one library: a process that both
// links the library and imports the module would otherwise load two copies of
// the same .so, and Qt refuses the second registration of the URI.
struct AppearanceForeign
{
Q_GADGET
QML_FOREIGN(Appearance)
QML_NAMED_ELEMENT(Appearance)
};
struct WallpaperForeign
{
Q_GADGET
QML_FOREIGN(Wallpaper)
QML_NAMED_ELEMENT(Wallpaper)
};
#endif // CUTEFISH_APPEARANCE_QMLREGISTRATION_H

@ -1,79 +1,56 @@
#include "wallpaper.h"
#include <QDBusServiceWatcher>
#include <QDir>
#include <QDirIterator>
Wallpaper::Wallpaper(QObject *parent)
: QObject(parent)
, m_interface(nullptr)
: Appearance(parent)
{
// The shell starts before cutefish-services, so the signals are hooked up
// again once the service appears; without this the desktop would keep the
// background it read at startup for the rest of the session.
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(this);
watcher->setConnection(QDBusConnection::sessionBus());
watcher->addWatchedService("com.cutefish.Services");
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &Wallpaper::init);
init();
connect(this, &Appearance::backgroundTypeChanged, this, &Wallpaper::typeChanged);
connect(this, &Appearance::wallpaperChanged, this, &Wallpaper::pathChanged);
connect(this, &Appearance::backgroundColorChanged, this, &Wallpaper::colorChanged);
}
void Wallpaper::init()
{
delete m_interface;
m_interface = new QDBusInterface("com.cutefish.Services",
"/com/cutefish/Services/Appearance",
"com.cutefish.Services.Appearance",
QDBusConnection::sessionBus(), this);
if (!m_interface->isValid())
return;
connect(m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onPathChanged(QString)));
connect(m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged()));
connect(m_interface, SIGNAL(backgroundTypeChanged()), this, SIGNAL(typeChanged()));
connect(m_interface, SIGNAL(backgroundColorChanged()), this, SIGNAL(colorChanged()));
connect(m_interface, SIGNAL(backgroundVisibleChanged()), this, SIGNAL(backgroundVisibleChanged()));
emit typeChanged();
emit pathChanged();
emit colorChanged();
emit dimsWallpaperChanged();
emit backgroundVisibleChanged();
}
QVariant Wallpaper::themeProperty(const char *name) const
int Wallpaper::type() const
{
return m_interface ? m_interface->property(name) : QVariant();
return backgroundType();
}
int Wallpaper::type() const
void Wallpaper::setType(int type)
{
return themeProperty("backgroundType").toInt();
setBackgroundType(type);
}
QString Wallpaper::path() const
{
return themeProperty("wallpaper").toString();
return wallpaper();
}
bool Wallpaper::dimsWallpaper() const
void Wallpaper::setPath(const QString &path)
{
return themeProperty("darkModeDimsWallpaer").toBool();
setWallpaper(path);
}
QString Wallpaper::color() const
{
return themeProperty("backgroundColor").toString();
return backgroundColor();
}
bool Wallpaper::backgroundVisible() const
void Wallpaper::setColor(const QString &color)
{
return themeProperty("backgroundVisible").toBool();
setBackgroundColor(color);
}
void Wallpaper::onPathChanged(QString path)
QStringList Wallpaper::backgrounds() const
{
Q_UNUSED(path);
QStringList result;
QDirIterator iterator(QStringLiteral("/usr/share/backgrounds/cutefishos"),
{QStringLiteral("*.jpg"), QStringLiteral("*.png")},
QDir::Files,
QDirIterator::Subdirectories);
while (iterator.hasNext())
result.append(iterator.next());
emit pathChanged();
result.sort();
return result;
}

@ -1,51 +1,40 @@
#ifndef WALLPAPER_H
#define WALLPAPER_H
#include <QObject>
#include <QDBusInterface>
#include "appearance.h"
#include <QStringList>
/**
* The desktop background as cutefish-services publishes it over
* com.cutefish.Services.Appearance: an image (type 0) or a plain colour (type 1).
*/
class Wallpaper : public QObject
class Wallpaper : public Appearance
{
Q_OBJECT
Q_PROPERTY(int type READ type NOTIFY typeChanged)
Q_PROPERTY(QString path READ path NOTIFY pathChanged)
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged)
Q_PROPERTY(QString color READ color NOTIFY colorChanged)
Q_PROPERTY(bool backgroundVisible READ backgroundVisible NOTIFY backgroundVisibleChanged)
Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QStringList backgrounds READ backgrounds CONSTANT)
public:
explicit Wallpaper(QObject *parent = nullptr);
int type() const;
Q_INVOKABLE void setType(int type);
QString path() const;
bool dimsWallpaper() const;
Q_INVOKABLE void setPath(const QString &path);
QString color() const;
bool backgroundVisible() const;
Q_INVOKABLE void setColor(const QString &color);
QStringList backgrounds() const;
signals:
void pathChanged();
void dimsWallpaperChanged();
void typeChanged();
void colorChanged();
void backgroundVisibleChanged();
private:
QVariant themeProperty(const char *name) const;
private slots:
void init();
void onPathChanged(QString path);
private:
// Recreated in init(): a QDBusInterface built while cutefish-services is
// not on the bus caches a failed introspection and never recovers.
QDBusInterface *m_interface;
};
#endif // WALLPAPER_H

@ -74,6 +74,7 @@ qt_add_qml_module(cutefish-framework-audio
PLUGIN_TARGET cutefish-framework-audio
CLASS_NAME Plugin
NO_GENERATE_PLUGIN_SOURCE
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Audio"
QML_FILES ${CUTEFISH_AUDIO_QML_FILES}
)

@ -24,6 +24,7 @@ qt_add_qml_module(cutefish-framework-bluetooth
PLUGIN_TARGET cutefish-framework-bluetooth
CLASS_NAME BluezQtExtensionPlugin
NO_GENERATE_PLUGIN_SOURCE
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Bluetooth"
QML_FILES DevicesModel.qml
)

@ -0,0 +1,25 @@
qt_policy(SET QTP0001 NEW)
if(NOT DEFINED INSTALL_QMLDIR)
find_program(QT_PATHS_EXECUTABLE NAMES qtpaths6 REQUIRED)
execute_process(COMMAND ${QT_PATHS_EXECUTABLE} -query QT_INSTALL_QML
OUTPUT_VARIABLE INSTALL_QMLDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
function(cutefish_install_qml_module target)
qt_query_qml_module("${target}"
TARGET_PATH module_path
QMLDIR module_qmldir
TYPEINFO module_qmltypes
)
set(module_install_dir "${INSTALL_QMLDIR}/${module_path}")
install(TARGETS "${target}" DESTINATION "${module_install_dir}")
install(FILES "${module_qmldir}" DESTINATION "${module_install_dir}")
if(module_qmltypes)
install(FILES "${module_qmltypes}" DESTINATION "${module_install_dir}")
endif()
endfunction()

@ -32,6 +32,7 @@ qt_add_qml_module(cutefish-framework-media
PLUGIN_TARGET cutefish-framework-media
CLASS_NAME QmlPlugins
NO_GENERATE_PLUGIN_SOURCE
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Media"
)

@ -56,6 +56,7 @@ qt_add_qml_module(cutefish-framework-network
PLUGIN_TARGET cutefish-framework-network
CLASS_NAME QmlPlugins
NO_GENERATE_PLUGIN_SOURCE
NO_PLUGIN_OPTIONAL
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Cutefish/Network"
)

@ -21,6 +21,7 @@
#define ACTIVECONNECTION_H
#include <QObject>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/ActiveConnection>
#include <NetworkManagerQt/Connection>
@ -30,6 +31,7 @@
class ActiveConnection : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString wirelessName READ wirelessName NOTIFY wirelessNameChanged)
Q_PROPERTY(QString wirelessIcon READ wirelessIcon NOTIFY wirelessIconChanged)

@ -24,12 +24,14 @@
#include <network_export.h>
#include <QSortFilterProxyModel>
#include <QtQml/qqmlregistration.h>
#include "networkmodelitem.h"
class CUTEFISH_NETWORK_EXPORT AppletProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QAbstractItemModel * sourceModel READ sourceModel WRITE setSourceModel)

@ -22,6 +22,7 @@
#define PLASMA_NM_CONFIGURATION_H
#include <QObject>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/Manager>
@ -37,6 +38,7 @@ class Q_DECL_EXPORT Configuration : public QObject
//Readonly constant property, as this value should only be set by the platform
Q_PROPERTY(bool showPasswordDialog READ showPasswordDialog CONSTANT)
Q_OBJECT
QML_ELEMENT
public:
Configuration();
@ -68,4 +70,3 @@ private:
};
#endif // PLAMA_NM_CONFIGURATION_H

@ -22,6 +22,7 @@
#define PLASMA_NM_ENABLED_CONNECTIONS_H
#include <QObject>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/Manager>
@ -49,6 +50,7 @@ Q_PROPERTY(bool wwanEnabled READ isWwanEnabled NOTIFY wwanEnabled)
Q_PROPERTY(bool wwanHwEnabled READ isWwanHwEnabled NOTIFY wwanHwEnabled)
Q_OBJECT
QML_ELEMENT
public:
explicit EnabledConnections(QObject* parent = nullptr);
~EnabledConnections() override;

@ -22,10 +22,13 @@
#define PLASMA_NM_ENUMS_H
#include <QObject>
#include <QtQml/qqmlregistration.h>
class Enums : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("Enums is only a namespace for enums")
Q_ENUMS(ConnectionStatus)
Q_ENUMS(ConnectionType)
Q_ENUMS(SecurityType)

@ -23,6 +23,7 @@
#include <QDBusInterface>
#include <QTimer>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/Settings>
@ -35,6 +36,7 @@
class Q_DECL_EXPORT Handler : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
enum HandlerAction {

@ -20,10 +20,12 @@
#include <QIdentityProxyModel>
#include <QModelIndex>
#include <QtQml/qqmlregistration.h>
class Q_DECL_EXPORT IdentityModel : public QIdentityProxyModel
{
Q_OBJECT
QML_ELEMENT
public:
explicit IdentityModel(QObject *parent = nullptr);
@ -45,4 +47,4 @@ public:
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
};
#endif // PLASMA_NM_KCM_IDENTITY_MODEL_H
#endif // PLASMA_NM_KCM_IDENTITY_MODEL_H

@ -25,6 +25,7 @@
#include <QAbstractListModel>
#include <QLoggingCategory>
#include <QtQml/qqmlregistration.h>
#include "networkitemslist.h"
@ -42,6 +43,7 @@ Q_DECLARE_LOGGING_CATEGORY(gLcNm)
class CUTEFISH_NETWORK_EXPORT NetworkModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
explicit NetworkModel(QObject *parent = nullptr);

@ -22,6 +22,7 @@
#define NETWORKMODELITEM_H
#include <network_export.h>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/ActiveConnection>
#include <NetworkManagerQt/Connection>
@ -34,6 +35,8 @@
class CUTEFISH_NETWORK_EXPORT NetworkModelItem : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("NetworkModelItem is created by NetworkModel")
public:
enum ItemType { UnavailableConnection, AvailableConnection, AvailableAccessPoint };

@ -1,30 +1,6 @@
#include "qmlplugins.h"
#include "networkmodel.h"
#include "networkmodelitem.h"
#include "activeconnection.h"
#include "appletproxymodel.h"
#include "wirelessitemsettings.h"
#include "identitymodel.h"
#include "handler.h"
#include "enabledconnections.h"
#include "enums.h"
#include "wifisettings.h"
#include "configuration.h"
#include <QQmlEngine>
void QmlPlugins::registerTypes(const char* uri)
{
qmlRegisterUncreatableType<NetworkModelItem>(uri, 1, 0, "NetworkModelItem",
QLatin1String("Cannot instantiate NetworkModelItem"));
qmlRegisterType<ActiveConnection>(uri, 1, 0, "ActiveConnection");
qmlRegisterType<AppletProxyModel>(uri, 1, 0, "AppletProxyModel");
qmlRegisterType<NetworkModel>(uri, 1, 0, "NetworkModel");
qmlRegisterType<WirelessItemSettings>(uri, 1, 0, "WirelessItemSettings");
qmlRegisterType<IdentityModel>(uri, 1, 0, "IdentityModel");
qmlRegisterType<Handler>(uri, 1, 0, "Handler");
qmlRegisterType<EnabledConnections>(uri, 1, 0, "EnabledConnections");
qmlRegisterType<WifiSettings>(uri, 1, 0, "WifiSettings");
qmlRegisterType<Configuration>(uri, 1, 0, "Configuration");
qmlRegisterUncreatableType<Enums>(uri, 1, 0, "Enums", "You cannot create Enums on yourself");
Q_UNUSED(uri);
}

@ -21,10 +21,12 @@
#define WIFISETTINGS_H
#include <QObject>
#include <QtQml/qqmlregistration.h>
class WifiSettings : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
WifiSettings(QObject *parent = nullptr);

@ -4,12 +4,14 @@
#include <network_export.h>
#include <QtCore/QObject>
#include <QtQml/qqmlregistration.h>
#include <NetworkManagerQt/Connection>
class CUTEFISH_NETWORK_EXPORT WirelessItemSettings : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(bool autoConnect READ autoConnect WRITE setAutoConnect NOTIFY autoConnectChanged)

Loading…
Cancel
Save