Separate the kill and launch instance actions
This commit is contained in:
parent
d232248268
commit
d4e544c62c
@ -224,6 +224,7 @@ public:
|
|||||||
TranslatedAction actionMoreNews;
|
TranslatedAction actionMoreNews;
|
||||||
TranslatedAction actionManageAccounts;
|
TranslatedAction actionManageAccounts;
|
||||||
TranslatedAction actionLaunchInstance;
|
TranslatedAction actionLaunchInstance;
|
||||||
|
TranslatedAction actionKillInstance;
|
||||||
TranslatedAction actionRenameInstance;
|
TranslatedAction actionRenameInstance;
|
||||||
TranslatedAction actionChangeInstGroup;
|
TranslatedAction actionChangeInstGroup;
|
||||||
TranslatedAction actionChangeInstIcon;
|
TranslatedAction actionChangeInstIcon;
|
||||||
@ -282,27 +283,6 @@ public:
|
|||||||
TranslatedToolbar instanceToolBar;
|
TranslatedToolbar instanceToolBar;
|
||||||
TranslatedToolbar newsToolBar;
|
TranslatedToolbar newsToolBar;
|
||||||
QVector<TranslatedToolbar *> all_toolbars;
|
QVector<TranslatedToolbar *> all_toolbars;
|
||||||
bool m_kill = false;
|
|
||||||
|
|
||||||
void updateLaunchAction()
|
|
||||||
{
|
|
||||||
if(m_kill)
|
|
||||||
{
|
|
||||||
actionLaunchInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Kill"));
|
|
||||||
actionLaunchInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Kill the running instance"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
actionLaunchInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Launch"));
|
|
||||||
actionLaunchInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance."));
|
|
||||||
}
|
|
||||||
actionLaunchInstance.retranslate();
|
|
||||||
}
|
|
||||||
void setLaunchAction(bool kill)
|
|
||||||
{
|
|
||||||
m_kill = kill;
|
|
||||||
updateLaunchAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void createMainToolbarActions(QMainWindow *MainWindow)
|
void createMainToolbarActions(QMainWindow *MainWindow)
|
||||||
{
|
{
|
||||||
@ -506,6 +486,7 @@ public:
|
|||||||
fileMenu->addAction(actionAddInstance);
|
fileMenu->addAction(actionAddInstance);
|
||||||
fileMenu->addAction(actionLaunchInstance);
|
fileMenu->addAction(actionLaunchInstance);
|
||||||
fileMenu->addAction(actionLaunchInstanceOffline);
|
fileMenu->addAction(actionLaunchInstanceOffline);
|
||||||
|
fileMenu->addAction(actionKillInstance);
|
||||||
fileMenu->addAction(actionCloseWindow);
|
fileMenu->addAction(actionCloseWindow);
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(actionEditInstance);
|
fileMenu->addAction(actionEditInstance);
|
||||||
@ -580,10 +561,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "Instance actions" are actions that require an instance to be selected (i.e. "new instance" is not here)
|
// "Instance actions" are actions that require an instance to be selected (i.e. "new instance" is not here)
|
||||||
|
// Actions that also require other conditions (e.g. a running instance) won't be changed.
|
||||||
void setInstanceActionsEnabled(bool enabled)
|
void setInstanceActionsEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
actionLaunchInstance->setEnabled(enabled);
|
|
||||||
actionLaunchInstanceOffline->setEnabled(enabled);
|
|
||||||
actionEditInstance->setEnabled(enabled);
|
actionEditInstance->setEnabled(enabled);
|
||||||
actionEditInstNotes->setEnabled(enabled);
|
actionEditInstNotes->setEnabled(enabled);
|
||||||
actionMods->setEnabled(enabled);
|
actionMods->setEnabled(enabled);
|
||||||
@ -670,6 +650,14 @@ public:
|
|||||||
actionLaunchInstanceOffline.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance in offline mode."));
|
actionLaunchInstanceOffline.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance in offline mode."));
|
||||||
all_actions.append(&actionLaunchInstanceOffline);
|
all_actions.append(&actionLaunchInstanceOffline);
|
||||||
|
|
||||||
|
actionKillInstance = TranslatedAction(MainWindow);
|
||||||
|
actionKillInstance->setObjectName(QStringLiteral("actionKillInstance"));
|
||||||
|
actionKillInstance->setDisabled(true);
|
||||||
|
actionKillInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Kill"));
|
||||||
|
actionKillInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Kill the running instance"));
|
||||||
|
actionKillInstance->setShortcut(QKeySequence(tr("Ctrl+K")));
|
||||||
|
all_actions.append(&actionKillInstance);
|
||||||
|
|
||||||
actionEditInstance = TranslatedAction(MainWindow);
|
actionEditInstance = TranslatedAction(MainWindow);
|
||||||
actionEditInstance->setObjectName(QStringLiteral("actionEditInstance"));
|
actionEditInstance->setObjectName(QStringLiteral("actionEditInstance"));
|
||||||
actionEditInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Edit Inst&ance..."));
|
actionEditInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Edit Inst&ance..."));
|
||||||
@ -785,6 +773,7 @@ public:
|
|||||||
|
|
||||||
instanceToolBar->addAction(actionLaunchInstance);
|
instanceToolBar->addAction(actionLaunchInstance);
|
||||||
instanceToolBar->addAction(actionLaunchInstanceOffline);
|
instanceToolBar->addAction(actionLaunchInstanceOffline);
|
||||||
|
instanceToolBar->addAction(actionKillInstance);
|
||||||
|
|
||||||
instanceToolBar->addSeparator();
|
instanceToolBar->addSeparator();
|
||||||
|
|
||||||
@ -1184,14 +1173,10 @@ void MainWindow::updateToolsMenu()
|
|||||||
QToolButton *launchButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance));
|
QToolButton *launchButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance));
|
||||||
QToolButton *launchOfflineButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstanceOffline));
|
QToolButton *launchOfflineButton = dynamic_cast<QToolButton*>(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstanceOffline));
|
||||||
|
|
||||||
if(m_selectedInstance && m_selectedInstance->isRunning())
|
bool currentInstanceRunning = m_selectedInstance && m_selectedInstance->isRunning();
|
||||||
{
|
|
||||||
ui->actionLaunchInstance->setMenu(nullptr);
|
ui->actionLaunchInstance->setDisabled(!m_selectedInstance || currentInstanceRunning);
|
||||||
ui->actionLaunchInstanceOffline->setMenu(nullptr);
|
ui->actionLaunchInstanceOffline->setDisabled(!m_selectedInstance || currentInstanceRunning);
|
||||||
launchButton->setPopupMode(QToolButton::InstantPopup);
|
|
||||||
launchOfflineButton->setPopupMode(QToolButton::InstantPopup);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu *launchMenu = ui->actionLaunchInstance->menu();
|
QMenu *launchMenu = ui->actionLaunchInstance->menu();
|
||||||
QMenu *launchOfflineMenu = ui->actionLaunchInstanceOffline->menu();
|
QMenu *launchOfflineMenu = ui->actionLaunchInstanceOffline->menu();
|
||||||
@ -1219,6 +1204,9 @@ void MainWindow::updateToolsMenu()
|
|||||||
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
|
normalLaunch->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
|
||||||
connect(normalLaunch, &QAction::triggered, [this]() {
|
connect(normalLaunch, &QAction::triggered, [this]() {
|
||||||
APPLICATION->launch(m_selectedInstance, true);
|
APPLICATION->launch(m_selectedInstance, true);
|
||||||
});
|
});
|
||||||
@ -1249,6 +1237,9 @@ void MainWindow::updateToolsMenu()
|
|||||||
}
|
}
|
||||||
else if (m_selectedInstance)
|
else if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
|
profilerAction->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
profilerOfflineAction->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
|
||||||
connect(profilerAction, &QAction::triggered, [this, profiler]()
|
connect(profilerAction, &QAction::triggered, [this, profiler]()
|
||||||
{
|
{
|
||||||
APPLICATION->launch(m_selectedInstance, true, profiler.get());
|
APPLICATION->launch(m_selectedInstance, true, profiler.get());
|
||||||
@ -2081,15 +2072,7 @@ void MainWindow::instanceActivated(QModelIndex index)
|
|||||||
|
|
||||||
void MainWindow::on_actionLaunchInstance_triggered()
|
void MainWindow::on_actionLaunchInstance_triggered()
|
||||||
{
|
{
|
||||||
if (!m_selectedInstance)
|
if(m_selectedInstance && !m_selectedInstance->isRunning())
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(m_selectedInstance->isRunning())
|
|
||||||
{
|
|
||||||
APPLICATION->kill(m_selectedInstance);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
APPLICATION->launch(m_selectedInstance);
|
APPLICATION->launch(m_selectedInstance);
|
||||||
}
|
}
|
||||||
@ -2108,6 +2091,14 @@ void MainWindow::on_actionLaunchInstanceOffline_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionKillInstance_triggered()
|
||||||
|
{
|
||||||
|
if(m_selectedInstance && m_selectedInstance->isRunning())
|
||||||
|
{
|
||||||
|
APPLICATION->kill(m_selectedInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::taskEnd()
|
void MainWindow::taskEnd()
|
||||||
{
|
{
|
||||||
QObject *sender = QObject::sender();
|
QObject *sender = QObject::sender();
|
||||||
@ -2141,17 +2132,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
{
|
{
|
||||||
ui->instanceToolBar->setEnabled(true);
|
ui->instanceToolBar->setEnabled(true);
|
||||||
ui->setInstanceActionsEnabled(true);
|
ui->setInstanceActionsEnabled(true);
|
||||||
if(m_selectedInstance->isRunning())
|
|
||||||
{
|
|
||||||
ui->actionLaunchInstance->setEnabled(true);
|
|
||||||
ui->setLaunchAction(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
|
ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
|
||||||
ui->setLaunchAction(false);
|
|
||||||
}
|
|
||||||
ui->actionLaunchInstanceOffline->setEnabled(m_selectedInstance->canLaunch());
|
ui->actionLaunchInstanceOffline->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
|
||||||
ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
|
ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
|
||||||
ui->renameButton->setText(m_selectedInstance->name());
|
ui->renameButton->setText(m_selectedInstance->name());
|
||||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||||
@ -2168,6 +2151,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
{
|
{
|
||||||
ui->instanceToolBar->setEnabled(false);
|
ui->instanceToolBar->setEnabled(false);
|
||||||
ui->setInstanceActionsEnabled(false);
|
ui->setInstanceActionsEnabled(false);
|
||||||
|
ui->actionLaunchInstance->setEnabled(false);
|
||||||
|
ui->actionLaunchInstanceOffline->setEnabled(false);
|
||||||
|
ui->actionKillInstance->setEnabled(false);
|
||||||
APPLICATION->settings()->set("SelectedInstance", QString());
|
APPLICATION->settings()->set("SelectedInstance", QString());
|
||||||
selectionBad();
|
selectionBad();
|
||||||
return;
|
return;
|
||||||
|
@ -148,6 +148,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionLaunchInstanceOffline_triggered();
|
void on_actionLaunchInstanceOffline_triggered();
|
||||||
|
|
||||||
|
void on_actionKillInstance_triggered();
|
||||||
|
|
||||||
void on_actionDeleteInstance_triggered();
|
void on_actionDeleteInstance_triggered();
|
||||||
|
|
||||||
void deleteGroup();
|
void deleteGroup();
|
||||||
|
Loading…
Reference in New Issue
Block a user