unify default videorec values loading/reloading, fix setting index/value from previous commit
authorkoda
Sun, 02 Dec 2012 17:01:51 +0100
changeset 8186 4ff8690df1b0
parent 8185 1c3739ba4352
child 8187 fa725fe25708
unify default videorec values loading/reloading, fix setting index/value from previous commit
QTfrontend/gameuiconfig.cpp
QTfrontend/ui/page/pagevideos.h
--- a/QTfrontend/gameuiconfig.cpp	Sun Dec 02 15:23:59 2012 +0100
+++ b/QTfrontend/gameuiconfig.cpp	Sun Dec 02 17:01:51 2012 +0100
@@ -141,10 +141,16 @@
 
 void GameUIConfig::reloadVideosValues(void)
 {
-    Form->ui.pageVideos->framerateBox->setCurrentIndex(1); //set to 25 fps
+    // one pass with default values
+    Form->ui.pageVideos->setDefaultOptions();
 
-    Form->ui.pageVideos->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
-    bool useGameRes = value("videorec/usegameres",true).toBool();
+    // then load user configuration
+    Form->ui.pageVideos->framerateBox->setCurrentIndex(
+            Form->ui.pageVideos->framerateBox->findData(
+                        value("videorec/framerate", rec_Framerate()).toString() + " fps",
+                    Qt::MatchExactly) );
+    Form->ui.pageVideos->bitrateBox->setValue(value("videorec/bitrate", rec_Bitrate()).toUInt());
+    bool useGameRes = value("videorec/usegameres",Form->ui.pageVideos->checkUseGameRes->isChecked()).toBool();
     if (useGameRes)
     {
         QRect res = vid_Resolution();
@@ -157,7 +163,8 @@
         Form->ui.pageVideos->heightEdit->setText(value("videorec/height","600").toString());
     }
     Form->ui.pageVideos->checkUseGameRes->setChecked(useGameRes);
-    Form->ui.pageVideos->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
+    Form->ui.pageVideos->checkRecordAudio->setChecked(
+            value("videorec/audio",Form->ui.pageVideos->checkRecordAudio->isChecked()).toBool() );
     if (!Form->ui.pageVideos->tryCodecs(value("videorec/format","no").toString(),
                                         value("videorec/videocodec","no").toString(),
                                         value("videorec/audiocodec","no").toString()))
@@ -291,7 +298,7 @@
     setValue("videorec/format", AVFormat());
     setValue("videorec/videocodec", videoCodec());
     setValue("videorec/audiocodec", audioCodec());
-    setValue("videorec/fps", rec_Framerate());
+    setValue("videorec/framerate", rec_Framerate());
     setValue("videorec/bitrate", rec_Bitrate());
     setValue("videorec/width", res.width());
     setValue("videorec/height", res.height());
@@ -530,7 +537,10 @@
 
 int GameUIConfig::rec_Framerate()
 {
-    return Form->ui.pageVideos->framerateBox->itemData(Form->ui.pageVideos->framerateBox->currentIndex()).toUInt();
+    // remove the "fps" label
+    QString fpsText = Form->ui.pageVideos->framerateBox->currentText();
+    QStringList fpsList = fpsText.split(" ");
+    return fpsList.first().toInt();
 }
 
 int GameUIConfig::rec_Bitrate()
--- a/QTfrontend/ui/page/pagevideos.h	Sun Dec 02 15:23:59 2012 +0100
+++ b/QTfrontend/ui/page/pagevideos.h	Sun Dec 02 17:01:51 2012 +0100
@@ -108,7 +108,6 @@
         void changeAVFormat(int index);
         void changeUseGameRes(int state);
         void changeRecordAudio(int state);
-        void setDefaultOptions();
         void encodingFinished(bool success);
         void updateProgress(float value);
         void cellDoubleClicked(int row, int column);
@@ -121,6 +120,9 @@
         void uploadToYouTube();
         void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
         void uploadFinished();
+
+    public slots:
+        void setDefaultOptions();
 };
 
 #endif // PAGE_VIDEOS_H