mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01: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 <QFont>
|
||||
|
||||
#include <AudioClient.h>
|
||||
#include <avatar/AvatarManager.h>
|
||||
|
@ -26,6 +27,18 @@
|
|||
|
||||
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) :
|
||||
QDialog(parent) {
|
||||
|
||||
|
@ -46,8 +59,14 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) :
|
|||
// move dialog to left side
|
||||
move(parentWidget()->geometry().topLeft());
|
||||
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() {
|
||||
savePreferences();
|
||||
close();
|
||||
|
|
Loading…
Reference in a new issue