From 01610f502720d2eb88a7da2ae7009db1e07f842d Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 23 Apr 2017 13:48:55 +0200 Subject: [PATCH] Register some enums/structs as Qt meta-type Reuired when creating a Plasmoid because these types might be accessed from QML then --- connector/syncthingconfig.h | 1 - connector/syncthingconnection.h | 9 ++++++++- connector/syncthingdev.h | 5 +++++ connector/syncthingdir.h | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/connector/syncthingconfig.h b/connector/syncthingconfig.h index ebfe3b5..388c71e 100644 --- a/connector/syncthingconfig.h +++ b/connector/syncthingconfig.h @@ -23,7 +23,6 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConfig QString syncthingUrl() const; }; - } // namespace Data #endif // DATA_SYNCTHINGCONFIG_H diff --git a/connector/syncthingconnection.h b/connector/syncthingconnection.h index 47e9b22..9cb7336 100644 --- a/connector/syncthingconnection.h +++ b/connector/syncthingconnection.h @@ -22,6 +22,7 @@ QT_FORWARD_DECLARE_CLASS(QJsonObject) QT_FORWARD_DECLARE_CLASS(QJsonArray) namespace Data { +Q_NAMESPACE struct SyncthingConnectionSettings; @@ -38,6 +39,7 @@ enum class SyncthingStatus OutOfSync, BeingDestroyed }; +Q_ENUM_NS(SyncthingStatus) enum class SyncthingErrorCategory { @@ -45,6 +47,7 @@ enum class SyncthingErrorCategory SpecificRequest, Parsing }; +Q_ENUM_NS(SyncthingErrorCategory) struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry { @@ -61,7 +64,9 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject Q_OBJECT Q_PROPERTY(QString syncthingUrl READ syncthingUrl WRITE setSyncthingUrl) Q_PROPERTY(QByteArray apiKey READ apiKey WRITE setApiKey) - Q_PROPERTY(SyncthingStatus status READ status NOTIFY statusChanged) + Q_PROPERTY(Data::SyncthingStatus status READ status NOTIFY statusChanged) + Q_PROPERTY(QString statusText READ statusText NOTIFY statusChanged) + Q_PROPERTY(bool connected READ isConnected NOTIFY statusChanged) Q_PROPERTY(bool hasUnreadNotifications READ hasUnreadNotifications) Q_PROPERTY(bool hasOutOfSyncDirs READ hasOutOfSyncDirs) Q_PROPERTY(int trafficPollInterval READ trafficPollInterval WRITE setTrafficPollInterval) @@ -518,4 +523,6 @@ inline const std::vector &SyncthingConnection::completedDirs() c } +Q_DECLARE_METATYPE(Data::SyncthingLogEntry) + #endif // SYNCTHINGCONNECTION_H diff --git a/connector/syncthingdev.h b/connector/syncthingdev.h index fc11ea5..a97298b 100644 --- a/connector/syncthingdev.h +++ b/connector/syncthingdev.h @@ -7,8 +7,10 @@ #include #include +#include namespace Data { +Q_NAMESPACE enum class SyncthingDevStatus { @@ -20,6 +22,7 @@ enum class SyncthingDevStatus OutOfSync, Rejected }; +Q_ENUM_NS(SyncthingDevStatus) QString statusString(SyncthingDevStatus status); @@ -53,4 +56,6 @@ inline SyncthingDev::SyncthingDev(const QString &id, const QString &name) : } // namespace Data +Q_DECLARE_METATYPE(Data::SyncthingDev) + #endif // DATA_SYNCTHINGDEV_H diff --git a/connector/syncthingdir.h b/connector/syncthingdir.h index 44aaee1..a5340e3 100644 --- a/connector/syncthingdir.h +++ b/connector/syncthingdir.h @@ -6,11 +6,13 @@ #include #include +#include #include QT_FORWARD_DECLARE_CLASS(QJsonObject) namespace Data { +Q_NAMESPACE enum class SyncthingDirStatus { @@ -21,6 +23,7 @@ enum class SyncthingDirStatus Synchronizing, OutOfSync }; +Q_ENUM_NS(SyncthingDirStatus) QString statusString(SyncthingDirStatus status); @@ -111,4 +114,8 @@ inline QString SyncthingDir::displayName() const } // namespace Data +Q_DECLARE_METATYPE(Data::SyncthingDirError) +Q_DECLARE_METATYPE(Data::SyncthingItemDownloadProgress) +Q_DECLARE_METATYPE(Data::SyncthingDir) + #endif // DATA_SYNCTHINGDIR_H