From: APTX Date: Mon, 21 Feb 2022 13:41:29 +0000 (+0900) Subject: Add option for cycle backwards to cycle backwards X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=35138c97e5c077d4e56cc77b16595be3638b4e38;p=aniplayer.git Add option for cycle backwards to cycle backwards --- 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;