From 11792ae565e6497af5358b4f1a75c62b79499b0a Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Thu, 3 Jul 2025 21:00:52 +0200 Subject: [PATCH] Add NewStuff Button --- .../contents/ui/settings/AppletListViewer.qml | 30 ++++++++++- .../ui/settings/SettingsComponent.qml | 51 ++++++++++++++----- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml index b7c34350..069f354c 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml @@ -9,6 +9,7 @@ import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import org.kde.plasma.plasmoid +import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.private.shell 2.0 import org.kde.private.mobile.homescreen.folio 1.0 as Folio import org.kde.kirigamiaddons.formcard 1.0 as FormCard @@ -39,6 +40,15 @@ MouseArea { color: Qt.rgba(0, 0, 0, 0.7) } + + PlasmaExtras.ModelContextMenu { + id: getWidgetsDialog + visualParent: getWidgetsButton + placement: PlasmaExtras.Menu.TopPosedLeftAlignedPopup + // model set on first invocation + onClicked: model.trigger() + } + RowLayout { id: header spacing: Kirigami.Units.largeSpacing @@ -46,6 +56,8 @@ MouseArea { anchors.leftMargin: Kirigami.Units.gridUnit anchors.top: parent.top anchors.topMargin: Kirigami.Units.gridUnit * 3 + root.homeScreen.topMargin + anchors.right: parent.right + anchors.rightMargin: Kirigami.Units.gridUnit PC3.ToolButton { Layout.alignment: Qt.AlignVCenter @@ -58,10 +70,24 @@ MouseArea { PC3.Label { id: heading - color: 'white' + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary text: i18n("Widgets") font.weight: Font.Bold font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.5 + Layout.fillWidth: true + } + + PC3.ToolButton { + id: getWidgetsButton + icon.name: "get-hot-new-stuff" + text: i18ndc("plasma_shell_org.kde.plasma.mobile", "@action:button The word 'new' refers to widgets", "Get New Widgets…") + Accessible.name: i18ndc("plasma_shell_org.kde.plasma.mobile", "@action:button", "Get New Widgets…") + + onClicked: { + getWidgetsDialog.model = widgetExplorer.widgetsMenuActions + getWidgetsDialog.openRelative() + } } } @@ -217,5 +243,7 @@ MouseArea { WidgetExplorer { id: widgetExplorer containment: Plasmoid + + onShouldClose: root.requestClose() } } diff --git a/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml b/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml index 89b4eb70..89adb2a4 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml @@ -21,7 +21,7 @@ Item { property var homeScreen property real settingsModeHomeScreenScale - readonly property bool homeScreenInteractive: !appletListViewer.open + readonly property bool homeScreenInteractive: !appletListViewerLoader.active property real bottomMargin: 0 property real leftMargin: 0 @@ -33,7 +33,7 @@ Item { // Close applet viewer when settings view closes function onViewStateChanged() { if (folio.HomeScreenState.viewState !== Folio.HomeScreenState.SettingsView) { - appletListViewer.requestClose(); + appletListViewerLoader.requestClose(); } } } @@ -142,7 +142,7 @@ Item { } onClicked: { - appletListViewer.open = true; + appletListViewerLoader.active = true; } } } @@ -215,27 +215,50 @@ Item { } ] - AppletListViewer { - id: appletListViewer - folio: root.folio + Loader { + id: appletListViewerLoader + asynchronous: true + active: false + + signal requestClose() + onRequestClose: item?.requestClose() + width: parent.width height: parent.height - property bool open: false - onRequestClose: open = false - - opacity: open ? 1 : 0 - + opacity: status == Loader.Ready ? 1 : 0 // move the settings out of the way if it is not visible // NOTE: we do this instead of setting visible to false, because // it doesn't mess with widget drag and drop - y: (opacity === 0) ? appletListViewer.height : 0 - - homeScreen: root.homeScreen + y: (opacity > 0) ? 0 : parent.height Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } } + + sourceComponent: AppletListViewer { + id: appletListViewer + folio: root.folio + + width: parent.width + height: parent.height + + onRequestClose: parent.active = false + + homeScreen: root.homeScreen + } + } + + PC3.BusyIndicator { + id: appletListLoadingIndicator + anchors.centerIn: parent + visible: appletListViewerLoader.status === Loader.Loading + + implicitHeight: Kirigami.Units.iconSizes.huge + implicitWidth: Kirigami.Units.iconSizes.huge + + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary } SettingsWindow {