fixed user popup not hidpi scaling properly

This commit is contained in:
fourtf 2017-12-18 01:17:02 +01:00
parent 01e9c723fa
commit 90db7a3995
2 changed files with 15 additions and 0 deletions

View file

@ -25,6 +25,8 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
{ {
_ui->setupUi(this); _ui->setupUi(this);
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::FramelessWindowHint);
this->initAsWindow(); this->initAsWindow();
@ -120,6 +122,8 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
util::twitch::getUserID(userNickname, this, util::twitch::getUserID(userNickname, this,
[=](const QString &id) { currentTwitchUser->setUserId(id); }); [=](const QString &id) { currentTwitchUser->setUserId(id); });
this->dpiMultiplyerChanged(this->getDpiMultiplier(), this->getDpiMultiplier());
} }
void AccountPopupWidget::setName(const QString &name) void AccountPopupWidget::setName(const QString &name)
@ -196,6 +200,14 @@ void AccountPopupWidget::updatePermissions()
} }
} }
void AccountPopupWidget::dpiMultiplyerChanged(float oldDpi, float newDpi)
{
this->setStyleSheet(QString("* { font-size: <font-size>px; }")
.replace("<font-size>", QString::number((int)(12 * newDpi))));
this->_ui->lblAvatar->setFixedSize((int)(100 * newDpi), (int)(100 * newDpi));
}
void AccountPopupWidget::updateButtons(QWidget *layout, bool state) void AccountPopupWidget::updateButtons(QWidget *layout, bool state)
{ {
for (auto button : layout->findChildren<QPushButton *>()) { for (auto button : layout->findChildren<QPushButton *>()) {

View file

@ -30,6 +30,9 @@ public:
void updatePermissions(); void updatePermissions();
protected:
virtual void dpiMultiplyerChanged(float oldDpi, float newDpi) override;
private: private:
Ui::AccountPopup *_ui; Ui::AccountPopup *_ui;