[plasma/khotkeys] /: gestures: Replace mouse button spinbox with a combobox

Fushan Wen null at kde.org
Mon Dec 20 15:57:04 GMT 2021


Git commit 3c4fbfa5a7caeb69b095bf40d747006480a24427 by Fushan Wen.
Committed on 20/12/2021 at 15:55.
Pushed by fusionfuture into branch 'master'.

gestures: Replace mouse button spinbox with a combobox

The mouse button spinbox only shows a number, which is not intuitive
enough for newcomers. We should use a combobox to indicate the mouse
button.

BUG: 445001
GUI: 445001

M  +2    -4    doc/kcm/index.docbook
M  +4    -4    kcm_hotkeys/global_settings_widget.cpp
M  +41   -10   kcm_hotkeys/global_settings_widget.ui

https://invent.kde.org/plasma/khotkeys/commit/3c4fbfa5a7caeb69b095bf40d747006480a24427

diff --git a/doc/kcm/index.docbook b/doc/kcm/index.docbook
index d648cc5..cf75719 100644
--- a/doc/kcm/index.docbook
+++ b/doc/kcm/index.docbook
@@ -726,12 +726,10 @@ gesture will be monitored and recognized by the system, in milliseconds.
 <varlistentry id="settings-gestures-mouse-button">
 <term><guilabel>Mouse button:</guilabel></term>
 <listitem><para>This specifies the mouse button to be used for mouse gestures.
-Usually, <userinput>1</userinput> is the &LMB;, <userinput>2</userinput> is the
-&RMB;, and <userinput>3</userinput> is the middle or wheel button.  If your
-mouse has more buttons, you can also use those instead.</para>
+If your mouse has more buttons, you can also use those instead.</para>
 
 <note>
-<para>Button 1 is unavailable, so mouse gestures do not interfere with the
+<para>Left button is unavailable, so mouse gestures do not interfere with the
 normal operation of your system.</para>
 </note>
 </listitem>
diff --git a/kcm_hotkeys/global_settings_widget.cpp b/kcm_hotkeys/global_settings_widget.cpp
index bf1567b..a926311 100644
--- a/kcm_hotkeys/global_settings_widget.cpp
+++ b/kcm_hotkeys/global_settings_widget.cpp
@@ -36,7 +36,7 @@ GlobalSettingsWidget::GlobalSettingsWidget(QWidget *parent)
     connect(ui.gestures_timeout, SIGNAL(valueChanged(int)), _changedSignals, SLOT(map()));
     _changedSignals->setMapping(ui.gestures_timeout, "gestures_timeout");
 
-    connect(ui.gestures_button, SIGNAL(valueChanged(int)), _changedSignals, SLOT(map()));
+    connect(ui.gestures_button, SIGNAL(currentIndexChanged(int)), _changedSignals, SLOT(map()));
     _changedSignals->setMapping(ui.gestures_button, "gestures_button");
 }
 
@@ -56,7 +56,7 @@ void GlobalSettingsWidget::doCopyFromObject()
         KHotKeys::Settings *settings = _model->settings();
         Q_ASSERT(settings);
         ui.gestures_group->setChecked(!settings->areGesturesDisabled());
-        ui.gestures_button->setValue(settings->gestureMouseButton());
+        ui.gestures_button->setCurrentIndex(settings->gestureMouseButton() - 2);
         ui.gestures_timeout->setValue(settings->gestureTimeOut());
     }
 }
@@ -73,7 +73,7 @@ void GlobalSettingsWidget::doCopyToObject()
         KHotKeys::Settings *settings = _model->settings();
         Q_ASSERT(settings);
         ui.gestures_group->isChecked() ? settings->enableGestures() : settings->disableGestures();
-        settings->setGestureMouseButton(ui.gestures_button->value());
+        settings->setGestureMouseButton(ui.gestures_button->currentIndex() + 2);
         settings->setGestureTimeOut(ui.gestures_timeout->value());
     }
 }
@@ -93,7 +93,7 @@ bool GlobalSettingsWidget::isChanged() const
         KHotKeys::Settings *settings = _model->settings();
         Q_ASSERT(settings);
         if ((!settings->areGesturesDisabled()) != ui.gestures_group->isChecked() //
-            || settings->gestureMouseButton() != ui.gestures_button->value() //
+            || settings->gestureMouseButton() - 2 != ui.gestures_button->currentIndex() //
             || settings->gestureTimeOut() != ui.gestures_timeout->value()) {
             return true;
         }
diff --git a/kcm_hotkeys/global_settings_widget.ui b/kcm_hotkeys/global_settings_widget.ui
index c849881..20cad63 100644
--- a/kcm_hotkeys/global_settings_widget.ui
+++ b/kcm_hotkeys/global_settings_widget.ui
@@ -117,16 +117,47 @@
        </spacer>
       </item>
       <item row="1" column="1">
-       <widget class="QSpinBox" name="gestures_button">
-        <property name="minimum">
-         <number>2</number>
-        </property>
-        <property name="maximum">
-         <number>10</number>
-        </property>
-        <property name="value">
-         <number>2</number>
-        </property>
+       <widget class="QComboBox" name="gestures_button">
+        <item>
+         <property name="text">
+          <string>Middle button</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Right button</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 4</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 5</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 6</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 7</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 8</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>Button 9</string>
+         </property>
+        </item>
        </widget>
       </item>
      </layout>


More information about the kde-doc-english mailing list