diff options
Diffstat (limited to 'launcher/MainWindow.cpp')
-rw-r--r-- | launcher/MainWindow.cpp | 273 |
1 files changed, 145 insertions, 128 deletions
diff --git a/launcher/MainWindow.cpp b/launcher/MainWindow.cpp index 67590946..c3cc6b8d 100644 --- a/launcher/MainWindow.cpp +++ b/launcher/MainWindow.cpp @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "MultiMC.h" +#include "Launcher.h" #include "BuildConfig.h" #include "MainWindow.h" @@ -133,11 +133,21 @@ public: { if(m_text) { - m_contained->setText(QApplication::translate("MainWindow", m_text)); + QString result; + result = QApplication::translate("MainWindow", m_text); + if(result.contains("%1")) { + result = result.arg(BuildConfig.LAUNCHER_NAME); + } + m_contained->setText(result); } if(m_tooltip) { - m_contained->setToolTip(QApplication::translate("MainWindow", m_tooltip)); + QString result; + result = QApplication::translate("MainWindow", m_tooltip); + if(result.contains("%1")) { + result = result.arg(BuildConfig.LAUNCHER_NAME); + } + m_contained->setToolTip(result); } } private: @@ -267,7 +277,7 @@ public: actionAddInstance = TranslatedAction(MainWindow); actionAddInstance->setObjectName(QStringLiteral("actionAddInstance")); - actionAddInstance->setIcon(MMC->getThemedIcon("new")); + actionAddInstance->setIcon(LAUNCHER->getThemedIcon("new")); actionAddInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Add Instance")); actionAddInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Add a new instance.")); all_actions.append(&actionAddInstance); @@ -280,7 +290,7 @@ public: actionViewInstanceFolder = TranslatedAction(MainWindow); actionViewInstanceFolder->setObjectName(QStringLiteral("actionViewInstanceFolder")); - actionViewInstanceFolder->setIcon(MMC->getThemedIcon("viewfolder")); + actionViewInstanceFolder->setIcon(LAUNCHER->getThemedIcon("viewfolder")); actionViewInstanceFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Instance Folder")); actionViewInstanceFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the instance folder in a file browser.")); all_actions.append(&actionViewInstanceFolder); @@ -288,7 +298,7 @@ public: actionViewCentralModsFolder = TranslatedAction(MainWindow); actionViewCentralModsFolder->setObjectName(QStringLiteral("actionViewCentralModsFolder")); - actionViewCentralModsFolder->setIcon(MMC->getThemedIcon("centralmods")); + actionViewCentralModsFolder->setIcon(LAUNCHER->getThemedIcon("centralmods")); actionViewCentralModsFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Central Mods Folder")); actionViewCentralModsFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the central mods folder in a file browser.")); all_actions.append(&actionViewCentralModsFolder); @@ -300,7 +310,7 @@ public: foldersMenuButton->setMenu(foldersMenu); foldersMenuButton->setPopupMode(QToolButton::InstantPopup); foldersMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - foldersMenuButton->setIcon(MMC->getThemedIcon("viewfolder")); + foldersMenuButton->setIcon(LAUNCHER->getThemedIcon("viewfolder")); foldersMenuButton->setFocusPolicy(Qt::NoFocus); all_toolbuttons.append(&foldersMenuButton); QWidgetAction* foldersButtonAction = new QWidgetAction(MainWindow); @@ -309,7 +319,7 @@ public: actionSettings = TranslatedAction(MainWindow); actionSettings->setObjectName(QStringLiteral("actionSettings")); - actionSettings->setIcon(MMC->getThemedIcon("settings")); + actionSettings->setIcon(LAUNCHER->getThemedIcon("settings")); actionSettings->setMenuRole(QAction::PreferencesRole); actionSettings.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Settings")); actionSettings.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Change settings.")); @@ -322,9 +332,9 @@ public: if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { actionReportBug = TranslatedAction(MainWindow); actionReportBug->setObjectName(QStringLiteral("actionReportBug")); - actionReportBug->setIcon(MMC->getThemedIcon("bug")); + actionReportBug->setIcon(LAUNCHER->getThemedIcon("bug")); actionReportBug.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Report a Bug")); - actionReportBug.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the bug tracker to report a bug with MultiMC.")); + actionReportBug.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the bug tracker to report a bug with %1.")); all_actions.append(&actionReportBug); helpMenu->addAction(actionReportBug); } @@ -332,9 +342,9 @@ public: if (!BuildConfig.DISCORD_URL.isEmpty()) { actionDISCORD = TranslatedAction(MainWindow); actionDISCORD->setObjectName(QStringLiteral("actionDISCORD")); - actionDISCORD->setIcon(MMC->getThemedIcon("discord")); + actionDISCORD->setIcon(LAUNCHER->getThemedIcon("discord")); actionDISCORD.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Discord")); - actionDISCORD.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open MultiMC discord voice chat.")); + actionDISCORD.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open %1 discord voice chat.")); all_actions.append(&actionDISCORD); helpMenu->addAction(actionDISCORD); } @@ -342,29 +352,29 @@ public: if (!BuildConfig.SUBREDDIT_URL.isEmpty()) { actionREDDIT = TranslatedAction(MainWindow); actionREDDIT->setObjectName(QStringLiteral("actionREDDIT")); - actionREDDIT->setIcon(MMC->getThemedIcon("reddit-alien")); + actionREDDIT->setIcon(LAUNCHER->getThemedIcon("reddit-alien")); actionREDDIT.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Reddit")); - actionREDDIT.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open MultiMC subreddit.")); + actionREDDIT.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open %1 subreddit.")); all_actions.append(&actionREDDIT); helpMenu->addAction(actionREDDIT); } actionAbout = TranslatedAction(MainWindow); actionAbout->setObjectName(QStringLiteral("actionAbout")); - actionAbout->setIcon(MMC->getThemedIcon("about")); + actionAbout->setIcon(LAUNCHER->getThemedIcon("about")); actionAbout->setMenuRole(QAction::AboutRole); - actionAbout.setTextId(QT_TRANSLATE_NOOP("MainWindow", "About MultiMC")); - actionAbout.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View information about MultiMC.")); + actionAbout.setTextId(QT_TRANSLATE_NOOP("MainWindow", "About %1")); + actionAbout.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View information about %1.")); all_actions.append(&actionAbout); helpMenu->addAction(actionAbout); helpMenuButton = TranslatedToolButton(MainWindow); helpMenuButton.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Help")); - helpMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Get help with MultiMC or Minecraft.")); + helpMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Get help with %1 or Minecraft.")); helpMenuButton->setMenu(helpMenu); helpMenuButton->setPopupMode(QToolButton::InstantPopup); helpMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - helpMenuButton->setIcon(MMC->getThemedIcon("help")); + helpMenuButton->setIcon(LAUNCHER->getThemedIcon("help")); helpMenuButton->setFocusPolicy(Qt::NoFocus); all_toolbuttons.append(&helpMenuButton); QWidgetAction* helpButtonAction = new QWidgetAction(MainWindow); @@ -375,9 +385,9 @@ public: { actionCheckUpdate = TranslatedAction(MainWindow); actionCheckUpdate->setObjectName(QStringLiteral("actionCheckUpdate")); - actionCheckUpdate->setIcon(MMC->getThemedIcon("checkupdate")); + actionCheckUpdate->setIcon(LAUNCHER->getThemedIcon("checkupdate")); actionCheckUpdate.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Update")); - actionCheckUpdate.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Check for new updates for MultiMC.")); + actionCheckUpdate.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Check for new updates for %1.")); all_actions.append(&actionCheckUpdate); mainToolBar->addAction(actionCheckUpdate); } @@ -386,16 +396,16 @@ public: actionPatreon = TranslatedAction(MainWindow); actionPatreon->setObjectName(QStringLiteral("actionPatreon")); - actionPatreon->setIcon(MMC->getThemedIcon("patreon")); - actionPatreon.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Support MultiMC")); - actionPatreon.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the MultiMC Patreon page.")); + actionPatreon->setIcon(LAUNCHER->getThemedIcon("patreon")); + actionPatreon.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Support %1")); + actionPatreon.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the %1 Patreon page.")); all_actions.append(&actionPatreon); mainToolBar->addAction(actionPatreon); actionCAT = TranslatedAction(MainWindow); actionCAT->setObjectName(QStringLiteral("actionCAT")); actionCAT->setCheckable(true); - actionCAT->setIcon(MMC->getThemedIcon("cat")); + actionCAT->setIcon(LAUNCHER->getThemedIcon("cat")); actionCAT.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Meow")); actionCAT.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "It's a fluffy kitty :3")); actionCAT->setPriority(QAction::LowPriority); @@ -408,7 +418,7 @@ public: actionManageAccounts.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Manage Accounts")); // FIXME: no tooltip! actionManageAccounts->setCheckable(false); - actionManageAccounts->setIcon(MMC->getThemedIcon("accounts")); + actionManageAccounts->setIcon(LAUNCHER->getThemedIcon("accounts")); all_actions.append(&actionManageAccounts); all_toolbars.append(&mainToolBar); @@ -435,9 +445,9 @@ public: actionMoreNews = TranslatedAction(MainWindow); actionMoreNews->setObjectName(QStringLiteral("actionMoreNews")); - actionMoreNews->setIcon(MMC->getThemedIcon("news")); + actionMoreNews->setIcon(LAUNCHER->getThemedIcon("news")); actionMoreNews.setTextId(QT_TRANSLATE_NOOP("MainWindow", "More news...")); - actionMoreNews.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the MultiMC development blog to read more news about MultiMC.")); + actionMoreNews.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the development blog to read more news about %1.")); all_actions.append(&actionMoreNews); newsToolBar->addAction(actionMoreNews); @@ -459,7 +469,7 @@ public: // NOTE: not added to toolbar, but used for instance context menu (right click) actionChangeInstIcon = TranslatedAction(MainWindow); actionChangeInstIcon->setObjectName(QStringLiteral("actionChangeInstIcon")); - actionChangeInstIcon->setIcon(QIcon(":/icons/instances/infinity")); + actionChangeInstIcon->setIcon(QIcon(":/icons/instances/grass")); actionChangeInstIcon->setIconVisibleInMenu(true); actionChangeInstIcon.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Change Icon")); actionChangeInstIcon.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Change the selected instance's icon.")); @@ -467,7 +477,7 @@ public: changeIconButton = new LabeledToolButton(MainWindow); changeIconButton->setObjectName(QStringLiteral("changeIconButton")); - changeIconButton->setIcon(MMC->getThemedIcon("news")); + changeIconButton->setIcon(LAUNCHER->getThemedIcon("news")); changeIconButton->setToolTip(actionChangeInstIcon->toolTip()); changeIconButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); instanceToolBar->addWidget(changeIconButton); @@ -578,7 +588,7 @@ public: actionCopyInstance = TranslatedAction(MainWindow); actionCopyInstance->setObjectName(QStringLiteral("actionCopyInstance")); - actionCopyInstance->setIcon(MMC->getThemedIcon("copy")); + actionCopyInstance->setIcon(LAUNCHER->getThemedIcon("copy")); actionCopyInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Copy Instance")); actionCopyInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Copy the selected instance.")); all_actions.append(&actionCopyInstance); @@ -595,10 +605,10 @@ public: MainWindow->setObjectName(QStringLiteral("MainWindow")); } MainWindow->resize(800, 600); - MainWindow->setWindowIcon(MMC->getThemedIcon("logo")); - MainWindow->setWindowTitle("MultiMC 5"); + MainWindow->setWindowIcon(LAUNCHER->getThemedIcon("logo")); + MainWindow->setWindowTitle(BuildConfig.LAUNCHER_DISPLAYNAME); #ifndef QT_NO_ACCESSIBILITY - MainWindow->setAccessibleName("MultiMC"); + MainWindow->setAccessibleName(BuildConfig.LAUNCHER_NAME); #endif createMainToolbar(MainWindow); @@ -623,7 +633,7 @@ public: void retranslateUi(QMainWindow *MainWindow) { - QString winTitle = tr("MultiMC 5 - Version %1").arg(BuildConfig.printableVersionString()); + QString winTitle = tr("%1 - Version %2", "Launcher - Version X").arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString()); if (!BuildConfig.BUILD_PLATFORM.isEmpty()) { winTitle += tr(" on %1", "on platform, as in operating system").arg(BuildConfig.BUILD_PLATFORM); @@ -672,7 +682,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow { m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL)); newsLabel = new QToolButton(); - newsLabel->setIcon(MMC->getThemedIcon("news")); + newsLabel->setIcon(LAUNCHER->getThemedIcon("news")); newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); newsLabel->setFocusPolicy(Qt::NoFocus); @@ -699,20 +709,20 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow connect(view, &GroupView::droppedURLs, this, &MainWindow::droppedURLs, Qt::QueuedConnection); proxymodel = new InstanceProxyModel(this); - proxymodel->setSourceModel(MMC->instances().get()); + proxymodel->setSourceModel(LAUNCHER->instances().get()); proxymodel->sort(0); connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged); view->setModel(proxymodel); view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool { - return MMC->instances()->isGroupCollapsed(groupName); + return LAUNCHER->instances()->isGroupCollapsed(groupName); }); - connect(view, &GroupView::groupStateChanged, MMC->instances().get(), &InstanceList::on_GroupStateChanged); + connect(view, &GroupView::groupStateChanged, LAUNCHER->instances().get(), &InstanceList::on_GroupStateChanged); ui->horizontalLayout->addWidget(view); } // The cat background { - bool cat_enable = MMC->settings()->get("TheCat").toBool(); + bool cat_enable = LAUNCHER->settings()->get("TheCat").toBool(); ui->actionCAT->setChecked(cat_enable); // NOTE: calling the operator like that is an ugly hack to appease ancient gcc... connect(ui->actionCAT.operator->(), SIGNAL(toggled(bool)), SLOT(onCatToggled(bool))); @@ -725,21 +735,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow connect(view->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::instanceChanged); // track icon changes and update the toolbar! - connect(MMC->icons().get(), &IconList::iconUpdated, this, &MainWindow::iconUpdated); + connect(LAUNCHER->icons().get(), &IconList::iconUpdated, this, &MainWindow::iconUpdated); // model reset -> selection is invalid. All the instance pointers are wrong. - connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); + connect(LAUNCHER->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); // handle newly added instances - connect(MMC->instances().get(), &InstanceList::instanceSelectRequest, this, &MainWindow::instanceSelectRequest); + connect(LAUNCHER->instances().get(), &InstanceList::instanceSelectRequest, this, &MainWindow::instanceSelectRequest); // When the global settings page closes, we want to know about it and update our state - connect(MMC, &MultiMC::globalSettingsClosed, this, &MainWindow::globalSettingsClosed); + connect(LAUNCHER, &Launcher::globalSettingsClosed, this, &MainWindow::globalSettingsClosed); m_statusLeft = new QLabel(tr("No instance selected"), this); m_statusCenter = new QLabel(tr("Total playtime: 0s."), this); statusBar()->addPermanentWidget(m_statusLeft, 1); - statusBar()->addPermanentWidget(m_statusCenter, 1); + statusBar()->addPermanentWidget(m_statusCenter, 0); // Add "manage accounts" button, right align QWidget *spacer = new QWidget(); @@ -754,7 +764,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow accountMenuButton->setMenu(accountMenu); accountMenuButton->setPopupMode(QToolButton::InstantPopup); accountMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - accountMenuButton->setIcon(MMC->getThemedIcon("noaccount")); + accountMenuButton->setIcon(LAUNCHER->getThemedIcon("noaccount")); QWidgetAction *accountMenuButtonAction = new QWidgetAction(this); accountMenuButtonAction->setDefaultWidget(accountMenuButton); @@ -765,14 +775,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow // Shouldn't have to use lambdas here like this, but if I don't, the compiler throws a fit. // Template hell sucks... connect( - MMC->accounts().get(), + LAUNCHER->accounts().get(), &AccountList::activeAccountChanged, [this] { activeAccountChanged(); } ); connect( - MMC->accounts().get(), + LAUNCHER->accounts().get(), &AccountList::listChanged, [this] { @@ -784,7 +794,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow activeAccountChanged(); // TODO: refresh accounts here? - // auto accounts = MMC->accounts(); + // auto accounts = LAUNCHER->accounts(); // load the news { @@ -795,20 +805,20 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow if(BuildConfig.UPDATER_ENABLED) { - bool updatesAllowed = MMC->updatesAreAllowed(); + bool updatesAllowed = LAUNCHER->updatesAreAllowed(); updatesAllowedChanged(updatesAllowed); // NOTE: calling the operator like that is an ugly hack to appease ancient gcc... connect(ui->actionCheckUpdate.operator->(), &QAction::triggered, this, &MainWindow::checkForUpdates); // set up the updater object. - auto updater = MMC->updateChecker(); + auto updater = LAUNCHER->updateChecker(); connect(updater.get(), &UpdateChecker::updateAvailable, this, &MainWindow::updateAvailable); connect(updater.get(), &UpdateChecker::noUpdateFound, this, &MainWindow::updateNotAvailable); // if automatic update checks are allowed, start one. - if (MMC->settings()->get("AutoUpdate").toBool() && updatesAllowed) + if (LAUNCHER->settings()->get("AutoUpdate").toBool() && updatesAllowed) { - updater->checkForUpdate(MMC->settings()->get("UpdateChannel").toString(), false); + updater->checkForUpdate(LAUNCHER->settings()->get("UpdateChannel").toString(), false); } } @@ -823,7 +833,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow checker->checkForNotifications(); } - setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); + setSelectedInstanceById(LAUNCHER->settings()->get("SelectedInstance").toString()); // removing this looks stupid view->setFocus(); @@ -833,7 +843,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow void MainWindow::retranslateUi() { - std::shared_ptr<AccountList> accounts = MMC->accounts(); + std::shared_ptr<AccountList> accounts = LAUNCHER->accounts(); MinecraftAccountPtr active_account = accounts->activeAccount(); if(active_account) { auto profileLabel = profileInUseFilter(active_account->profileName(), active_account->isInUse()); @@ -897,7 +907,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos) { auto group = view->groupNameAt(pos); - QAction *actionVoid = new QAction("MultiMC", this); + QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_NAME, this); actionVoid->setEnabled(false); QAction *actionCreateInstance = new QAction(tr("Create instance"), this); @@ -971,16 +981,16 @@ void MainWindow::updateToolsMenu() QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline")); connect(normalLaunch, &QAction::triggered, [this]() { - MMC->launch(m_selectedInstance, true); + LAUNCHER->launch(m_selectedInstance, true); }); connect(normalLaunchOffline, &QAction::triggered, [this]() { - MMC->launch(m_selectedInstance, false); + LAUNCHER->launch(m_selectedInstance, false); }); QString profilersTitle = tr("Profilers"); launchMenu->addSeparator()->setText(profilersTitle); launchOfflineMenu->addSeparator()->setText(profilersTitle); - for (auto profiler : MMC->profilers().values()) + for (auto profiler : LAUNCHER->profilers().values()) { QAction *profilerAction = launchMenu->addAction(profiler->name()); QAction *profilerOfflineAction = launchOfflineMenu->addAction(profiler->name()); @@ -997,11 +1007,11 @@ void MainWindow::updateToolsMenu() { connect(profilerAction, &QAction::triggered, [this, profiler]() { - MMC->launch(m_selectedInstance, true, profiler.get()); + LAUNCHER->launch(m_selectedInstance, true, profiler.get()); }); connect(profilerOfflineAction, &QAction::triggered, [this, profiler]() { - MMC->launch(m_selectedInstance, false, profiler.get()); + LAUNCHER->launch(m_selectedInstance, false, profiler.get()); }); } } @@ -1013,7 +1023,7 @@ void MainWindow::repopulateAccountsMenu() { accountMenu->clear(); - std::shared_ptr<AccountList> accounts = MMC->accounts(); + std::shared_ptr<AccountList> accounts = LAUNCHER->accounts(); MinecraftAccountPtr active_account = accounts->activeAccount(); QString active_profileId = ""; @@ -1059,7 +1069,7 @@ void MainWindow::repopulateAccountsMenu() QAction *action = new QAction(tr("No Default Account"), this); action->setCheckable(true); - action->setIcon(MMC->getThemedIcon("noaccount")); + action->setIcon(LAUNCHER->getThemedIcon("noaccount")); action->setData(""); if (active_profileId.isEmpty()) { action->setChecked(true); @@ -1099,7 +1109,7 @@ void MainWindow::changeActiveAccount() id = data.toString(); } - MMC->accounts()->setActiveAccount(id); + LAUNCHER->accounts()->setActiveAccount(id); activeAccountChanged(); } @@ -1108,7 +1118,7 @@ void MainWindow::activeAccountChanged() { repopulateAccountsMenu(); - MinecraftAccountPtr account = MMC->accounts()->activeAccount(); + MinecraftAccountPtr account = LAUNCHER->accounts()->activeAccount(); // FIXME: this needs adjustment for MSA if (account != nullptr && account->profileName() != "") @@ -1120,7 +1130,7 @@ void MainWindow::activeAccountChanged() } // Set the icon to the "no account" icon. - accountMenuButton->setIcon(MMC->getThemedIcon("noaccount")); + accountMenuButton->setIcon(LAUNCHER->getThemedIcon("noaccount")); accountMenuButton->setText(tr("Profiles")); } @@ -1182,7 +1192,7 @@ void MainWindow::updateNewsLabel() void MainWindow::updateAvailable(GoUpdate::Status status) { - if(!MMC->updatesAreAllowed()) + if(!LAUNCHER->updatesAreAllowed()) { updateNotAvailable(); return; @@ -1228,7 +1238,7 @@ QString intListToString(const QList<int> &list) void MainWindow::notificationsChanged() { QList<NotificationChecker::NotificationEntry> entries = m_notificationChecker->notificationEntries(); - QList<int> shownNotifications = stringToIntList(MMC->settings()->get("ShownNotifications").toString()); + QList<int> shownNotifications = stringToIntList(LAUNCHER->settings()->get("ShownNotifications").toString()); for (auto it = entries.begin(); it != entries.end(); ++it) { NotificationChecker::NotificationEntry entry = *it; @@ -1241,20 +1251,20 @@ void MainWindow::notificationsChanged() } } } - MMC->settings()->set("ShownNotifications", intListToString(shownNotifications)); + LAUNCHER->settings()->set("ShownNotifications", intListToString(shownNotifications)); } void MainWindow::downloadUpdates(GoUpdate::Status status) { - if(!MMC->updatesAreAllowed()) + if(!LAUNCHER->updatesAreAllowed()) { return; } qDebug() << "Downloading updates."; ProgressDialog updateDlg(this); - status.rootPath = MMC->root(); + status.rootPath = LAUNCHER->root(); - auto dlPath = FS::PathCombine(MMC->root(), "update", "XXXXXX"); + auto dlPath = FS::PathCombine(LAUNCHER->root(), "update", "XXXXXX"); if (!FS::ensureFilePathExists(dlPath)) { CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); @@ -1267,10 +1277,10 @@ void MainWindow::downloadUpdates(GoUpdate::Status status) * NOTE: This disables launching instances until the update either succeeds (and this process exits) * or the update fails (and the control leaves this scope). */ - MMC->updateIsRunning(true); - UpdateController update(this, MMC->root(), updateTask.updateFilesDir(), updateTask.operations()); + LAUNCHER->updateIsRunning(true); + UpdateController update(this, LAUNCHER->root(), updateTask.updateFilesDir(), updateTask.operations()); update.installUpdates(); - MMC->updateIsRunning(false); + LAUNCHER->updateIsRunning(false); } else { @@ -1281,7 +1291,7 @@ void MainWindow::downloadUpdates(GoUpdate::Status status) void MainWindow::onCatToggled(bool state) { setCatBackground(state); - MMC->settings()->set("TheCat", state); + LAUNCHER->settings()->set("TheCat", state); } namespace { @@ -1339,7 +1349,7 @@ void MainWindow::runModalTask(Task *task) void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask) { - unique_qobject_ptr<Task> task(MMC->instances()->wrapInstanceTask(rawTask)); + unique_qobject_ptr<Task> task(LAUNCHER->instances()->wrapInstanceTask(rawTask)); runModalTask(task.get()); } @@ -1356,7 +1366,7 @@ void MainWindow::on_actionCopyInstance_triggered() copyTask->setName(copyInstDlg.instName()); copyTask->setGroup(copyInstDlg.instGroup()); copyTask->setIcon(copyInstDlg.iconKey()); - unique_qobject_ptr<Task> task(MMC->instances()->wrapInstanceTask(copyTask)); + unique_qobject_ptr<Task> task(LAUNCHER->instances()->wrapInstanceTask(copyTask)); runModalTask(task.get()); } @@ -1364,7 +1374,7 @@ void MainWindow::finalizeInstance(InstancePtr inst) { view->updateGeometries(); setSelectedInstanceById(inst->id()); - if (MMC->accounts()->anyAccountIsValid()) + if (LAUNCHER->accounts()->anyAccountIsValid()) { ProgressDialog loadDialog(this); auto update = inst->createUpdateTask(Net::Mode::Online); @@ -1381,10 +1391,13 @@ void MainWindow::finalizeInstance(InstancePtr inst) } else { - CustomMessageBox::selectable(this, tr("Error"), tr("MultiMC cannot download Minecraft or update instances unless you have at least " - "one account added.\nPlease add your Mojang or Minecraft account."), - QMessageBox::Warning) - ->show(); + CustomMessageBox::selectable( + this, + tr("Error"), + tr("The launcher cannot download Minecraft or update instances unless you have at least " + "one account added.\nPlease add your Mojang or Minecraft account."), + QMessageBox::Warning + )->show(); } } @@ -1407,14 +1420,14 @@ void MainWindow::addInstance(QString url) if(groupName.isEmpty()) { - groupName = MMC->settings()->get("LastUsedGroupForNewInstance").toString(); + groupName = LAUNCHER->settings()->get("LastUsedGroupForNewInstance").toString(); } NewInstanceDialog newInstDlg(groupName, url, this); if (!newInstDlg.exec()) return; - MMC->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup()); + LAUNCHER->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup()); InstanceTask * creationTask = newInstDlg.extractTask(); if(creationTask) @@ -1465,7 +1478,7 @@ void MainWindow::on_actionChangeInstIcon_triggered() if (dlg.result() == QDialog::Accepted) { m_selectedInstance->setIconKey(dlg.selectedIconKey); - auto icon = MMC->icons()->getIcon(dlg.selectedIconKey); + auto icon = LAUNCHER->icons()->getIcon(dlg.selectedIconKey); ui->actionChangeInstIcon->setIcon(icon); ui->changeIconButton->setIcon(icon); } @@ -1475,7 +1488,7 @@ void MainWindow::iconUpdated(QString icon) { if (icon == m_currentInstIcon) { - auto icon = MMC->icons()->getIcon(m_currentInstIcon); + auto icon = LAUNCHER->icons()->getIcon(m_currentInstIcon); ui->actionChangeInstIcon->setIcon(icon); ui->changeIconButton->setIcon(icon); } @@ -1484,7 +1497,7 @@ void MainWindow::iconUpdated(QString icon) void MainWindow::updateInstanceToolIcon(QString new_icon) { m_currentInstIcon = new_icon; - auto icon = MMC->icons()->getIcon(m_currentInstIcon); + auto icon = LAUNCHER->icons()->getIcon(m_currentInstIcon); ui->actionChangeInstIcon->setIcon(icon); ui->changeIconButton->setIcon(icon); } @@ -1493,7 +1506,7 @@ void MainWindow::setSelectedInstanceById(const QString &id) { if (id.isNull()) return; - const QModelIndex index = MMC->instances()->getInstanceIndexById(id); + const QModelIndex index = LAUNCHER->instances()->getInstanceIndexById(id); if (index.isValid()) { QModelIndex selectionIndex = proxymodel->mapFromSource(index); @@ -1509,8 +1522,8 @@ void MainWindow::on_actionChangeInstGroup_triggered() bool ok = false; InstanceId instId = m_selectedInstance->id(); - QString name(MMC->instances()->getInstanceGroup(instId)); - auto groups = MMC->instances()->getGroups(); + QString name(LAUNCHER->instances()->getInstanceGroup(instId)); + auto groups = LAUNCHER->instances()->getGroups(); groups.insert(0, ""); groups.sort(Qt::CaseInsensitive); int foo = groups.indexOf(name); @@ -1519,7 +1532,7 @@ void MainWindow::on_actionChangeInstGroup_triggered() name = name.simplified(); if (ok) { - MMC->instances()->setInstanceGroup(instId, name); + LAUNCHER->instances()->setInstanceGroup(instId, name); } } @@ -1541,25 +1554,25 @@ void MainWindow::deleteGroup() .arg(groupName), QMessageBox::Yes | QMessageBox::No); if(reply == QMessageBox::Yes) { - MMC->instances()->deleteGroup(groupName); + LAUNCHER->instances()->deleteGroup(groupName); } } } void MainWindow::on_actionViewInstanceFolder_triggered() { - QString str = MMC->settings()->get("InstanceDir").toString(); + QString str = LAUNCHER->settings()->get("InstanceDir").toString(); DesktopServices::openDirectory(str); } void MainWindow::refreshInstances() { - MMC->instances()->loadList(); + LAUNCHER->instances()->loadList(); } void MainWindow::on_actionViewCentralModsFolder_triggered() { - DesktopServices::openDirectory(MMC->settings()->get("CentralModsDir").toString(), true); + DesktopServices::openDirectory(LAUNCHER->settings()->get("CentralModsDir").toString(), true); } void MainWindow::on_actionConfig_Folder_triggered() @@ -1575,8 +1588,8 @@ void MainWindow::checkForUpdates() { if(BuildConfig.UPDATER_ENABLED) { - auto updater = MMC->updateChecker(); - updater->checkForUpdate(MMC->settings()->get("UpdateChannel").toString(), true); + auto updater = LAUNCHER->updateChecker(); + updater->checkForUpdate(LAUNCHER->settings()->get("UpdateChannel").toString(), true); } else { @@ -1586,13 +1599,13 @@ void MainWindow::checkForUpdates() void MainWindow::on_actionSettings_triggered() { - MMC->ShowGlobalSettings(this, "global-settings"); + LAUNCHER->ShowGlobalSettings(this, "global-settings"); } void MainWindow::globalSettingsClosed() { // FIXME: quick HACK to make this work. improve, optimize. - MMC->instances()->loadList(); + LAUNCHER->instances()->loadList(); proxymodel->invalidate(); proxymodel->sort(0); updateToolsMenu(); @@ -1601,32 +1614,32 @@ void MainWindow::globalSettingsClosed() void MainWindow::on_actionInstanceSettings_triggered() { - MMC->showInstanceWindow(m_selectedInstance, "settings"); + LAUNCHER->showInstanceWindow(m_selectedInstance, "settings"); } void MainWindow::on_actionEditInstNotes_triggered() { - MMC->showInstanceWindow(m_selectedInstance, "notes"); + LAUNCHER->showInstanceWindow(m_selectedInstance, "notes"); } void MainWindow::on_actionWorlds_triggered() { - MMC->showInstanceWindow(m_selectedInstance, "worlds"); + LAUNCHER->showInstanceWindow(m_selectedInstance, "worlds"); } void MainWindow::on_actionEditInstance_triggered() { - MMC->showInstanceWindow(m_selectedInstance); + LAUNCHER->showInstanceWindow(m_selectedInstance); } void MainWindow::on_actionScreenshots_triggered() { - MMC->showInstanceWindow(m_selectedInstance, "screenshots"); + LAUNCHER->showInstanceWindow(m_selectedInstance, "screenshots"); } void MainWindow::on_actionManageAccounts_triggered() { - MMC->ShowGlobalSettings(this, "accounts"); + LAUNCHER->ShowGlobalSettings(this, "accounts"); } void MainWindow::on_actionReportBug_triggered() @@ -1680,7 +1693,7 @@ void MainWindow::on_actionDeleteInstance_triggered() )->exec(); if (response == QMessageBox::Yes) { - MMC->instances()->deleteInstance(id); + LAUNCHER->instances()->deleteInstance(id); } } @@ -1728,8 +1741,8 @@ void MainWindow::on_actionViewSelectedMCFolder_triggered() void MainWindow::closeEvent(QCloseEvent *event) { // Save the window state and geometry. - MMC->settings()->set("MainWindowState", saveState().toBase64()); - MMC->settings()->set("MainWindowGeometry", saveGeometry().toBase64()); + LAUNCHER->settings()->set("MainWindowState", saveState().toBase64()); + LAUNCHER->settings()->set("MainWindowGeometry", saveGeometry().toBase64()); event->accept(); emit isClosing(); } @@ -1748,7 +1761,7 @@ void MainWindow::instanceActivated(QModelIndex index) if (!index.isValid()) return; QString id = index.data(InstanceList::InstanceIDRole).toString(); - InstancePtr inst = MMC->instances()->getInstanceById(id); + InstancePtr inst = LAUNCHER->instances()->getInstanceById(id); if (!inst) return; @@ -1763,24 +1776,24 @@ void MainWindow::on_actionLaunchInstance_triggered() } if(m_selectedInstance->isRunning()) { - MMC->kill(m_selectedInstance); + LAUNCHER->kill(m_selectedInstance); } else { - MMC->launch(m_selectedInstance); + LAUNCHER->launch(m_selectedInstance); } } void MainWindow::activateInstance(InstancePtr instance) { - MMC->launch(instance); + LAUNCHER->launch(instance); } void MainWindow::on_actionLaunchInstanceOffline_triggered() { if (m_selectedInstance) { - MMC->launch(m_selectedInstance, false); + LAUNCHER->launch(m_selectedInstance, false); } } @@ -1804,12 +1817,12 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & { if (!current.isValid()) { - MMC->settings()->set("SelectedInstance", QString()); + LAUNCHER->settings()->set("SelectedInstance", QString()); selectionBad(); return; } QString id = current.data(InstanceList::InstanceIDRole).toString(); - m_selectedInstance = MMC->instances()->getInstanceById(id); + m_selectedInstance = LAUNCHER->instances()->getInstanceById(id); if (m_selectedInstance) { ui->instanceToolBar->setEnabled(true); @@ -1832,12 +1845,12 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & updateToolsMenu(); - MMC->settings()->set("SelectedInstance", m_selectedInstance->id()); + LAUNCHER->settings()->set("SelectedInstance", m_selectedInstance->id()); } else { ui->instanceToolBar->setEnabled(false); - MMC->settings()->set("SelectedInstance", QString()); + LAUNCHER->settings()->set("SelectedInstance", QString()); selectionBad(); return; } @@ -1866,33 +1879,37 @@ void MainWindow::selectionBad() statusBar()->clearMessage(); ui->instanceToolBar->setEnabled(false); ui->renameButton->setText(tr("Rename Instance")); - updateInstanceToolIcon("infinity"); + updateInstanceToolIcon("grass"); // ...and then see if we can enable the previously selected instance - setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); + setSelectedInstanceById(LAUNCHER->settings()->get("SelectedInstance").toString()); } void MainWindow::checkInstancePathForProblems() { - QString instanceFolder = MMC->settings()->get("InstanceDir").toString(); + QString instanceFolder = LAUNCHER->settings()->get("InstanceDir").toString(); if (FS::checkProblemticPathJava(QDir(instanceFolder))) { QMessageBox warning(this); warning.setText(tr("Your instance folder contains \'!\' and this is known to cause Java problems!")); - warning.setInformativeText(tr("You have now two options: <br/>" - " - change the instance folder in the settings <br/>" - " - move this installation of MultiMC5 to a different folder")); + warning.setInformativeText( + tr( + "You have now two options: <br/>" + " - change the instance folder in the settings <br/>" + " - move this installation of %1 to a different folder" + ).arg(BuildConfig.LAUNCHER_NAME) + ); warning.setDefaultButton(QMessageBox::Ok); warning.exec(); } auto tempFolderText = tr("This is a problem: <br/>" - " - MultiMC will likely be deleted without warning by the operating system <br/>" - " - close MultiMC now and extract it to a real location, not a temporary folder"); + " - The launcher will likely be deleted without warning by the operating system <br/>" + " - close the launcher now and extract it to a real location, not a temporary folder"); QString pathfoldername = QDir(instanceFolder).absolutePath(); if (pathfoldername.contains("Rar$", Qt::CaseInsensitive)) { QMessageBox warning(this); - warning.setText(tr("Your instance folder contains \'Rar$\' - that means you haven't extracted the MultiMC zip!")); + warning.setText(tr("Your instance folder contains \'Rar$\' - that means you haven't extracted the launcher archive!")); warning.setInformativeText(tempFolderText); warning.setDefaultButton(QMessageBox::Ok); warning.exec(); @@ -1909,7 +1926,7 @@ void MainWindow::checkInstancePathForProblems() void MainWindow::updateStatusCenter() { - int timeplayed = MMC->instances()->getTotalPlayTime(); + int timeplayed = LAUNCHER->instances()->getTotalPlayTime(); int minutesTotal = timeplayed / 60; int seconds = timeplayed % 60; int minutes = minutesTotal % 60; |