From 2d6271c5ff89e7aab50ade77c421cc119a1edc01 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Sun, 1 Nov 2026 07:19:39 -0300
Subject: kmilo: Add TCC controls for multimedia key volume steps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 kmilo/generic/CMakeLists.txt                 |   2 +
 kmilo/generic/README                         |  10 +-
 kmilo/generic/kcmkmilokeys/CMakeLists.txt    |  38 ++++++++
 kmilo/generic/kcmkmilokeys/kmilokeys.desktop |  14 +++
 kmilo/generic/kcmkmilokeys/main.cpp          | 137 +++++++++++++++++++++++++++
 kmilo/generic/kcmkmilokeys/main.h            |  38 ++++++++
 6 files changed, 234 insertions(+), 5 deletions(-)
 create mode 100644 kmilo/generic/kcmkmilokeys/CMakeLists.txt
 create mode 100644 kmilo/generic/kcmkmilokeys/kmilokeys.desktop
 create mode 100644 kmilo/generic/kcmkmilokeys/main.cpp
 create mode 100644 kmilo/generic/kcmkmilokeys/main.h

diff --git a/kmilo/generic/CMakeLists.txt b/kmilo/generic/CMakeLists.txt
index a5154245..56649b8a 100644
--- a/kmilo/generic/CMakeLists.txt
+++ b/kmilo/generic/CMakeLists.txt
@@ -32,6 +32,8 @@ tde_add_kpart( kmilo_generic AUTOMOC
   DESTINATION ${PLUGIN_INSTALL_DIR}
 )
 
+add_subdirectory( kcmkmilokeys )
+
 
 ##### other data ################################
 
diff --git a/kmilo/generic/README b/kmilo/generic/README
index 1727e8e7..5601e234 100644
--- a/kmilo/generic/README
+++ b/kmilo/generic/README
@@ -7,12 +7,12 @@ XF86AudioRaiseVolume, XF86AudioMute. You can use "xev" program to watch events
 generated by X server and "xmodmap" program to assign events (keycodes) to
 keysyms. Also watch kernel log (dmesg) for unknown scancodes.
 
-If you use CTRL in conjunction with volUp/Down it changes the volume by 1%,
-otherwise by 10%.
+By default, CTRL with volUp/Down changes the volume by 1%; otherwise it changes
+by 10%. Both increments can be configured below.
 
-This module is now configurable (though with no configuration GUI), you can
-change which channels (kmix device indexes) to change volume on, you can also
-tweak volume changing steps. Channels are represented by numeric indexes
+The volume changing steps can be configured in the TDE Control Center under
+Sound & Multimedia -> Multimedia Keys. Channel selection (kmix device indexes) is still
+configured through kmilodrc. Channels are represented by numeric indexes
 starting from zero, in order to get the right channel, you have to experiment
 a little (keep the kmix mixer window open). ;) Examples:
 
diff --git a/kmilo/generic/kcmkmilokeys/CMakeLists.txt b/kmilo/generic/kcmkmilokeys/CMakeLists.txt
new file mode 100644
index 00000000..ab0ab510
--- /dev/null
+++ b/kmilo/generic/kcmkmilokeys/CMakeLists.txt
@@ -0,0 +1,38 @@
+#################################################
+#
+#  Copyright (C) 2026 Trinity Desktop Project
+#
+#  This file is released under the GNU
+#  General Public License version 2 or later.
+#
+#################################################
+
+include_directories(
+  ${CMAKE_BINARY_DIR}
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${TDE_INCLUDE_DIR}
+  ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+  ${TQT_LIBRARY_DIRS}
+)
+
+
+##### kcm_kmilokeys (kpart) #####################
+
+tde_add_kpart( kcm_kmilokeys AUTOMOC
+  SOURCES main.cpp
+  LINK tdeui-shared
+  DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+
+##### other data ################################
+
+tde_create_translated_desktop(
+  SOURCE kmilokeys.desktop
+  DESTINATION ${XDG_APPS_INSTALL_DIR}
+  PO_DIR kmilo-desktops
+)
diff --git a/kmilo/generic/kcmkmilokeys/kmilokeys.desktop b/kmilo/generic/kcmkmilokeys/kmilokeys.desktop
new file mode 100644
index 00000000..8ba61a77
--- /dev/null
+++ b/kmilo/generic/kcmkmilokeys/kmilokeys.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Type=Application
+Exec=tdecmshell kmilokeys
+Icon=kmix
+
+X-TDE-Library=kmilokeys
+X-TDE-ModuleType=Library
+X-TDE-ParentApp=kcontrol
+
+Name=Multimedia Keys
+Comment=Configure the behavior of multimedia keys
+Keywords=volume;multimedia;keys;KMilo;Ctrl;
+
+Categories=Qt;TDE;Settings;X-TDE-settings-sound;
diff --git a/kmilo/generic/kcmkmilokeys/main.cpp b/kmilo/generic/kcmkmilokeys/main.cpp
new file mode 100644
index 00000000..8e129289
--- /dev/null
+++ b/kmilo/generic/kcmkmilokeys/main.cpp
@@ -0,0 +1,137 @@
+/*
+ *  KMilo multimedia keys configuration module
+ *
+ *  Copyright (C) 2026 Trinity Desktop Project
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ */
+
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqspinbox.h>
+#include <tqwhatsthis.h>
+
+#include <dcopclient.h>
+#include <kgenericfactory.h>
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <tdeglobal.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <tdeconfig.h>
+#include <tdecmodule.h>
+#include <tdelocale.h>
+
+#include "main.h"
+
+typedef KGenericFactory<KMiloKeysModule, TQWidget> KMiloKeysModuleFactory;
+K_EXPORT_COMPONENT_FACTORY(kcm_kmilokeys, KMiloKeysModuleFactory("kmilokeys"))
+
+KMiloKeysModule::KMiloKeysModule(TQWidget *parent, const char *name,
+                                  const TQStringList &)
+    : TDECModule(KMiloKeysModuleFactory::instance(), parent, name)
+{
+    TDEGlobal::locale()->insertCatalogue("kmilo_generic");
+
+    TDEAboutData *about = new TDEAboutData(
+        "kmilokeys", I18N_NOOP("Multimedia Keys"), 0, 0,
+        TDEAboutData::License_GPL,
+        "Copyright (C) 2026 Trinity Desktop Project");
+    setAboutData(about);
+
+    setButtons( TDECModule::Default | TDECModule::Apply );
+
+    TQGridLayout *layout = new TQGridLayout(this, 3, 2,
+                                           KDialog::marginHint(),
+                                           KDialog::spacingHint());
+
+    TQLabel *fastLabel = new TQLabel(i18n("Normal volume increment:"), this);
+    m_fastStep = new TQSpinBox(1, 100, 1, this);
+    m_fastStep->setSuffix(i18n("keep short, unit in spinbox", "%"));
+    TQWhatsThis::add(m_fastStep, i18n(
+        "The percentage applied when you press a multimedia volume key. "
+        "Hold Ctrl to use the fine volume increment."));
+    fastLabel->setBuddy(m_fastStep);
+    layout->addWidget(fastLabel, 0, 0);
+    layout->addWidget(m_fastStep, 0, 1);
+
+    TQLabel *slowLabel = new TQLabel(i18n("Fine volume increment:"), this);
+    m_slowStep = new TQSpinBox(1, 100, 1, this);
+    m_slowStep->setSuffix(i18n("keep short, unit in spinbox", "%"));
+    TQWhatsThis::add(m_slowStep, i18n(
+        "The percentage applied when you hold Ctrl and press a multimedia "
+        "volume key."));
+    slowLabel->setBuddy(m_slowStep);
+    layout->addWidget(slowLabel, 1, 0);
+    layout->addWidget(m_slowStep, 1, 1);
+
+    layout->setRowStretch(2, 1);
+
+    connect(m_fastStep, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotChanged()));
+    connect(m_slowStep, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotChanged()));
+
+    load();
+}
+
+void KMiloKeysModule::load()
+{
+    load(false);
+}
+
+void KMiloKeysModule::load(bool useDefaults)
+{
+    TDEConfig config("kmilodrc");
+    config.setReadDefaults(useDefaults);
+    config.setGroup("generic monitor");
+
+    m_fastStep->blockSignals(true);
+    m_slowStep->blockSignals(true);
+    m_fastStep->setValue(config.readNumEntry("volumeStepFast", 10));
+    m_slowStep->setValue(config.readNumEntry("volumeStepSlow", 1));
+    m_fastStep->blockSignals(false);
+    m_slowStep->blockSignals(false);
+
+    emit changed(useDefaults);
+}
+
+void KMiloKeysModule::save()
+{
+    TDEConfig config("kmilodrc");
+    config.setGroup("generic monitor");
+    config.writeEntry("volumeStepFast", m_fastStep->value());
+    config.writeEntry("volumeStepSlow", m_slowStep->value());
+    config.sync();
+
+    DCOPClient *client = tdeApp->dcopClient();
+    if (!client->isAttached() && !client->attach()) {
+        kdDebug() << "KMiloKeysModule: cannot attach to DCOP server; settings "
+                     "will apply when KMilo starts."
+                  << endl;
+    } else {
+        TQByteArray data, replyData;
+        TQCString replyType;
+        if (!client->call("kded", "kmilod", "reconfigure()",
+                          data, replyType, replyData)) {
+            kdDebug() << "KMiloKeysModule: KMilo reconfiguration service is "
+                         "not available; settings will apply when it starts."
+                      << endl;
+        }
+    }
+
+    emit changed(false);
+}
+
+void KMiloKeysModule::defaults()
+{
+    load(true);
+}
+
+void KMiloKeysModule::slotChanged()
+{
+    emit changed(true);
+}
+
+#include "main.moc"
diff --git a/kmilo/generic/kcmkmilokeys/main.h b/kmilo/generic/kcmkmilokeys/main.h
new file mode 100644
index 00000000..df95c0f4
--- /dev/null
+++ b/kmilo/generic/kcmkmilokeys/main.h
@@ -0,0 +1,38 @@
+/*
+ *  KMilo multimedia keys configuration module
+ *
+ *  Copyright (C) 2026 Trinity Desktop Project
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ */
+
+#ifndef KCM_KMILOKEYS_MAIN_H
+#define KCM_KMILOKEYS_MAIN_H
+
+#include <tdecmodule.h>
+
+class TQSpinBox;
+
+class KMiloKeysModule : public TDECModule
+{
+    TQ_OBJECT
+
+public:
+    KMiloKeysModule(TQWidget *parent, const char *name, const TQStringList &);
+    void load();
+    void load(bool useDefaults);
+    void save();
+    void defaults();
+
+private:
+    TQSpinBox *m_fastStep;
+    TQSpinBox *m_slowStep;
+
+private slots:
+    void slotChanged();
+};
+
+#endif
-- 
cgit v1.2.3

