Add option for unique config

This commit is contained in:
LorenDB 2020-10-21 19:20:02 -04:00
parent 8a188ac6f7
commit a2bd266c11
7 changed files with 69 additions and 24 deletions

View file

@ -53,10 +53,11 @@
MainWindow *MainWindow::instance_ = nullptr;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
MainWindow::MainWindow(const QString profile, QWidget *parent)
: QMainWindow(parent),
profile_{ profile }
{
setWindowTitle("nheko");
setWindowTitle(0);
setObjectName("MainWindow");
modal_ = new OverlayModal(this);
@ -104,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(
chat_page_, &ChatPage::showOverlayProgressBar, this, &MainWindow::showOverlayProgressBar);
connect(
chat_page_, SIGNAL(changeWindowTitle(QString)), this, SLOT(setWindowTitle(QString)));
chat_page_, &ChatPage::unreadMessages, this, &MainWindow::setWindowTitle);
connect(chat_page_, SIGNAL(unreadMessages(int)), trayIcon_, SLOT(setUnreadCount(int)));
connect(chat_page_, &ChatPage::showLoginPage, this, [this](const QString &msg) {
login_page_->loginError(msg);
@ -178,6 +179,19 @@ MainWindow::MainWindow(QWidget *parent)
}
}
void
MainWindow::setWindowTitle(int notificationCount)
{
QString name = "nheko";
if (!profile_.isEmpty())
name += " | " + profile_;
if (notificationCount > 0)
{
name.append(QString{" (%1)"}.arg(notificationCount));
}
QMainWindow::setWindowTitle(name);
}
void
MainWindow::showEvent(QShowEvent *event)
{