diff --git a/src/main.cpp b/src/main.cpp index 580f36902..f28c3d688 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,9 +33,9 @@ void installCustomPalette(); int main(int argc, char *argv[]) { - QApplication::setAttribute(Qt::AA_Use96Dpi, true); +// QApplication::setAttribute(Qt::AA_Use96Dpi, false); #ifdef Q_OS_WIN32 - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); +// QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); #endif // QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true); QApplication a(argc, argv); diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index d051984ce..493871e42 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -124,35 +124,6 @@ void BaseWidget::setScale(float value) this->scaleChanged.invoke(value); this->setScaleIndependantSize(this->getScaleIndependantSize()); - - // set scale for all children - BaseWidget::setScaleRecursive(value, this); -} - -void BaseWidget::setScaleRecursive(float scale, QObject *object) -{ - for (QObject *child : object->children()) { - BaseWidget *widget = dynamic_cast(child); - if (widget != nullptr) { - widget->setScale(scale); - continue; - } - - // QLayout *layout = nullptr; - // QWidget *widget = dynamic_cast(child); - - // if (widget != nullptr) { - // layout = widget->layout(); - // } - - // else { - QLayout *layout = dynamic_cast(object); - - if (layout != nullptr) { - setScaleRecursive(scale, layout); - } - // } - } } void BaseWidget::scaleChangedEvent(float newDpi) diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index 66017bac1..1348492bf 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -52,8 +52,6 @@ private: pajlada::Signals::Connection themeConnection; - static void setScaleRecursive(float scale, QObject *object); - friend class BaseWindow; }; diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 9acf6d340..7a64e3411 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -628,9 +628,13 @@ void BaseWindow::paintEvent(QPaintEvent *) void BaseWindow::updateScale() { - this->setScale(this->nativeScale_ * (this->flags_ & DisableCustomScaling - ? 1 - : getApp()->windows->getUiScaleValue())); + auto scale = this->nativeScale_ * + (this->flags_ & DisableCustomScaling ? 1 : getApp()->windows->getUiScaleValue()); + this->setScale(scale); + + for (auto child : this->findChildren()) { + child->setScale(scale); + } } void BaseWindow::calcButtonsSizes() diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 1b8ca9e2b..1ab100300 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -213,6 +213,9 @@ void NotebookTab::paintEvent(QPaintEvent *) QPainter painter(this); float scale = this->getScale(); + qDebug() << painter.device()->devicePixelRatioF() << painter.device()->devicePixelRatioFScale() + << painter.device()->logicalDpiX(); + painter.setFont(getApp()->fonts->getFont(FontStyle::UiTabs, scale * this->devicePixelRatioF())); QFontMetrics metrics = app->fonts->getFontMetrics(FontStyle::UiTabs, scale * this->devicePixelRatioF()); diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index 0a0fcd133..204f66556 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -69,7 +69,7 @@ void Label::setFontStyle(FontStyle style) this->updateSize(); } -void Label::scaleChangedEvent(float) +void Label::scaleChangedEvent(float scale) { this->updateSize(); }