diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/ossmodel.cpp | 15 | ||||
| -rw-r--r-- | src/model/ossmodel.h | 3 | ||||
| -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 |
5 files changed, 70 insertions, 28 deletions
diff --git a/src/model/ossmodel.cpp b/src/model/ossmodel.cpp index 35aa842..fb14c2c 100644 --- a/src/model/ossmodel.cpp +++ b/src/model/ossmodel.cpp @@ -4,6 +4,8 @@ #include <fcntl.h> #include <unistd.h> #include <stdio.h> +#include <errno.h> +#include <string.h> #include <tdeconfig.h> #include <tdeglobal.h> #include <tqtimer.h> @@ -34,7 +36,11 @@ bool OssModel::open() ::close(probe); openCard(i, TQString::fromLocal8Bit(path)); } - if ( m_devices.isEmpty() ) return false; + if ( m_devices.isEmpty() ) { + if ( m_lastError.isEmpty() ) + m_lastError = TQString("No OSS mixer devices found."); + return false; + } m_timer->start(500); emit ready(); return true; @@ -43,7 +49,12 @@ bool OssModel::open() void OssModel::openCard( int cardIdx, const TQString &path ) { int fd = ::open(path.local8Bit().data(), O_RDWR); - if ( fd < 0 ) return; + if ( fd < 0 ) { + if ( m_lastError.isEmpty() ) + m_lastError = path + ": " + TQString::fromLocal8Bit(strerror(errno)); + return; + } + m_lastError = TQString(); mixer_info info; TQString cardName; diff --git a/src/model/ossmodel.h b/src/model/ossmodel.h index 8c3db8b..0ab6b15 100644 --- a/src/model/ossmodel.h +++ b/src/model/ossmodel.h @@ -25,6 +25,8 @@ public: bool open(); void close(); + TQString lastError() const { return m_lastError; } + TQValueList<OssCard> cards() const { return m_cards; } TQPtrList<OssDevice> devices() const { return m_devices; } TQPtrList<OssDevice> devicesForCard( int cardIdx ) const; @@ -47,4 +49,5 @@ private: TQPtrList<OssDevice> m_devices; TQValueList<int> m_fds; // one open fd per card, owned here TQTimer *m_timer; + TQString m_lastError; }; 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; }; |
