From b31b6289dd1d34a66f54dd40e22340ea18eb1a91 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 27 Aug 2019 12:13:00 +0200 Subject: [PATCH] resume launch feedback window --- .../homescreen2/applicationlistmodel.cpp | 4 + .../homescreen2/applicationlistmodel.h | 2 + .../package/contents/ui/FeedbackWindow.qml | 118 +++++++++++++++++ .../package/contents/ui/KRunner.qml | 124 ++++++++++++++++++ .../package/contents/ui/launcher/Delegate.qml | 23 ++-- .../homescreen2/package/contents/ui/main.qml | 25 ++++ 6 files changed, 286 insertions(+), 10 deletions(-) create mode 100644 containments/homescreen2/package/contents/ui/FeedbackWindow.qml create mode 100644 containments/homescreen2/package/contents/ui/KRunner.qml diff --git a/containments/homescreen2/applicationlistmodel.cpp b/containments/homescreen2/applicationlistmodel.cpp index 14e64209..b048e172 100644 --- a/containments/homescreen2/applicationlistmodel.cpp +++ b/containments/homescreen2/applicationlistmodel.cpp @@ -67,6 +67,7 @@ QHash ApplicationListModel::roleNames() const roleNames[ApplicationStorageIdRole] = "ApplicationStorageIdRole"; roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole"; roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole"; + roleNames[ApplicationStartupNotifyRole] = "ApplicationStartupNotifyRole"; roleNames[ApplicationLocationRole] = "ApplicationLocationRole"; return roleNames; @@ -148,6 +149,7 @@ void ApplicationListModel::loadApplications() data.icon = service->icon(); data.storageId = service->storageId(); data.entryPath = service->exec(); + data.startupNotify = service->property("StartupNotify").toBool(); if (m_favorites.contains(data.storageId)) { data.location = Favorites; @@ -198,6 +200,8 @@ QVariant ApplicationListModel::data(const QModelIndex &index, int role) const return m_applicationList.at(index.row()).entryPath; case ApplicationOriginalRowRole: return index.row(); + case ApplicationStartupNotifyRole: + return m_applicationList.at(index.row()).startupNotify; case ApplicationLocationRole: return m_applicationList.at(index.row()).location; diff --git a/containments/homescreen2/applicationlistmodel.h b/containments/homescreen2/applicationlistmodel.h index 198008e7..f9027e6e 100644 --- a/containments/homescreen2/applicationlistmodel.h +++ b/containments/homescreen2/applicationlistmodel.h @@ -37,6 +37,7 @@ struct ApplicationData { QString storageId; QString entryPath; int location = 0; //FIXME + bool startupNotify = true; }; class ApplicationListModel : public QAbstractListModel { @@ -59,6 +60,7 @@ public: ApplicationStorageIdRole, ApplicationEntryPathRole, ApplicationOriginalRowRole, + ApplicationStartupNotifyRole, ApplicationLocationRole }; diff --git a/containments/homescreen2/package/contents/ui/FeedbackWindow.qml b/containments/homescreen2/package/contents/ui/FeedbackWindow.qml new file mode 100644 index 00000000..e83ddfae --- /dev/null +++ b/containments/homescreen2/package/contents/ui/FeedbackWindow.qml @@ -0,0 +1,118 @@ +/* + * Copyright 2015 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.2 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +Window { + id: window + + property alias state: background.state + property alias icon: icon.source + width: Screen.width + height: Screen.height + color: "transparent" + onVisibleChanged: { + if (!visible) { + background.state = "closed"; + } + } + onActiveChanged: { + if (!active) { + background.state = "closed"; + } + } + + PlasmaCore.ColorScope { + id: background + anchors.fill: parent + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + width: window.width + height: window.height + state: "closed" + Rectangle { + anchors.fill: parent + color: background.backgroundColor + + ColumnLayout { + anchors.centerIn: parent + PlasmaCore.IconItem { + id: icon + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + Layout.preferredWidth: units.iconSizes.enormous + Layout.preferredHeight: Layout.preferredWidth + Layout.alignment: Qt.AlignCenter + } + PlasmaExtras.Heading { + text: window.title + Layout.alignment: Qt.AlignCenter + } + PlasmaComponents.BusyIndicator { + Layout.alignment: Qt.AlignCenter + } + } + } + + states: [ + State { + name: "closed" + PropertyChanges { + target: background + scale: 0 + } + PropertyChanges { + target: window + visible: false + } + }, + State { + name: "open" + PropertyChanges { + target: background + scale: 1 + } + PropertyChanges { + target: window + visible: true + } + } + ] + + transitions: [ + Transition { + from: "closed" + SequentialAnimation { + ScriptAction { + script: window.visible = true; + } + PropertyAnimation { + target: background + duration: units.longDuration + easing.type: Easing.InOutQuad + properties: "scale" + } + } + } + ] + } +} diff --git a/containments/homescreen2/package/contents/ui/KRunner.qml b/containments/homescreen2/package/contents/ui/KRunner.qml new file mode 100644 index 00000000..7a586adb --- /dev/null +++ b/containments/homescreen2/package/contents/ui/KRunner.qml @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2015 Vishesh Handa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + */ + +import QtQuick 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.1 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +import org.kde.milou 0.1 as Milou + +Rectangle { + id: krunner + anchors.fill: parent + height: childrenRect.height + color: listView.visible ? Qt.rgba(0, 0, 0, 0.8) : "transparent" + property alias showingResults: listView.visible + property int inputHeight: queryField.height + background.fixedMargins.top/2 + background.fixedMargins.bottom + + MouseArea { + enabled: listView.visible + anchors.fill: parent + preventStealing: true + onClicked: queryField.text = ""; + } + PlasmaCore.FrameSvgItem { + id: background + anchors { + left: parent.left + right: parent.right + top: parent.top + } + clip: true + imagePath: "widgets/background" + enabledBorders: PlasmaCore.FrameSvg.BottomBorder + height: childrenRect.height + fixedMargins.top/2 + fixedMargins.bottom + Behavior on height { + NumberAnimation { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + transform: Translate { + y: root.locked || editOverlay.visible ? -background.height : 0 + Behavior on y { + NumberAnimation { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + + ColumnLayout { + height: Qt.inputMethod.keyboardRectangle.height > 0 ? (Math.min(implicitHeight, Qt.inputMethod.keyboardRectangle.y - plasmoid.availableScreenRect.y)) : implicitHeight + anchors { + left: parent.left + right: parent.right + top: parent.top + topMargin: background.fixedMargins.top / 2 + leftMargin: background.fixedMargins.left / 2 + rightMargin: background.fixedMargins.right / 2 + } + PlasmaComponents.TextField { + id: queryField + clearButtonShown: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + + Keys.onEscapePressed: runnerWindow.visible = false + placeholderText: "Search..." + } + + PlasmaExtras.ScrollArea { + visible: listView.count > 0 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredHeight: listView.contentHeight + Layout.alignment: Qt.AlignTop + + Milou.ResultsListView { + id: listView + queryString: queryField.text + highlight: null + + onActivated: queryField.text = "" + onUpdateQueryString: { + queryField.text = text + queryField.cursorPosition = cursorPosition + } + } + } + + Keys.onReturnPressed: { + if (queryField.texr.length == 0) + runnerWindow.visible = false; + } + Keys.onEnterPressed: { + if (queryField.texr.length == 0) + runnerWindow.visible = false; + } + } + } +} + diff --git a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml index 3a2c8f7e..e14cc62d 100644 --- a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml @@ -37,8 +37,8 @@ ContainmentLayoutManager.ItemContainer { property var modelData: typeof model !== "undefined" ? model : null - Layout.minimumWidth: availableCellWidth + units.gridUnit - Layout.minimumHeight: availableCellHeight + units.gridUnit + Layout.minimumWidth: availableCellWidth + Layout.minimumHeight: availableCellHeight leftPadding: units.smallSpacing * 2 topPadding: units.smallSpacing * 2 @@ -72,6 +72,9 @@ ContainmentLayoutManager.ItemContainer { dragCenterY = dragCenter.y; launcherDragManager.dragItem(delegate, dragCenter.x, dragCenter.y); + delegate.height = availableCellHeight; + delegate.width = availableCellWidth; + var pos = plasmoid.fullRepresentationItem.mapFromItem(delegate, dragCenter.x, dragCenter.y); //SCROLL UP if (pos.y < plasmoid.fullRepresentationItem.height / 4) { @@ -87,12 +90,12 @@ ContainmentLayoutManager.ItemContainer { contentItem: MouseArea { onClicked: { - if (modelData.ApplicationStartupNotifyRole) { - clickFedbackAnimation.target = delegate; - clickFedbackAnimation.running = true; - feedbackWindow.title = modelData.ApplicationNameRole; - feedbackWindow.state = "open"; - } + clickFedbackAnimation.target = delegate; + clickFedbackAnimation.running = true; + feedbackWindow.title = modelData.ApplicationNameRole; + feedbackWindow.icon = modelData.ApplicationIconRole; + feedbackWindow.state = "open"; + plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole); } @@ -129,9 +132,9 @@ ContainmentLayoutManager.ItemContainer { maximumLineCount: 2 elide: Text.ElideRight - text: modelData ? modelData.ApplicationNameRole : "" + text: model.ApplicationNameRole + " "+model.ApplicationLocationRole font.pixelSize: theme.defaultFont.pixelSize - color: model.ApplicationLocationRole == ApplicationListModel.Desktop ? "white" : PlasmaCore.Theme.textColor + color: model.ApplicationLocationRole == ApplicationListModel.Desktop ? "white" : "black"//PlasmaCore.Theme.textColor layer.enabled: model.ApplicationLocationRole == ApplicationListModel.Desktop layer.effect: DropShadow { diff --git a/containments/homescreen2/package/contents/ui/main.qml b/containments/homescreen2/package/contents/ui/main.qml index 88d34962..b4cf66a1 100644 --- a/containments/homescreen2/package/contents/ui/main.qml +++ b/containments/homescreen2/package/contents/ui/main.qml @@ -91,6 +91,31 @@ Text { } } + FeedbackWindow { + id: feedbackWindow + } + SequentialAnimation { + id: clickFedbackAnimation + property Item target + NumberAnimation { + target: clickFedbackAnimation.target + properties: "scale" + to: 2 + duration: units.longDuration + easing.type: Easing.InOutQuad + } + PauseAnimation { + duration: units.shortDuration + } + NumberAnimation { + target: clickFedbackAnimation.target + properties: "scale" + to: 1 + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + Launcher.LauncherDragManager { id: launcherDragManager appletsLayout: appletsLayout