summaryrefslogtreecommitdiff
path: root/src/ui/oss
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2026-05-24 14:45:24 -0400
committerCalvin Morrison <calvin@pobox.com>2026-05-24 14:45:24 -0400
commitff020f03a29dd26bda0b891c562226fa7a61eb19 (patch)
tree2152d68b222dfc654e55a2add1860cbc6e8e5bdf /src/ui/oss
parent71d01139cf2ac4380c2ee13ecdcff77eb1d42897 (diff)
show error page in OSS mixer window when backend fails to open
If /dev/mixer can't be opened (missing device, bad permissions, etc.) the window now shows the error reason instead of silently not appearing. The tray is also skipped in the error case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/ui/oss')
-rw-r--r--src/ui/oss/ossmixerwindow.cpp46
-rw-r--r--src/ui/oss/ossmixerwindow.h22
2 files changed, 49 insertions, 19 deletions
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;
};