1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Save camera video res in settings

Fixes #1033
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-24 02:03:26 +01:00
parent 44ddb8789c
commit 8876dad457
3 changed files with 40 additions and 4 deletions

View File

@ -204,6 +204,10 @@ void Settings::load()
filterAudio = s.value("filterAudio", false).toBool(); filterAudio = s.value("filterAudio", false).toBool();
s.endGroup(); s.endGroup();
s.beginGroup("Video");
camVideoRes = s.value("camVideoRes",QSize()).toSize();
s.endGroup();
// Read the embedded DHT bootsrap nodes list if needed // Read the embedded DHT bootsrap nodes list if needed
if (dhtServerList.isEmpty()) if (dhtServerList.isEmpty())
{ {
@ -350,6 +354,10 @@ void Settings::save(QString path, bool writeFriends)
s.setValue("filterAudio", filterAudio); s.setValue("filterAudio", filterAudio);
s.endGroup(); s.endGroup();
s.beginGroup("Video");
s.setValue("camVideoRes",camVideoRes);
s.endGroup();
if (!writeFriends || currentProfile.isEmpty()) // Core::switchConfiguration if (!writeFriends || currentProfile.isEmpty()) // Core::switchConfiguration
return; return;
@ -940,6 +948,16 @@ void Settings::setFilterAudio(bool newValue)
filterAudio = newValue; filterAudio = newValue;
} }
QSize Settings::getCamVideoRes() const
{
return camVideoRes;
}
void Settings::setCamVideoRes(QSize newValue)
{
camVideoRes = newValue;
}
QString Settings::getFriendAdress(const QString &publicKey) const QString Settings::getFriendAdress(const QString &publicKey) const
{ {
QString key = ToxID::fromString(publicKey).publicKey; QString key = ToxID::fromString(publicKey).publicKey;

View File

@ -139,6 +139,9 @@ public:
bool getFilterAudio() const; bool getFilterAudio() const;
void setFilterAudio(bool newValue); void setFilterAudio(bool newValue);
QSize getCamVideoRes() const;
void setCamVideoRes(QSize newValue);
// Assume all widgets have unique names // Assume all widgets have unique names
// Don't use it to save every single thing you want to save, use it // 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, // for some general purpose widgets, such as MainWindows or Splitters,
@ -317,6 +320,9 @@ private:
QString outDev; QString outDev;
bool filterAudio; bool filterAudio;
// Video
QSize camVideoRes;
struct friendProp struct friendProp
{ {
QString alias; QString alias;

View File

@ -95,7 +95,9 @@ void AVForm::on_HueSlider_sliderMoved(int position)
void AVForm::on_videoModescomboBox_currentIndexChanged(int index) 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) void AVForm::onPropProbingFinished(Camera::Prop prop, double val)
@ -121,14 +123,24 @@ void AVForm::onPropProbingFinished(Camera::Prop prop, double val)
void AVForm::onResProbingFinished(QList<QSize> res) void AVForm::onResProbingFinished(QList<QSize> res)
{ {
QSize savedRes = Settings::getInstance().getCamVideoRes();
int savedResIndex = -1;
bodyUI->videoModescomboBox->clear(); bodyUI->videoModescomboBox->clear();
bodyUI->videoModescomboBox->blockSignals(true); bodyUI->videoModescomboBox->blockSignals(true);
for (QSize r : res) for (int i=0; i<res.size(); ++i)
{
QSize& r = res[i];
bodyUI->videoModescomboBox->addItem(QString("%1x%2").arg(QString::number(r.width()),QString::number(r.height())), r); bodyUI->videoModescomboBox->addItem(QString("%1x%2").arg(QString::number(r.width()),QString::number(r.height())), r);
if (r == savedRes)
savedResIndex = i;
}
//reset index, otherwise cameras with only one resolution won't get initialized //reset index, otherwise cameras with only one resolution won't get initialized
bodyUI->videoModescomboBox->setCurrentIndex(-1); bodyUI->videoModescomboBox->setCurrentIndex(-1);
bodyUI->videoModescomboBox->blockSignals(false); bodyUI->videoModescomboBox->blockSignals(false);
if (savedResIndex != -1)
bodyUI->videoModescomboBox->setCurrentIndex(savedResIndex);
else
bodyUI->videoModescomboBox->setCurrentIndex(bodyUI->videoModescomboBox->count()-1); bodyUI->videoModescomboBox->setCurrentIndex(bodyUI->videoModescomboBox->count()-1);
} }