Verified Commit 16bf436f authored by ivan tkachenko's avatar ivan tkachenko
Browse files

[applets/systemtray] Use `onPressed: wasExpanded = ...` idiom

This is a common snippet of code in applets. It prevents applet from
re-expanding again when user clicks on the compact representation when
the applet is already expanded and located on a desktop containment.
parent c6ef22f9
Pipeline #184467 passed with stage
in 6 minutes and 15 seconds
......@@ -38,8 +38,12 @@ PlasmaCore.ToolTipArea {
MouseArea {
id: arrowMouseArea
anchors.fill: parent
property bool wasExpanded
onPressed: wasExpanded = systemTrayState.expanded
onClicked: {
systemTrayState.expanded = !systemTrayState.expanded;
systemTrayState.expanded = !wasExpanded;
expandedRepresentation.hiddenLayout.currentIndex = -1;
}
......
......@@ -218,6 +218,12 @@ MouseArea {
}
}
Timer {
id: expandedSync
interval: 100
onTriggered: systemTrayState.expanded = dialog.visible;
}
//Main popup
PlasmaCore.Dialog {
id: dialog
......@@ -231,15 +237,14 @@ MouseArea {
appletInterface: Plasmoid.self
onVisibleChanged: {
systemTrayState.expanded = visible;
if (!systemTrayState.expanded) {
return;
}
if (expandedRepresentation.plasmoidContainer.visible) {
expandedRepresentation.plasmoidContainer.forceActiveFocus();
} else if (expandedRepresentation.hiddenLayout.visible) {
expandedRepresentation.hiddenLayout.forceActiveFocus();
if (!visible) {
expandedSync.restart();
} else {
if (expandedRepresentation.plasmoidContainer.visible) {
expandedRepresentation.plasmoidContainer.forceActiveFocus();
} else if (expandedRepresentation.hiddenLayout.visible) {
expandedRepresentation.hiddenLayout.forceActiveFocus();
}
}
}
mainItem: ExpandedRepresentation {
......
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