Commit 9316d47f authored by Isa's avatar Isa Committed by Andreas Traczyk

fix: allow user to select input/output device and maintain persistency

Change-Id: Iaa3349619d034fc21770c2445358b20c594bf5bc
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent fc33a49c
......@@ -839,30 +839,26 @@ SettingsWidget::populateAVSettings()
connect(deviceModel_, SIGNAL(currentIndexChanged(int)),
this, SLOT(deviceIndexChanged(int)));
if (ui->deviceBox->count() > 0) {
deviceBoxCurrentIndexChangedSlot(0);
}
if (currentResIndex >= 0) {
ui->sizeBox->setCurrentIndex(currentResIndex);
}
// Audio settings
auto inputModel = Audio::Settings::instance().inputDeviceModel();
auto outputModel = Audio::Settings::instance().outputDeviceModel();
ui->outputComboBox->setModel(outputModel);
ui->inputComboBox->setModel(inputModel);
if (ui->outputComboBox->count() > 0) {
ui->outputComboBox->setCurrentIndex(0);
}
if (ui->inputComboBox->count() > 0) {
ui->inputComboBox->setCurrentIndex(0);
}
ui->outputComboBox->setModel(outputModel);
isLoading_ = true;
auto inputIndex = inputModel->selectionModel()->currentIndex();
auto outputIndex = outputModel->selectionModel()->currentIndex();
showPreview();
ui->inputComboBox->setCurrentIndex(inputIndex.row());
ui->outputComboBox->setCurrentIndex(outputIndex.row());
if (ui->deviceBox->count() > 0) {
deviceBoxCurrentIndexChangedSlot(0);
}
if (currentResIndex >= 0) {
ui->sizeBox->setCurrentIndex(currentResIndex);
}
connect(ui->outputComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsWidget::outputDevIndexChangedSlot);
......@@ -873,6 +869,8 @@ SettingsWidget::populateAVSettings()
&SettingsWidget::deviceBoxCurrentIndexChangedSlot);
connect(ui->sizeBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&SettingsWidget::sizeBoxCurrentIndexChangedSlot);
showPreview();
}
......@@ -903,14 +901,12 @@ SettingsWidget::deviceBoxCurrentIndexChangedSlot(int index)
return;
}
if (!isLoading_)
deviceModel_->setActive(index);
deviceModel_->setActive(index);
auto device = deviceModel_->activeDevice();
ui->sizeBox->clear();
isLoading_ = true;
if (device->channelList().size() > 0) {
for (auto resolution : device->channelList()[0]->validResolutions()) {
ui->sizeBox->addItem(resolution->name());
......@@ -918,17 +914,22 @@ SettingsWidget::deviceBoxCurrentIndexChangedSlot(int index)
}
ui->sizeBox->setCurrentIndex(
device->channelList()[0]->activeResolution()->relativeIndex());
isLoading_ = false;
}
void
SettingsWidget::sizeBoxCurrentIndexChangedSlot(int index)
{
auto device = deviceModel_->activeDevice();
if (index < 0) {
return;
}
if (index < 0) return;
auto device = deviceModel_->activeDevice();
device->channelList()[0]->setActiveResolution(device->channelList()[0]->validResolutions()[index]);
QTimer::singleShot(200, this, [this]() {
deviceModel_->setActive(ui->deviceBox->currentIndex());
});
}
void
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment