From 00105125e3010438663b1355f6f1579476ee9510 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 16 Sep 2020 23:34:21 +0900 Subject: This is a temporary commit to save WIP done on this topic. Development of this feature will only resume after the release of R14.1.0. Relates to bug 3159. NOTE: this commit needs to be completed/reworked. It should not be merged to master as is. Signed-off-by: Michele Calgaro --- kmix/KMixApp.cpp | 9 ++++++++- kmix/KMixApp.h | 6 ++++-- kmix/kmix-platforms.cpp | 2 -- kmix/kmix.cpp | 12 ++++++++++-- kmix/kmix.h | 1 + kmix/mixer.cpp | 4 ++-- kmix/mixertoolbox.cpp | 20 +++++++++++++------- kmix/mixertoolbox.h | 7 ++++--- 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/kmix/KMixApp.cpp b/kmix/KMixApp.cpp index d511605c..a1032e2e 100644 --- a/kmix/KMixApp.cpp +++ b/kmix/KMixApp.cpp @@ -26,7 +26,7 @@ KMixApp::KMixApp() - : KUniqueApplication(), m_kmix( 0 ) + : KUniqueApplication(), m_kmix(NULL), m_updateMixersTimer(NULL) { // We handle autostart via standard autostart-enabled .desktop file instead of the session manager disableSessionManagement(); @@ -35,6 +35,10 @@ KMixApp::KMixApp() KMixApp::~KMixApp() { + if (m_updateMixersTimer) + { + delete m_updateMixersTimer; + } if (m_kmix) { delete m_kmix; @@ -52,6 +56,9 @@ KMixApp::newInstance() else { m_kmix = new KMixWindow; + m_updateMixersTimer = new TQTimer(); + connect(m_updateMixersTimer, TQT_SIGNAL(timeout()), m_kmix, TQT_SLOT(updateMixers())); + m_updateMixersTimer->start(5000); connect(this, TQT_SIGNAL(stopUpdatesOnVisibility()), m_kmix, TQT_SLOT(stopVisibilityUpdates())); if ( isRestored() && TDEMainWindow::canBeRestored(0) ) { diff --git a/kmix/KMixApp.h b/kmix/KMixApp.h index 7630e1f8..d48fc1b0 100644 --- a/kmix/KMixApp.h +++ b/kmix/KMixApp.h @@ -2,6 +2,7 @@ #define KMixApp_h #include +#include class KMixWindow; @@ -12,9 +13,9 @@ Q_OBJECT public: KMixApp(); ~KMixApp(); - int newInstance (); + int newInstance(); - public slots: + public slots: void quitExtended(); // For a hack on visibility() signals: @@ -22,6 +23,7 @@ Q_OBJECT private: KMixWindow *m_kmix; + TQTimer *m_updateMixersTimer; }; #endif diff --git a/kmix/kmix-platforms.cpp b/kmix/kmix-platforms.cpp index b27a9ed7..b9182796 100644 --- a/kmix/kmix-platforms.cpp +++ b/kmix/kmix-platforms.cpp @@ -20,8 +20,6 @@ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* This code is being #include'd from mixer.cpp */ - #ifndef KMIX_PLATFORMS_CPP #define KMIX_PLATFORMS_CPP diff --git a/kmix/kmix.cpp b/kmix/kmix.cpp index 3ebf6729..9a786abe 100644 --- a/kmix/kmix.cpp +++ b/kmix/kmix.cpp @@ -546,8 +546,16 @@ void KMixWindow::stopVisibilityUpdates() m_visibilityUpdateAllowed = false; } -void -KMixWindow::slotHWInfo() { +void KMixWindow::updateMixers() +{ +tqWarning("MIKE update mixers ENTER"); + if (MixerToolBox::updateMixer(Mixer::mixers(), m_multiDriverMode, m_hwInfoString)) + { + initMixerWidgets(); + } +} + +void KMixWindow::slotHWInfo() { KMessageBox::information( 0, m_hwInfoString, i18n("Mixer Hardware Information") ); } diff --git a/kmix/kmix.h b/kmix/kmix.h index c41beb65..fb1d99eb 100644 --- a/kmix/kmix.h +++ b/kmix/kmix.h @@ -109,6 +109,7 @@ KMixWindow : public TDEMainWindow, virtual public KMixIface void saveVolumes(); virtual void applyPrefs( KMixPrefDlg *prefDlg ); void stopVisibilityUpdates(); + void updateMixers(); private: TDEAccel *m_keyAccel; diff --git a/kmix/mixer.cpp b/kmix/mixer.cpp index 778d6af9..74f41136 100644 --- a/kmix/mixer.cpp +++ b/kmix/mixer.cpp @@ -80,8 +80,8 @@ bool Mixer::isValid(int driver, int device) Mixer_Backend *mb = mf(device); if (mb) { - bool ret = mb->isValid(); - delete mb; + bool ret = mb->isValid(); + delete mb; return ret; } } diff --git a/kmix/mixertoolbox.cpp b/kmix/mixertoolbox.cpp index 1021fd8c..25836ae3 100644 --- a/kmix/mixertoolbox.cpp +++ b/kmix/mixertoolbox.cpp @@ -249,7 +249,6 @@ void MixerToolBox::initMixer(TQPtrList &mixers, bool multiDriverMode, TQS } - /* * Clean up and free all resources of all found Mixers, which were found in the initMixer() call */ @@ -278,10 +277,6 @@ void MixerToolBox::deinitMixer(TQPtrList &mixers) // kdDebug(67100) << "OUT MixerToolBox::deinitMixer(TQPtrList &mixers)" << endl; } -/** - * Clean up and free all resources of the given mixers - * @par mixers The list of mixers to deinitialize. - */ /** * Scan for Mixers in the System and update the given list. No longer existing mixers * will be deinitialized. @@ -291,12 +286,15 @@ void MixerToolBox::deinitMixer(TQPtrList &mixers) * @par multiDriverMode Whether the Mixer scan should try more all backendends. * 'true' means to scan all backends. 'false' means: After scanning the * current backend the next backend is only scanned if no Mixers were found yet. + * @return true if any change in the mixers list has been detected. */ -void MixerToolBox::updateMixer(TQPtrList &mixers, bool multiDriverMode, TQString& ref_hwInfoString) +bool MixerToolBox::updateMixer(TQPtrList &mixers, bool multiDriverMode, TQString& ref_hwInfoString) { + bool changesDetected = false; TQPtrList newMixers; // Scan for new mixers initMixer(newMixers, multiDriverMode, ref_hwInfoString); +tqWarning("MIKE OLD mixer=%d NEW=%d",mixers.count(),newMixers.count()); // Remove no longer existing mixers TQPtrList mixersToDeinit; Mixer *searchMixer = NULL; @@ -314,13 +312,16 @@ void MixerToolBox::updateMixer(TQPtrList &mixers, bool multiDriverMode, T } if (!searchMixer) { + changesDetected = true; mixers.take(); mixersToDeinit.append(currMixer); +tqWarning("MIKE remove mixer=("+currMixer->id()+")="+currMixer->mixerName()); } currMixer = mixers.next(); } deinitMixer(mixersToDeinit); // Add newly found mixers + int insertLocation = 0; searchMixer = newMixers.first(); while (searchMixer) { @@ -336,11 +337,16 @@ void MixerToolBox::updateMixer(TQPtrList &mixers, bool multiDriverMode, T if (!currMixer) { // New mixer, append to existing list + changesDetected = true; newMixers.take(); - mixers.append(searchMixer); + mixers.insert(insertLocation, searchMixer); +tqWarning("MIKE add new mixer=("+searchMixer->id()+")="+searchMixer->mixerName()); } searchMixer = newMixers.next(); + ++insertLocation; } // Deallocate duplicated mixers deinitMixer(newMixers); + + return changesDetected; } diff --git a/kmix/mixertoolbox.h b/kmix/mixertoolbox.h index a964e9a9..59d86726 100644 --- a/kmix/mixertoolbox.h +++ b/kmix/mixertoolbox.h @@ -12,12 +12,13 @@ class Mixer; * The reason, why it is not put in a common base class is, that the classes are * very different and cannot be changed (e.g. KPanelApplet) without major headache. */ -class MixerToolBox { - public: +class MixerToolBox +{ + public: static void initMixer(TQPtrList &mixers, bool multiDriverMode, TQString& ref_hwInfoString); static void deinitMixer(); static void deinitMixer(TQPtrList&); - static void updateMixer(TQPtrList &mixers, bool multiDriverMode, TQString& ref_hwInfoString); + static bool updateMixer(TQPtrList &mixers, bool multiDriverMode, TQString& ref_hwInfoString); }; -- cgit v1.2.3