Bug 79909 - [Patch] Make Slider in Mediacontrol Applet configurable
Summary: [Patch] Make Slider in Mediacontrol Applet configurable
Status: RESOLVED DUPLICATE of bug 90389
Alias: None
Product: mediacontrol
Classification: Unmaintained
Component: general (other bugs)
Version First Reported In: 0.3
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Stefan Gehn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-18 20:17 UTC by Christof Musik
Modified: 2005-11-15 14:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christof Musik 2004-04-18 20:17:23 UTC
Version:            (using KDE KDE 3.2.2)
Installed from:    Debian testing/unstable Packages
OS:          Linux

This Patch makes it possible to show and hide the time slider in the mediacontrol applet.

May be you can use it.

CU
Christof

diff -U3 -r /home/christof/mediacontrol.orig/configfrontend.cpp mediacontrol/configfrontend.cpp
--- /home/christof/mediacontrol.orig/configfrontend.cpp	2003-06-27 15:43:16.000000000 +0200
+++ mediacontrol/configfrontend.cpp	2004-03-12 16:30:52.000000000 +0100
@@ -94,4 +94,15 @@
 
 // ====================================================================================
 
+bool ConfigFrontend::enableSlider() const
+{
+	return _config->readBoolEntry("EnableSlider", true);
+}
+
+void ConfigFrontend::setEnableSlider( const bool use )
+{
+	_config->writeEntry("EnableSlider", use);
+	_config->sync();
+}
+
 #include "configfrontend.moc"
diff -U3 -r /home/christof/mediacontrol.orig/configfrontend.h mediacontrol/configfrontend.h
--- /home/christof/mediacontrol.orig/configfrontend.h	2002-05-14 13:56:39.000000000 +0200
+++ mediacontrol/configfrontend.h	2004-03-12 16:31:44.000000000 +0100
@@ -36,12 +36,14 @@
 		QString player() const;
 		QString theme() const;
 		bool useCustomTheme() const;
+		bool enableSlider() const;
 
 	public slots:
 		void setMouseWheelSpeed(const uint);
 		void setPlayer(const QString &player);
 		void setTheme(const QString &theme);
 		void setUseCustomTheme(const bool use);
+		void setEnableSlider(const bool use);
 		void reparseConfiguration() { _config->reparseConfiguration(); }
 
 	private:
Nur in mediacontrol/: .deps.
Nur in mediacontrol/: Makefile.
diff -U3 -r /home/christof/mediacontrol.orig/mediacontrolconfig.cpp mediacontrol/mediacontrolconfig.cpp
--- /home/christof/mediacontrol.orig/mediacontrolconfig.cpp	2003-06-03 09:39:43.000000000 +0200
+++ mediacontrol/mediacontrolconfig.cpp	2004-03-12 16:35:07.000000000 +0100
@@ -74,6 +74,8 @@
 	connect(_child->themeListBox, SIGNAL(selectionChanged(QListBoxItem *)), SLOT(slotChangePreview(QListBoxItem *)));
 	connect(_child->mUseThemes, SIGNAL(toggled(bool)), SLOT(slotConfigChanged()) );
 	connect(_child->mUseThemes, SIGNAL(toggled(bool)), SLOT(slotUseThemesToggled(bool)) );
+	connect(_child->enableSliderCheckbox, SIGNAL(toggled(bool)), SLOT(slotConfigChanged()) );
+	connect(_child->enableSliderCheckbox, SIGNAL(toggled(bool)), SLOT(slotEnableSliderToggled(bool)) );
 
 	load();
 	show();
@@ -128,6 +130,10 @@
 	bool ison = _configFrontend->useCustomTheme();
 	_child->mUseThemes->setChecked( ison );
 	slotUseThemesToggled( ison );
+
+	ison = _configFrontend->enableSlider();
+	_child->enableSliderCheckbox->setChecked( ison );
+	slotEnableSliderToggled( ison );
 }
 
 void MediaControlConfig::save()
@@ -152,6 +158,7 @@
 	}
 
 	_configFrontend->setUseCustomTheme( _child->mUseThemes->isChecked() );
+	_configFrontend->setEnableSlider( _child->enableSliderCheckbox->isChecked() );
 
 	emit configChanged();
 }
@@ -193,3 +200,9 @@
 	_child->themeListBox->setEnabled(on);
 	_child->previewGroupBox->setEnabled(on);
 }
+
+void MediaControlConfig::slotEnableSliderToggled ( bool on )
+{
+	_child->mWheelScrollAmount->setEnabled(on);
+}
+
diff -U3 -r /home/christof/mediacontrol.orig/mediacontrolconfig.h mediacontrol/mediacontrolconfig.h
--- /home/christof/mediacontrol.orig/mediacontrolconfig.h	2002-09-06 22:21:20.000000000 +0200
+++ mediacontrol/mediacontrolconfig.h	2004-03-12 16:16:15.000000000 +0100
@@ -45,6 +45,7 @@
 		void slotConfigChanged();
 		void slotChangePreview( QListBoxItem *item );
 		void slotUseThemesToggled( bool );
+		void slotEnableSliderToggled ( bool );
 		virtual void slotApply();
 		virtual void slotOk();
 		virtual void slotCancel();
diff -U3 -r /home/christof/mediacontrol.orig/mediacontrolconfigwidget.ui mediacontrol/mediacontrolconfigwidget.ui
--- /home/christof/mediacontrol.orig/mediacontrolconfigwidget.ui	2004-02-28 10:41:31.000000000 +0100
+++ mediacontrol/mediacontrolconfigwidget.ui	2004-03-12 15:54:23.000000000 +0100
@@ -10,8 +10,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>318</width>
-            <height>245</height>
+            <width>342</width>
+            <height>221</height>
         </rect>
     </property>
     <property name="caption">
@@ -52,7 +52,7 @@
                     <property name="name">
                         <cstring>unnamed</cstring>
                     </property>
-                    <widget class="QGroupBox" row="0" column="0">
+                    <widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="2">
                         <property name="name">
                             <cstring>gbMediaPlayer</cstring>
                         </property>
@@ -73,7 +73,7 @@
                             </widget>
                         </grid>
                     </widget>
-                    <widget class="QLayoutWidget" row="1" column="0">
+                    <widget class="QLayoutWidget" row="1" column="1">
                         <property name="name">
                             <cstring>Layout5</cstring>
                         </property>
@@ -102,6 +102,14 @@
                             </widget>
                         </hbox>
                     </widget>
+                    <widget class="QCheckBox" row="1" column="0">
+                        <property name="name">
+                            <cstring>enableSliderCheckbox</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Enable Slider</string>
+                        </property>
+                    </widget>
                 </grid>
             </widget>
             <widget class="QWidget">
Nur in mediacontrol/: mediacontrolconfigwidget.ui~.
diff -U3 -r /home/christof/mediacontrol.orig/mediacontrol.cpp mediacontrol/mediacontrol.cpp
--- /home/christof/mediacontrol.orig/mediacontrol.cpp	2003-11-30 10:40:39.000000000 +0100
+++ mediacontrol/mediacontrol.cpp	2004-03-13 17:59:52.000000000 +0100
@@ -43,6 +43,8 @@
 #include <kprocess.h>
 #include <dcopclient.h>
 
+#include <iostream>
+
 #define MC_BUTTONSIZE 18 // TODO: Might become dynamical for bigger panels
 
 extern "C"
@@ -91,16 +93,19 @@
 	_dcopClient->registerAs("mediacontrol", false);
 
 	setAcceptDrops(true);
+	//showSlider = true;
 
 	prev_button  = new TrayButton ( this, "PREVIOUS" );
 	play_button  = new TrayButton ( this, "PLAY" );
 	pause_button = new TrayButton ( this, "PAUSE" );
 	stop_button  = new TrayButton ( this, "STOP" );
 	next_button  = new TrayButton ( this, "NEXT" );
-	time_slider  = new QSlider (QSlider::Horizontal, this, "time_slider" );
-	time_slider->setRange(0,0);
-	time_slider->setValue(0);
-	time_slider->setTracking( false );
+	if (showSlider) {
+		time_slider  = new QSlider (QSlider::Horizontal, this, "time_slider" );
+		time_slider->setRange(0,0);
+		time_slider->setValue(0);
+		time_slider->setTracking( false );
+	}
 
 	// request notification of changes in icon style
 	kapp->addKipcEventMask(KIPC::IconChanged);
@@ -138,19 +143,21 @@
 
 void MediaControl::setSliderPosition(int len ,int time)
 {
-	time_slider->blockSignals ( true );
-	if( orientation() == Vertical)
-	  time = len - time;
-
-	if ( lastLen != len )
-	  time_slider->setRange(0,len);
-	lastLen = len;
-
-	if ( lastTime != time )
-	  time_slider->setValue ( time );
-	lastTime = time;
+	if (showSlider) {
+		time_slider->blockSignals ( true );
+		if( orientation() == Vertical)
+			time = len - time;
+
+		if ( lastLen != len )
+			time_slider->setRange(0,len);
+		lastLen = len;
+
+		if ( lastTime != time )
+			time_slider->setValue ( time );
+		lastTime = time;
 
-	time_slider->blockSignals ( false );
+		time_slider->blockSignals ( false );
+	}
 }
 
 void MediaControl::enableAll(void)
@@ -160,7 +167,7 @@
 	pause_button->setDisabled(false);
 	stop_button->setDisabled(false);
 	next_button->setDisabled(false);
-	time_slider->setDisabled(false);
+	if (showSlider) time_slider->setDisabled(false);
 }
 
 void MediaControl::disableAll(void)
@@ -170,7 +177,7 @@
 	pause_button->setDisabled(true);
 	stop_button->setDisabled(true);
 	next_button->setDisabled(true);
-	time_slider->setDisabled(true);
+	if (showSlider) time_slider->setDisabled(true);
 }
 
 void MediaControl::slotIconChanged()
@@ -263,7 +270,7 @@
 	{
 		_player->disconnect();	// disconnect from all things
 
-		time_slider->disconnect();
+		if (showSlider) time_slider->disconnect();
 		prev_button->disconnect();
 		play_button->disconnect();
 		pause_button->disconnect();
@@ -281,13 +288,36 @@
 	lastTime = -1;
 
 	QString playerString = _configFrontend->player();
+	showSlider = _configFrontend->enableSlider();
+
+	if (!showSlider) { 
+		if (time_slider != 0L) 
+		{
+			time_slider->disconnect();
+			delete slider_tooltip;
+			delete time_slider;
+		}
+	}
+	else 
+	{
+		if (orientation() == Vertical)
+			time_slider = new QSlider (QSlider::Vertical, this, "time_slider" );
+		else
+			time_slider = new QSlider (QSlider::Horizontal, this, "time_slider" );
+
+		time_slider->show();
+		time_slider->setRange(0,0);
+		time_slider->setValue(0);
+		time_slider->setTracking( false );
 
+		resizeEvent(0L);
+	}
 #ifdef HAVE_XMMS
 	if ( playerString == "XMMS" )
 	{
 //		kdDebug() << "player = XMMS" << endl;
 		_player = new XmmsInterface ();
-		time_slider->setSteps((_configFrontend->mouseWheelSpeed()*1000),
+		if (showSlider) time_slider->setSteps((_configFrontend->mouseWheelSpeed()*1000),
 			(_configFrontend->mouseWheelSpeed()*1000));
 	}
 	// player is noatun or something wrong was written to the config
@@ -296,14 +326,14 @@
         {
 //		kdDebug() << "player = Noatun" << endl;
 		_player = new NoatunInterface();
-		time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
+		if (showSlider) time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
 			(_configFrontend->mouseWheelSpeed()));
 	}
         if ( playerString == "JuK")
         {
                 kdDebug() << "player = JuK" << endl;
                 _player = new JuKInterface();
-		time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
+		if (showSlider) time_slider->setSteps((_configFrontend->mouseWheelSpeed()),
 			(_configFrontend->mouseWheelSpeed()));
         }
 
@@ -330,7 +360,7 @@
 		}
 		else // icon-theme is invalid or not there
 		{
-			KNotifyClient::event("warning",
+			KNotifyClient::event(winId(), "warning",
 				i18n("There was trouble loading theme %1. Please choose a different theme.").arg(skindir));
 
 			// default to kde-icons, they have to be installed :)
@@ -346,7 +376,7 @@
 		slotIconChanged();
 	}
 
-	slider_tooltip = new MediaControlToolTip(time_slider, _player);
+	if (showSlider) slider_tooltip = new MediaControlToolTip(time_slider, _player);
 
 	connect(prev_button, SIGNAL(clicked()), _player, SLOT(prev()));
 	connect(play_button, SIGNAL(clicked()), _player, SLOT(play()));
@@ -354,10 +384,12 @@
 	connect(stop_button, SIGNAL(clicked()), _player, SLOT(stop()));
 	connect(next_button, SIGNAL(clicked()), _player, SLOT(next()));
 
-	connect(time_slider, SIGNAL(sliderPressed()), _player, SLOT(sliderStartDrag()));
-	connect(time_slider, SIGNAL(sliderReleased()), _player, SLOT(sliderStopDrag()));
-	connect(time_slider, SIGNAL(valueChanged(int)), this, SLOT(adjustTime(int)));
-	connect(this, SIGNAL(newJumpToTime(int)), _player, SLOT(jumpToTime(int)));
+	if (showSlider) {
+		connect(time_slider, SIGNAL(sliderPressed()), _player, SLOT(sliderStartDrag()));
+		connect(time_slider, SIGNAL(sliderReleased()), _player, SLOT(sliderStopDrag()));
+		connect(time_slider, SIGNAL(valueChanged(int)), this, SLOT(adjustTime(int)));
+		connect(this, SIGNAL(newJumpToTime(int)), _player, SLOT(jumpToTime(int)));
+	}
 }
 
 // Widget Placement ===================================================================
@@ -370,7 +402,9 @@
 //	kdDebug() << "slider needs: " << time_slider->minimumSizeHint().height() << endl;
 
 	// slider height + button height
-	if ( height >= (time_slider->minimumSizeHint().height()+MC_BUTTONSIZE) )
+	int size = MC_BUTTONSIZE;
+	if (showSlider) size += time_slider->minimumSizeHint().height();
+	if ( height >= size )
 	{	// slider UNDER buttons
 		// (5 * button width + spaces between them);
 		return (5*MC_BUTTONSIZE+10);
@@ -389,7 +423,9 @@
 //	kdDebug() << "kicker width: " << width << endl;
 
 	// slider height + button height
-	if ( width >= (time_slider->minimumSizeHint().width()+MC_BUTTONSIZE) )
+	int size = MC_BUTTONSIZE;
+	if (showSlider) size += time_slider->minimumSizeHint().width();
+	if ( width >= size )
 	{	// slider ASIDE icons
 		// (5 * button width + spaces between them);
 		return (5*MC_BUTTONSIZE+10);
@@ -415,10 +451,13 @@
 	int h = height();
 	if ( orientation() == Vertical )
 	{		// ====== VERTICAL =================================================
-		time_slider->setOrientation(QSlider::Vertical);
-		int slider_width = time_slider->minimumSizeHint().width();
-		// some styles need more space for sliders than avilable in very small panels :(
-		if ( slider_width > w ) slider_width = w;
+		int slider_width = 0;
+		if (showSlider) {
+			time_slider->setOrientation(QSlider::Vertical);
+			slider_width = time_slider->minimumSizeHint().width();
+			// some styles need more space for sliders than avilable in very small panels :(
+			if ( slider_width > w ) slider_width = w;
+		}
 
 		// that width would be needed to put the slider aside the buttons
 		if ( w >= (slider_width+MC_BUTTONSIZE) )
@@ -432,7 +471,7 @@
 			pause_button->setGeometry ( applet_space, 5+2*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			stop_button->setGeometry  ( applet_space, 7+3*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			next_button->setGeometry  ( applet_space, 9+4*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
-			time_slider->setGeometry  ( applet_space+MC_BUTTONSIZE, 1, slider_width, 5*MC_BUTTONSIZE+8 );
+			if (showSlider) time_slider->setGeometry  ( applet_space+MC_BUTTONSIZE, 1, slider_width, 5*MC_BUTTONSIZE+8 );
 		}
 		else
 		{	// Slider UNDER Icons
@@ -444,15 +483,18 @@
 			pause_button->setGeometry ( button_space, 5+2*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			stop_button->setGeometry  ( button_space, 7+3*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			next_button->setGeometry  ( button_space, 9+4*MC_BUTTONSIZE, MC_BUTTONSIZE, MC_BUTTONSIZE );
-			time_slider->setGeometry  ( slider_space, 11+5*MC_BUTTONSIZE, slider_width, 5*MC_BUTTONSIZE+8 );
+			if (showSlider) time_slider->setGeometry  ( slider_space, 11+5*MC_BUTTONSIZE, slider_width, 5*MC_BUTTONSIZE+8 );
 		}
 	}
 	else	// ====== HORIZONTAL ===============================================
 	{
-		time_slider->setOrientation(QSlider::Horizontal);
-		int slider_height = time_slider->minimumSizeHint().height();
-		// some styles need more space for sliders than avilable in very small panels :(
-		if ( slider_height > h ) slider_height = h;
+		int slider_height = 0;
+		if (showSlider) {
+			time_slider->setOrientation(QSlider::Horizontal);
+			slider_height = time_slider->minimumSizeHint().height();
+			// some styles need more space for sliders than avilable in very small panels :(
+			if ( slider_height > h ) slider_height = h;
+		}
 
 		// that h would be needed to put the slider under the buttons
 		if ( h >= (slider_height+MC_BUTTONSIZE) )
@@ -466,7 +508,7 @@
 			pause_button->setGeometry ( 5+2*MC_BUTTONSIZE, applet_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			stop_button->setGeometry  ( 7+3*MC_BUTTONSIZE, applet_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			next_button->setGeometry  ( 9+4*MC_BUTTONSIZE, applet_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
-			time_slider->setGeometry  ( 1, applet_space + MC_BUTTONSIZE, 5*MC_BUTTONSIZE+8, slider_height );
+			if (showSlider) time_slider->setGeometry  ( 1, applet_space + MC_BUTTONSIZE, 5*MC_BUTTONSIZE+8, slider_height );
 		}
 		else
 		{	// Slider ASIDE Icons
@@ -478,7 +520,7 @@
 			pause_button->setGeometry ( 5+2*MC_BUTTONSIZE, button_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			stop_button->setGeometry  ( 7+3*MC_BUTTONSIZE, button_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
 			next_button->setGeometry  ( 9+4*MC_BUTTONSIZE, button_space, MC_BUTTONSIZE, MC_BUTTONSIZE );
-			time_slider->setGeometry  ( 11+5*MC_BUTTONSIZE, slider_space, 5*MC_BUTTONSIZE+8, slider_height );
+			if (showSlider) time_slider->setGeometry  ( 11+5*MC_BUTTONSIZE, slider_space, 5*MC_BUTTONSIZE+8, slider_height );
 		}
 	}
 }
@@ -492,6 +534,8 @@
 
 	pbg.begin(&bg);
 	pbg.fillRect(rect(), colorGroup().brush(QColorGroup::Background));
+
+
 	if ( isDown() || isOn() )
 	{	// Draw shapes to indicate the down state.
 		pbg.setPen(Qt::black);
diff -U3 -r /home/christof/mediacontrol.orig/mediacontrol.h mediacontrol/mediacontrol.h
--- /home/christof/mediacontrol.orig/mediacontrol.h	2003-06-05 08:57:42.000000000 +0200
+++ mediacontrol/mediacontrol.h	2004-03-12 15:38:50.000000000 +0100
@@ -99,6 +99,7 @@
 		QSlider *time_slider;
 		int lastLen, lastTime;
 		QPopupMenu *rmbMenu;
+		bool showSlider;
 
 		virtual void mousePressEvent(QMouseEvent* e);
 		void resizeEvent(QResizeEvent*);
Nur in mediacontrol/pics/blueish: Makefile.
Nur in mediacontrol/pics/default: Makefile.
Nur in mediacontrol/pics: Makefile.
Comment 1 Marcin Orlowski 2004-09-28 12:45:33 UTC
Could you please expand your code and make each control button configurable? Since I need just play and pause buttons visible it'd be damn useful to have the ability to hide all the others (incl. slider). Thanks
Comment 2 Stefan Gehn 2005-07-03 15:46:32 UTC

*** This bug has been marked as a duplicate of 90389 ***
Comment 3 Martin Zbořil 2005-11-15 14:01:50 UTC
annoying mention: how this could be duplication when it is about five months older than <a href="http://bugs.kde.org/show_bug.cgi?id=90389">90389</a>?