QTfrontend/gameuiconfig.cpp
branchui-scaling
changeset 15663 d92eeb468dad
parent 15283 c4fd2813b127
parent 15299 3bf780084c86
equal deleted inserted replaced
15283:c4fd2813b127 15663:d92eeb468dad
    91 
    91 
    92     QString widthStr = QString::number(screenSize.width());
    92     QString widthStr = QString::number(screenSize.width());
    93     QString heightStr = QString::number(screenSize.height());
    93     QString heightStr = QString::number(screenSize.height());
    94     QString wWidth = value("video/windowedWidth", widthStr).toString();
    94     QString wWidth = value("video/windowedWidth", widthStr).toString();
    95     QString wHeight = value("video/windowedHeight", heightStr).toString();
    95     QString wHeight = value("video/windowedHeight", heightStr).toString();
       
    96     pIsEngineWindowMaximized = value("video/windowedMaximized", false).toBool();
    96     // If left blank reset the resolution to the default
    97     // If left blank reset the resolution to the default
    97     wWidth = (wWidth == "" ? widthStr : wWidth);
    98     wWidth = (wWidth == "" ? widthStr : wWidth);
    98     wHeight = (wHeight == "" ? heightStr : wHeight);
    99     wHeight = (wHeight == "" ? heightStr : wHeight);
    99     Form->ui.pageOptions->windowWidthEdit->setValue(wWidth.toInt());
   100     Form->ui.pageOptions->windowWidthEdit->setValue(wWidth.toInt());
   100     Form->ui.pageOptions->windowHeightEdit->setValue(wHeight.toInt());
   101     Form->ui.pageOptions->windowHeightEdit->setValue(wHeight.toInt());
   230 {
   231 {
   231     // fill 2/3 of the screen desktop
   232     // fill 2/3 of the screen desktop
   232     const QRect deskSize = HWApplication::desktop()->screenGeometry(-1);
   233     const QRect deskSize = HWApplication::desktop()->screenGeometry(-1);
   233     Form->resize(value("frontend/width", qMin(qMax(deskSize.width()*2/3,800),deskSize.width())).toUInt(),
   234     Form->resize(value("frontend/width", qMin(qMax(deskSize.width()*2/3,800),deskSize.width())).toUInt(),
   234                  value("frontend/height", qMin(qMax(deskSize.height()*2/3,600),deskSize.height())).toUInt());
   235                  value("frontend/height", qMin(qMax(deskSize.height()*2/3,600),deskSize.height())).toUInt());
       
   236     if(value("frontend/maximized", false) == true)
       
   237         Form->setWindowState(Form->windowState() | Qt::WindowMaximized);
       
   238     else
       
   239         Form->setWindowState(Form->windowState() & ~Qt::WindowMaximized);
   235 
   240 
   236     // move the window to the center of the screen
   241     // move the window to the center of the screen
   237     QPoint center = HWApplication::desktop()->availableGeometry(-1).center();
   242     QPoint center = HWApplication::desktop()->availableGeometry(-1).center();
   238     center.setX(center.x() - (Form->width()/2));
   243     center.setX(center.x() - (Form->width()/2));
   239     center.setY(center.y() - (Form->height()/2));
   244     center.setY(center.y() - (Form->height()/2));
   243 void GameUIConfig::SaveOptions()
   248 void GameUIConfig::SaveOptions()
   244 {
   249 {
   245     setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
   250     setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
   246     setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->value());
   251     setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->value());
   247     setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->value());
   252     setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->value());
       
   253     setValue("video/windowedMaximized", vid_Maximized());
   248     setValue("video/fullscreen", vid_Fullscreen());
   254     setValue("video/fullscreen", vid_Fullscreen());
   249 
   255 
   250     setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
   256     setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
   251     setValue("video/zoom", Form->ui.pageOptions->SLZoom->value());
   257     setValue("video/zoom", Form->ui.pageOptions->SLZoom->value());
   252     setValue("video/stereo", stereoMode());
   258     setValue("video/stereo", stereoMode());
   260     emit frontendFullscreen(ffscr);
   266     emit frontendFullscreen(ffscr);
   261     if (!ffscr)
   267     if (!ffscr)
   262     {
   268     {
   263         setValue("frontend/width", Form->width());
   269         setValue("frontend/width", Form->width());
   264         setValue("frontend/height", Form->height());
   270         setValue("frontend/height", Form->height());
       
   271         setValue("frontend/maximized", (Form->windowState() & Qt::WindowMaximized) != 0);
   265     }
   272     }
   266     else
   273     else
   267     {
   274     {
   268         //resizeToConfigValues(); // TODO: why this has been made?
   275         //resizeToConfigValues(); // TODO: why this has been made?
   269     }
   276     }
   379     std::pair<QRect, QRect> result = vid_ResolutionPair();
   386     std::pair<QRect, QRect> result = vid_ResolutionPair();
   380     if(Form->ui.pageOptions->CBFullscreen->isChecked())
   387     if(Form->ui.pageOptions->CBFullscreen->isChecked())
   381         return result.first;
   388         return result.first;
   382     else
   389     else
   383         return result.second;
   390         return result.second;
       
   391 }
       
   392 
       
   393 bool GameUIConfig::vid_Maximized()
       
   394 {
       
   395     return pIsEngineWindowMaximized;
       
   396 }
       
   397 
       
   398 void GameUIConfig::vid_SetMaximized(bool isMaximized)
       
   399 {
       
   400     pIsEngineWindowMaximized = isMaximized;
   384 }
   401 }
   385 
   402 
   386 bool GameUIConfig::vid_Fullscreen()
   403 bool GameUIConfig::vid_Fullscreen()
   387 {
   404 {
   388     return Form->ui.pageOptions->CBFullscreen->isChecked();
   405     return Form->ui.pageOptions->CBFullscreen->isChecked();