From 8971f294e80addc859b823890b4a09fcfd3fb220 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 14 Apr 2020 18:15:30 +0200 Subject: [PATCH] Improve Plasmoid's connections menu further --- plasmoid/package/contents/ui/FullRepresentation.qml | 10 +++------- plasmoid/package/contents/ui/TinyButton.qml | 1 + plasmoid/package/contents/ui/TinyButtonStyle.qml | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plasmoid/package/contents/ui/FullRepresentation.qml b/plasmoid/package/contents/ui/FullRepresentation.qml index 22c07a7..791186b 100644 --- a/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/plasmoid/package/contents/ui/FullRepresentation.qml @@ -392,6 +392,7 @@ ColumnLayout { text: plasmoid.nativeInterface.currentConnectionConfigName icon: "network-connect" paddingEnabled: true + enforceMenuArrow: true onClicked: connectionConfigsMenu.toggle(x, y + height) Shortcut { sequence: "Ctrl+Shift+C" @@ -400,9 +401,8 @@ ColumnLayout { } PlasmaComponents.Menu { id: connectionConfigsMenu - property bool opened: false function toggle(x, y) { - if (!(connectionConfigsMenu.opened = !connectionConfigsMenu.opened)) { + if (connectionConfigsMenu.status === PlasmaComponents.DialogStatus.Open) { close() return } @@ -419,10 +419,6 @@ ColumnLayout { } open(x, y) } - function hide() { - close() - opened = false - } } Component { id: menuItem @@ -431,7 +427,7 @@ ColumnLayout { checkable: true onClicked: { plasmoid.nativeInterface.currentConnectionConfigIndex = index - connectionConfigsMenu.hide() + connectionConfigsMenu.close() } } } diff --git a/plasmoid/package/contents/ui/TinyButton.qml b/plasmoid/package/contents/ui/TinyButton.qml index 7a620ad..4bd34f3 100644 --- a/plasmoid/package/contents/ui/TinyButton.qml +++ b/plasmoid/package/contents/ui/TinyButton.qml @@ -3,6 +3,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents PlasmaComponents.ToolButton { property int iconSize: units.iconSizes.small property bool paddingEnabled: false + property bool enforceMenuArrow: false // define our own icon property and use that within the style to be able to set QIcon a directly // note: The iconSource alias defined in org/kde/plasma/components/ToolButton.qml seems to break diff --git a/plasmoid/package/contents/ui/TinyButtonStyle.qml b/plasmoid/package/contents/ui/TinyButtonStyle.qml index 6ab5740..50da69f 100644 --- a/plasmoid/package/contents/ui/TinyButtonStyle.qml +++ b/plasmoid/package/contents/ui/TinyButtonStyle.qml @@ -22,6 +22,7 @@ QtQuickControlStyle.ButtonStyle { property bool controlHovered: control.hovered && !(QtQuickControlsPrivate.Settings.hasTouchScreen && QtQuickControlsPrivate.Settings.isMobile) + property bool needsMenuArrow: control.menu || control.enforceMenuArrow label: RowLayout { id: buttonContent @@ -65,14 +66,14 @@ QtQuickControlStyle.ButtonStyle { PlasmaExtras.ConditionalLoader { id: arrow - when: control.menu !== null + when: needsMenuArrow visible: when Layout.preferredWidth: units.iconSizes.small Layout.preferredHeight: units.iconSizes.small source: Component { PlasmaCore.SvgItem { - visible: control.menu !== null + visible: needsMenuArrow svg: PlasmaCore.Svg { imagePath: "widgets/arrows" colorGroup: (style.controlHovered || !style.flat)