1/* 2 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5*/ 6 7import QtQuick 2.0 8import QtQuick.Layouts 1.0 9import org.kde.plasma.components 2.0 as PlasmaComponents 10import org.kde.plasma.extras 2.0 as PlasmaExtras 11import org.kde.plasma.core 2.0 as PlasmaCore 12 13 14PlasmaCore.Dialog { 15 id: contextMenu 16 visualParent: settingsButton 17 location: plasmoid.location 18 type: PlasmaCore.Dialog.PopupMenu 19 flags: Qt.Popup | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus 20 mainItem: ColumnLayout { 21 id: menuColumn 22 Layout.minimumWidth: menuColumn.implicitWidth 23 Layout.minimumHeight: menuColumn.implicitHeight 24 spacing: PlasmaCore.Units.smallSpacing 25 26 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft 27 LayoutMirroring.childrenInherit: true 28 29 PlasmaComponents.ToolButton { 30 Layout.fillWidth: true 31 // we want destructive actions to be far from the initial cursor 32 // position, so show this on the top unless it's on a top panel 33 visible: location !== PlasmaCore.Types.TopEdge 34 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Remove Panel") 35 iconSource: "delete" 36 onClicked: plasmoid.action("remove").trigger(); 37 } 38 39 PlasmaExtras.Heading { 40 level: 3 41 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Panel Alignment") 42 } 43 PlasmaComponents.ButtonColumn { 44 spacing: 0 45 Layout.fillWidth: true 46 PlasmaComponents.ToolButton { 47 anchors { 48 left: parent.left 49 right: parent.right 50 } 51 text: panel.formFactor === PlasmaCore.Types.Vertical ? i18nd("plasma_shell_org.kde.plasma.desktop", "Top") : i18nd("plasma_shell_org.kde.plasma.desktop", "Left") 52 checkable: true 53 checked: panel.alignment === Qt.AlignLeft 54 onClicked: panel.alignment = Qt.AlignLeft 55 flat: false 56 } 57 PlasmaComponents.ToolButton { 58 anchors { 59 left: parent.left 60 right: parent.right 61 } 62 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Center") 63 checkable: true 64 checked: panel.alignment === Qt.AlignCenter 65 onClicked: panel.alignment = Qt.AlignCenter 66 flat: false 67 } 68 PlasmaComponents.ToolButton { 69 anchors { 70 left: parent.left 71 right: parent.right 72 } 73 text: panel.formFactor === PlasmaCore.Types.Vertical ? i18nd("plasma_shell_org.kde.plasma.desktop", "Bottom") : i18nd("plasma_shell_org.kde.plasma.desktop", "Right") 74 checkable: true 75 checked: panel.alignment === Qt.AlignRight 76 onClicked: panel.alignment = Qt.AlignRight 77 flat: false 78 } 79 } 80 81 PlasmaExtras.Heading { 82 level: 3 83 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Visibility") 84 } 85 PlasmaComponents.ButtonColumn { 86 spacing: 0 87 Layout.fillWidth: true 88 Layout.minimumWidth: implicitWidth 89 PlasmaComponents.ToolButton { 90 width: Math.max(implicitWidth, parent.width) 91 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Always Visible") 92 checkable: true 93 checked: configDialog.visibilityMode === 0 94 onClicked: configDialog.visibilityMode = 0 95 flat: false 96 } 97 PlasmaComponents.ToolButton { 98 width: Math.max(implicitWidth, parent.width) 99 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Auto Hide") 100 checkable: true 101 checked: configDialog.visibilityMode === 1 102 onClicked: configDialog.visibilityMode = 1 103 flat: false 104 } 105 PlasmaComponents.ToolButton { 106 width: Math.max(implicitWidth, parent.width) 107 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Windows Can Cover") 108 checkable: true 109 checked: configDialog.visibilityMode === 2 110 onClicked: configDialog.visibilityMode = 2 111 flat: false 112 } 113 PlasmaComponents.ToolButton { 114 width: Math.max(implicitWidth, parent.width) 115 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Windows Go Below") 116 checkable: true 117 checked: configDialog.visibilityMode === 3 118 onClicked: configDialog.visibilityMode = 3 119 flat: false 120 } 121 } 122 PlasmaExtras.Heading { 123 level: 3 124 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Opacity") 125 visible: panel.adaptiveOpacityEnabled 126 } 127 PlasmaComponents.ButtonColumn { 128 spacing: 0 129 visible: panel.adaptiveOpacityEnabled 130 Layout.fillWidth: true 131 Layout.minimumWidth: implicitWidth 132 PlasmaComponents.ToolButton { 133 width: Math.max(implicitWidth, parent.width) 134 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Adaptive") 135 checkable: true 136 checked: configDialog.opacityMode === 0 137 onClicked: configDialog.opacityMode = 0 138 flat: false 139 } 140 PlasmaComponents.ToolButton { 141 width: Math.max(implicitWidth, parent.width) 142 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Opaque") 143 checkable: true 144 checked: configDialog.opacityMode === 1 145 onClicked: configDialog.opacityMode = 1 146 flat: false 147 } 148 PlasmaComponents.ToolButton { 149 width: Math.max(implicitWidth, parent.width) 150 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Translucent") 151 checkable: true 152 checked: configDialog.opacityMode === 2 153 onClicked: configDialog.opacityMode = 2 154 flat: false 155 } 156 } 157 PlasmaComponents.ToolButton { 158 Layout.fillWidth: true 159 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Maximize Panel") 160 iconSource: panel.formFactor === PlasmaCore.Types.Vertical ? "zoom-fit-height" : "zoom-fit-width" 161 onClicked: panel.maximize(); 162 } 163 PlasmaComponents.ToolButton { 164 Layout.fillWidth: true 165 // we want destructive actions to be far from the initial cursor 166 // position, so show this on the bottom for top panels 167 visible: location === PlasmaCore.Types.TopEdge 168 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Remove Panel") 169 iconSource: "delete" 170 onClicked: plasmoid.action("remove").trigger(); 171 } 172 } 173 174 function hide() { 175 visible = false; 176 } 177 178 Component.onCompleted: { 179 dialogRoot.closeContextMenu.connect(hide); 180 } 181} 182