Commit 68f1c739 authored by Andreas Traczyk's avatar Andreas Traczyk

settings: better respond to lack of video devices

- prevents crash when no video capture devices are available
- disables combo boxes and labels accordingly

Change-Id: I9436353d4747a44db143f1afa3fb19f160b13976
parent ca45bd4a
......@@ -908,17 +908,30 @@ void SettingsWidget::populateAVSettings()
this, &SettingsWidget::slotDeviceBoxCurrentIndexChanged);
disconnect(ui->formatBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsWidget::slotFormatBoxCurrentIndexChanged);
ui->deviceBox->clear();
auto devices = LRCInstance::avModel().getDevices();
auto device = LRCInstance::avModel().getDefaultDeviceName();
bool shouldReinitializePreview = currentDisplayedVideoDevice_ != device;
currentDisplayedVideoDevice_ = device;
auto deviceIndex = Utils::indexInVector(devices, device);
for (auto d : devices) {
ui->deviceBox->addItem(QString::fromStdString(d).toUtf8());
bool shouldReinitializePreview = true;
ui->deviceBox->clear();
ui->formatBox->clear();
bool hasVideoDevices = devices.size();
ui->deviceBox->setEnabled(hasVideoDevices);
ui->formatBox->setEnabled(hasVideoDevices);
ui->labelVideoDevice->setEnabled(hasVideoDevices);
ui->labelVideoFormat->setEnabled(hasVideoDevices);
if (hasVideoDevices) {
auto device = LRCInstance::avModel().getDefaultDeviceName();
shouldReinitializePreview = currentDisplayedVideoDevice_ != device;
currentDisplayedVideoDevice_ = device;
auto deviceIndex = Utils::indexInVector(devices, device);
for (auto d : devices) {
ui->deviceBox->addItem(QString::fromStdString(d).toUtf8());
}
ui->deviceBox->setCurrentIndex(deviceIndex);
setFormatListForDevice(device);
} else {
currentDisplayedVideoDevice_.clear();
ui->deviceBox->addItem(QObject::tr("None"));
ui->formatBox->addItem(QObject::tr("None"));
}
ui->deviceBox->setCurrentIndex(deviceIndex);
setFormatListForDevice(device);
connect(ui->deviceBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsWidget::slotDeviceBoxCurrentIndexChanged);
connect(ui->formatBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
......@@ -1004,6 +1017,9 @@ void SettingsWidget::showPreview()
void SettingsWidget::setFormatListForDevice(const std::string& device)
{
auto deviceCapabilities = LRCInstance::avModel().getDeviceCapabilities(device);
if (deviceCapabilities.size() == 0) {
return;
}
auto currentSettings = LRCInstance::avModel().getDeviceSettings(device);
auto currentChannel = currentSettings.channel;
currentChannel = currentChannel.empty() ? "default" : currentChannel;
......
......@@ -376,7 +376,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="generalSettings">
<property name="sizePolicy">
......@@ -1251,7 +1251,7 @@
<x>0</x>
<y>0</y>
<width>749</width>
<height>1416</height>
<height>1387</height>
</rect>
</property>
<property name="styleSheet">
......@@ -2574,7 +2574,7 @@
<x>0</x>
<y>0</y>
<width>749</width>
<height>886</height>
<height>864</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayoutsip_12" stretch="0">
......@@ -3680,7 +3680,7 @@
<number>7</number>
</property>
<item>
<widget class="QLabel" name="label_20">
<widget class="QLabel" name="labelVideoDevice">
<property name="font">
<font>
<pointsize>11</pointsize>
......@@ -3748,7 +3748,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="labelVideoFormat">
<property name="font">
<font>
<pointsize>11</pointsize>
......
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