diff --git a/lib/appbase/widgets/Label.cpp b/lib/appbase/widgets/Label.cpp index 189b37a1..084307ed 100644 --- a/lib/appbase/widgets/Label.cpp +++ b/lib/appbase/widgets/Label.cpp @@ -83,12 +83,20 @@ QSize Label::minimumSizeHint() const void Label::paintEvent(QPaintEvent *) { QPainter painter(this); + + qreal deviceDpi = +#ifdef Q_OS_WIN + this->devicePixelRatioF(); +#else + 1.0; +#endif + QFontMetrics metrics = getFonts()->getFontMetrics( this->getFontStyle(), - this->scale() * 96.f / this->logicalDpiX() * this->devicePixelRatioF()); + this->scale() * 96.f / this->logicalDpiX() * deviceDpi); painter.setFont(getFonts()->getFont( - this->getFontStyle(), this->scale() * 96.f / this->logicalDpiX() * - this->devicePixelRatioF())); + this->getFontStyle(), + this->scale() * 96.f / this->logicalDpiX() * deviceDpi)); int offset = this->getOffset(); diff --git a/src/.clang-format b/src/.clang-format index 64970a15..0ef59b1f 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -9,7 +9,6 @@ AlwaysBreakAfterDefinitionReturnType: false AlwaysBreakBeforeMultilineStrings: false BasedOnStyle: Google BraceWrapping: { - AfterCaseLabel: 'false' AfterClass: 'true' AfterControlStatement: 'true' AfterFunction: 'true' diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index faaa1d6b..2ae6aedb 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -22,6 +22,16 @@ #include namespace chatterino { +namespace { + qreal deviceDpi(QWidget *widget) + { +#ifdef Q_OS_WIN + return widget->devicePixelRatioF(); +#else + return 1.0; +#endif + } +} // namespace NotebookTab::NotebookTab(Notebook *notebook) : Button(notebook) @@ -83,11 +93,10 @@ void NotebookTab::themeChangedEvent() void NotebookTab::updateSize() { float scale = this->scale(); - int width; + QFontMetrics metrics = getApp()->fonts->getFontMetrics( - FontStyle::UiTabs, - float(qreal(this->scale()) * this->devicePixelRatioF())); + FontStyle::UiTabs, float(qreal(this->scale()) * deviceDpi(this))); if (this->hasXButton()) { @@ -276,10 +285,10 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.setFont(getApp()->fonts->getFont( FontStyle::UiTabs, - scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF())); + scale * 96.f / this->logicalDpiX() * deviceDpi(this))); QFontMetrics metrics = app->fonts->getFontMetrics( FontStyle::UiTabs, - scale * 96.f / this->logicalDpiX() * this->devicePixelRatioF()); + scale * 96.f / this->logicalDpiX() * deviceDpi(this)); int height = int(scale * NOTEBOOK_TAB_HEIGHT); @@ -299,12 +308,12 @@ void NotebookTab::paintEvent(QPaintEvent *) bool windowFocused = this->window() == QApplication::activeWindow(); QBrush tabBackground = /*this->mouseOver_ ? colors.backgrounds.hover - :*/ + :*/ (windowFocused ? colors.backgrounds.regular : colors.backgrounds.unfocused); // fill the tab background - auto bgRect = rect(); + auto bgRect = this->rect(); bgRect.setTop(ceil((this->selected_ ? 0.f : 1.f) * scale)); painter.fillRect(bgRect, tabBackground);