]> Some of my projects - aniplayer.git/commitdiff
Add option for cycle backwards to cycle backwards
authorAPTX <marek321@gmail.com>
Mon, 21 Feb 2022 13:41:29 +0000 (22:41 +0900)
committerAPTX <marek321@gmail.com>
Mon, 21 Feb 2022 13:41:29 +0000 (22:41 +0900)
uiplugins/ui_desktop_qml_default/qml/BasicButton.qml
uiplugins/ui_desktop_qml_default/qml/ComboButton.qml

index b5eefb15b19417dc0e4c631e209f5d2ae0dfccb4..a08cfd81e30a79796a5d405c52e1e329e29296ad 100644 (file)
@@ -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)
index b0a858b22dd4a2fdebb3ef16042acaf4e3292704..61f929b120ae2ccd873ee4901db9e927d6213e73 100644 (file)
@@ -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;