Fix bugs with instance menu bar options when opening without instances
- The launch option is no longer empty. - The program now checks on startup whether an instance is selected to decide whether to disable instance options. Also, get rid of a dynamic cast.
This commit is contained in:
parent
9bad83a551
commit
3acc761419
@ -636,6 +636,8 @@ public:
|
|||||||
|
|
||||||
actionLaunchInstance = TranslatedAction(MainWindow);
|
actionLaunchInstance = TranslatedAction(MainWindow);
|
||||||
actionLaunchInstance->setObjectName(QStringLiteral("actionLaunchInstance"));
|
actionLaunchInstance->setObjectName(QStringLiteral("actionLaunchInstance"));
|
||||||
|
actionLaunchInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Launch"));
|
||||||
|
actionLaunchInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Launch the selected instance."));
|
||||||
all_actions.append(&actionLaunchInstance);
|
all_actions.append(&actionLaunchInstance);
|
||||||
|
|
||||||
actionLaunchInstanceOffline = TranslatedAction(MainWindow);
|
actionLaunchInstanceOffline = TranslatedAction(MainWindow);
|
||||||
@ -734,6 +736,7 @@ public:
|
|||||||
actionCopyInstance->setShortcut(QKeySequence(tr("Ctrl+D")));
|
actionCopyInstance->setShortcut(QKeySequence(tr("Ctrl+D")));
|
||||||
all_actions.append(&actionCopyInstance);
|
all_actions.append(&actionCopyInstance);
|
||||||
|
|
||||||
|
setInstanceActionsEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createInstanceToolbar(QMainWindow *MainWindow)
|
void createInstanceToolbar(QMainWindow *MainWindow)
|
||||||
@ -784,7 +787,7 @@ public:
|
|||||||
MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar);
|
MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupUi(QMainWindow *MainWindow)
|
void setupUi(MainWindow *MainWindow)
|
||||||
{
|
{
|
||||||
if (MainWindow->objectName().isEmpty())
|
if (MainWindow->objectName().isEmpty())
|
||||||
{
|
{
|
||||||
@ -798,7 +801,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
createMainToolbarActions(MainWindow);
|
createMainToolbarActions(MainWindow);
|
||||||
createMenuActions(dynamic_cast<class MainWindow *>(MainWindow));
|
createMenuActions(MainWindow);
|
||||||
createInstanceActions(MainWindow);
|
createInstanceActions(MainWindow);
|
||||||
|
|
||||||
createMenuBar(MainWindow);
|
createMenuBar(MainWindow);
|
||||||
@ -818,6 +821,8 @@ public:
|
|||||||
createNewsToolbar(MainWindow);
|
createNewsToolbar(MainWindow);
|
||||||
createInstanceToolbar(MainWindow);
|
createInstanceToolbar(MainWindow);
|
||||||
|
|
||||||
|
MainWindow->updateToolsMenu();
|
||||||
|
|
||||||
retranslateUi(MainWindow);
|
retranslateUi(MainWindow);
|
||||||
|
|
||||||
QMetaObject::connectSlotsByName(MainWindow);
|
QMetaObject::connectSlotsByName(MainWindow);
|
||||||
@ -1146,7 +1151,7 @@ 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())
|
if(m_selectedInstance && m_selectedInstance->isRunning())
|
||||||
{
|
{
|
||||||
ui->actionLaunchInstance->setMenu(nullptr);
|
ui->actionLaunchInstance->setMenu(nullptr);
|
||||||
ui->actionLaunchInstanceOffline->setMenu(nullptr);
|
ui->actionLaunchInstanceOffline->setMenu(nullptr);
|
||||||
@ -1179,14 +1184,20 @@ void MainWindow::updateToolsMenu()
|
|||||||
normalLaunch->setShortcut(QKeySequence::Open);
|
normalLaunch->setShortcut(QKeySequence::Open);
|
||||||
QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline"));
|
QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline"));
|
||||||
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
||||||
connect(normalLaunch, &QAction::triggered, [this]()
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
APPLICATION->launch(m_selectedInstance, true);
|
connect(normalLaunch, &QAction::triggered, [this]() {
|
||||||
});
|
APPLICATION->launch(m_selectedInstance, true);
|
||||||
connect(normalLaunchOffline, &QAction::triggered, [this]()
|
});
|
||||||
{
|
connect(normalLaunchOffline, &QAction::triggered, [this]() {
|
||||||
APPLICATION->launch(m_selectedInstance, false);
|
APPLICATION->launch(m_selectedInstance, false);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalLaunch->setDisabled(true);
|
||||||
|
normalLaunchOffline->setDisabled(true);
|
||||||
|
}
|
||||||
QString profilersTitle = tr("Profilers");
|
QString profilersTitle = tr("Profilers");
|
||||||
launchMenu->addSeparator()->setText(profilersTitle);
|
launchMenu->addSeparator()->setText(profilersTitle);
|
||||||
launchOfflineMenu->addSeparator()->setText(profilersTitle);
|
launchOfflineMenu->addSeparator()->setText(profilersTitle);
|
||||||
@ -1203,7 +1214,7 @@ void MainWindow::updateToolsMenu()
|
|||||||
profilerAction->setToolTip(profilerToolTip);
|
profilerAction->setToolTip(profilerToolTip);
|
||||||
profilerOfflineAction->setToolTip(profilerToolTip);
|
profilerOfflineAction->setToolTip(profilerToolTip);
|
||||||
}
|
}
|
||||||
else
|
else if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
connect(profilerAction, &QAction::triggered, [this, profiler]()
|
connect(profilerAction, &QAction::triggered, [this, profiler]()
|
||||||
{
|
{
|
||||||
@ -1214,6 +1225,11 @@ void MainWindow::updateToolsMenu()
|
|||||||
APPLICATION->launch(m_selectedInstance, false, profiler.get());
|
APPLICATION->launch(m_selectedInstance, false, profiler.get());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profilerAction->setDisabled(true);
|
||||||
|
profilerOfflineAction->setDisabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ui->actionLaunchInstance->setMenu(launchMenu);
|
ui->actionLaunchInstance->setMenu(launchMenu);
|
||||||
ui->actionLaunchInstanceOffline->setMenu(launchOfflineMenu);
|
ui->actionLaunchInstanceOffline->setMenu(launchOfflineMenu);
|
||||||
|
Loading…
Reference in New Issue
Block a user