From f9fc387a2138c2561b600b4bb183dbab8e0fbf7a Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 19 Jun 2026 15:16:35 +0900
Subject: kicker: add functionality to scroll the taskbar using the mouse
 wheel.

This commit does the following:

1. add a new groupbox and two comboboxes to the taskbar action configuration tab
   to setup the `cycle windows` and `scroll taskbar` actions.
2. add logic to scroll the taskbar up/down or left/right using the mouse
   wheel, based on the configured settings.
3. add a tdeconf_update script to map the original setting of `m_cycleWheel`
   to the corresponding action.
4. remove the original `m_cycleWheel` checkbox.

Co-authored-by: Opencode/Big Pickle
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 kcontrol/taskbar/CMakeLists.txt                    |  5 ++
 kcontrol/taskbar/kcmtaskbar.cpp                    | 41 ++++++++--
 kcontrol/taskbar/kcmtaskbar.h                      |  6 +-
 kcontrol/taskbar/kcmtaskbarui.ui                   | 95 ++++++++++++++++------
 kcontrol/taskbar/tdeconf_update/CMakeLists.txt     |  2 +
 .../taskbar/tdeconf_update/taskbar_wheel_action.sh | 10 +++
 .../tdeconf_update/taskbar_wheel_action.upd        |  2 +
 kicker/taskbar/taskbar.cpp                         | 42 ++++++++--
 kicker/taskbar/taskbar.h                           |  3 +-
 kicker/taskbar/taskbar.kcfg                        | 26 ++++--
 10 files changed, 185 insertions(+), 47 deletions(-)
 create mode 100644 kcontrol/taskbar/tdeconf_update/CMakeLists.txt
 create mode 100755 kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.sh
 create mode 100644 kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.upd

diff --git a/kcontrol/taskbar/CMakeLists.txt b/kcontrol/taskbar/CMakeLists.txt
index fad268c09..80afb3fc0 100644
--- a/kcontrol/taskbar/CMakeLists.txt
+++ b/kcontrol/taskbar/CMakeLists.txt
@@ -23,6 +23,11 @@ link_directories(
   ${TQT_LIBRARY_DIRS}
 )
 
+##### tdeconf_update ############################
+
+add_subdirectory( tdeconf_update )
+
+
 ##### other data ################################
 
 tde_create_translated_desktop(
diff --git a/kcontrol/taskbar/kcmtaskbar.cpp b/kcontrol/taskbar/kcmtaskbar.cpp
index 0d6de4f0c..d241055d6 100644
--- a/kcontrol/taskbar/kcmtaskbar.cpp
+++ b/kcontrol/taskbar/kcmtaskbar.cpp
@@ -93,7 +93,7 @@ void TaskbarAppearance::alterSettings() const
 }
 
 // These are the strings that are actually stored in the config file.
-const TQStringList& TaskbarConfig::actionList()
+const TQStringList& TaskbarConfig::buttonActionList()
 {
     static TQStringList list(
             TQStringList() << I18N_NOOP("Show Task List") << I18N_NOOP("Show Operations Menu")
@@ -106,10 +106,32 @@ const TQStringList& TaskbarConfig::actionList()
 }
 
 // Get a translated version of the above string list.
-TQStringList TaskbarConfig::i18nActionList()
+TQStringList TaskbarConfig::i18nButtonActionList()
 {
    TQStringList i18nList;
-   for( TQStringList::ConstIterator it = actionList().begin(); it != actionList().end(); ++it ) {
+   for( TQStringList::ConstIterator it = buttonActionList().begin(); it != buttonActionList().end(); ++it ) {
+      i18nList << i18n((*it).latin1());
+   }
+   return i18nList;
+}
+
+// These are the strings that are actually stored in the config file.
+const TQStringList& TaskbarConfig::wheelActionList()
+{
+    static TQStringList list(
+            TQStringList() << I18N_NOOP("Disabled")
+            << I18N_NOOP("Enabled")
+            << I18N_NOOP("Enabled with Alt")
+            << I18N_NOOP("Enabled with Ctrl")
+            << I18N_NOOP("Enabled with Shift") );
+    return list;
+}
+
+// Get a translated version of the above string list.
+TQStringList TaskbarConfig::i18nWheelActionList()
+{
+   TQStringList i18nList;
+   for( TQStringList::ConstIterator it = wheelActionList().begin(); it != wheelActionList().end(); ++it ) {
       i18nList << i18n((*it).latin1());
    }
    return i18nList;
@@ -233,10 +255,13 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
                 " windows at once or only those on the current desktop."
                 " You can also configure whether or not the Window List button will be displayed."));
 
-    TQStringList list = i18nActionList();
-    m_widget->kcfg_LeftButtonAction->insertStringList(list);
-    m_widget->kcfg_MiddleButtonAction->insertStringList(list);
-    m_widget->kcfg_RightButtonAction->insertStringList(list);
+    TQStringList buttonActionList = i18nButtonActionList();
+    m_widget->kcfg_LeftButtonAction->insertStringList(buttonActionList);
+    m_widget->kcfg_MiddleButtonAction->insertStringList(buttonActionList);
+    m_widget->kcfg_RightButtonAction->insertStringList(buttonActionList);
+    TQStringList wheelActionList = i18nWheelActionList();
+    m_widget->kcfg_CycleWindowsWAction->insertStringList(wheelActionList);
+    m_widget->kcfg_ScrollTaskbarWAction->insertStringList(wheelActionList);
     m_widget->kcfg_DisplayIconsNText->insertStringList(i18ndisplayIconsNText());
     m_widget->kcfg_GroupTasks->insertStringList(i18nGroupModeList());
     m_widget->kcfg_ShowTaskStates->insertStringList(i18nShowTaskStatesList());
@@ -367,7 +392,7 @@ void TaskbarConfig::slotUpdateComboBox()
     }
     else
     {
-        TQString action = i18nActionList()[pos];
+        TQString action = i18n(buttonActionList()[pos].latin1());
         m_widget->kcfg_LeftButtonAction->changeItem(action,pos);
         m_widget->kcfg_MiddleButtonAction->changeItem(action,pos);
         m_widget->kcfg_RightButtonAction->changeItem(action,pos);
diff --git a/kcontrol/taskbar/kcmtaskbar.h b/kcontrol/taskbar/kcmtaskbar.h
index a67386abf..7a16aa738 100644
--- a/kcontrol/taskbar/kcmtaskbar.h
+++ b/kcontrol/taskbar/kcmtaskbar.h
@@ -81,8 +81,10 @@ private:
     void updateAppearanceCombo();
     void updateIconsTextCombo();
     void updateCustomAppearance();
-    static const TQStringList& actionList();
-    static TQStringList i18nActionList();
+    static const TQStringList& buttonActionList();
+    static TQStringList i18nButtonActionList();
+    static const TQStringList& wheelActionList();
+    static TQStringList i18nWheelActionList();
     static const TQStringList& groupModeList();
     static TQStringList i18nGroupModeList();
     static const TQStringList& showTaskStatesList();
diff --git a/kcontrol/taskbar/kcmtaskbarui.ui b/kcontrol/taskbar/kcmtaskbarui.ui
index 385991e55..c50bcd1f3 100644
--- a/kcontrol/taskbar/kcmtaskbarui.ui
+++ b/kcontrol/taskbar/kcmtaskbarui.ui
@@ -948,7 +948,7 @@
                     </property>
                     <widget class="TQGroupBox">
                         <property name="name">
-                            <cstring>actionsGroup</cstring>
+                            <cstring>buttonActionsGroup</cstring>
                         </property>
                         <property name="sizePolicy">
                             <sizepolicy>
@@ -959,7 +959,7 @@
                             </sizepolicy>
                         </property>
                         <property name="title">
-                            <string>Mouse Actions</string>
+                            <string>Mouse Buttons</string>
                         </property>
                         <grid>
                             <property name="name">
@@ -1013,6 +1013,17 @@
                                     </sizepolicy>
                                 </property>
                             </widget>
+                            <widget class="TQLabel" row="2" column="0">
+                                <property name="name">
+                                    <cstring>rightButtonLabel</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Right b&amp;utton:</string>
+                                </property>
+                                <property name="buddy" stdset="0">
+                                    <cstring>kcfg_RightButtonAction</cstring>
+                                </property>
+                            </widget>
                             <widget class="TQComboBox" row="2" column="1">
                                 <property name="name">
                                     <cstring>kcfg_RightButtonAction</cstring>
@@ -1026,45 +1037,81 @@
                                     </sizepolicy>
                                 </property>
                             </widget>
-                            <widget class="TQLabel" row="2" column="0">
+                        </grid>
+                    </widget>
+                    <widget class="TQGroupBox">
+                        <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>
+                        <grid>
+                            <property name="name">
+                                <cstring>unnamed</cstring>
+                            </property>
+                            <widget class="TQLabel" row="0" column="0">
                                 <property name="name">
-                                    <cstring>rightButtonLabel</cstring>
+                                    <cstring>cycleWindowsLabel</cstring>
                                 </property>
                                 <property name="text">
-                                    <string>Right b&amp;utton:</string>
+                                    <string>&amp;Cycle windows:</string>
                                 </property>
                                 <property name="buddy" stdset="0">
-                                    <cstring>kcfg_RightButtonAction</cstring>
+                                    <cstring>kcfg_CycleWindowsWAction</cstring>
+                                </property>
+                            </widget>
+                            <widget class="TQComboBox" row="0" column="1">
+                                <property name="name">
+                                    <cstring>kcfg_CycleWindowsWAction</cstring>
+                                </property>
+                                <property name="sizePolicy">
+                                    <sizepolicy>
+                                        <hsizetype>7</hsizetype>
+                                        <vsizetype>0</vsizetype>
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                  <string>If this option is enabled (with or without a keyboard modifier) you can cycle through the current list of windows by using the mouse wheel on the taskbar.</string>
                                 </property>
                             </widget>
-                            <widget class="TQCheckBox" row="4" column="0" colspan="2">
+                            <widget class="TQLabel" row="1" column="0">
                                 <property name="name">
-                                    <cstring>kcfg_CycleWheel</cstring>
+                                    <cstring>scrollTaskbarLabel</cstring>
                                 </property>
                                 <property name="text">
-                                    <string>Cycle through windows with mouse wheel</string>
+                                    <string>&amp;Scroll taskbar:</string>
                                 </property>
-                                <property name="checked">
-                                    <bool>true</bool>
+                                <property name="buddy" stdset="0">
+                                    <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
                             </widget>
-                            <spacer row="3" column="0">
+                            <widget class="TQComboBox" row="1" column="1">
                                 <property name="name">
-                                    <cstring>spacer11</cstring>
+                                    <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
-                                <property name="orientation">
-                                    <enum>Vertical</enum>
-                                </property>
-                                <property name="sizeType">
-                                    <enum>Fixed</enum>
+                                <property name="sizePolicy">
+                                    <sizepolicy>
+                                        <hsizetype>7</hsizetype>
+                                        <vsizetype>0</vsizetype>
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
                                 </property>
-                                <property name="sizeHint">
-                                    <size>
-                                        <width>20</width>
-                                        <height>21</height>
-                                    </size>
+                                <property name="whatsThis" stdset="0">
+                                  <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>
-                            </spacer>
+                            </widget>
                         </grid>
                     </widget>
                     <spacer>
diff --git a/kcontrol/taskbar/tdeconf_update/CMakeLists.txt b/kcontrol/taskbar/tdeconf_update/CMakeLists.txt
new file mode 100644
index 000000000..aec17effb
--- /dev/null
+++ b/kcontrol/taskbar/tdeconf_update/CMakeLists.txt
@@ -0,0 +1,2 @@
+install( FILES taskbar_wheel_action.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
+install( PROGRAMS taskbar_wheel_action.sh DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
diff --git a/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.sh b/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.sh
new file mode 100755
index 000000000..97751b7de
--- /dev/null
+++ b/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+find "$TDEHOME/share/config" -mindepth 1 -maxdepth 1 -type f \
+    '(' -name 'ktaskbarrc' -o -name 'taskbar_panelapplet_*_rc' ')' -print0 |
+    xargs -0 grep -l 'CycleWheel' |
+    xargs sed -i '
+s/^CycleWheel=true$/CycleWindowsWAction=ModNone/
+s/^CycleWheel=false$/CycleWindowsWAction=ActionDisabled/
+/^CycleWheel=/d
+'
diff --git a/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.upd b/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.upd
new file mode 100644
index 000000000..afb33e272
--- /dev/null
+++ b/kcontrol/taskbar/tdeconf_update/taskbar_wheel_action.upd
@@ -0,0 +1,2 @@
+Id=trinity.taskbarWheelActions
+Script=taskbar_wheel_action.sh,sh
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index 3f82f1e50..896c4ae5b 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -50,11 +50,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "taskbar.moc"
 
 #define READ_MERGED_TASKBAR_SETTING(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->x():m_settingsObject->x())
+#define READ_MERGED_TASKBAR_WACTION(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->wAction(x):m_settingsObject->wAction(x))
 
 TaskBar::TaskBar( TaskBarSettings* settingsObject, TaskBarSettings* globalSettingsObject, TQWidget *parent, const char *name )
     : Panner( parent, name ),
       m_showAllWindows(false),
-      m_cycleWheel(false),
+      m_cycleWindowsAction(0),
+      m_scrollTaskbarAction(0),
       m_currentScreen(-1),
       m_showOnlyCurrentScreen(false),
       m_sortByDesktop(false),
@@ -238,7 +240,8 @@ void TaskBar::configure()
 {
     bool wasShowWindows = m_showAllWindows;
     bool wasSortByDesktop = m_sortByDesktop;
-    bool wasCycleWheel = m_cycleWheel;
+    int  wasCycleWindowsAction = m_cycleWindowsAction;
+    int  wasScrollTaskbarAction = m_scrollTaskbarAction;
     bool wasDisplayIconsNText = m_displayIconsNText;
     bool wasShowOnlyIconified = m_showOnlyIconified;
     int  wasShowTaskStates = m_showTaskStates;
@@ -248,7 +251,8 @@ void TaskBar::configure()
     m_sortByDesktop = m_showAllWindows && READ_MERGED_TASKBAR_SETTING(sortByDesktop);
     m_displayIconsNText = READ_MERGED_TASKBAR_SETTING(displayIconsNText);
     m_showOnlyIconified = READ_MERGED_TASKBAR_SETTING(showOnlyIconified);
-    m_cycleWheel = READ_MERGED_TASKBAR_SETTING(cycleWheel);
+    m_cycleWindowsAction = READ_MERGED_TASKBAR_WACTION(TaskBarSettings::CycleWindows);
+    m_scrollTaskbarAction = READ_MERGED_TASKBAR_WACTION(TaskBarSettings::ScrollTaskbar);
     m_showTaskStates = READ_MERGED_TASKBAR_SETTING(showTaskStates);
     m_iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
 
@@ -273,7 +277,8 @@ void TaskBar::configure()
     if (wasShowWindows != m_showAllWindows ||
         wasSortByDesktop != m_sortByDesktop ||
         wasDisplayIconsNText != m_displayIconsNText ||
-        wasCycleWheel != m_cycleWheel ||
+        wasCycleWindowsAction != m_cycleWindowsAction ||
+        wasScrollTaskbarAction != m_scrollTaskbarAction ||
         wasShowOnlyIconified != m_showOnlyIconified ||
         wasShowTaskStates != m_showTaskStates ||
         wasIconSize != m_iconSize)
@@ -1173,20 +1178,43 @@ void TaskBar::activateNextTask(bool forward)
 
 void TaskBar::wheelEvent(TQWheelEvent* e)
 {
+    bool altPressed = (e->state() & TQt::AltButton);
+    bool ctrlPressed = (e->state() & TQt::ControlButton);
+    bool shiftPressed = (e->state() & TQt::ShiftButton);
+    bool noMod = !altPressed && !ctrlPressed && !shiftPressed;
 
-    if(READ_MERGED_TASKBAR_SETTING(cycleWheel)) {
+    int cycleAction = READ_MERGED_TASKBAR_WACTION(TaskBarSettings::CycleWindows);
+    int scrollAction = READ_MERGED_TASKBAR_WACTION(TaskBarSettings::ScrollTaskbar);
 
+    if ((cycleAction == m_settingsObject->ModNone && noMod) ||
+        (cycleAction == m_settingsObject->ModAlt && altPressed) ||
+        (cycleAction == m_settingsObject->ModCtrl && ctrlPressed) ||
+        (cycleAction == m_settingsObject->ModShift && shiftPressed))
+    {
         if (e->delta() > 0)
         {
-            // scroll away from user, previous task
             activateNextTask(false);
         }
         else
         {
-            // scroll towards user, next task
             activateNextTask(true);
         }
     }
+
+    if ((scrollAction == m_settingsObject->ModNone && noMod) ||
+        (scrollAction == m_settingsObject->ModAlt && altPressed) ||
+        (scrollAction == m_settingsObject->ModCtrl && ctrlPressed) ||
+        (scrollAction == m_settingsObject->ModShift && shiftPressed))
+    {
+        if (e->delta() > 0)
+        {
+            scrollLeftUp();
+        }
+        else
+        {
+            scrollRightDown();
+        }
+    }
 }
 
 void TaskBar::slotActivateNextTask()
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index dc34129e0..205418f71 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -146,7 +146,8 @@ private:
 
     bool                blocklayout;
     bool                m_showAllWindows;
-    bool                m_cycleWheel;
+    int                 m_cycleWindowsAction;
+    int                 m_scrollTaskbarAction;
     int                 m_currentScreen;    // The screen to show, -1 for all screens
     bool                m_showOnlyCurrentScreen;
     bool                m_sortByDesktop;
diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg
index 0665470df..1ec3abaa1 100644
--- a/kicker/taskbar/taskbar.kcfg
+++ b/kicker/taskbar/taskbar.kcfg
@@ -21,11 +21,6 @@
             <label>Show windows from all desktops</label>
             <whatsthis>Turning this option off will cause the taskbar to display <b>only</b> the windows on the current desktop. By default, this option is selected and all windows are shown.</whatsthis>
         </entry>
-        <entry key="CycleWheel" type="Bool" >
-            <default>true</default>
-            <label>Cycle through windows with mouse wheel</label>
-            <whatsthis>Enabling this option causes the taskbar to cycle through the current list of windows when using the mouse wheel</whatsthis>
-        </entry>
         <entry key="ShowOnlyIconified" type="Bool" >
             <default>false</default>
             <label>Show only minimized windows</label>
@@ -160,6 +155,27 @@
             <label>Mouse button actions</label>
             <whatsthis></whatsthis>
         </entry>
+        <!-- Suffixes can't be the same in parameterized forms, so use
+             "WAction" to distinguish it from the button's "Action" -->
+        <entry key="$(Wheel)WAction" name="$(Wheel)WAction" type="Enum" >
+            <parameter name="Wheel" type="Enum">
+                <values>
+                    <value>CycleWindows</value>
+                    <value>ScrollTaskbar</value>
+                </values>
+            </parameter>
+            <choices>
+                <choice name="ActionDisabled"/>
+                <choice name="ModNone"/>
+                <choice name="ModAlt"/>
+                <choice name="ModCtrl"/>
+                <choice name="ModShift"/>
+            </choices>
+            <default param="CycleWindows">ModNone</default>
+            <default param="ScrollTaskbar">ActionDisabled</default>
+            <label>Wheel actions</label>
+            <whatsthis></whatsthis>
+        </entry>
     </group>
 
     <group name="Appearance">
-- 
cgit v1.2.3

