Improve Plasmoid's connections menu further

This commit is contained in:
Martchus 2020-04-14 18:15:30 +02:00
parent 50a3299254
commit 8971f294e8
3 changed files with 7 additions and 9 deletions

View File

@ -392,6 +392,7 @@ ColumnLayout {
text: plasmoid.nativeInterface.currentConnectionConfigName text: plasmoid.nativeInterface.currentConnectionConfigName
icon: "network-connect" icon: "network-connect"
paddingEnabled: true paddingEnabled: true
enforceMenuArrow: true
onClicked: connectionConfigsMenu.toggle(x, y + height) onClicked: connectionConfigsMenu.toggle(x, y + height)
Shortcut { Shortcut {
sequence: "Ctrl+Shift+C" sequence: "Ctrl+Shift+C"
@ -400,9 +401,8 @@ ColumnLayout {
} }
PlasmaComponents.Menu { PlasmaComponents.Menu {
id: connectionConfigsMenu id: connectionConfigsMenu
property bool opened: false
function toggle(x, y) { function toggle(x, y) {
if (!(connectionConfigsMenu.opened = !connectionConfigsMenu.opened)) { if (connectionConfigsMenu.status === PlasmaComponents.DialogStatus.Open) {
close() close()
return return
} }
@ -419,10 +419,6 @@ ColumnLayout {
} }
open(x, y) open(x, y)
} }
function hide() {
close()
opened = false
}
} }
Component { Component {
id: menuItem id: menuItem
@ -431,7 +427,7 @@ ColumnLayout {
checkable: true checkable: true
onClicked: { onClicked: {
plasmoid.nativeInterface.currentConnectionConfigIndex = index plasmoid.nativeInterface.currentConnectionConfigIndex = index
connectionConfigsMenu.hide() connectionConfigsMenu.close()
} }
} }
} }

View File

@ -3,6 +3,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
PlasmaComponents.ToolButton { PlasmaComponents.ToolButton {
property int iconSize: units.iconSizes.small property int iconSize: units.iconSizes.small
property bool paddingEnabled: false 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 // 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 // note: The iconSource alias defined in org/kde/plasma/components/ToolButton.qml seems to break

View File

@ -22,6 +22,7 @@ QtQuickControlStyle.ButtonStyle {
property bool controlHovered: control.hovered property bool controlHovered: control.hovered
&& !(QtQuickControlsPrivate.Settings.hasTouchScreen && !(QtQuickControlsPrivate.Settings.hasTouchScreen
&& QtQuickControlsPrivate.Settings.isMobile) && QtQuickControlsPrivate.Settings.isMobile)
property bool needsMenuArrow: control.menu || control.enforceMenuArrow
label: RowLayout { label: RowLayout {
id: buttonContent id: buttonContent
@ -65,14 +66,14 @@ QtQuickControlStyle.ButtonStyle {
PlasmaExtras.ConditionalLoader { PlasmaExtras.ConditionalLoader {
id: arrow id: arrow
when: control.menu !== null when: needsMenuArrow
visible: when visible: when
Layout.preferredWidth: units.iconSizes.small Layout.preferredWidth: units.iconSizes.small
Layout.preferredHeight: units.iconSizes.small Layout.preferredHeight: units.iconSizes.small
source: Component { source: Component {
PlasmaCore.SvgItem { PlasmaCore.SvgItem {
visible: control.menu !== null visible: needsMenuArrow
svg: PlasmaCore.Svg { svg: PlasmaCore.Svg {
imagePath: "widgets/arrows" imagePath: "widgets/arrows"
colorGroup: (style.controlHovered || !style.flat) colorGroup: (style.controlHovered || !style.flat)