Fixed some labels being too big on hi-dpi

This commit is contained in:
fourtf 2018-06-24 17:01:45 +02:00
parent 683017008a
commit 68ddd1e7c9
6 changed files with 13 additions and 37 deletions

View file

@ -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);

View file

@ -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<BaseWidget *>(child);
if (widget != nullptr) {
widget->setScale(scale);
continue;
}
// QLayout *layout = nullptr;
// QWidget *widget = dynamic_cast<QWidget *>(child);
// if (widget != nullptr) {
// layout = widget->layout();
// }
// else {
QLayout *layout = dynamic_cast<QLayout *>(object);
if (layout != nullptr) {
setScaleRecursive(scale, layout);
}
// }
}
}
void BaseWidget::scaleChangedEvent(float newDpi)

View file

@ -52,8 +52,6 @@ private:
pajlada::Signals::Connection themeConnection;
static void setScaleRecursive(float scale, QObject *object);
friend class BaseWindow;
};

View file

@ -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<BaseWidget *>()) {
child->setScale(scale);
}
}
void BaseWindow::calcButtonsSizes()

View file

@ -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());

View file

@ -69,7 +69,7 @@ void Label::setFontStyle(FontStyle style)
this->updateSize();
}
void Label::scaleChangedEvent(float)
void Label::scaleChangedEvent(float scale)
{
this->updateSize();
}