update window title when changing accounts

This commit is contained in:
Rasmus Karlsson 2017-12-18 21:02:17 +01:00
parent e46357ad9b
commit bf39851776
2 changed files with 17 additions and 0 deletions

View file

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

View file

@ -58,6 +58,8 @@ public:
Notebook &getNotebook();
void refreshWindowTitle(const QString &username);
boost::signals2::signal<void()> closed;
protected: