summaryrefslogtreecommitdiff
path: root/src/ui/tmixtray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/tmixtray.cpp')
-rw-r--r--src/ui/tmixtray.cpp104
1 files changed, 84 insertions, 20 deletions
diff --git a/src/ui/tmixtray.cpp b/src/ui/tmixtray.cpp
index c0980f0..4048270 100644
--- a/src/ui/tmixtray.cpp
+++ b/src/ui/tmixtray.cpp
@@ -1,5 +1,24 @@
#include "tmixtray.h"
#include "tmixpopup.h"
+#include "mixerwindow.h"
+
+class RecordingTray : public KSystemTray
+{
+public:
+ RecordingTray( TmixTray *owner, TQWidget *parent )
+ : KSystemTray(parent), m_owner(owner) {}
+protected:
+ void mousePressEvent( TQMouseEvent *e ) {
+ if ( e->button() == TQt::LeftButton ) {
+ m_owner->toggleRecordingPopup();
+ e->accept();
+ } else {
+ KSystemTray::mousePressEvent( e );
+ }
+ }
+private:
+ TmixTray *m_owner;
+};
#include "../model/audiodevice.h"
#include "../model/pulsemodel.h"
@@ -7,6 +26,7 @@
#include <tqpixmap.h>
#include <tqstringlist.h>
#include <tqtooltip.h>
+#include <tqapplication.h>
#include <tdeglobal.h>
#include <kiconloader.h>
#include <kstandarddirs.h>
@@ -16,7 +36,9 @@
TmixTray::TmixTray( TQWidget *parent )
: KSystemTray(parent), m_model(0), m_device(0), m_recTray(0),
- m_popup(0), m_recordingCount(0)
+ m_popup(0), m_recPopup(0), m_popupMode(-1),
+ m_popupShowOutput(false), m_popupShowMic(false), m_popupShowApps(false),
+ m_recordingCount(0)
{
setCaption( i18n("Volume Control") );
@@ -58,29 +80,49 @@ void TmixTray::mousePressEvent( TQMouseEvent *e )
{
if ( e->button() == TQt::LeftButton ) {
if ( !m_model ) { KSystemTray::mousePressEvent(e); return; }
-
- TDEConfig *cfg = TDEGlobal::config();
- cfg->setGroup("General");
- bool showPopup = cfg->readBoolEntry("ShowPopup", true);
-
- if ( showPopup ) {
- if ( !m_popup ) {
- m_popup = new TmixPopup( m_model, this );
- connect( m_popup, TQ_SIGNAL(showMixerRequested()),
- parentWidget(), TQ_SLOT(show()) );
- }
- if ( m_popup->justHidden() ) { e->accept(); return; }
- m_popup->toggleAt( mapToGlobal( TQPoint(0,0) ), size() );
- } else {
- TQWidget *win = parentWidget();
- win->isVisible() ? win->hide() : win->show();
- }
+ executeSingleClick();
e->accept();
return;
}
KSystemTray::mousePressEvent( e );
}
+
+void TmixTray::executeSingleClick()
+{
+ TDEConfig *cfg = TDEGlobal::config();
+ cfg->setGroup("General");
+ int mode = cfg->readNumEntry( "PopupMode", 1 );
+ bool showOutput = cfg->readBoolEntry("PopupShowOutput", true );
+ bool showMic = cfg->readBoolEntry("PopupShowMic", false );
+ bool showApps = cfg->readBoolEntry("PopupShowApps", true );
+
+ if ( mode >= 1 ) {
+ if ( m_popup && ( mode != m_popupMode ||
+ showOutput != m_popupShowOutput ||
+ showMic != m_popupShowMic ||
+ showApps != m_popupShowApps ) ) {
+ delete m_popup;
+ m_popup = 0;
+ }
+ if ( !m_popup ) {
+ m_popupMode = mode;
+ m_popupShowOutput = showOutput;
+ m_popupShowMic = showMic;
+ m_popupShowApps = showApps;
+ m_popup = new TmixPopup( m_model, showOutput, showMic, showApps, this );
+ }
+ if ( m_popup->justHidden() ) return;
+ m_popup->toggleAt( mapToGlobal( TQPoint(0,0) ), size() );
+ } else {
+ MixerWindow *win = static_cast<MixerWindow*>( parentWidget() );
+ if ( win->isVisible() )
+ win->hide();
+ else
+ win->bringToFront();
+ }
+}
+
void TmixTray::updateIcon()
{
int vol = m_device ? m_device->volume() : 0;
@@ -120,7 +162,7 @@ void TmixTray::updateRecordingTray()
if ( m_recordingCount > 0 && showRec ) {
if ( !m_recTray ) {
- m_recTray = new KSystemTray( parentWidget() );
+ m_recTray = new RecordingTray( this, parentWidget() );
m_recTray->setCaption( i18n("Microphone Active") );
TQString path = TDEGlobal::dirs()->findResource( "data",
@@ -148,9 +190,24 @@ void TmixTray::updateRecordingTray()
m_recTray->show();
} else if ( m_recTray ) {
m_recTray->hide();
+ if ( m_recPopup && m_recPopup->isVisible() )
+ m_recPopup->hide();
}
}
+void TmixTray::toggleRecordingPopup()
+{
+ if ( !m_model ) return;
+ if ( !m_recPopup )
+ m_recPopup = new TmixPopup( m_model,
+ false /*output*/, true /*mic*/,
+ false /*apps*/, true /*recording*/,
+ 0 );
+ if ( m_recPopup->justHidden() ) return;
+ TQPoint pos = m_recTray->mapToGlobal( TQPoint(0,0) );
+ m_recPopup->toggleAt( pos, m_recTray->size() );
+}
+
void TmixTray::wheelEvent( TQWheelEvent *e )
{
if ( !m_device ) return;
@@ -169,7 +226,14 @@ void TmixTray::contextMenuAboutToShow( TDEPopupMenu *menu )
while ( menu->count() > 1 )
menu->removeItemAt( 1 );
- TQWidget *win = parentWidget();
+ MixerWindow *win = static_cast<MixerWindow*>( parentWidget() );
+
+ TDEConfig *cfg = TDEGlobal::config();
+ cfg->setGroup("General");
+ if ( cfg->readNumEntry("PopupMode", 1) >= 1 )
+ menu->insertItem( SmallIcon("tmix"), i18n("&Open Mixer"),
+ win, TQ_SLOT(bringToFront()) );
+
menu->insertItem( SmallIcon("configure"), i18n("&Configure TMix..."),
win, TQ_SLOT(showPreferences()) );
menu->insertItem( SmallIcon("help"), i18n("&About TMix"),