diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/backendcontroller.cpp | 12 | ||||
| -rw-r--r-- | src/ui/oss/ossmixerwindow.cpp | 46 | ||||
| -rw-r--r-- | src/ui/oss/ossmixerwindow.h | 22 |
3 files changed, 54 insertions, 26 deletions
diff --git a/src/ui/backendcontroller.cpp b/src/ui/backendcontroller.cpp index e24b0e1..25716e0 100644 --- a/src/ui/backendcontroller.cpp +++ b/src/ui/backendcontroller.cpp @@ -130,25 +130,23 @@ void BackendController::startAlsa( bool showWindow ) void BackendController::startOss( bool showWindow ) { m_ossModel = new OssModel( this ); - if ( !m_ossModel->open() ) { - delete m_ossModel; - m_ossModel = 0; - return; - } + m_ossModel->open(); // window shows an error page if this fails + m_ossWin = new OssMixerWindow( m_ossModel ); connect( m_ossWin, TQ_SIGNAL(settingsChanged()), this, TQ_SLOT(onSettingsChanged()) ); static_cast<TmixApp*>(tdeApp)->setMainWindow( m_ossWin ); + bool hasError = !m_ossModel->lastError().isEmpty(); TDEConfig *cfg = TDEGlobal::config(); cfg->setGroup("Tray"); bool dockInTray = cfg->readBoolEntry("DockInTray", true); - if ( dockInTray ) { + if ( dockInTray && !hasError ) { m_ossTray = new OssTray( m_ossModel, m_ossWin, m_ossWin ); m_ossWin->setTray( m_ossTray ); m_ossTray->show(); } - if ( !dockInTray || showWindow ) + if ( !dockInTray || showWindow || hasError ) m_ossWin->show(); } #endif diff --git a/src/ui/oss/ossmixerwindow.cpp b/src/ui/oss/ossmixerwindow.cpp index e817e29..f8d8a74 100644 --- a/src/ui/oss/ossmixerwindow.cpp +++ b/src/ui/oss/ossmixerwindow.cpp @@ -9,6 +9,7 @@ #include <tqcombobox.h> #include <tqtabwidget.h> #include <tqlabel.h> +#include <tqwidgetstack.h> #include <tdeapplication.h> #include <tdelocale.h> #include <tdemenubar.h> @@ -22,26 +23,36 @@ OssMixerWindow::OssMixerWindow( OssModel *model, TQWidget *parent ) : TDEMainWindow(parent, "OssMixerWindow"), - m_model(model), m_tray(0), m_posRestored(false) + m_model(model), m_tray(0), m_posRestored(false), + m_outerStack(0), m_errorLabel(0), + m_cardCombo(0), m_tabs(0), m_outputPage(0), m_inputPage(0), + m_outputLayout(0), m_inputLayout(0) { m_widgets.setAutoDelete(true); setCaption(i18n("Volume Control")); TQWidget *central = new TQWidget(this); setCentralWidget(central); - TQVBoxLayout *vbox = new TQVBoxLayout(central, 8, 6); + TQVBoxLayout *vbox = new TQVBoxLayout(central, 0, 0); + + m_outerStack = new TQWidgetStack(central); + vbox->addWidget(m_outerStack, 1); + + // Page 0: normal mixer content + TQWidget *mixerPage = new TQWidget(m_outerStack); + TQVBoxLayout *mixerLayout = new TQVBoxLayout(mixerPage, 8, 6); TQHBoxLayout *topRow = new TQHBoxLayout(0, 0, 6); topRow->addStretch(); - topRow->addWidget(new TQLabel(i18n("Card:"), central)); - m_cardCombo = new TQComboBox(false, central); + topRow->addWidget(new TQLabel(i18n("Card:"), mixerPage)); + m_cardCombo = new TQComboBox(false, mixerPage); TQValueList<OssCard> cards = model->cards(); for ( TQValueListConstIterator<OssCard> it = cards.begin(); it != cards.end(); ++it ) m_cardCombo->insertItem((*it).name); topRow->addWidget(m_cardCombo); - vbox->addLayout(topRow); + mixerLayout->addLayout(topRow); - m_tabs = new TQTabWidget(central); + m_tabs = new TQTabWidget(mixerPage); m_outputPage = new TQWidget(m_tabs); m_outputLayout = new TQHBoxLayout(m_outputPage, 8, 6); @@ -51,10 +62,25 @@ OssMixerWindow::OssMixerWindow( OssModel *model, TQWidget *parent ) m_inputLayout = new TQHBoxLayout(m_inputPage, 8, 6); m_tabs->addTab(m_inputPage, i18n("Input")); - vbox->addWidget(m_tabs, 1); - - if ( !cards.isEmpty() ) - rebuildTabs(cards.front().index); + mixerLayout->addWidget(m_tabs, 1); + m_outerStack->addWidget(mixerPage, 0); + + // Page 1: error page + TQWidget *errorPage = new TQWidget(m_outerStack); + TQVBoxLayout *errorLayout = new TQVBoxLayout(errorPage, 8, 6); + m_errorLabel = new TQLabel(errorPage); + m_errorLabel->setAlignment(TQt::AlignCenter | TQt::WordBreak); + errorLayout->addWidget(m_errorLabel); + m_outerStack->addWidget(errorPage, 1); + + if ( model->lastError().isEmpty() ) { + m_outerStack->raiseWidget(0); + if ( !cards.isEmpty() ) + rebuildTabs(cards.front().index); + } else { + m_errorLabel->setText(i18n("Could not open OSS mixer:\n%1").arg(model->lastError())); + m_outerStack->raiseWidget(1); + } setMinimumSize(400, 250); diff --git a/src/ui/oss/ossmixerwindow.h b/src/ui/oss/ossmixerwindow.h index 220c0cd..0b9f087 100644 --- a/src/ui/oss/ossmixerwindow.h +++ b/src/ui/oss/ossmixerwindow.h @@ -10,6 +10,8 @@ class OssTray; class TQComboBox; class TQTabWidget; class TQHBoxLayout; +class TQLabel; +class TQWidgetStack; class TQWidget; class OssMixerWindow : public TDEMainWindow @@ -40,14 +42,16 @@ private slots: private: void rebuildTabs( int cardIdx ); - OssModel *m_model; - OssTray *m_tray; - bool m_posRestored; - TQComboBox *m_cardCombo; - TQTabWidget *m_tabs; - TQWidget *m_outputPage; - TQWidget *m_inputPage; - TQHBoxLayout *m_outputLayout; - TQHBoxLayout *m_inputLayout; + OssModel *m_model; + OssTray *m_tray; + bool m_posRestored; + TQWidgetStack *m_outerStack; + TQLabel *m_errorLabel; + TQComboBox *m_cardCombo; + TQTabWidget *m_tabs; + TQWidget *m_outputPage; + TQWidget *m_inputPage; + TQHBoxLayout *m_outputLayout; + TQHBoxLayout *m_inputLayout; TQPtrList<OssDeviceWidget> m_widgets; }; |
