Skip to content

Commit 54c75de

Browse files
committed
Toggle menus using press state
1 parent 3d1fafc commit 54c75de

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
project(Earie VERSION 1.1.1 LANGUAGES CXX)
3+
project(Earie VERSION 1.2.0 LANGUAGES CXX)
44

55
set(TARGET_NAME Earie)
66

qml/Main.qml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Item {
9292
Layout.preferredWidth: 28
9393
Layout.preferredHeight: 28
9494
padding: 0
95+
property bool wasOpenOnPress: false
9596
font.family: theme.iconFont
9697
font.pixelSize: 14
9798
text: theme.glyphSettings
@@ -101,7 +102,15 @@ Item {
101102
color: settingsBtn.hovered ? theme.cellHover : "transparent"
102103
}
103104

104-
onClicked: settingsMenu.open()
105+
onPressed: wasOpenOnPress = settingsMenu.visible
106+
onClicked: {
107+
if (wasOpenOnPress) {
108+
wasOpenOnPress = false
109+
settingsMenu.close()
110+
return
111+
}
112+
settingsMenu.open()
113+
}
105114

106115
StyledMenu {
107116
id: settingsMenu
@@ -200,6 +209,7 @@ Item {
200209
Layout.preferredWidth: 28
201210
Layout.preferredHeight: 28
202211
padding: 0
212+
property bool wasOpenOnPress: false
203213
font.family: theme.iconFont
204214
font.pixelSize: 14
205215
text: theme.glyphEye
@@ -209,7 +219,15 @@ Item {
209219
color: hiddenBtn.hovered ? theme.cellHover : "transparent"
210220
}
211221

212-
onClicked: hiddenMenu.open()
222+
onPressed: wasOpenOnPress = hiddenMenu.visible
223+
onClicked: {
224+
if (wasOpenOnPress) {
225+
wasOpenOnPress = false
226+
hiddenMenu.close()
227+
return
228+
}
229+
hiddenMenu.open()
230+
}
213231

214232
StyledMenu {
215233
id: hiddenMenu

qml/components/StyledMenu.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Menu {
88

99
padding: 6
1010
implicitWidth: 190
11-
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
11+
closePolicy: Popup.CloseOnReleaseOutside | Popup.CloseOnEscape
1212

1313
onAboutToShow: if (appController) appController.popupOpened()
1414
onAboutToHide: if (appController) appController.popupClosed()

0 commit comments

Comments
 (0)