QTfrontend/gameuiconfig.cpp
changeset 8190 92792d48574b
parent 8183 9b1c206a6cf2
parent 8186 4ff8690df1b0
child 8206 1633a6510834
equal deleted inserted replaced
8183:9b1c206a6cf2 8190:92792d48574b
   139     }
   139     }
   140 }
   140 }
   141 
   141 
   142 void GameUIConfig::reloadVideosValues(void)
   142 void GameUIConfig::reloadVideosValues(void)
   143 {
   143 {
   144     Form->ui.pageOptions->framerateBox->setValue(value("videorec/fps",25).toUInt());
   144     // one pass with default values
   145     Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
   145     Form->ui.pageOptions->setDefaultOptions();
   146     bool useGameRes = value("videorec/usegameres",true).toBool();
   146 
       
   147     // then load user configuration
       
   148     Form->ui.pageOptions->framerateBox->setCurrentIndex(
       
   149             Form->ui.pageOptions->framerateBox->findData(
       
   150                         value("videorec/framerate", rec_Framerate()).toString() + " fps",
       
   151                     Qt::MatchExactly) );
       
   152     Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate", rec_Bitrate()).toUInt());
       
   153     bool useGameRes = value("videorec/usegameres",Form->ui.pageOptions->checkUseGameRes->isChecked()).toBool();
   147     if (useGameRes)
   154     if (useGameRes)
   148     {
   155     {
   149         QRect res = vid_Resolution();
   156         QRect res = vid_Resolution();
   150         Form->ui.pageOptions->widthEdit->setText(QString::number(res.width()));
   157         Form->ui.pageOptions->widthEdit->setText(QString::number(res.width()));
   151         Form->ui.pageOptions->heightEdit->setText(QString::number(res.height()));
   158         Form->ui.pageOptions->heightEdit->setText(QString::number(res.height()));
   154     {
   161     {
   155         Form->ui.pageOptions->widthEdit->setText(value("videorec/width","800").toString());
   162         Form->ui.pageOptions->widthEdit->setText(value("videorec/width","800").toString());
   156         Form->ui.pageOptions->heightEdit->setText(value("videorec/height","600").toString());
   163         Form->ui.pageOptions->heightEdit->setText(value("videorec/height","600").toString());
   157     }
   164     }
   158     Form->ui.pageOptions->checkUseGameRes->setChecked(useGameRes);
   165     Form->ui.pageOptions->checkUseGameRes->setChecked(useGameRes);
   159     Form->ui.pageOptions->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
   166     Form->ui.pageOptions->checkRecordAudio->setChecked(
       
   167             value("videorec/audio",Form->ui.pageOptions->checkRecordAudio->isChecked()).toBool() );
   160     if (!Form->ui.pageOptions->tryCodecs(value("videorec/format","no").toString(),
   168     if (!Form->ui.pageOptions->tryCodecs(value("videorec/format","no").toString(),
   161                                         value("videorec/videocodec","no").toString(),
   169                                         value("videorec/videocodec","no").toString(),
   162                                         value("videorec/audiocodec","no").toString()))
   170                                         value("videorec/audiocodec","no").toString()))
   163         Form->ui.pageOptions->setDefaultCodecs();
   171         Form->ui.pageOptions->setDefaultCodecs();
   164 }
   172 }
   177     return cleanedList;
   185     return cleanedList;
   178 }
   186 }
   179 
   187 
   180 void GameUIConfig::resizeToConfigValues()
   188 void GameUIConfig::resizeToConfigValues()
   181 {
   189 {
   182     Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt());
   190     // fill 2/3 of the screen desktop
       
   191     const QRect deskSize = QApplication::desktop()->screenGeometry(-1);
       
   192     Form->resize(value("frontend/width", deskSize.width()*2/3).toUInt(),
       
   193                  value("frontend/height", deskSize.height()*2/3).toUInt());
       
   194 
       
   195     // move the window to the center of the screen
       
   196     QPoint center = QApplication::desktop()->availableGeometry(-1).center();
       
   197     center.setX(center.x() - (Form->width()/2));
       
   198     center.setY(center.y() - (Form->height()/2));
       
   199     Form->move(center);
   183 }
   200 }
   184 
   201 
   185 void GameUIConfig::SaveOptions()
   202 void GameUIConfig::SaveOptions()
   186 {
   203 {
   187     setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
   204     setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
   279 {
   296 {
   280     QRect res = rec_Resolution();
   297     QRect res = rec_Resolution();
   281     setValue("videorec/format", AVFormat());
   298     setValue("videorec/format", AVFormat());
   282     setValue("videorec/videocodec", videoCodec());
   299     setValue("videorec/videocodec", videoCodec());
   283     setValue("videorec/audiocodec", audioCodec());
   300     setValue("videorec/audiocodec", audioCodec());
   284     setValue("videorec/fps", rec_Framerate());
   301     setValue("videorec/framerate", rec_Framerate());
   285     setValue("videorec/bitrate", rec_Bitrate());
   302     setValue("videorec/bitrate", rec_Bitrate());
   286     setValue("videorec/width", res.width());
   303     setValue("videorec/width", res.width());
   287     setValue("videorec/height", res.height());
   304     setValue("videorec/height", res.height());
   288     setValue("videorec/usegameres", Form->ui.pageOptions->checkUseGameRes->isChecked());
   305     setValue("videorec/usegameres", Form->ui.pageOptions->checkUseGameRes->isChecked());
   289     setValue("videorec/audio", recordAudio());
   306     setValue("videorec/audio", recordAudio());
   518     return res;
   535     return res;
   519 }
   536 }
   520 
   537 
   521 int GameUIConfig::rec_Framerate()
   538 int GameUIConfig::rec_Framerate()
   522 {
   539 {
   523     return Form->ui.pageOptions->framerateBox->value();
   540     // remove the "fps" label
       
   541     QString fpsText = Form->ui.pageOptions->framerateBox->currentText();
       
   542     QStringList fpsList = fpsText.split(" ");
       
   543     return fpsList.first().toInt();
   524 }
   544 }
   525 
   545 
   526 int GameUIConfig::rec_Bitrate()
   546 int GameUIConfig::rec_Bitrate()
   527 {
   547 {
   528     return Form->ui.pageOptions->bitrateBox->value();
   548     return Form->ui.pageOptions->bitrateBox->value();