MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / updateToolsMenu

Method updateToolsMenu

launcher/ui/MainWindow.cpp:1223–1315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1221}
1222
1223void MainWindow::updateToolsMenu()
1224{
1225 QToolButton *launchButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance));
1226
1227 bool currentInstanceRunning = m_selectedInstance && m_selectedInstance->isRunning();
1228
1229 ui->actionLaunchInstance->setDisabled(!m_selectedInstance || currentInstanceRunning);
1230 ui->actionLaunchInstanceOffline->setDisabled(!m_selectedInstance || currentInstanceRunning);
1231 ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
1232
1233 QMenu *launchMenu = ui->actionLaunchInstance->menu();
1234 launchButton->setPopupMode(QToolButton::MenuButtonPopup);
1235 if (launchMenu)
1236 {
1237 launchMenu->clear();
1238 }
1239 else
1240 {
1241 launchMenu = new QMenu(this);
1242 }
1243
1244 QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
1245 normalLaunch->setShortcut(QKeySequence::Open);
1246 QAction *normalLaunchOffline = launchMenu->addAction(tr("Launch Offline"));
1247 normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
1248 QAction *normalLaunchDemo = launchMenu->addAction(tr("Launch Demo"));
1249 normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
1250 if (m_selectedInstance)
1251 {
1252 normalLaunch->setEnabled(m_selectedInstance->canLaunch());
1253 normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch());
1254 normalLaunchDemo->setEnabled(m_selectedInstance->canLaunch());
1255
1256 connect(normalLaunch, &QAction::triggered, [this]() {
1257 APPLICATION->launch(m_selectedInstance, true, false);
1258 });
1259 connect(normalLaunchOffline, &QAction::triggered, [this]() {
1260 APPLICATION->launch(m_selectedInstance, false, false);
1261 });
1262 connect(normalLaunchDemo, &QAction::triggered, [this]() {
1263 APPLICATION->launch(m_selectedInstance, false, true);
1264 });
1265 }
1266 else
1267 {
1268 normalLaunch->setDisabled(true);
1269 normalLaunchOffline->setDisabled(true);
1270 normalLaunchDemo->setDisabled(true);
1271 }
1272
1273 // Disable demo-mode if not available.
1274 auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
1275 if (instance) {
1276 normalLaunchDemo->setEnabled(instance->supportsDemo());
1277 }
1278
1279 QString profilersTitle = tr("Profilers");
1280 launchMenu->addSeparator()->setText(profilersTitle);

Callers 1

setupUiMethod · 0.80

Calls 12

addActionMethod · 0.80
setEnabledMethod · 0.80
supportsDemoMethod · 0.80
addSeparatorMethod · 0.80
launchMethod · 0.65
isRunningMethod · 0.45
clearMethod · 0.45
canLaunchMethod · 0.45
getMethod · 0.45
setTextMethod · 0.45
nameMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected