From 3897a29975c8dd5d69b7d9c24352ebbb23ecf94b Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Fri, 3 Jul 2026 00:02:41 +0300
Subject: kicker: make it optional to set mouse wheel scrolling speed
 explicitly

In 5b415043e a setting was introduce to set mouse wheel scrolling speed
in a per-pixel value. This makes the setting optional and defaults to
calculation of the distance based on
`TQApplication::wheelScrollLines()`.

Also it increases default and maximum value for the manually set mouse
wheel scrolling speed to 72 and 200 respectively.

Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/issues/758
See-also: https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/pulls/759
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 kcontrol/taskbar/kcmtaskbar.cpp  |  7 +++--
 kcontrol/taskbar/kcmtaskbarui.ui | 62 +++++++++++++++++-----------------------
 kicker/taskbar/taskbar.cpp       | 22 ++++++++++----
 kicker/taskbar/taskbar.h         |  1 +
 kicker/taskbar/taskbar.kcfg      |  9 ++++--
 5 files changed, 55 insertions(+), 46 deletions(-)

diff --git a/kcontrol/taskbar/kcmtaskbar.cpp b/kcontrol/taskbar/kcmtaskbar.cpp
index 0c1af6069..c36ab811b 100644
--- a/kcontrol/taskbar/kcmtaskbar.cpp
+++ b/kcontrol/taskbar/kcmtaskbar.cpp
@@ -385,9 +385,10 @@ void TaskbarConfig::slotUpdateCustomColors()
 
 void TaskbarConfig::slotScrollTaskbarActionChanged(int index)
 {
-    m_widget->wheelScrollSpeedLabel->setEnabled(index != 0);
-    m_widget->wheelScrollStepSlider->setEnabled(index != 0);
-    m_widget->kcfg_WheelScrollStep->setEnabled(index != 0);
+    m_widget->kcfg_UseCustomWheelScrollStep->setEnabled(index != 0);
+    bool customChecked = m_widget->kcfg_UseCustomWheelScrollStep->isChecked();
+    m_widget->wheelScrollStepSlider->setEnabled(index != 0 && customChecked);
+    m_widget->kcfg_WheelScrollStep->setEnabled(index != 0 && customChecked);
 }
 
 void TaskbarConfig::slotUpdateComboBox()
diff --git a/kcontrol/taskbar/kcmtaskbarui.ui b/kcontrol/taskbar/kcmtaskbarui.ui
index d01a27503..4c010978e 100644
--- a/kcontrol/taskbar/kcmtaskbarui.ui
+++ b/kcontrol/taskbar/kcmtaskbarui.ui
@@ -1055,14 +1055,6 @@
                         <property name="name">
                             <cstring>wheelActionsGroup</cstring>
                         </property>
-                        <property name="sizePolicy">
-                            <sizepolicy>
-                                <hsizetype>5</hsizetype>
-                                <vsizetype>1</vsizetype>
-                                <horstretch>0</horstretch>
-                                <verstretch>0</verstretch>
-                            </sizepolicy>
-                        </property>
                         <property name="title">
                             <string>Mouse Wheel</string>
                         </property>
@@ -1081,7 +1073,7 @@
                                     <cstring>kcfg_CycleWindowsWAction</cstring>
                                 </property>
                             </widget>
-                            <widget class="TQComboBox" row="0" column="1" rowspan="1" colspan="2">
+                            <widget class="TQComboBox" row="0" column="1">
                                 <property name="name">
                                     <cstring>kcfg_CycleWindowsWAction</cstring>
                                 </property>
@@ -1108,7 +1100,7 @@
                                     <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
                             </widget>
-                            <widget class="TQComboBox" row="1" column="1" rowspan="1" colspan="2">
+                            <widget class="TQComboBox" row="1" column="1">
                                 <property name="name">
                                     <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
@@ -1124,26 +1116,12 @@
                                     <string>If this option is enabled (with or without a keyboard modifier) and if the taskbar is holding more buttons than what could be displayed (the two arrows for scrolling are visible), you can scroll the taskbar by using the mouse wheel.</string>
                                 </property>
                             </widget>
-                            <spacer row="2" column="0" rowspan="1" colspan="2">
+                            <widget class="TQLayoutWidget" row="2" column="1">
                                 <property name="name">
-                                    <cstring>scrollStepSpacer</cstring>
-                                </property>
-                                <property name="orientation">
-                                    <enum>Horizontal</enum>
+                                    <cstring>layout4</cstring>
                                 </property>
-                                <property name="sizeType">
-                                    <enum>Expanding</enum>
-                                </property>
-                                <property name="sizeHint">
-                                    <size>
-                                        <width>30</width>
-                                        <height>40</height>
-                                    </size>
-                                </property>
-                            </spacer>
-                            <widget class="TQLayoutWidget" row="2" column="2">
-                                <property name="name">
-                                    <cstring>scrollStepLayout</cstring>
+                                <property name="sizeType" stdset="0">
+                                    <string>Expanding</string>
                                 </property>
                                 <hbox>
                                     <property name="name">
@@ -1166,12 +1144,12 @@
                                             </size>
                                         </property>
                                     </spacer>
-                                    <widget class="TQLabel">
+                                    <widget class="TQCheckBox">
                                         <property name="name">
-                                            <cstring>wheelScrollSpeedLabel</cstring>
+                                            <cstring>kcfg_UseCustomWheelScrollStep</cstring>
                                         </property>
                                         <property name="text">
-                                            <string>Scrolling speed</string>
+                                            <string>Custom scrolling speed:</string>
                                         </property>
                                     </widget>
                                     <widget class="TQSlider">
@@ -1182,13 +1160,13 @@
                                             <number>1</number>
                                         </property>
                                         <property name="maxValue">
-                                            <number>128</number>
+                                            <number>200</number>
                                         </property>
                                         <property name="pageStep">
                                             <number>8</number>
                                         </property>
                                         <property name="value">
-                                            <number>16</number>
+                                            <number>72</number>
                                         </property>
                                         <property name="orientation">
                                             <enum>Horizontal</enum>
@@ -1202,14 +1180,14 @@
                                             <cstring>kcfg_WheelScrollStep</cstring>
                                         </property>
                                         <property name="value">
-                                            <number>16</number>
+                                            <number>72</number>
                                         </property>
                                         <property name="minValue">
                                             <number>1</number>
                                         </property>
                                         <property name="maxValue">
-                                            <number>128</number>
-                                        </property>
+                                            <number>200</number>
+                                            </property>
                                         <property name="suffix">
                                             <string> pixels</string>
                                         </property>
@@ -1309,6 +1287,18 @@
         <receiver>wheelScrollStepSlider</receiver>
         <slot>setValue(int)</slot>
     </connection>
+    <connection>
+        <sender>kcfg_UseCustomWheelScrollStep</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>kcfg_WheelScrollStep</receiver>
+        <slot>setEnabled(bool)</slot>
+    </connection>
+    <connection>
+        <sender>kcfg_UseCustomWheelScrollStep</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>wheelScrollStepSlider</receiver>
+        <slot>setEnabled(bool)</slot>
+    </connection>
 </connections>
 <includes>
     <include location="global" impldecl="in implementation">kcolorbutton.h</include>
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index e2486e348..5b6f34b3e 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -819,20 +819,20 @@ void TaskBar::reLayout()
             int y = (row * bheight) + topPadding;
 
             c->setArrowType(arrowType);
-            
+
             if (childX(c) != x || childY(c) != y)
                 moveChild(c, x, y);
-                
+
             if (c->width() != bwidth || c->height() != bheight)
                 c->resize( bwidth, bheight );
-                
+
             c->setBackground();
         }
     }
     else // vertical layout
     {
         // Adjust min button height to keep gaps into account
-        int minButtonHeightAdjusted=minButtonHeight+4;
+        int minButtonHeightAdjusted=minButtonHeight+BUTTON_VERTICAL_GAP;
         // adjust content size
         if (contentsRect().height() < (int)list.count() * minButtonHeightAdjusted)
         {
@@ -1207,10 +1207,22 @@ void TaskBar::wheelEvent(TQWheelEvent* e)
         (scrollAction == m_settingsObject->ModCtrl && ctrlPressed) ||
         (scrollAction == m_settingsObject->ModShift && shiftPressed))
     {
+        int wheelScrollStep;
+        if (READ_MERGED_TASKBAR_SETTING(useCustomWheelScrollStep)) {
+            wheelScrollStep = m_wheelScrollStep;
+        } else {
+            int btnSz = orientation() == TQt::Horizontal ?
+                buttonWidth() : (buttonHeight() + BUTTON_VERTICAL_GAP);
+            wheelScrollStep = btnSz * TQApplication::wheelScrollLines();
+        }
+        // Avoid scrolling more than there is avaliable space
+        wheelScrollStep = TQMIN(wheelScrollStep,
+                orientation() == TQt::Horizontal ? visibleWidth() : visibleHeight());
+
         // the delta is defined as multiples of WHEEL_DELTA,
         // which is set to 120. See TQETWidget::translateMouseEvent()
         // in tqapplication_x11.cpp for more details.
-        int step = e->delta() * m_wheelScrollStep / 120;
+        int step = e->delta() * wheelScrollStep / 120;
         if ( orientation() == TQt::Horizontal )
         {
             scrollBy( -step, 0 );
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index 1f2e04b1f..b9c2c0b77 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 const int WINDOWLISTBUTTON_SIZE = 15;
 const int BUTTON_MAX_WIDTH      = 200;
 const int BUTTON_MIN_WIDTH      = 24;    // 24 = 4+2+16+2 -> Space for borders, application icon and gaps
+const int BUTTON_VERTICAL_GAP   = 4;
 
 class Startup;
 class Task;
diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg
index 57a018467..9cb034b28 100644
--- a/kicker/taskbar/taskbar.kcfg
+++ b/kicker/taskbar/taskbar.kcfg
@@ -176,10 +176,15 @@
             <label>Wheel actions</label>
             <whatsthis></whatsthis>
         </entry>
+        <entry key="UseCustomWheelScrollStep" type="Bool">
+            <default>false</default>
+            <label>Custom Wheel Scroll Step</label>
+            <whatsthis>Use a custom scroll step defined in pixels when scrolling with mouse wheel. If disabled use general TDE mouse settings (3 taskbar buttons by default).</whatsthis>
+        </entry>
         <entry key="WheelScrollStep" type="Int">
-            <default>16</default>
+            <default>72</default>
             <min>1</min>
-            <max>128</max>
+            <max>200</max>
             <label>Scroll step size</label>
             <whatsthis>Sets the number of pixels the taskbar scrolls with each step when using the mouse wheel.<br/>Scrolling with the buttons will used a fixed scrolling pattern, starting slow and accelerating over time.</whatsthis>
         </entry>
-- 
cgit v1.2.3

