[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] Fixing the KMix applet
From:       Christian Esken <c.esken () cityweb ! de>
Date:       2003-12-01 22:41:09
[Download RAW message or body]

On Monday 01 December 2003 09:54, Andras Mantia wrote:
> Indeed, this is match cleaner and simpler. I told you, I'm a simple user.
> :-)
>
> Another bug: the applet is unusable if it's put on a vertical panel.

I finally found out why this happens: The KMix applet used the 
"popupDirection()" stuff from the panel class. It was *always* wrong to use 
it and now it is deprecated *and* has (probably) changed its sematics.

Additionaly there were bugs introduced in other KMix classes.

I agree that the KMixApplet shoul not ship like this. I did a fix, but it is 
big, working around the "popupDirection()" stuff. Here's the patch, do I get 
authorization to commit it?

Chris

["kmixapplet3.2.patch" (text/x-diff)]

Index: kmixapplet.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kmix/kmixapplet.cpp,v
retrieving revision 1.48
diff -u -r1.48 kmixapplet.cpp
--- kmixapplet.cpp	24 Nov 2003 21:41:48 -0000	1.48
+++ kmixapplet.cpp	1 Dec 2003 22:31:30 -0000
@@ -274,7 +274,7 @@
 	//  Find out wether the applet should be reversed
 	reversedDir = cfg->readBoolEntry("ReversedDirection", false);
 	
-	popupDirectionChange(KPanelApplet::Up);
+	//positionChange(position()); // To take over reversedDir
 	
 	m_aboutData.addCredit( I18N_NOOP( "For detailed credits, please refer to the About \
information of the KMix program" ) );  }
@@ -348,9 +348,11 @@
       {
          delete m_errorLabel;
          m_errorLabel = 0;
+
+	 KPanelApplet::Direction dirHack = getDirectionFromPositionHack(position());
          m_mixerWidget = new KMixerWidget( 0, mixer, mixer->mixerName(),
                                            mixer->mixerNum(), true,
-                                           popupDirection(), MixDevice::SLIDER, this \
); +                                           checkReverse(dirHack), \
MixDevice::SLIDER, this );  setColors();
          m_mixerWidget->show();
          m_mixerWidget->setGeometry( 0, 0, width(), height() );
@@ -361,6 +363,24 @@
    }
 }
 
+KPanelApplet::Direction KMixApplet::getDirectionFromPositionHack(Position pos) {
+	/*
+	Position hack: KMixApplet was using popupDirection() which is nonsense and now \
leeds to +	an unusable KMixApplet on vertical panels. As the "Direction" is used \
throughout +	KMix we now use position and do an ugly conversion.
+	This is to be removed for KMix2.1 !!!
+	*/
+	KPanelApplet::Direction dir = KPanelApplet::Down; // Random default value
+	switch ( pos ) {
+		case KPanelApplet::pTop    : dir=KPanelApplet::Up; break;
+		case KPanelApplet::pLeft   : dir=KPanelApplet::Left; break;
+		case KPanelApplet::pRight  : dir=KPanelApplet::Right; break;
+		case KPanelApplet::pBottom : dir=KPanelApplet::Down; break;
+	}
+	return dir;
+}
+
+
 void KMixApplet::triggerUpdateLayout()
 {
    if ( m_lockedLayout ) return;
@@ -434,9 +454,10 @@
         m_mixerWidget->setColors( m_colors );
 }
 
-void KMixApplet::popupDirectionChange(Direction dir) {
+void KMixApplet::positionChange(Position pos) {
   if (!m_errorLabel) {
     if (m_mixerWidget) delete m_mixerWidget;
+    Direction dir = getDirectionFromPositionHack(pos);
     m_mixerWidget = new KMixerWidget( 0, mixer, mixerName, mixerNum, true,
                                       checkReverse(dir), MixDevice::ALL, this );
     m_mixerWidget->loadConfig( config(), "Widget" );
@@ -491,8 +512,8 @@
 
     reversedDir = m_pref->reverseDirection();
     QSize si = m_mixerWidget->size();
-    popupDirectionChange( popupDirection());
-    if( popupDirection() == Up || popupDirection() == Down )
+    positionChange( position());
+    if( position() == pTop || position() == pBottom )
         m_mixerWidget->setIcons( si.height()>=32 );
     else
         m_mixerWidget->setIcons( si.width()>=32 );
Index: kmixapplet.h
===================================================================
RCS file: /home/kde/kdemultimedia/kmix/kmixapplet.h,v
retrieving revision 1.18
diff -u -r1.18 kmixapplet.h
--- kmixapplet.h	28 Sep 2003 21:58:08 -0000	1.18
+++ kmixapplet.h	1 Dec 2003 22:31:30 -0000
@@ -105,8 +105,9 @@
    int m_lockedLayout;
    AppletConfigDialog *m_pref;
    bool reversedDir; //  reverses direction of sliders and icon position
-   void popupDirectionChange(Direction);
+   void positionChange(Position);
    Direction checkReverse(Direction);
+   Direction getDirectionFromPositionHack(Position pos);
    void setColors();
 
    static int s_instCount;
Index: kmixerwidget.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kmix/kmixerwidget.cpp,v
retrieving revision 1.61
diff -u -r1.61 kmixerwidget.cpp
--- kmixerwidget.cpp	30 Nov 2003 06:27:32 -0000	1.61
+++ kmixerwidget.cpp	1 Dec 2003 22:31:31 -0000
@@ -36,6 +36,7 @@
 #include <qmap.h>
 #include <qsize.h>
 #include <qhbox.h>
+#include <qvbox.h>
 
 #include <kcombobox.h>
 #include <kdebug.h>
@@ -143,11 +144,14 @@
    }
    else
    {
-   		// This is called for the small version (PanelApplet)
-   		// Bad. With the current design, users will not see recordable devices, e.g. \
                PCM, CD, ...
-   		// This is because "Output" currently means: "can be recorded"
-      m_oWidget = new QHBox( this, "OutputTab" );
-      m_appletLayout = new QHBoxLayout( this, 0, 0 );
+      if ( m_direction == KPanelApplet::Left || m_direction == KPanelApplet::Right ) \
{ +	m_oWidget = new QVBox( this, "OutputTab" );
+        m_appletLayout = new QVBoxLayout( this, 0, 0 );
+      }
+      else {
+	m_oWidget = new QHBox( this, "OutputTab" );
+	m_appletLayout = new QHBoxLayout( this, 0, 0 );
+      }
       m_appletLayout->add( m_oWidget );
 		createDeviceWidgets();
    }
Index: kmixerwidget.h
===================================================================
RCS file: /home/kde/kdemultimedia/kmix/kmixerwidget.h,v
retrieving revision 1.28
diff -u -r1.28 kmixerwidget.h
--- kmixerwidget.h	12 Oct 2003 15:53:08 -0000	1.28
+++ kmixerwidget.h	1 Dec 2003 22:31:31 -0000
@@ -119,7 +119,7 @@
    QSlider *m_balanceSlider;
    QWidget *m_swWidget;
    QVBoxLayout *m_topLayout;
-   QHBoxLayout *m_appletLayout;
+   QBoxLayout *m_appletLayout;
    QWidget *m_iWidget;
    QWidget *m_oWidget;
    QGridLayout *m_devSwitchLayout;



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic