mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
Add auto-scale to preferences dialog
This commit is contained in:
parent
45ec7fdf07
commit
a5b737314d
1 changed files with 19 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
#include <AudioClient.h>
|
#include <AudioClient.h>
|
||||||
#include <avatar/AvatarManager.h>
|
#include <avatar/AvatarManager.h>
|
||||||
|
@ -26,6 +27,18 @@
|
||||||
|
|
||||||
const int PREFERENCES_HEIGHT_PADDING = 20;
|
const int PREFERENCES_HEIGHT_PADDING = 20;
|
||||||
|
|
||||||
|
void scaleWidgetFontSizes(QWidget* widget, float scale) {
|
||||||
|
for (auto child : widget->findChildren<QWidget*>()) {
|
||||||
|
if (child->parent() == widget) {
|
||||||
|
scaleWidgetFontSizes(child, scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QFont font = widget->font();
|
||||||
|
qDebug() << "Pref: " << widget->objectName() << ": " << font.pointSizeF();
|
||||||
|
font.setPointSizeF(font.pointSizeF() * scale);
|
||||||
|
widget->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
PreferencesDialog::PreferencesDialog(QWidget* parent) :
|
PreferencesDialog::PreferencesDialog(QWidget* parent) :
|
||||||
QDialog(parent) {
|
QDialog(parent) {
|
||||||
|
|
||||||
|
@ -46,8 +59,14 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) :
|
||||||
// move dialog to left side
|
// move dialog to left side
|
||||||
move(parentWidget()->geometry().topLeft());
|
move(parentWidget()->geometry().topLeft());
|
||||||
setFixedHeight(parentWidget()->size().height() - PREFERENCES_HEIGHT_PADDING);
|
setFixedHeight(parentWidget()->size().height() - PREFERENCES_HEIGHT_PADDING);
|
||||||
|
|
||||||
|
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
float dpiScale = 72.0f / glCanvas->logicalDpiX();
|
||||||
|
|
||||||
|
scaleWidgetFontSizes(ui.scrollArea, dpiScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreferencesDialog::accept() {
|
void PreferencesDialog::accept() {
|
||||||
savePreferences();
|
savePreferences();
|
||||||
close();
|
close();
|
||||||
|
|
Loading…
Reference in a new issue