mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed some labels being too big on hi-dpi
This commit is contained in:
parent
683017008a
commit
68ddd1e7c9
6 changed files with 13 additions and 37 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -52,8 +52,6 @@ private:
|
|||
|
||||
pajlada::Signals::Connection themeConnection;
|
||||
|
||||
static void setScaleRecursive(float scale, QObject *object);
|
||||
|
||||
friend class BaseWindow;
|
||||
};
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -69,7 +69,7 @@ void Label::setFontStyle(FontStyle style)
|
|||
this->updateSize();
|
||||
}
|
||||
|
||||
void Label::scaleChangedEvent(float)
|
||||
void Label::scaleChangedEvent(float scale)
|
||||
{
|
||||
this->updateSize();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue