Commit e7db45ae authored by Volker Krause's avatar Volker Krause Committed by Claudio Cambra
Browse files

Port menus away from PC2

On the contact page this also fixes the menu content being duplicated with
each opening, and improves the menu content strings.
parent 3580da59
Pipeline #214166 failed with stage
in 3 minutes and 22 seconds
......@@ -8,7 +8,6 @@ import org.kde.kirigami 2.19 as Kirigami
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kalendar.contact 1.0
PlasmaComponents3.ScrollView {
......@@ -40,7 +39,7 @@ PlasmaComponents3.ScrollView {
property var header: PlasmaExtras.PlasmoidHeading {
Component {
id: menuItemComponent
PlasmaComponents.MenuItem { }
PlasmaComponents3.MenuItem { }
}
RowLayout {
width: parent.width
......@@ -64,27 +63,23 @@ PlasmaComponents3.ScrollView {
if (model.length === 1) {
page.callNumber(model[0].normalizedNumber);
} else {
model.forEach((item) => {
let menuItem = menuItemComponent.createObject(menuCall, {
text: item.number,
if (menuCall.count == 0) {
model.forEach((item) => {
let menuItem = menuItemComponent.createObject(menuCall, {
text: i18n("%1 (%2)", item.typeLabel, item.number)
});
menuItem.clicked.connect(() => {
callNumber(item.number);
});
menuCall.addItem(menuItem);
});
menuItem.clicked.connect(() => {
callNumber(item.number);
});
menuCall.addMenuItem(menuItem);
});
menuCall.openRelative();
}
menuCall.open();
}
}
PlasmaComponents.ContextMenu {
PlasmaComponents3.Menu {
id: menuCall
visualParent: configureButtonCall
placement: PlasmaCore.Types.BottomPosedLeftAlignedPopup
onStatusChanged: {
if (status === PlasmaComponents.DialogStatus.Closed) {
configureButtonCall.checked = false;
}
}
y: configureButtonCall.height
}
}
......@@ -100,27 +95,23 @@ PlasmaComponents3.ScrollView {
if (addressee.phoneNumbers.length === 1) {
sendSms(model[0].normalizedNumber);
} else {
model.forEach((item) => {
let menuItem = menuItemComponent.createObject(menuSms, {
text: item.number,
if (menuSms.count == 0) {
model.forEach((item) => {
let menuItem = menuItemComponent.createObject(menuSms, {
text: i18n("%1 (%2)", item.typeLabel, item.number)
});
menuItem.clicked.connect(() => {
sendSms(item.number);
});
menuSms.addItem(menuItem);
});
menuItem.clicked.connect(() => {
sendSms(item.number);
});
menuSms.addMenuItem(menuItem);
});
menuSms.openRelative();
}
menuSms.open();
}
}
PlasmaComponents.ContextMenu {
PlasmaComponents3.Menu {
id: menuSms
visualParent: configureButtonSms
placement: PlasmaCore.Types.BottomPosedLeftAlignedPopup
onStatusChanged: {
if (status === PlasmaComponents.DialogStatus.Closed) {
configureButtonSms.checked = false;
}
}
y: configureButtonSms.height
}
}
......
......@@ -7,7 +7,6 @@ import QtQml 2.15
import QtQuick.Layouts 1.15
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.components 2.0 as PlasmaComponents // For ContextMenu
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.extras 2.0 as PlasmaExtras
......@@ -39,18 +38,14 @@ ColumnLayout {
Component {
id: menuItemComponent
PlasmaComponents.MenuItem { }
PlasmaComponents3.MenuItem { }
}
PlasmaComponents.ContextMenu {
PlasmaComponents3.Menu {
id: menu
visualParent: configureButton
placement: PlasmaCore.Types.BottomPosedLeftAlignedPopup
onStatusChanged: {
if (status == PlasmaComponents.DialogStatus.Closed) {
configureButton.checked = false;
}
}
x: configureButton.x
y: configureButton.y + configureButton.height
onClosed: configureButton.checked = false
Component.onCompleted: {
[
......@@ -69,7 +64,7 @@ ColumnLayout {
barcodeItem.barcodeType = item.type;
Plasmoid.configuration.barcodeType = item.type;
});
menu.addMenuItem(menuItem);
menu.addItem(menuItem);
});
}
}
......@@ -77,7 +72,8 @@ ColumnLayout {
id: configureButton
checkable: true
icon.name: "configure"
onClicked: menu.openRelative()
onCheckedChanged: console.log("checked", checked)
onClicked: menu.open()
PlasmaComponents3.ToolTip {
text: i18n("Change the QR code type")
......
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