From 5b64a6d44215a22ffa9a4d7b64b695ffe9dfa858 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 17 Jul 2017 18:01:37 +0200 Subject: democompositor: Expose the AppListModel and use to display apps Replace the static configuration of the launch buttons with a Repeater and the instantiated appModel. Use Component.onCompleted to parse the app files. Maybe we can make this a property to ease starting it? It is hardcoding the install directory for the *.app files but I am not sure how to do it differently. Change-Id: I5ef1d78a472f6e0f1dc1c0a3b050179949e6d818 Reviewed-by: Paul Olav Tvete --- wayland/democompositor/main.cpp | 3 ++ wayland/democompositor/qml/Screen.qml | 60 ++++++++++++----------------------- 2 files changed, 24 insertions(+), 39 deletions(-) (limited to 'wayland') diff --git a/wayland/democompositor/main.cpp b/wayland/democompositor/main.cpp index c10e9c2..ac25eaf 100644 --- a/wayland/democompositor/main.cpp +++ b/wayland/democompositor/main.cpp @@ -55,11 +55,14 @@ #include #include #include + +#include "apps/applistmodel.h" #include "processlauncher.h" static void registerTypes() { qmlRegisterType("com.theqtcompany.wlprocesslauncher", 1, 0, "ProcessLauncher"); + qmlRegisterType("com.theqtcompany.wlapplistmodel", 1, 0, "AppListModel"); } diff --git a/wayland/democompositor/qml/Screen.qml b/wayland/democompositor/qml/Screen.qml index 34fd090..b609ca2 100644 --- a/wayland/democompositor/qml/Screen.qml +++ b/wayland/democompositor/qml/Screen.qml @@ -53,6 +53,7 @@ import QtQuick.Window 2.2 import QtWayland.Compositor 1.0 import com.theqtcompany.wlprocesslauncher 1.0 +import com.theqtcompany.wlapplistmodel 1.0 WaylandOutput { @@ -85,6 +86,13 @@ WaylandOutput { id: launcher } + AppListModel { + id: apps + } + + Component.onCompleted: { + apps.addAndWatchDir("/data/user/democompositor/apps/") + } Rectangle { id: curtain @@ -252,46 +260,20 @@ WaylandOutput { height: 5 width: 1 } - LaunchButton { - height: 60 - width: sidebar.width - 10 - buttonColor: backgroundCol - pressedColor: pressedCol - textColor: textCol - text.text: "Clocks" - executable: "./clocks" - icon.source: "qrc:/images/Icon_Clocks.png" - } - LaunchButton { - height: 60 - width: sidebar.width - 10 - buttonColor: backgroundCol - pressedColor: pressedCol - textColor: textCol - text.text: "RSS News" - executable: "./rssnews" - icon.source: "qrc:/images/Icon_RSS.png" - } - LaunchButton { - height: 60 - width: sidebar.width - 10 - buttonColor: backgroundCol - pressedColor: pressedCol - textColor: textCol - text.text: "StoQt" - executable: "./stocqt" - icon.source: "qrc:/images/Icon_StocQt.png" - } - LaunchButton { - height: 60 - width: sidebar.width - 10 - buttonColor: backgroundCol - pressedColor: pressedCol - textColor: textCol - text.text: "Maps" - executable: "./qml_location_mapviewer" - icon.source: "qrc:/images/Icon_Maps.png" + Repeater { + model: apps + + LaunchButton { + height: 60 + width: sidebar.width - 10 + buttonColor: backgroundCol + pressedColor: pressedCol + textColor: textCol + text.text: model.applicationName + executable: model.executableName + icon.source: model.iconName + } } TimedButton { -- cgit v1.2.3