From 656903bd86011df03f449376b2d6906f652c917a Mon Sep 17 00:00:00 2001 From: wackyideas <17151-wackyideas@users.noreply.gitgud.io> Date: Thu, 1 Sep 2022 18:37:59 +0200 Subject: [PATCH] Hopefully fixed SevenTasks now. --- .../contents/ui/AdvMenu.qml | 94 +++++++++++++++++++ .../contents/ui/ContextMenuBackend.qml | 20 ++++ .../contents/ui/MenuBackend.qml | 94 +++++++++++++++++++ .../contents/ui/main.qml | 3 + .../seventasks_src/build/install_manifest.txt | 2 + .../src/package/contents/ui/main.qml | 3 + 6 files changed, 216 insertions(+) create mode 100644 Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/AdvMenu.qml create mode 100644 Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml create mode 100644 Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml diff --git a/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/AdvMenu.qml b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/AdvMenu.qml new file mode 100644 index 0000000..92e31bc --- /dev/null +++ b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/AdvMenu.qml @@ -0,0 +1,94 @@ +/* + SPDX-FileCopyrightText: 2016 Marco Martin + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +import QtQuick 2.7 +import QtQuick.Controls 2.15 +import QtQuick.Templates 2.15 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kirigami 2.5 as Kirigami + +T.Menu { + id: control + + palette: Kirigami.Theme.palette + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding + + delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() } + + margins: 0 + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + contentItem: ListView { + implicitHeight: contentHeight + property bool hasCheckables: false + property bool hasIcons: false + model: control.contentModel + + implicitWidth: { + var maxWidth = 0; + for (var i = 0; i < contentItem.children.length; ++i) { + maxWidth = Math.max(maxWidth, contentItem.children[i].implicitWidth); + } + return maxWidth; + } + + interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false + clip: true + currentIndex: control.currentIndex || 0 + keyNavigationEnabled: true + keyNavigationWraps: true + + T.ScrollBar.vertical: ScrollBar {} + } + + Connections { + target: control.contentItem.contentItem + + function onChildrenChanged() { + for (var i in control.contentItem.contentItem.children) { + var child = control.contentItem.contentItem.children[i]; + if (child.checkable) { + control.contentItem.hasCheckables = true; + } + if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.length > 0)) { + control.contentItem.hasIcons = true; + } + } + } + } + + enter: Transition { + NumberAnimation { + property: "opacity" + from: 0 + to: 1 + easing.type: Easing.InOutQuad + duration: PlasmaCore.Units.shortDuration + } + } + + exit: Transition { + NumberAnimation { + property: "opacity" + from: 1 + to: 0 + easing.type: Easing.InOutQuad + duration: PlasmaCore.Units.shortDuration + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/background" + implicitWidth: PlasmaCore.Units.gridUnit * 8 + implicitHeight: PlasmaCore.Units.gridUnit * 2 + } +} diff --git a/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml new file mode 100644 index 0000000..acd712a --- /dev/null +++ b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml @@ -0,0 +1,20 @@ +/* + SPDX-FileCopyrightText: 2011 Marco Martin + SPDX-FileCopyrightText: 2011 Nokia Corporation and /or its subsidiary(-ies) + + This file is part of the Qt Components project. + + SPDX-License-Identifier: BSD-3-Clause +*/ + +import QtQuick 2.1 +import org.kde.plasma.components 2.0 as PlasmaComponents + +/** + * Provides a component with list of options that the user can choose from. + * + * All elements of this component are defined in Menu, its base component. + */ +MenuBackend { + id: root +} diff --git a/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml new file mode 100644 index 0000000..92e31bc --- /dev/null +++ b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml @@ -0,0 +1,94 @@ +/* + SPDX-FileCopyrightText: 2016 Marco Martin + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +import QtQuick 2.7 +import QtQuick.Controls 2.15 +import QtQuick.Templates 2.15 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kirigami 2.5 as Kirigami + +T.Menu { + id: control + + palette: Kirigami.Theme.palette + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding + + delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() } + + margins: 0 + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + contentItem: ListView { + implicitHeight: contentHeight + property bool hasCheckables: false + property bool hasIcons: false + model: control.contentModel + + implicitWidth: { + var maxWidth = 0; + for (var i = 0; i < contentItem.children.length; ++i) { + maxWidth = Math.max(maxWidth, contentItem.children[i].implicitWidth); + } + return maxWidth; + } + + interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false + clip: true + currentIndex: control.currentIndex || 0 + keyNavigationEnabled: true + keyNavigationWraps: true + + T.ScrollBar.vertical: ScrollBar {} + } + + Connections { + target: control.contentItem.contentItem + + function onChildrenChanged() { + for (var i in control.contentItem.contentItem.children) { + var child = control.contentItem.contentItem.children[i]; + if (child.checkable) { + control.contentItem.hasCheckables = true; + } + if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.length > 0)) { + control.contentItem.hasIcons = true; + } + } + } + } + + enter: Transition { + NumberAnimation { + property: "opacity" + from: 0 + to: 1 + easing.type: Easing.InOutQuad + duration: PlasmaCore.Units.shortDuration + } + } + + exit: Transition { + NumberAnimation { + property: "opacity" + from: 1 + to: 0 + easing.type: Easing.InOutQuad + duration: PlasmaCore.Units.shortDuration + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/background" + implicitWidth: PlasmaCore.Units.gridUnit * 8 + implicitHeight: PlasmaCore.Units.gridUnit * 2 + } +} diff --git a/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/main.qml b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/main.qml index 7b3a622..20cf020 100644 --- a/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/main.qml +++ b/Plasma/Plasma Widgets/User/Task Icons/org.kde.plasma.seventasks/contents/ui/main.qml @@ -104,6 +104,9 @@ MouseArea { } } + ContextMenu { + id: testMenu + } TaskManager.TasksModel { id: tasksModel diff --git a/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/build/install_manifest.txt b/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/build/install_manifest.txt index 04380cb..378479c 100644 --- a/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/build/install_manifest.txt +++ b/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/build/install_manifest.txt @@ -23,6 +23,8 @@ /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipInstance.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipWindowMouseArea.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/main.qml +/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml +/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.desktop /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.json /usr/share/metainfo/org.kde.plasma.seventasks.appdata.xml diff --git a/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/src/package/contents/ui/main.qml b/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/src/package/contents/ui/main.qml index 7b3a622..20cf020 100644 --- a/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/src/package/contents/ui/main.qml +++ b/Plasma/Plasma Widgets/User/Task Icons/seventasks_src/src/package/contents/ui/main.qml @@ -104,6 +104,9 @@ MouseArea { } } + ContextMenu { + id: testMenu + } TaskManager.TasksModel { id: tasksModel