QTfrontend/hwform.cpp
changeset 7235 baa69bd025d9
parent 7180 53ffc8853008
child 7280 fd707afbc3a2
--- a/QTfrontend/hwform.cpp	Mon Jun 11 17:56:10 2012 +0400
+++ b/QTfrontend/hwform.cpp	Mon Jun 11 18:15:30 2012 +0400
@@ -76,6 +76,7 @@
 #include "pagegamestats.h"
 #include "pageplayrecord.h"
 #include "pagedata.h"
+#include "pagevideos.h"
 #include "hwconsts.h"
 #include "newnetclient.h"
 #include "gamecfgwidget.h"
@@ -141,6 +142,8 @@
 
     config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
 
+    ui.pageVideos->config = config;
+
 #ifdef __APPLE__
     panel = new M3Panel;
 
@@ -199,6 +202,9 @@
     connect(ui.pageNetGame, SIGNAL(DLCClicked()), pageSwitchMapper, SLOT(map()));
     pageSwitchMapper->setMapping(ui.pageNetGame, ID_PAGE_DATADOWNLOAD);
 
+    connect(ui.pageMain->BtnVideos, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
+    pageSwitchMapper->setMapping(ui.pageMain->BtnVideos, ID_PAGE_VIDEOS);
+
     //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
     //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
 
@@ -289,6 +295,7 @@
 
     connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
 
+    connect(ui.pageVideos, SIGNAL(goBack()), config, SLOT(SaveVideosOptions()));
 
     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
     ui.pageScheme->setModel(ammoSchemeModel);
@@ -604,6 +611,11 @@
         config->reloadValues();
     }
 
+    if (id == ID_PAGE_VIDEOS )
+    {
+        config->reloadVideosValues();
+    }
+
     // load and save ignore/friends lists
     if (lastid == ID_PAGE_NETGAME) // leaving a room
         ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text());
@@ -1409,15 +1421,16 @@
         }
     }
 
-    QDir videosDir(cfgdir->absolutePath() + "/Videos/");
+    // encode videos
+    QDir videosDir(cfgdir->absolutePath() + "/VideoTemp/");
     QStringList files = videosDir.entryList(QStringList("*.txtout"), QDir::Files);
-    for (QStringList::iterator str = files.begin(); str != files.end(); str++)
+    foreach (const QString & str, files)
     {
-        str->chop(7); // remove ".txtout"
-        // need to rename this file to not open it twice
-        videosDir.rename(*str + ".txtout", *str + ".txtin");
+        QString prefix = str;
+        prefix.chop(7); // remove ".txtout"
+        videosDir.rename(prefix + ".txtout", prefix + ".txtin"); // rename this file to not open it twice
         HWRecorder* pRecorder = new HWRecorder(config);
-        pRecorder->EncodeVideo(record, *str);
+        pRecorder->EncodeVideo(record, prefix);
     }
 }
 
@@ -1459,6 +1472,7 @@
     xfire_free();
 #endif
     config->SaveOptions();
+    config->SaveVideosOptions();
     event->accept();
 }