From 31e8c393ea88c99f43817bb91d35355015597e4b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 16 Nov 2017 13:19:48 -0500 Subject: Another attempt to fix the Repeater of objects issue in Lumina 2. --- .../src-desktop/src-cpp/RootDesktopObject.cpp | 7 +++++++ .../lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h | 1 + .../lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 9842712e..ee15c9c2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -36,6 +36,13 @@ QList RootDesktopObject::screens(){ return s_objects; } +ScreenObject* RootDesktopObject::screen(QString id){ + for(int i=0; iname()==id){ return s_objects[i]; } + } + return 0; +} + void RootDesktopObject::logout(){ emit startLogout(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index dd7c7ab3..786d90e2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -30,6 +30,7 @@ public: //QML Read Functions QList screens(); + Q_INVOKABLE ScreenObject* screen(QString id); //QML Access Functions Q_INVOKABLE void logout(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp index 4c1d6189..7b84882e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp @@ -16,7 +16,7 @@ void ScreenObject::RegisterType(){ qmlRegisterType("Lumina.Backend.ScreenObject",2,0, "ScreenObject"); } -QString ScreenObject::name(){ return bg_screen->name(); } +QString ScreenObject::name(){ return bg_screen->name().replace("-","_"); } QString ScreenObject::background(){ qDebug() << "Got Background:" << bg_screen->name() << bg << bg_screen->geometry(); return bg; } int ScreenObject::x(){ return bg_screen->geometry().x(); } int ScreenObject::y(){ return bg_screen->geometry().y(); } -- cgit From d626a9ab0dd8d9ca8c4d6c69a6693acebb8e1f1a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 16 Nov 2017 15:16:02 -0500 Subject: Get the Iteration over objects working for Lumina 2 (wallpapers). QML Note: The "Repeater" class cannot iterate over objects, just items. To work around this, provide a QStringList instead of a QList, and implement a callback function to return the Object* based on the String ID. --- .../src-desktop/src-cpp/RootDesktopObject.cpp | 8 ++++++-- .../src-desktop/src-cpp/RootDesktopObject.h | 4 ++-- .../lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index ee15c9c2..60cf56c3 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -32,11 +32,15 @@ RootDesktopObject* RootDesktopObject::instance(){ } //QML Read Functions -QList RootDesktopObject::screens(){ - return s_objects; +QStringList RootDesktopObject::screens(){ + qDebug() << "Request Screens:" << s_objects.length(); + QStringList names; + for(int i=0; iname(); } + return names; } ScreenObject* RootDesktopObject::screen(QString id){ + qDebug() << "Got Screen Request:" << id; for(int i=0; iname()==id){ return s_objects[i]; } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index 786d90e2..ba586701 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -16,7 +16,7 @@ class RootDesktopObject : public QObject{ Q_OBJECT //Define all the QML Properties here (interface between QML and the C++ methods below) - Q_PROPERTY( QList screens READ screens NOTIFY screensChanged) + Q_PROPERTY( QStringList screens READ screens NOTIFY screensChanged) public: //main contructor/destructor @@ -29,7 +29,7 @@ public: static RootDesktopObject* instance(); //QML Read Functions - QList screens(); + QStringList screens(); Q_INVOKABLE ScreenObject* screen(QString id); //QML Access Functions diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp index 7b84882e..4c1d6189 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp @@ -16,7 +16,7 @@ void ScreenObject::RegisterType(){ qmlRegisterType("Lumina.Backend.ScreenObject",2,0, "ScreenObject"); } -QString ScreenObject::name(){ return bg_screen->name().replace("-","_"); } +QString ScreenObject::name(){ return bg_screen->name(); } QString ScreenObject::background(){ qDebug() << "Got Background:" << bg_screen->name() << bg << bg_screen->geometry(); return bg; } int ScreenObject::x(){ return bg_screen->geometry().x(); } int ScreenObject::y(){ return bg_screen->geometry().y(); } -- cgit