diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 65bc21b20..c85bec6fc 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -2,6 +2,7 @@ #include "singletons/settingsmanager.hpp" #include "util/nativeeventhelper.hpp" +#include "widgets/helper/rippleeffectlabel.hpp" #include "widgets/tooltipwidget.hpp" #include @@ -149,7 +150,6 @@ bool BaseWindow::hasCustomWindowFrame() { #ifdef Q_OS_WIN return this->enableCustomFrame; -// return false; #else return false; #endif @@ -182,6 +182,19 @@ void BaseWindow::addTitleBarButton(const TitleBarButton::Style &style, QObject::connect(button, &TitleBarButton::clicked, this, [onClicked] { onClicked(); }); } +RippleEffectLabel *BaseWindow::addTitleBarLabel(std::function onClicked) +{ + RippleEffectLabel *button = new RippleEffectLabel; + button->setScaleIndependantHeight(30); + + this->buttons.push_back(button); + this->titlebarBox->insertWidget(2, button); + + QObject::connect(button, &RippleEffectLabel::clicked, this, [onClicked] { onClicked(); }); + + return button; +} + void BaseWindow::changeEvent(QEvent *) { TooltipWidget::getInstance()->hide(); diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index fc6ccd756..3f4c3c0f1 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -10,6 +10,7 @@ class QHBoxLayout; namespace chatterino { namespace widgets { class RippleEffectButton; +class RippleEffectLabel; class TitleBarButton; class BaseWindow : public BaseWidget @@ -23,6 +24,7 @@ public: QWidget *getLayoutContainer(); bool hasCustomWindowFrame(); void addTitleBarButton(const TitleBarButton::Style &style, std::function onClicked); + RippleEffectLabel *addTitleBarLabel(std::function onClicked); void setStayInScreenRect(bool value); bool getStayInScreenRect() const; diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index d83dd4812..29f7d4a5b 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -39,9 +39,14 @@ Window::Window(const QString &windowName, singletons::ThemeManager &_themeManage this->addTitleBarButton(TitleBarButton::Settings, [] { singletons::WindowManager::getInstance().showSettingsDialog(); }); - this->addTitleBarButton(TitleBarButton::User, [this] { + auto user = this->addTitleBarLabel([this] { singletons::WindowManager::getInstance().showAccountSelectPopup(QCursor::pos()); }); + + singletons::AccountManager::getInstance().Twitch.userChanged.connect([this, user] { + user->getLabel().setText( + singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName()); + }); } QVBoxLayout *layout = new QVBoxLayout(this);