diff options
author | AlexTMjugador <AlexTMjugador@users.noreply.github.com> | 2019-04-15 00:42:06 +0200 |
---|---|---|
committer | AlexTMjugador <AlexTMjugador@users.noreply.github.com> | 2019-04-15 00:42:06 +0200 |
commit | 0ce637bf0ece752ea82ddc8333cde3a74e0918a8 (patch) | |
tree | 79789fa6da58b5badbc4903fd596232e13bebe67 | |
parent | 70ed30f9e6b47fbfb3151078ca61a2bb419feccb (diff) | |
download | MultiMC-0ce637bf0ece752ea82ddc8333cde3a74e0918a8.tar MultiMC-0ce637bf0ece752ea82ddc8333cde3a74e0918a8.tar.gz MultiMC-0ce637bf0ece752ea82ddc8333cde3a74e0918a8.tar.lz MultiMC-0ce637bf0ece752ea82ddc8333cde3a74e0918a8.tar.xz MultiMC-0ce637bf0ece752ea82ddc8333cde3a74e0918a8.zip |
Support launching profiler in offline mode
This commit adds the necessary GUI controls to let the user choose
whether they want to launch Minecraft in offline mode with a configured profiler.
-rw-r--r-- | application/MainWindow.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 3c957995..69457e11 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -902,15 +902,21 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos) void MainWindow::updateToolsMenu() { QToolButton *launchButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance)); + QToolButton* launchOfflineButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstanceOffline)); + if(!m_selectedInstance || m_selectedInstance->isRunning()) { ui->actionLaunchInstance->setMenu(nullptr); + ui->actionLaunchInstanceOffline->setMenu(nullptr); launchButton->setPopupMode(QToolButton::InstantPopup); + launchOfflineButton->setPopupMode(QToolButton::InstantPopup); return; } QMenu *launchMenu = ui->actionLaunchInstance->menu(); + QMenu* launchOfflineMenu = ui->actionLaunchInstanceOffline->menu(); launchButton->setPopupMode(QToolButton::MenuButtonPopup); + launchOfflineButton->setPopupMode(QToolButton::MenuButtonPopup); if (launchMenu) { launchMenu->clear(); @@ -919,21 +925,37 @@ void MainWindow::updateToolsMenu() { launchMenu = new QMenu(this); } + if (launchOfflineMenu) { + launchOfflineMenu->clear(); + } + else + { + launchOfflineMenu = new QMenu(this); + } QAction *normalLaunch = launchMenu->addAction(tr("Launch")); + QAction* normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch")); connect(normalLaunch, &QAction::triggered, [this]() { - MMC->launch(m_selectedInstance); + MMC->launch(m_selectedInstance, true); + }); + connect(normalLaunchOffline, &QAction::triggered, [this]() + { + MMC->launch(m_selectedInstance, false); }); launchMenu->addSeparator()->setText(tr("Profilers")); + launchOfflineMenu->addSeparator()->setText(tr("Profilers")); for (auto profiler : MMC->profilers().values()) { QAction *profilerAction = launchMenu->addAction(profiler->name()); + QAction* profilerOfflineAction = launchOfflineMenu->addAction(profiler->name()); QString error; if (!profiler->check(&error)) { profilerAction->setDisabled(true); + profilerOfflineAction->setDisabled(true); profilerAction->setToolTip(tr("Profiler not setup correctly. Go into settings, \"External Tools\".")); + profilerOfflineAction->setToolTip(tr("Profiler not setup correctly. Go into settings, \"External Tools\".")); } else { @@ -941,9 +963,14 @@ void MainWindow::updateToolsMenu() { MMC->launch(m_selectedInstance, true, profiler.get()); }); + connect(profilerOfflineAction, &QAction::triggered, [this, profiler]() + { + MMC->launch(m_selectedInstance, false, profiler.get()); + }); } } ui->actionLaunchInstance->setMenu(launchMenu); + ui->actionLaunchInstanceOffline->setMenu(launchOfflineMenu); } QString profileInUseFilter(const QString & profile, bool used) |