From c7bff3f428940d35e85412597e57adda910621e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Thu, 4 Aug 2022 15:51:03 +0200 Subject: [PATCH] add refresh button to stream dialog --- src/streamdialog.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/streamdialog.cpp b/src/streamdialog.cpp index 89316e9..5a151fb 100644 --- a/src/streamdialog.cpp +++ b/src/streamdialog.cpp @@ -19,9 +19,19 @@ StreamDialog::StreamDialog() : QWidget() { targetLabel->setText("Which app do you want to stream sound from?"); layout->addWidget(targetLabel); + auto targetHBox = new QHBoxLayout(this); + layout->addLayout(targetHBox); + m_targetComboBox = new QComboBox(this); updateTargets(); - layout->addWidget(m_targetComboBox); + targetHBox->addWidget(m_targetComboBox); + + auto refreshTargetsButton = new QPushButton(this); + refreshTargetsButton->setFixedSize(30, 30); + refreshTargetsButton->setIcon(QIcon::fromTheme("view-refresh")); + connect(refreshTargetsButton, &QPushButton::clicked, this, + &StreamDialog::updateTargets); + targetHBox->addWidget(refreshTargetsButton); auto qualityLabel = new QLabel(this); qualityLabel->setText("Stream Quality"); @@ -70,11 +80,17 @@ void StreamDialog::startStream() { } void StreamDialog::updateTargets() { + auto lastTarget = m_targetComboBox->currentText(); + m_targetComboBox->clear(); m_targetComboBox->addItem("[None]"); m_targetComboBox->addItem("[All Desktop Audio]"); for (auto target : Virtmic::getTargets()) { m_targetComboBox->addItem(target); } - m_targetComboBox->setCurrentText("[All Desktop Audio]"); + + if (m_targetComboBox->findText(lastTarget) != -1) + m_targetComboBox->setCurrentText(lastTarget); + else + m_targetComboBox->setCurrentText("[All Desktop Audio]"); }