diff --git a/src/file/indexerstate.h b/src/file/indexerstate.h --- a/src/file/indexerstate.h +++ b/src/file/indexerstate.h @@ -22,10 +22,13 @@ #ifndef BALOO_INDEXER_STATE_H #define BALOO_INDEXER_STATE_H +#include #include #include namespace Baloo { +Q_NAMESPACE + enum IndexerState { Idle, Suspended, @@ -38,6 +41,7 @@ StaleIndexEntriesClean, LowPowerIdle, }; +Q_ENUM_NS(IndexerState) inline QString stateString(IndexerState state) { diff --git a/src/qml/experimental/CMakeLists.txt b/src/qml/experimental/CMakeLists.txt --- a/src/qml/experimental/CMakeLists.txt +++ b/src/qml/experimental/CMakeLists.txt @@ -15,6 +15,8 @@ ${DBUS_INTERFACES} ) +qt5_wrap_cpp(baloomonitorplugin_SRCS ../../file/indexerstate.h) + add_library(baloomonitorplugin SHARED ${baloomonitorplugin_SRCS}) add_dependencies(baloomonitorplugin BalooDBusInterfaces) diff --git a/src/qml/experimental/baloomonitorplugin.cpp b/src/qml/experimental/baloomonitorplugin.cpp --- a/src/qml/experimental/baloomonitorplugin.cpp +++ b/src/qml/experimental/baloomonitorplugin.cpp @@ -19,13 +19,14 @@ #include "baloomonitorplugin.h" #include "monitor.h" +#include "indexerstate.h" #include void BalooMonitorPlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.baloo.experimental")); qmlRegisterType(uri, 0, 1, "Monitor"); + qmlRegisterUncreatableMetaObject(Baloo::staticMetaObject, uri, 0, 1, "Baloo", "Error: only enums"); } - diff --git a/src/qml/experimental/monitor.h b/src/qml/experimental/monitor.h --- a/src/qml/experimental/monitor.h +++ b/src/qml/experimental/monitor.h @@ -42,16 +42,16 @@ Q_PROPERTY(uint filesIndexed MEMBER m_filesIndexed NOTIFY newFileIndexed) Q_PROPERTY(QString remainingTime READ remainingTime NOTIFY remainingTimeChanged) Q_PROPERTY(QString stateString READ stateString NOTIFY indexerStateChanged) - Q_PROPERTY(int state READ state NOTIFY indexerStateChanged) + Q_PROPERTY(Baloo::IndexerState state READ state NOTIFY indexerStateChanged) public: explicit Monitor(QObject* parent = nullptr); // Property readers QString filePath() const { return m_filePath; } QString suspendState() const; QString remainingTime() const { return m_remainingTime; } QString stateString() const { return Baloo::stateString(m_indexerState); } - int state() const { return static_cast(m_indexerState); } + Baloo::IndexerState state() const { return m_indexerState; } // Invokable methods Q_INVOKABLE void toggleSuspendState();