diff options
Diffstat (limited to 'src/ui/mixerwindow.cpp')
| -rw-r--r-- | src/ui/mixerwindow.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/src/ui/mixerwindow.cpp b/src/ui/mixerwindow.cpp index d8463f1..12a6666 100644 --- a/src/ui/mixerwindow.cpp +++ b/src/ui/mixerwindow.cpp @@ -4,6 +4,7 @@ #include "../model/pulsemodel.h" #include <tqlayout.h> +#include <tqlabel.h> #include <tqscrollview.h> #include <tqwidgetstack.h> #include <tqtoolbutton.h> @@ -54,7 +55,8 @@ static MixerWindow::Tab makeTab( KTabWidget *tabs, const TQString &label ) MixerWindow::MixerWindow( PulseModel *model, TQWidget *parent ) : TDEMainWindow(parent), m_model(model), m_prefsDlg(0), - m_devicesBtn(0), m_devicesPage(0), m_devicesInTabs(false), m_quitting(false) + m_devicesBtn(0), m_devicesPage(0), m_devicesInTabs(false), + m_quitting(false), m_totalDevCount(0), m_waitLabel(0) { setPlainCaption( i18n("Volume Control") ); setIcon( TDEGlobal::iconLoader()->loadIcon( "kmix", TDEIcon::Desktop, 48 ) ); @@ -82,7 +84,7 @@ MixerWindow::MixerWindow( PulseModel *model, TQWidget *parent ) onDefaultOutputChanged( model->defaultOutput() ); TDEConfig *cfg = TDEGlobal::config(); - cfg->setGroup("General"); + cfg->setGroup("Tray"); if ( cfg->readBoolEntry("DockInTray", true) ) m_tray->show(); @@ -93,14 +95,23 @@ MixerWindow::MixerWindow( PulseModel *model, TQWidget *parent ) TQVBoxLayout *top = new TQVBoxLayout( central, 0, 0 ); - // Outer stack: page 0 = mixer content, page 1 = devices (no-tab mode only) + // Outer stack: page 0 = mixer, page 1 = devices (no-tab mode), page 2 = waiting m_outerStack = new TQWidgetStack( central ); top->addWidget( m_outerStack, 1 ); TQWidget *mixerPage = new TQWidget( m_outerStack ); TQVBoxLayout *mixerLayout = new TQVBoxLayout( mixerPage, 0, 0 ); m_outerStack->addWidget( mixerPage, 0 ); - m_outerStack->raiseWidget( 0 ); + + // Page 2: shown when PA is not yet connected / no devices present + TQWidget *waitPage = new TQWidget( m_outerStack ); + TQVBoxLayout *waitLayout = new TQVBoxLayout( waitPage, 0, 0 ); + m_waitLabel = new TQLabel( i18n("Waiting for PulseAudio to start..."), waitPage ); + m_waitLabel->setAlignment( Qt::AlignCenter ); + waitLayout->addWidget( m_waitLabel ); + m_outerStack->addWidget( waitPage, 2 ); + + m_outerStack->raiseWidget( 2 ); // start on waiting page; switch to 0 on first device m_stack = new TQWidgetStack( mixerPage ); mixerLayout->addWidget( m_stack ); @@ -189,7 +200,7 @@ bool MixerWindow::queryClose() if ( m_quitting || tdeApp->sessionSaving() ) return true; TDEConfig *cfg = TDEGlobal::config(); - cfg->setGroup("General"); + cfg->setGroup("Tray"); if ( cfg->readBoolEntry("DockInTray", true) ) { saveMainWindowSettings( TDEGlobal::config(), "MainWindow" ); TDEConfig *c = TDEGlobal::config(); @@ -200,6 +211,21 @@ bool MixerWindow::queryClose() hide(); return false; } + // Not in systray — show confirm if needed, then let TDE close the window + // normally (returning true). TDE quits the app when the last main window closes. + TDEConfig *gcfg = TDEGlobal::config(); + gcfg->setGroup("General"); + if ( gcfg->readBoolEntry("ConfirmQuit", false) ) { + int r = KMessageBox::questionYesNo( + this, + i18n("Are you sure you want to quit TMix?"), + i18n("Quit TMix"), + KStdGuiItem::quit(), + KStdGuiItem::cancel() ); + if ( r != KMessageBox::Yes ) + return false; + } + m_quitting = true; return true; } @@ -249,6 +275,10 @@ static void updateSeparators( TQHBoxLayout *layout ) void MixerWindow::onDeviceAdded( AudioDevice *dev ) { + if ( m_totalDevCount == 0 ) + m_outerStack->raiseWidget( 0 ); + m_totalDevCount++; + if ( m_stack->id( m_stack->visibleWidget() ) == 1 ) { TQWidget *w = dev->createWidget( m_allStrip ); m_allLayout->insertWidget( m_allCount, w ); @@ -291,6 +321,9 @@ void MixerWindow::onDeviceRemoved( AudioDevice *dev ) delete w; updateSeparators( t.layout ); } + m_totalDevCount--; + if ( m_totalDevCount == 0 ) + m_outerStack->raiseWidget( 2 ); } @@ -381,7 +414,7 @@ void MixerWindow::applySettings() { TDEConfig *cfg = TDEGlobal::config(); - cfg->setGroup("General"); + cfg->setGroup("Tray"); if ( cfg->readBoolEntry("DockInTray", true) ) m_tray->show(); else @@ -398,6 +431,7 @@ void MixerWindow::applySettings() m_tabs->setTabEnabled( m_playback.scroll, cfg->readBoolEntry("ShowPlayback", true) ); m_tabs->setTabEnabled( m_recording.scroll, cfg->readBoolEntry("ShowRecording", true) ); } + emit settingsChanged(); } void MixerWindow::toggleDevices() |
