From bf39851776aa53016f1b451a1ecffc6a8ce3f31f Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Mon, 18 Dec 2017 21:02:17 +0100 Subject: [PATCH] update window title when changing accounts --- src/widgets/window.cpp | 15 +++++++++++++++ src/widgets/window.hpp | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 28859f3d3..5a5eb1b96 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -1,4 +1,5 @@ #include "widgets/window.hpp" +#include "accountmanager.hpp" #include "channelmanager.hpp" #include "colorscheme.hpp" #include "settingsmanager.hpp" @@ -25,6 +26,15 @@ Window::Window(const QString &_windowName, ChannelManager &_channelManager, { this->initAsWindow(); + AccountManager::getInstance().Twitch.currentUsername.connect( + [this](const std::string &newUsername, auto) { + if (newUsername.empty()) { + this->refreshWindowTitle("Not logged in"); + } else { + this->refreshWindowTitle(QString::fromStdString(newUsername)); + } + }); + QVBoxLayout *layout = new QVBoxLayout(this); // add titlebar @@ -110,6 +120,11 @@ Notebook &Window::getNotebook() return this->notebook; } +void Window::refreshWindowTitle(const QString &username) +{ + this->setWindowTitle(username + " - Chatterino for Twitch"); +} + void Window::closeEvent(QCloseEvent *) { const QRect &geom = this->geometry(); diff --git a/src/widgets/window.hpp b/src/widgets/window.hpp index 4d5c7a76a..7af3536d2 100644 --- a/src/widgets/window.hpp +++ b/src/widgets/window.hpp @@ -58,6 +58,8 @@ public: Notebook &getNotebook(); + void refreshWindowTitle(const QString &username); + boost::signals2::signal closed; protected: