summaryrefslogtreecommitdiff
path: root/src/ui/alsa/alsapopup.cpp
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2026-05-22 10:16:15 -0400
committerCalvin Morrison <calvin@pobox.com>2026-05-22 10:16:15 -0400
commitcdf72828e599a63fca4a0f1ceeb3145fba581aa3 (patch)
tree16ee02f0ce1e317a09fd4c2a3f9fbdc04aadfe60 /src/ui/alsa/alsapopup.cpp
parentb30b234afa3ec18156e432b9f2a7ad2ca80cc672 (diff)
parentd9876849f0208291cc7010522e85593703ff52bd (diff)
Merge branch 'and-the-oss-you-rode-in-on'
Diffstat (limited to 'src/ui/alsa/alsapopup.cpp')
-rw-r--r--src/ui/alsa/alsapopup.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/ui/alsa/alsapopup.cpp b/src/ui/alsa/alsapopup.cpp
new file mode 100644
index 0000000..0a6269d
--- /dev/null
+++ b/src/ui/alsa/alsapopup.cpp
@@ -0,0 +1,79 @@
+#include "alsapopup.h"
+#include "alsadevicewidget.h"
+#include "../../model/alsamodel.h"
+#include "../../model/alsadevice.h"
+
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqapplication.h>
+#include <tqdesktopwidget.h>
+#include <twin.h>
+#include <tdelocale.h>
+
+AlsaPopup::AlsaPopup( AlsaModel *model, TQWidget *parent )
+ : TQWidget( parent, "AlsaPopup",
+ WStyle_Customize | WType_Popup | WStyle_DialogBorder ),
+ m_model(model), m_container(0), m_widget(0)
+{
+ TQVBoxLayout *outer = new TQVBoxLayout( this, 4, 0 );
+ m_container = new TQWidget( this );
+ outer->addWidget( m_container );
+
+ connect( model, TQ_SIGNAL(deviceAdded(AlsaDevice*)), this, TQ_SLOT(rebuild()) );
+ connect( model, TQ_SIGNAL(preferredOutputChanged(AlsaDevice*)), this, TQ_SLOT(rebuild()) );
+
+ rebuild();
+}
+
+void AlsaPopup::rebuild()
+{
+ delete m_container->layout();
+ if ( m_widget ) { delete m_widget; m_widget = 0; }
+
+ TQVBoxLayout *vbox = new TQVBoxLayout( m_container, 4, 0 );
+ AlsaDevice *dev = m_model->preferredOutput();
+ if ( dev ) {
+ m_widget = new AlsaDeviceWidget( dev, m_container );
+ vbox->addWidget( m_widget );
+ m_widget->show();
+ } else {
+ vbox->addWidget( new TQLabel( i18n("No output device."), m_container ) );
+ }
+
+ if ( isVisible() )
+ adjustSize();
+}
+
+void AlsaPopup::toggleAt( const TQPoint &trayPos, const TQSize &traySize )
+{
+ if ( isVisible() ) { hide(); return; }
+
+ rebuild();
+ adjustSize();
+
+ TQRect screen = TQApplication::desktop()->screenGeometry( trayPos );
+ int x = trayPos.x() + traySize.width() / 2 - width() / 2;
+ int y = trayPos.y() - height();
+ if ( y < screen.top() ) y = trayPos.y() + traySize.height();
+ if ( x + width() > screen.right() ) x = screen.right() - width();
+ if ( x < screen.left() ) x = screen.left();
+
+ move( x, y );
+ show();
+
+ KWin::setState( winId(), NET::KeepAbove | NET::SkipTaskbar | NET::SkipPager );
+ KWin::setOnAllDesktops( winId(), true );
+}
+
+bool AlsaPopup::justHidden() const
+{
+ return m_hideTime.isValid() && m_hideTime.elapsed() < 100;
+}
+
+void AlsaPopup::hideEvent( TQHideEvent *e )
+{
+ TQWidget::hideEvent( e );
+ m_hideTime.start();
+}
+
+#include "alsapopup.moc"