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

Method instanceChanged

launcher/ui/MainWindow.cpp:2231–2283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2229}
2230
2231void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &previous)
2232{
2233 if (!current.isValid())
2234 {
2235 APPLICATION->settings()->set("SelectedInstance", QString());
2236 selectionBad();
2237 return;
2238 }
2239 if (m_selectedInstance) {
2240 disconnect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
2241 }
2242 QString id = current.data(InstanceList::InstanceIDRole).toString();
2243 m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
2244 if (m_selectedInstance)
2245 {
2246 ui->instanceToolBar->setEnabled(true);
2247 ui->setInstanceActionsEnabled(true);
2248 ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
2249 ui->actionLaunchInstanceOffline->setEnabled(m_selectedInstance->canLaunch());
2250 ui->actionLaunchInstanceDemo->setEnabled(m_selectedInstance->canLaunch());
2251
2252 // Disable demo-mode if not available.
2253 auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
2254 if (instance) {
2255 ui->actionLaunchInstanceDemo->setEnabled(instance->supportsDemo());
2256 }
2257
2258 ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
2259 ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
2260 ui->renameButton->setText(m_selectedInstance->name());
2261 m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
2262 updateStatusCenter();
2263 updateInstanceToolIcon(m_selectedInstance->iconKey());
2264
2265 updateToolsMenu();
2266
2267 APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
2268
2269 connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
2270 }
2271 else
2272 {
2273 ui->instanceToolBar->setEnabled(false);
2274 ui->setInstanceActionsEnabled(false);
2275 ui->actionLaunchInstance->setEnabled(false);
2276 ui->actionLaunchInstanceOffline->setEnabled(false);
2277 ui->actionLaunchInstanceDemo->setEnabled(false);
2278 ui->actionKillInstance->setEnabled(false);
2279 APPLICATION->settings()->set("SelectedInstance", QString());
2280 selectionBad();
2281 return;
2282 }
2283}
2284
2285void MainWindow::instanceSelectRequest(QString id)
2286{

Callers

nothing calls this directly

Calls 15

QStringClass · 0.85
getInstanceByIdMethod · 0.80
instancesMethod · 0.80
setEnabledMethod · 0.80
supportsDemoMethod · 0.80
isValidMethod · 0.45
setMethod · 0.45
settingsMethod · 0.45
getMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected