Commit d13233b0 authored by Nate Graham's avatar Nate Graham
Browse files

applet: port away from contextMenu and use contextualActionsModel

With changes to ExpandableListItem, we can now define both contextual
actions and a custom content view. This means we can put the actions
that are currently in the context menu in the contextual actions list
instead, so they will be displayed in the expanded view above the custom
content.

This yields several benefits:
- Makes these items more consistent with other expandable list items in
  other widgets
- Removes the use of a context menu, which goes against the purpose of
  this component (to be fully usable with only left-clicks or touches)
- Removes a PlasmaComponents2 import
parent aee1498f
Pipeline #159150 failed with stage
in 1 minute and 32 seconds
......@@ -13,7 +13,6 @@ import org.kde.kcoreaddons 1.0 as KCoreAddons
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents // for ContextMenu+MenuItem
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
......@@ -35,6 +34,7 @@ PlasmaExtras.ExpandableListItem {
property real rxBytes: 0
property real txBytes: 0
property Component showQRComponent: null
icon: model.ConnectionIcon
title: model.ItemUniqueName
......@@ -62,54 +62,33 @@ PlasmaExtras.ExpandableListItem {
}
}
customExpandedViewContent: detailsComponent
contextMenu: PlasmaComponents.Menu {
id: contextMenu
property Component showQRComponent: null
function prepare() {
showQRMenuItem.visible = false;
if (Uuid && Type === PlasmaNM.Enums.Wireless && passwordIsStatic) {
if (!showQRComponent) {
showQRComponent = Qt.createComponent("ShowQR.qml", this);
if (showQRComponent.status === Component.Error) {
console.warn("Cannot create QR code component:", showQRComponent.errorString());
contextualActionsModel: [
Action {
enabled: connectionItem.isDefault
text: i18n("Show network's QR code")
icon.name: "view-barcode-qr"
onTriggered: {
if (Uuid && Type === PlasmaNM.Enums.Wireless && passwordIsStatic) {
if (!connectionItem.showQRComponent) {
connectionItem.showQRComponent = Qt.createComponent("ShowQR.qml", this);
if (connectionItem.showQRComponent.status === Component.Error) {
console.warn("Cannot create QR code component:", connectionItemshowQRComponent.errorString());
}
}
}
showQRMenuItem.visible = (showQRComponent.status === Component.Ready);
}
}
PlasmaComponents.MenuItem {
text: ItemUniqueName
enabled: false
}
PlasmaComponents.MenuItem {
text: stateChangeButton.text
icon: (ConnectionState == PlasmaNM.Enums.Deactivated) ? "network-connect" : "network-disconnect"
onClicked: changeState()
}
PlasmaComponents.MenuItem {
id: showQRMenuItem
text: i18n("Show network's QR code")
icon: "view-barcode-qr"
// Updated in prepare()
visible: false
onClicked: {
const data = handler.wifiCode(ConnectionPath, Ssid, SecurityType)
var obj = contextMenu.showQRComponent.createObject(connectionItem, { content: data });
var obj = connectionItem.showQRComponent.createObject(connectionItem, { content: data });
obj.showMaximized()
}
}
PlasmaComponents.MenuItem {
},
Action {
text: i18n("Configure…")
icon: "settings-configure"
onClicked: KCMShell.open([mainWindow.kcm, "--args", "Uuid=" + Uuid])
icon.name: "configure"
onTriggered: KCMShell.open([mainWindow.kcm, "--args", "Uuid=" + Uuid])
}
}
]
customExpandedViewContent: detailsComponent
Component {
id: detailsComponent
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment