summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp102
1 files changed, 72 insertions, 30 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9ae66d3..b35a8f9 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1,6 +1,11 @@
#include "mainwindow.h"
#include "slxoutput.h"
+#include <PulseAudioQt/Sink>
+#include <PulseAudioQt/Port>
+#include <PulseAudioQt/Card>
+#include <PulseAudioQt/Profile>
+
MainWindow::MainWindow() : QDialog()
{
setupUi(this);
@@ -12,43 +17,80 @@ MainWindow::~MainWindow()
}
-SlxOutput* MainWindow::getOutput(const QString &id, bool isSink, const QString &newTitle)
+SlxOutput* MainWindow::getDevice(const PulseAudioQt::Card *card, const PulseAudioQt::Sink *sink, const PulseAudioQt::Port *port)
+{
+ PulseAudioQt::Profile *profile = nullptr;
+ QString cardId;
+ QString id = sink->name() + port->name();
+ SlxOutput* w = _widgets.value(id, nullptr);
+ QString heading = port->description();
+
+ if (card != nullptr) {
+ cardId = card->name();
+ if (card->activeProfileIndex() < card->profiles().size()) {
+ profile = card->profiles().at(card->activeProfileIndex());
+ heading.append(QLatin1String(" (")).append(profile->description()).append(QLatin1String(")"));
+ }
+ }
+ if (w != nullptr) {
+ w->headingLabel->setText(heading);
+ return w;
+ }
+
+ w = new SlxOutput(SlxOutput::SinkPortItem, id, cardId, QLatin1String(), sink->name(), port->name(),
+ heading, sink->description());
+ _widgets.insert(id, w);
+
+ insertItemWidget(w, true);
+ return w;
+}
+
+SlxOutput* MainWindow::getCardProfile(const PulseAudioQt::Card *card, const PulseAudioQt::Profile *profile)
{
+
+ QString id = card->name() + profile->name();
SlxOutput* w = _widgets.value(id, nullptr);
- if (w == nullptr) {
- w = new SlxOutput(nullptr, id);
- _widgets.insert(id, w);
- bool done = false;
- printf("New %s - %s\n", isSink ? "SINK" : "PROF", newTitle.toLocal8Bit().constData());
- printf("Conteints: %d\n", container->count());
- int idx;
- for (idx = 0; idx < container->count(); ++idx) {
- auto *l = container->itemAt(idx);
- SlxOutput *other = qobject_cast<SlxOutput*>(l->widget());
- if (other == nullptr)
- continue;
- printf(" Comparing %s - %s\n", other->isSink() ? "SINK" : "PROF", other->nameLabel->text().toLocal8Bit().constData());
- if (isSink != other->isSink()) {
- if (isSink)
- break;
- continue;
- }
- if (newTitle.compare(other->nameLabel->text()) < 0) {
- done = true;
- printf("Inserting before that (%d)!\n", idx);
- container->insertWidget(idx, w);
+ if (w != nullptr)
+ return w;
+
+ w = new SlxOutput(SlxOutput::CardProfileItem, id, card->name(), profile->name(), QLatin1String(), QLatin1String(),
+ profile->description(), card->description());
+ _widgets.insert(id, w);
+
+ insertItemWidget(w, false);
+ return w;
+}
+
+void MainWindow::insertItemWidget(SlxOutput* w, bool isDevice)
+{
+ bool done = false;
+ int idx;
+
+ for (idx = 0; idx < container->count(); ++idx) {
+ auto *l = container->itemAt(idx);
+ SlxOutput *other = qobject_cast<SlxOutput*>(l->widget());
+ if (other == nullptr)
+ continue;
+ printf(" Comparing %s - %s\n", other->isDevice() ? "SINK" : "PROF", other->nameLabel->text().toLocal8Bit().constData());
+ if (isDevice != other->isDevice()) {
+ if (isDevice)
break;
- }
+ continue;
}
- if (!done) {
- if (idx == -1) {
- idx = 0;
- }
- printf("Inserting before that (%d) 2!\n", idx);
+ if (w->compareTo(other) < 0) {
+ done = true;
+ printf("Inserting before that (%d)!\n", idx);
container->insertWidget(idx, w);
+ break;
}
}
- return w;
+ if (!done) {
+ if (idx == -1) {
+ idx = 0;
+ }
+ printf("Inserting before that (%d) 2!\n", idx);
+ container->insertWidget(idx, w);
+ }
}
/**