diff options
author | Ken Moore <ken@ixsystems.com> | 2017-11-16 15:16:02 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-11-16 15:16:02 -0500 |
commit | d626a9ab0dd8d9ca8c4d6c69a6693acebb8e1f1a (patch) | |
tree | 86be8c00d7abd6c08345a436fa357c2899666bf9 | |
parent | Another attempt to fix the Repeater of objects issue in Lumina 2. (diff) | |
download | lumina-d626a9ab0dd8d9ca8c4d6c69a6693acebb8e1f1a.tar.gz lumina-d626a9ab0dd8d9ca8c4d6c69a6693acebb8e1f1a.tar.bz2 lumina-d626a9ab0dd8d9ca8c4d6c69a6693acebb8e1f1a.zip |
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<Object*>, and implement a callback function to return the Object* based on the String ID.
8 files changed, 19 insertions, 15 deletions
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<ScreenObject*> RootDesktopObject::screens(){ - return s_objects; +QStringList RootDesktopObject::screens(){ + qDebug() << "Request Screens:" << s_objects.length(); + QStringList names; + for(int i=0; i<s_objects.length(); i++){ names << s_objects[i]->name(); } + return names; } ScreenObject* RootDesktopObject::screen(QString id){ + qDebug() << "Got Screen Request:" << id; for(int i=0; i<s_objects.length(); i++){ if(s_objects[i]->name()==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<ScreenObject*> 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<ScreenObject*> 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<ScreenObject>("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(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml index e5bac0b5..7360d81f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/ContextMenu.qml @@ -6,7 +6,7 @@ //=========================================== import QtQuick 2.2 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 1 import Lumina.Backend.RootDesktopObject 2.0 diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml index 6b341fee..9db05c45 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml @@ -17,7 +17,7 @@ //=========================================== import QtQuick 2.2 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 1 import "." as QML @@ -29,7 +29,7 @@ Rectangle { color: "black" //Setup the right-click context menu - MouseArea { + /*MouseArea { anchors.fill: rootCanvas acceptedButtons: Qt.RightButton onClicked: { @@ -43,14 +43,13 @@ Rectangle { } //Create the context menu itself - QML.ContextMenu { id: contextMenu } + QML.ContextMenu { id: contextMenu }*/ //Setup the wallpapers Repeater{ model: RootObject.screens QML.WallpaperImage{ - //console.log( modelData.name() ) - screen_id: modelData.name() + screen_id: modelData z: 0+index } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml index 97357617..1b44963f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/WallpaperImage.qml @@ -6,13 +6,13 @@ //=========================================== import QtQuick 2.2 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 1 import Lumina.Backend.ScreenObject 2.0 AnimatedImage { //C++ backend object - property text screen_id + property string screen_id property ScreenObject object: RootObject.screen(screen_id) //Normal geometries/placements diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri index 99905253..fed18e02 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.pri @@ -1,7 +1,8 @@ #Show the QML files to lupdate for translation purposes - not for the actual build lupdate_only{ SOURCES *= $${PWD}/RootDesktop.qml \ - $${PWD}/ContextMenu.qml + $${PWD}/ContextMenu.qml \ + $${PWD}/WallpaperImage.qml } RESOURCES *= $${PWD}/src-qml.qrc diff --git a/src-qt5/core/lumina-desktop/lumina-desktop.pro b/src-qt5/core/lumina-desktop/lumina-desktop.pro index 2c944a11..f7fead13 100644 --- a/src-qt5/core/lumina-desktop/lumina-desktop.pro +++ b/src-qt5/core/lumina-desktop/lumina-desktop.pro @@ -175,7 +175,7 @@ dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_RO manpage.path=$${L_MANDIR}/man8/ manpage.extra="$${MAN_ZIP} lumina-desktop.8 > $(INSTALL_ROOT)$${L_MANDIR}/man8/lumina-desktop.8.gz" -INSTALLS += target desktop icons wallpapers defaults conf fluxconf manpage +INSTALLS += target desktop icons defaults conf fluxconf manpage WITH_I18N{ INSTALLS += dotrans |