summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-15 09:18:55 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-17 01:00:15 +0100
commit9cf8b42d8923454b335159b08cc6dd551afd9301 (patch)
treeb7fb92cc5089b56009548ce584b4475382081d02
parent12f6534e77d28ba5dc5fd5f555d43e7cd9da9336 (diff)
downloadMultiMC-9cf8b42d8923454b335159b08cc6dd551afd9301.tar
MultiMC-9cf8b42d8923454b335159b08cc6dd551afd9301.tar.gz
MultiMC-9cf8b42d8923454b335159b08cc6dd551afd9301.tar.lz
MultiMC-9cf8b42d8923454b335159b08cc6dd551afd9301.tar.xz
MultiMC-9cf8b42d8923454b335159b08cc6dd551afd9301.zip
NOISSUE mark profile in use also on the main window profile button
-rw-r--r--application/MainWindow.cpp30
-rw-r--r--application/MainWindow.h22
2 files changed, 34 insertions, 18 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 5ef32804..e5ea81f6 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -699,6 +699,18 @@ void MainWindow::updateToolsMenu()
ui->actionLaunchInstance->setMenu(launchMenu);
}
+QString profileInUseFilter(const QString & profile, bool used)
+{
+ if(used)
+ {
+ return profile + QObject::tr(" (in use)");
+ }
+ else
+ {
+ return profile;
+ }
+}
+
void MainWindow::repopulateAccountsMenu()
{
accountMenu->clear();
@@ -709,7 +721,14 @@ void MainWindow::repopulateAccountsMenu()
QString active_username = "";
if (active_account != nullptr)
{
- active_username = accounts->activeAccount()->username();
+ active_username = active_account->username();
+ const AccountProfile *profile = active_account->currentProfile();
+ // this can be called before accountMenuButton exists
+ if (profile != nullptr && accountMenuButton)
+ {
+ auto profileLabel = profileInUseFilter(profile->name, active_account->isInUse());
+ accountMenuButton->setText(profileLabel);
+ }
}
if (accounts->count() <= 0)
@@ -726,11 +745,7 @@ void MainWindow::repopulateAccountsMenu()
MojangAccountPtr account = accounts->at(i);
for (auto profile : account->profiles())
{
- auto profileLabel = profile.name;
- if(account->isInUse())
- {
- profileLabel += tr(" (in use)");
- }
+ auto profileLabel = profileInUseFilter(profile.name, account->isInUse());
QAction *action = new QAction(profileLabel, this);
action->setData(account->username());
action->setCheckable(true);
@@ -798,8 +813,9 @@ void MainWindow::activeAccountChanged()
const AccountProfile *profile = account->currentProfile();
if (profile != nullptr)
{
+ auto profileLabel = profileInUseFilter(profile->name, account->isInUse());
accountMenuButton->setIcon(SkinUtils::getFaceFromCache(profile->id));
- accountMenuButton->setText(profile->name);
+ accountMenuButton->setText(profileLabel);
return;
}
}
diff --git a/application/MainWindow.h b/application/MainWindow.h
index 506f7ee3..3ee03a7f 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -176,16 +176,16 @@ private:
std::unique_ptr<Ui> ui;
// these are managed by Qt's memory management model!
- GroupView *view;
- InstanceProxyModel *proxymodel;
- LabeledToolButton *renameButton;
- QToolButton *changeIconButton;
- QToolButton *newsLabel;
- QLabel *m_statusLeft;
- ServerStatus *m_statusRight;
- QMenu *accountMenu;
- QToolButton *accountMenuButton;
- QAction *manageAccountsAction;
+ GroupView *view = nullptr;
+ InstanceProxyModel *proxymodel = nullptr;
+ LabeledToolButton *renameButton = nullptr;
+ QToolButton *changeIconButton = nullptr;
+ QToolButton *newsLabel = nullptr;
+ QLabel *m_statusLeft = nullptr;
+ ServerStatus *m_statusRight = nullptr;
+ QMenu *accountMenu = nullptr;
+ QToolButton *accountMenuButton = nullptr;
+ QAction *manageAccountsAction = nullptr;
unique_qobject_ptr<NetJob> skin_download_job;
unique_qobject_ptr<NewsChecker> m_newsChecker;
@@ -195,5 +195,5 @@ private:
QString m_currentInstIcon;
// managed by the application object
- Task *m_versionLoadTask;
+ Task *m_versionLoadTask = nullptr;
};