diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c23675..ddff4ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/accounts/CMakeLists.txt b/accounts/CMakeLists.txt index fe3f607..7ace6f4 100644 --- a/accounts/CMakeLists.txt +++ b/accounts/CMakeLists.txt @@ -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" ) diff --git a/appearance/CMakeLists.txt b/appearance/CMakeLists.txt index bf919a0..6dfa971 100644 --- a/appearance/CMakeLists.txt +++ b/appearance/CMakeLists.txt @@ -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 + $ + $ ) -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() diff --git a/appearance/appearance.cpp b/appearance/appearance.cpp new file mode 100644 index 0000000..d93234e --- /dev/null +++ b/appearance/appearance.cpp @@ -0,0 +1,254 @@ +#include "appearance.h" + +#include +#include +#include + +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(); +} diff --git a/appearance/appearance.h b/appearance/appearance.h new file mode 100644 index 0000000..e95123e --- /dev/null +++ b/appearance/appearance.h @@ -0,0 +1,97 @@ +#ifndef CUTEFISH_APPEARANCE_H +#define CUTEFISH_APPEARANCE_H + +#include +#include +#include + +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 diff --git a/appearance/plugin.cpp b/appearance/plugin.cpp deleted file mode 100644 index 5dfb068..0000000 --- a/appearance/plugin.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#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(uri, 1, 0, "Wallpaper"); - } -}; - -#include "plugin.moc" \ No newline at end of file diff --git a/appearance/qmlregistration.cpp b/appearance/qmlregistration.cpp new file mode 100644 index 0000000..33110b0 --- /dev/null +++ b/appearance/qmlregistration.cpp @@ -0,0 +1 @@ +#include "qmlregistration.h" diff --git a/appearance/qmlregistration.h b/appearance/qmlregistration.h new file mode 100644 index 0000000..f898361 --- /dev/null +++ b/appearance/qmlregistration.h @@ -0,0 +1,29 @@ +#ifndef CUTEFISH_APPEARANCE_QMLREGISTRATION_H +#define CUTEFISH_APPEARANCE_QMLREGISTRATION_H + +#include + +#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 diff --git a/appearance/wallpaper.cpp b/appearance/wallpaper.cpp index bc478d1..82ff708 100644 --- a/appearance/wallpaper.cpp +++ b/appearance/wallpaper.cpp @@ -1,79 +1,56 @@ #include "wallpaper.h" -#include +#include +#include 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; } diff --git a/appearance/wallpaper.h b/appearance/wallpaper.h index 2f2669c..fbcb49d 100644 --- a/appearance/wallpaper.h +++ b/appearance/wallpaper.h @@ -1,51 +1,40 @@ #ifndef WALLPAPER_H #define WALLPAPER_H -#include -#include +#include "appearance.h" + +#include /** * 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 diff --git a/audio/CMakeLists.txt b/audio/CMakeLists.txt index 6ae0ccf..72dfae4 100644 --- a/audio/CMakeLists.txt +++ b/audio/CMakeLists.txt @@ -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} ) diff --git a/bluetooth/CMakeLists.txt b/bluetooth/CMakeLists.txt index f973610..7316b1e 100644 --- a/bluetooth/CMakeLists.txt +++ b/bluetooth/CMakeLists.txt @@ -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 ) diff --git a/cmake/CutefishFrameworkQml.cmake b/cmake/CutefishFrameworkQml.cmake new file mode 100644 index 0000000..9803577 --- /dev/null +++ b/cmake/CutefishFrameworkQml.cmake @@ -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() diff --git a/media/CMakeLists.txt b/media/CMakeLists.txt index ecec52b..8bc8f69 100644 --- a/media/CMakeLists.txt +++ b/media/CMakeLists.txt @@ -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" ) diff --git a/network/CMakeLists.txt b/network/CMakeLists.txt index d77d60a..c42d3bb 100644 --- a/network/CMakeLists.txt +++ b/network/CMakeLists.txt @@ -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" ) diff --git a/network/activeconnection.h b/network/activeconnection.h index 6989d23..2142175 100644 --- a/network/activeconnection.h +++ b/network/activeconnection.h @@ -21,6 +21,7 @@ #define ACTIVECONNECTION_H #include +#include #include #include @@ -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) diff --git a/network/appletproxymodel.h b/network/appletproxymodel.h index b0b7fee..9a3ee51 100644 --- a/network/appletproxymodel.h +++ b/network/appletproxymodel.h @@ -24,12 +24,14 @@ #include #include +#include #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) diff --git a/network/configuration.h b/network/configuration.h index fd1bdcc..3d649ec 100644 --- a/network/configuration.h +++ b/network/configuration.h @@ -22,6 +22,7 @@ #define PLASMA_NM_CONFIGURATION_H #include +#include #include @@ -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 - diff --git a/network/enabledconnections.h b/network/enabledconnections.h index 8cd3367..76e65ed 100644 --- a/network/enabledconnections.h +++ b/network/enabledconnections.h @@ -22,6 +22,7 @@ #define PLASMA_NM_ENABLED_CONNECTIONS_H #include +#include #include @@ -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; diff --git a/network/enums.h b/network/enums.h index 4bf414c..8b23f12 100644 --- a/network/enums.h +++ b/network/enums.h @@ -22,10 +22,13 @@ #define PLASMA_NM_ENUMS_H #include +#include 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) diff --git a/network/handler.h b/network/handler.h index 52c8363..0c9443f 100644 --- a/network/handler.h +++ b/network/handler.h @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -35,6 +36,7 @@ class Q_DECL_EXPORT Handler : public QObject { Q_OBJECT +QML_ELEMENT public: enum HandlerAction { diff --git a/network/identitymodel.h b/network/identitymodel.h index 4f8f3d9..fcaa653 100644 --- a/network/identitymodel.h +++ b/network/identitymodel.h @@ -20,10 +20,12 @@ #include #include +#include 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 \ No newline at end of file +#endif // PLASMA_NM_KCM_IDENTITY_MODEL_H diff --git a/network/networkmodel.h b/network/networkmodel.h index b562d81..89657aa 100644 --- a/network/networkmodel.h +++ b/network/networkmodel.h @@ -25,6 +25,7 @@ #include #include +#include #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); diff --git a/network/networkmodelitem.h b/network/networkmodelitem.h index bfbbd08..213acd7 100644 --- a/network/networkmodelitem.h +++ b/network/networkmodelitem.h @@ -22,6 +22,7 @@ #define NETWORKMODELITEM_H #include +#include #include #include @@ -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 }; diff --git a/network/qmlplugins.cpp b/network/qmlplugins.cpp index 013b2c6..80e7ea0 100644 --- a/network/qmlplugins.cpp +++ b/network/qmlplugins.cpp @@ -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 void QmlPlugins::registerTypes(const char* uri) { - qmlRegisterUncreatableType(uri, 1, 0, "NetworkModelItem", - QLatin1String("Cannot instantiate NetworkModelItem")); - qmlRegisterType(uri, 1, 0, "ActiveConnection"); - qmlRegisterType(uri, 1, 0, "AppletProxyModel"); - qmlRegisterType(uri, 1, 0, "NetworkModel"); - qmlRegisterType(uri, 1, 0, "WirelessItemSettings"); - qmlRegisterType(uri, 1, 0, "IdentityModel"); - qmlRegisterType(uri, 1, 0, "Handler"); - qmlRegisterType(uri, 1, 0, "EnabledConnections"); - qmlRegisterType(uri, 1, 0, "WifiSettings"); - qmlRegisterType(uri, 1, 0, "Configuration"); - qmlRegisterUncreatableType(uri, 1, 0, "Enums", "You cannot create Enums on yourself"); + Q_UNUSED(uri); } diff --git a/network/wifisettings.h b/network/wifisettings.h index 3d74f96..e690327 100644 --- a/network/wifisettings.h +++ b/network/wifisettings.h @@ -21,10 +21,12 @@ #define WIFISETTINGS_H #include +#include class WifiSettings : public QObject { Q_OBJECT + QML_ELEMENT public: WifiSettings(QObject *parent = nullptr); diff --git a/network/wirelessitemsettings.h b/network/wirelessitemsettings.h index a45e827..f1c2441 100644 --- a/network/wirelessitemsettings.h +++ b/network/wirelessitemsettings.h @@ -4,12 +4,14 @@ #include #include +#include #include 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)