Skip to content

Commit

Permalink
Disable custom interface scaling
Browse files Browse the repository at this point in the history
We should now handle DPI scaling correctly, ignore user setting.

The setting was a ugly hack anyway, didn't work properly.
  • Loading branch information
rodlie committed Aug 11, 2024
1 parent 9ff62f0 commit fd88cec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/app/GUI/Settings/generalsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)
, mAutoBackup(nullptr)
, mAutoSave(nullptr)
, mAutoSaveTimer(nullptr)
, mDefaultInterfaceScaling(nullptr)
, mInterfaceScaling(nullptr)
//, mDefaultInterfaceScaling(nullptr)
//, mInterfaceScaling(nullptr)
, mImportFileDir(nullptr)
, mToolBarActionNew(nullptr)
, mToolBarActionOpen(nullptr)
Expand Down Expand Up @@ -90,7 +90,7 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)

mProjectLayout->addWidget(mAutoSaveWidget);

const auto mScaleWidget = new QGroupBox(this);
/*const auto mScaleWidget = new QGroupBox(this);
mScaleWidget->setObjectName("BlueBox");
mScaleWidget->setTitle(tr("Interface Scaling"));
mScaleWidget->setContentsMargins(0, 0, 0, 0);
Expand Down Expand Up @@ -123,7 +123,7 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)
infoLabel->setText(tr("Changes here will require a restart of Friction."));
mScaleLayout->addWidget(infoLabel);
mGeneralLayout->addWidget(mScaleWidget);
mGeneralLayout->addWidget(mScaleWidget);*/

const auto mImportFileWidget = new QWidget(this);
mImportFileWidget->setContentsMargins(0, 0, 0, 0);
Expand All @@ -150,7 +150,7 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)
eSizesUI::widget.add(mAutoBackup, [this](const int size) {
mAutoBackup->setFixedHeight(size);
mAutoSave->setFixedHeight(size);
mDefaultInterfaceScaling->setFixedHeight(size);
//mDefaultInterfaceScaling->setFixedHeight(size);
});
}

Expand All @@ -167,8 +167,8 @@ void GeneralSettingsWidget::applySettings()
(mAutoSaveTimer->value() * 60) * 1000);
MainWindow::sGetInstance()->updateAutoSaveBackupState();

mSett.fDefaultInterfaceScaling = mDefaultInterfaceScaling->isChecked();
mSett.fInterfaceScaling = mInterfaceScaling->value() * 0.01;
//mSett.fDefaultInterfaceScaling = mDefaultInterfaceScaling->isChecked();
//mSett.fInterfaceScaling = mInterfaceScaling->value() * 0.01;
mSett.fImportFileDirOpt = mImportFileDir->currentData().toInt();

mSett.fToolBarActionNew = mToolBarActionNew->isChecked();
Expand Down Expand Up @@ -197,8 +197,8 @@ void GeneralSettingsWidget::updateSettings(bool restore)
if (ms < 60000) { ms = 60000; }
mAutoSaveTimer->setValue((ms / 1000) / 60);

mDefaultInterfaceScaling->setChecked(mSett.fDefaultInterfaceScaling);
mInterfaceScaling->setValue(mDefaultInterfaceScaling->isChecked() ? 100 : 100 * mSett.fInterfaceScaling);
//mDefaultInterfaceScaling->setChecked(mSett.fDefaultInterfaceScaling);
//mInterfaceScaling->setValue(mDefaultInterfaceScaling->isChecked() ? 100 : 100 * mSett.fInterfaceScaling);

mToolBarActionNew->setChecked(mSett.fToolBarActionNew);
mToolBarActionOpen->setChecked(mSett.fToolBarActionOpen);
Expand Down
4 changes: 2 additions & 2 deletions src/app/GUI/Settings/generalsettingswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class GeneralSettingsWidget : public SettingsWidget
QCheckBox *mAutoSave;
QSpinBox *mAutoSaveTimer;

QCheckBox *mDefaultInterfaceScaling;
QSlider *mInterfaceScaling;
//QCheckBox *mDefaultInterfaceScaling;
//QSlider *mInterfaceScaling;

QComboBox *mImportFileDir;

Expand Down
9 changes: 2 additions & 7 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,9 @@ int main(int argc, char *argv[])

OS_FONT = QApplication::font();
eSizesUI::font.setEvaluator([&settings]() {
qreal dpi = 1.0;
if (!settings.fDefaultInterfaceScaling) {
dpi = settings.fInterfaceScaling;
} else {
dpi = qApp->desktop()->logicalDpiX() / 96.0; //QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.0
}
qreal dpi = qApp->desktop()->logicalDpiX() / 96.0; //QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.0
settings.fCurrentInterfaceDPI = dpi;
qDebug() << "DPI" << dpi;
qWarning() << "DPI:" << dpi;
const auto fm = QFontMetrics(OS_FONT);
const qreal scaling = qBound(0.5, dpi, 1.5);
return qRound(fm.height()*scaling);
Expand Down

0 comments on commit fd88cec

Please sign in to comment.