MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / instanceChanged

Method instanceChanged

launcher/ui/MainWindow.cpp:1649–1685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1647}
1648
1649void MainWindow::instanceChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
1650{
1651 if (!current.isValid()) {
1652 APPLICATION->settings()->set("SelectedInstance", QString());
1653 selectionBad();
1654 return;
1655 }
1656 if (m_selectedInstance) {
1657 disconnect(m_selectedInstance, &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
1658 disconnect(m_selectedInstance, &BaseInstance::profilerChanged, this, &MainWindow::refreshCurrentInstance);
1659 }
1660 QString id = current.data(InstanceList::InstanceIDRole).toString();
1661 m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
1662 if (m_selectedInstance) {
1663 ui->instanceToolBar->setEnabled(true);
1664 setInstanceActionsEnabled(true);
1665 ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
1666
1667 ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
1668 ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
1669 renameButton->setText(m_selectedInstance->name());
1670 m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
1671 updateStatusCenter();
1672 updateInstanceToolIcon(m_selectedInstance->iconKey());
1673
1674 updateLaunchButton();
1675
1676 APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
1677
1678 connect(m_selectedInstance, &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
1679 connect(m_selectedInstance, &BaseInstance::profilerChanged, this, &MainWindow::refreshCurrentInstance);
1680 } else {
1681 APPLICATION->settings()->set("SelectedInstance", QString());
1682 selectionBad();
1683 return;
1684 }
1685}
1686
1687void MainWindow::instanceSelectRequest(QString id)
1688{

Callers

nothing calls this directly

Calls 15

getInstanceByIdMethod · 0.80
instancesMethod · 0.80
setEnabledMethod · 0.80
QStringClass · 0.50
isValidMethod · 0.45
setMethod · 0.45
settingsMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
canLaunchMethod · 0.45
isRunningMethod · 0.45
canExportMethod · 0.45

Tested by

no test coverage detected