Merged changes from upstream.
authorMitchell Kember <mk12360@gmail.com>
Sun, 02 Dec 2012 13:57:21 -0500
changeset 8190 92792d48574b
parent 8183 9b1c206a6cf2 (current diff)
parent 8187 fa725fe25708 (diff)
child 8192 81da6576b0c3
Merged changes from upstream.
QTfrontend/gameuiconfig.cpp
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/page/pagevideos.h
--- a/QTfrontend/gameuiconfig.cpp	Sat Dec 01 21:32:34 2012 -0500
+++ b/QTfrontend/gameuiconfig.cpp	Sun Dec 02 13:57:21 2012 -0500
@@ -141,9 +141,16 @@
 
 void GameUIConfig::reloadVideosValues(void)
 {
-    Form->ui.pageOptions->framerateBox->setValue(value("videorec/fps",25).toUInt());
-    Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
-    bool useGameRes = value("videorec/usegameres",true).toBool();
+    // one pass with default values
+    Form->ui.pageOptions->setDefaultOptions();
+
+    // then load user configuration
+    Form->ui.pageOptions->framerateBox->setCurrentIndex(
+            Form->ui.pageOptions->framerateBox->findData(
+                        value("videorec/framerate", rec_Framerate()).toString() + " fps",
+                    Qt::MatchExactly) );
+    Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate", rec_Bitrate()).toUInt());
+    bool useGameRes = value("videorec/usegameres",Form->ui.pageOptions->checkUseGameRes->isChecked()).toBool();
     if (useGameRes)
     {
         QRect res = vid_Resolution();
@@ -156,7 +163,8 @@
         Form->ui.pageOptions->heightEdit->setText(value("videorec/height","600").toString());
     }
     Form->ui.pageOptions->checkUseGameRes->setChecked(useGameRes);
-    Form->ui.pageOptions->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
+    Form->ui.pageOptions->checkRecordAudio->setChecked(
+            value("videorec/audio",Form->ui.pageOptions->checkRecordAudio->isChecked()).toBool() );
     if (!Form->ui.pageOptions->tryCodecs(value("videorec/format","no").toString(),
                                         value("videorec/videocodec","no").toString(),
                                         value("videorec/audiocodec","no").toString()))
@@ -179,7 +187,16 @@
 
 void GameUIConfig::resizeToConfigValues()
 {
-    Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt());
+    // fill 2/3 of the screen desktop
+    const QRect deskSize = QApplication::desktop()->screenGeometry(-1);
+    Form->resize(value("frontend/width", deskSize.width()*2/3).toUInt(),
+                 value("frontend/height", deskSize.height()*2/3).toUInt());
+
+    // move the window to the center of the screen
+    QPoint center = QApplication::desktop()->availableGeometry(-1).center();
+    center.setX(center.x() - (Form->width()/2));
+    center.setY(center.y() - (Form->height()/2));
+    Form->move(center);
 }
 
 void GameUIConfig::SaveOptions()
@@ -281,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());
@@ -520,7 +537,10 @@
 
 int GameUIConfig::rec_Framerate()
 {
-    return Form->ui.pageOptions->framerateBox->value();
+    // remove the "fps" label
+    QString fpsText = Form->ui.pageOptions->framerateBox->currentText();
+    QStringList fpsList = fpsText.split(" ");
+    return fpsList.first().toInt();
 }
 
 int GameUIConfig::rec_Bitrate()
--- a/QTfrontend/main.cpp	Sat Dec 01 21:32:34 2012 -0500
+++ b/QTfrontend/main.cpp	Sun Dec 02 13:57:21 2012 -0500
@@ -105,8 +105,28 @@
     return true;
 }
 
+#ifdef __APPLE__
+static CocoaInitializer *cocoaInit = NULL;
+// Function to be called at end of program's termination on OS X to release
+// the NSAutoReleasePool contained within the CocoaInitializer.
+void releaseCocoaPool(void)
+{
+    if (cocoaInit != NULL)
+    {
+        delete cocoaInit;
+        cocoaInit = NULL;
+    }
+}
+#endif
+
 int main(int argc, char *argv[])
 {
+#ifdef __APPLE__
+    // This creates the autoreleasepool that prevents leaking, and destroys it only on exit
+    cocoaInit = new CocoaInitializer();
+    atexit(releaseCocoaPool);
+#endif
+
     HWApplication app(argc, argv);
 
     FileEngineHandler engine(argv[0]);
@@ -254,10 +274,6 @@
         registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\"));
     }
 #endif
-#ifdef __APPLE__
-    // this creates the autoreleasepool that prevents leaking
-    CocoaInitializer initializer;
-#endif
 
     QString style = "";
     QString fname;
--- a/QTfrontend/ui/page/pagevideos.h	Sat Dec 01 21:32:34 2012 -0500
+++ b/QTfrontend/ui/page/pagevideos.h	Sun Dec 02 13:57:21 2012 -0500
@@ -93,6 +93,9 @@
         void uploadToYouTube();
         void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
         void uploadFinished();
+
+    public slots:
+        void setDefaultOptions();
 };
 
 #endif // PAGE_VIDEOS_H