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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication::setAttribute(Qt::AA_Use96Dpi, true);
|
// QApplication::setAttribute(Qt::AA_Use96Dpi, false);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
|
// QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
|
||||||
#endif
|
#endif
|
||||||
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
|
@ -124,35 +124,6 @@ void BaseWidget::setScale(float value)
|
||||||
this->scaleChanged.invoke(value);
|
this->scaleChanged.invoke(value);
|
||||||
|
|
||||||
this->setScaleIndependantSize(this->getScaleIndependantSize());
|
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)
|
void BaseWidget::scaleChangedEvent(float newDpi)
|
||||||
|
|
|
@ -52,8 +52,6 @@ private:
|
||||||
|
|
||||||
pajlada::Signals::Connection themeConnection;
|
pajlada::Signals::Connection themeConnection;
|
||||||
|
|
||||||
static void setScaleRecursive(float scale, QObject *object);
|
|
||||||
|
|
||||||
friend class BaseWindow;
|
friend class BaseWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -628,9 +628,13 @@ void BaseWindow::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
void BaseWindow::updateScale()
|
void BaseWindow::updateScale()
|
||||||
{
|
{
|
||||||
this->setScale(this->nativeScale_ * (this->flags_ & DisableCustomScaling
|
auto scale = this->nativeScale_ *
|
||||||
? 1
|
(this->flags_ & DisableCustomScaling ? 1 : getApp()->windows->getUiScaleValue());
|
||||||
: getApp()->windows->getUiScaleValue()));
|
this->setScale(scale);
|
||||||
|
|
||||||
|
for (auto child : this->findChildren<BaseWidget *>()) {
|
||||||
|
child->setScale(scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWindow::calcButtonsSizes()
|
void BaseWindow::calcButtonsSizes()
|
||||||
|
|
|
@ -213,6 +213,9 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
float scale = this->getScale();
|
float scale = this->getScale();
|
||||||
|
|
||||||
|
qDebug() << painter.device()->devicePixelRatioF() << painter.device()->devicePixelRatioFScale()
|
||||||
|
<< painter.device()->logicalDpiX();
|
||||||
|
|
||||||
painter.setFont(getApp()->fonts->getFont(FontStyle::UiTabs, scale * this->devicePixelRatioF()));
|
painter.setFont(getApp()->fonts->getFont(FontStyle::UiTabs, scale * this->devicePixelRatioF()));
|
||||||
QFontMetrics metrics =
|
QFontMetrics metrics =
|
||||||
app->fonts->getFontMetrics(FontStyle::UiTabs, scale * this->devicePixelRatioF());
|
app->fonts->getFontMetrics(FontStyle::UiTabs, scale * this->devicePixelRatioF());
|
||||||
|
|
|
@ -69,7 +69,7 @@ void Label::setFontStyle(FontStyle style)
|
||||||
this->updateSize();
|
this->updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::scaleChangedEvent(float)
|
void Label::scaleChangedEvent(float scale)
|
||||||
{
|
{
|
||||||
this->updateSize();
|
this->updateSize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue