diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index d28dda196..2d5de4ca1 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -119,6 +119,39 @@ void CSettingsView::fillValidResolutions() fillValidResolutionsForScreen(ui->comboBoxDisplayIndex->isVisible() ? ui->comboBoxDisplayIndex->currentIndex() : 0); } +QSize CSettingsView::getPreferredRenderingResolution() +{ +#ifndef VCMI_MOBILE + bool fullscreen = settings["video"]["fullscreen"].Bool(); + bool realFullscreen = settings["video"]["realFullscreen"].Bool(); + + if (!fullscreen || realFullscreen) + { + int resX = settings["video"]["resolution"]["width"].Integer(); + int resY = settings["video"]["resolution"]["height"].Integer(); + return QSize(resX, resY); + } +#endif + return QApplication::primaryScreen()->geometry().size(); +} + +void CSettingsView::fillValidScalingRange() +{ + //FIXME: this code is copy of ScreenHandler::getSupportedScalingRange + + // H3 resolution, any resolution smaller than that is not correctly supported + static const QSize minResolution = {800, 600}; + // arbitrary limit on *downscaling*. Allow some downscaling, if requested by user. Should be generally limited to 100+ for all but few devices + static const double minimalScaling = 50; + + QSize renderResolution = getPreferredRenderingResolution(); + double maximalScalingWidth = 100.0 * renderResolution.width() / minResolution.width(); + double maximalScalingHeight = 100.0 * renderResolution.height() / minResolution.height(); + double maximalScaling = std::min(maximalScalingWidth, maximalScalingHeight); + + ui->spinBoxInterfaceScaling->setRange(minimalScaling, maximalScaling); +} + #ifndef VCMI_MOBILE static QVector findAvailableResolutions(int displayIndex) @@ -153,39 +186,6 @@ static QVector findAvailableResolutions(int displayIndex) return result; } -QSize CSettingsView::getPreferredRenderingResolution() -{ -#ifndef VCMI_MOBILE - bool fullscreen = settings["video"]["fullscreen"].Bool(); - bool realFullscreen = settings["video"]["realFullscreen"].Bool(); - - if (!fullscreen || realFullscreen) - { - int resX = settings["video"]["resolution"]["width"].Integer(); - int resY = settings["video"]["resolution"]["height"].Integer(); - return QSize(resX, resY); - } -#endif - return QApplication::primaryScreen()->geometry().size(); -} - -void CSettingsView::fillValidScalingRange() -{ - //FIXME: this code is copy of ScreenHandler::getSupportedScalingRange - - // H3 resolution, any resolution smaller than that is not correctly supported - static const QSize minResolution = {800, 600}; - // arbitrary limit on *downscaling*. Allow some downscaling, if requested by user. Should be generally limited to 100+ for all but few devices - static const double minimalScaling = 50; - - QSize renderResolution = getPreferredRenderingResolution(); - double maximalScalingWidth = 100.0 * renderResolution.width() / minResolution.width(); - double maximalScalingHeight = 100.0 * renderResolution.height() / minResolution.height(); - double maximalScaling = std::min(maximalScalingWidth, maximalScalingHeight); - - ui->spinBoxInterfaceScaling->setRange(minimalScaling, maximalScaling); -} - void CSettingsView::fillValidResolutionsForScreen(int screenIndex) { ui->comboBoxResolution->blockSignals(true); // avoid saving wrong resolution after adding first item from the list