From 35138c97e5c077d4e56cc77b16595be3638b4e38 Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 21 Feb 2022 22:41:29 +0900 Subject: [PATCH] Add option for cycle backwards to cycle backwards --- .../ui_desktop_qml_default/qml/BasicButton.qml | 5 +++-- .../ui_desktop_qml_default/qml/ComboButton.qml | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/uiplugins/ui_desktop_qml_default/qml/BasicButton.qml b/uiplugins/ui_desktop_qml_default/qml/BasicButton.qml index b5eefb1..a08cfd8 100644 --- a/uiplugins/ui_desktop_qml_default/qml/BasicButton.qml +++ b/uiplugins/ui_desktop_qml_default/qml/BasicButton.qml @@ -5,8 +5,9 @@ Rectangle { property string text: "" property bool checkable: false property bool checked: false + property alias acceptedButtons: ma.acceptedButtons - signal clicked + signal clicked(var mouse) signal checkedChangedByUser(bool checked) width: label.width + 6 @@ -36,7 +37,7 @@ Rectangle { onPressed: buttonRoot.state = "pressed" onReleased: { if (buttonRoot.state === "pressed") { - buttonRoot.clicked(); + buttonRoot.clicked(mouse); if (checkable) { checked = !checked buttonRoot.checkedChangedByUser(checked) diff --git a/uiplugins/ui_desktop_qml_default/qml/ComboButton.qml b/uiplugins/ui_desktop_qml_default/qml/ComboButton.qml index b0a858b..61f929b 100644 --- a/uiplugins/ui_desktop_qml_default/qml/ComboButton.qml +++ b/uiplugins/ui_desktop_qml_default/qml/ComboButton.qml @@ -7,6 +7,8 @@ BasicButton { signal activated(int index) + acceptedButtons: Qt.LeftButton | Qt.RightButton + ListModel { id: ph } @@ -25,9 +27,18 @@ BasicButton { onClicked: { if (!model) return; var nextIndex = currentIndex; - ++nextIndex; - if (nextIndex >= model.count) - nextIndex = 0; + if (mouse.button & Qt.LeftButton) { + ++nextIndex; + if (nextIndex >= model.count) + nextIndex = 0; + } else if (mouse.button & Qt.RightButton) { + --nextIndex; + if (nextIndex < 0) + nextIndex = model.count - 1; + if (!model.count) + nextIndex = 0; + } + if (nextIndex === currentIndex) return; -- 2.52.0