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

List:       kde-core-devel
Subject:    Re: PATCH - Disable All Sounds button in System Notifications
From:       Neil Stevens <neil () qualityassistant ! com>
Date:       2002-01-30 1:38:57
[Download RAW message or body]

On Tuesday January 29, 2002 04:25, Waldo Bastian wrote:
> On Tuesday 29 January 2002 04:03 pm, Neil Stevens wrote:
> > > Not sure what would be better though.. maybe a checkbox?
> >
> > Wouldn't it be confusing, though, to have sounds checked on as well as
> > a box saying no sounds?  The UI would just be contradicting itself.
>
> Hm.. what about changing the text on the pushbutton then? So that we
> toggle between "disable all sounds" and "enable all sounds"?
>
> That would solve both problems nicely. We can check for
> !event->soundfile.isEmpty() to decide which sounds should be part of
> "all sounds".

I like that idea.  Here's the second patch attempt using that idea.

-- 
Neil Stevens
neil@qualityassistant.com

Don't think of a bug as a problem.  Think of it as a call to action.

["disablesoundspatch2" (text/x-diff)]

Index: knotify.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/knotify/knotify.cpp,v
retrieving revision 1.51
diff -u -r1.51 knotify.cpp
--- knotify.cpp	2002/01/25 09:49:55	1.51
+++ knotify.cpp	2002/01/30 01:36:28
@@ -110,6 +110,9 @@
     connect( volumeSlider, SIGNAL( valueChanged( int ) ), SLOT( changed() ) );
     l->setBuddy( volumeSlider );
 
+    soundButton = new QPushButton( box );
+    // this is configured in updateView
+
     m_events = new Events();
     qApp->processEvents(); // let's show up
 
@@ -135,6 +138,7 @@
     QListViewItem *appItem = 0L;
     KNListViewItem *eItem  = 0L;
     KNEvent *e;
+    bool soundsDisabled = true;
 
     QPixmap icon = SmallIcon("idea");
 
@@ -146,6 +150,8 @@
 
 	KNEventListIterator it2( *(*it)->eventList() );
 	while( (e = it2.current()) ) {
+	    if(e->presentation & KNotifyClient::Sound) soundsDisabled = false;
+
 	    eItem = new KNListViewItem( appItem, eItem, e );
 	    eItem->setPixmap( 0, icon );
 
@@ -156,6 +162,18 @@
 	++it;
     }
     updating = save_updating;
+
+	soundButton->disconnect(this);
+	if(soundsDisabled)
+	{
+		soundButton->setText( i18n("&Enable All Sounds") );
+		connect(soundButton, SIGNAL(clicked()), this, SLOT(enableAllSounds()));
+	}
+	else
+	{
+		soundButton->setText( i18n("&Disable All Sounds") );
+		connect(soundButton, SIGNAL(clicked()), this, SLOT(disableAllSounds()));
+	}
 }
 
 
@@ -358,7 +376,32 @@
     }
 }
 
+void KNotifyWidget::disableAllSounds()
+{
+	for(KNApplicationListIterator app(m_events->apps()); app.current(); ++app)
+	{
+		for(KNEventListIterator event(*(*app)->eventList()); event.current(); ++event)
+		{
+			(*event)->presentation &= ~KNotifyClient::Sound;
+		}
+	}
+	updateView();
+	changed();
+}
 
+void KNotifyWidget::enableAllSounds()
+{
+	for(KNApplicationListIterator app(m_events->apps()); app.current(); ++app)
+	{
+		for(KNEventListIterator event(*(*app)->eventList()); event.current(); ++event)
+		{
+			if(!(*event)->soundfile.isNull())
+				(*event)->presentation |= KNotifyClient::Sound;
+		}
+	}
+	updateView();
+	changed();
+}
 ///////////////////////////////////////////////////////////////////
 
 /**
Index: knotify.h
===================================================================
RCS file: /home/kde/kdebase/kcontrol/knotify/knotify.h,v
retrieving revision 1.19
diff -u -r1.19 knotify.h
--- knotify.h	2001/12/28 02:29:07	1.19
+++ knotify.h	2002/01/30 01:36:28
@@ -55,6 +55,8 @@
 
 public slots:
     virtual void load();
+    void disableAllSounds();
+    void enableAllSounds();
 
 private slots:
     void slotRequesterClicked( KURLRequester * );
@@ -71,7 +73,7 @@
     QCheckBox *cbExternal;
     QListView *view;
     KURLRequester *requester, *reqExternal;
-    QPushButton *playButton;
+    QPushButton *playButton, *soundButton;
     QSlider *volumeSlider;
     Events *m_events;
     KNCheckListItem *currentItem;


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

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