fixes tab and split header title text size

This commit is contained in:
fourtf 2019-10-06 21:31:12 +02:00
parent 4ab8a7e9dd
commit 9f52564b9c
3 changed files with 27 additions and 11 deletions

View file

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

View file

@ -9,7 +9,6 @@ AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakBeforeMultilineStrings: false
BasedOnStyle: Google
BraceWrapping: {
AfterCaseLabel: 'false'
AfterClass: 'true'
AfterControlStatement: 'true'
AfterFunction: 'true'

View file

@ -22,6 +22,16 @@
#include <boost/bind.hpp>
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);