From 8876dad457a6ff10c693eaa2633bb37b376e9f82 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Sat, 24 Jan 2015 02:03:26 +0100 Subject: [PATCH] Save camera video res in settings Fixes #1033 --- src/misc/settings.cpp | 18 ++++++++++++++++++ src/misc/settings.h | 6 ++++++ src/widget/form/settings/avform.cpp | 20 ++++++++++++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index ff6adfbdf..962fff3aa 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -204,6 +204,10 @@ void Settings::load() filterAudio = s.value("filterAudio", false).toBool(); s.endGroup(); + s.beginGroup("Video"); + camVideoRes = s.value("camVideoRes",QSize()).toSize(); + s.endGroup(); + // Read the embedded DHT bootsrap nodes list if needed if (dhtServerList.isEmpty()) { @@ -350,6 +354,10 @@ void Settings::save(QString path, bool writeFriends) s.setValue("filterAudio", filterAudio); s.endGroup(); + s.beginGroup("Video"); + s.setValue("camVideoRes",camVideoRes); + s.endGroup(); + if (!writeFriends || currentProfile.isEmpty()) // Core::switchConfiguration return; @@ -940,6 +948,16 @@ void Settings::setFilterAudio(bool newValue) filterAudio = newValue; } +QSize Settings::getCamVideoRes() const +{ + return camVideoRes; +} + +void Settings::setCamVideoRes(QSize newValue) +{ + camVideoRes = newValue; +} + QString Settings::getFriendAdress(const QString &publicKey) const { QString key = ToxID::fromString(publicKey).publicKey; diff --git a/src/misc/settings.h b/src/misc/settings.h index 03899cdc4..86a9bdf31 100644 --- a/src/misc/settings.h +++ b/src/misc/settings.h @@ -139,6 +139,9 @@ public: bool getFilterAudio() const; void setFilterAudio(bool newValue); + QSize getCamVideoRes() const; + void setCamVideoRes(QSize newValue); + // Assume all widgets have unique names // Don't use it to save every single thing you want to save, use it // for some general purpose widgets, such as MainWindows or Splitters, @@ -317,6 +320,9 @@ private: QString outDev; bool filterAudio; + // Video + QSize camVideoRes; + struct friendProp { QString alias; diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index ed7905fa2..b650a202a 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -95,7 +95,9 @@ void AVForm::on_HueSlider_sliderMoved(int position) void AVForm::on_videoModescomboBox_currentIndexChanged(int index) { - Camera::getInstance()->setResolution(bodyUI->videoModescomboBox->itemData(index).toSize()); + QSize res = bodyUI->videoModescomboBox->itemData(index).toSize(); + Settings::getInstance().setCamVideoRes(res); + Camera::getInstance()->setResolution(res); } void AVForm::onPropProbingFinished(Camera::Prop prop, double val) @@ -121,15 +123,25 @@ void AVForm::onPropProbingFinished(Camera::Prop prop, double val) void AVForm::onResProbingFinished(QList res) { + QSize savedRes = Settings::getInstance().getCamVideoRes(); + int savedResIndex = -1; bodyUI->videoModescomboBox->clear(); bodyUI->videoModescomboBox->blockSignals(true); - for (QSize r : res) + for (int i=0; ivideoModescomboBox->addItem(QString("%1x%2").arg(QString::number(r.width()),QString::number(r.height())), r); - //reset index, otherwise cameras with only one resolution won't get initialized + if (r == savedRes) + savedResIndex = i; + } + //reset index, otherwise cameras with only one resolution won't get initialized bodyUI->videoModescomboBox->setCurrentIndex(-1); bodyUI->videoModescomboBox->blockSignals(false); - bodyUI->videoModescomboBox->setCurrentIndex(bodyUI->videoModescomboBox->count()-1); + if (savedResIndex != -1) + bodyUI->videoModescomboBox->setCurrentIndex(savedResIndex); + else + bodyUI->videoModescomboBox->setCurrentIndex(bodyUI->videoModescomboBox->count()-1); } void AVForm::hideEvent(QHideEvent *)