Merge Launch Buttons

Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou 2022-10-10 23:20:21 +02:00
parent aabcca5059
commit 93a2e0f777
No known key found for this signature in database
GPG Key ID: C644BAF5B95BCB71

View File

@ -792,7 +792,6 @@ public:
instanceToolBar->addSeparator(); instanceToolBar->addSeparator();
instanceToolBar->addAction(actionLaunchInstance); instanceToolBar->addAction(actionLaunchInstance);
instanceToolBar->addAction(actionLaunchInstanceOffline);
instanceToolBar->addAction(actionKillInstance); instanceToolBar->addAction(actionKillInstance);
instanceToolBar->addSeparator(); instanceToolBar->addSeparator();
@ -1197,7 +1196,6 @@ void MainWindow::updateMainToolBar()
void MainWindow::updateToolsMenu() 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));
bool currentInstanceRunning = m_selectedInstance && m_selectedInstance->isRunning(); bool currentInstanceRunning = m_selectedInstance && m_selectedInstance->isRunning();
@ -1206,9 +1204,7 @@ void MainWindow::updateToolsMenu()
ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning); ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
QMenu *launchMenu = ui->actionLaunchInstance->menu(); QMenu *launchMenu = ui->actionLaunchInstance->menu();
QMenu *launchOfflineMenu = ui->actionLaunchInstanceOffline->menu();
launchButton->setPopupMode(QToolButton::MenuButtonPopup); launchButton->setPopupMode(QToolButton::MenuButtonPopup);
launchOfflineButton->setPopupMode(QToolButton::MenuButtonPopup);
if (launchMenu) if (launchMenu)
{ {
launchMenu->clear(); launchMenu->clear();
@ -1217,19 +1213,12 @@ void MainWindow::updateToolsMenu()
{ {
launchMenu = new QMenu(this); launchMenu = new QMenu(this);
} }
if (launchOfflineMenu) {
launchOfflineMenu->clear();
}
else
{
launchOfflineMenu = new QMenu(this);
}
QAction *normalLaunch = launchMenu->addAction(tr("Launch")); QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
normalLaunch->setShortcut(QKeySequence::Open); normalLaunch->setShortcut(QKeySequence::Open);
QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline")); QAction *normalLaunchOffline = launchMenu->addAction(tr("Launch Offline"));
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O"))); normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
QAction *normalLaunchDemo = launchOfflineMenu->addAction(tr("Launch Demo")); QAction *normalLaunchDemo = launchMenu->addAction(tr("Launch Demo"));
normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O"))); normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
if (m_selectedInstance) if (m_selectedInstance)
{ {
@ -1262,11 +1251,10 @@ void MainWindow::updateToolsMenu()
QString profilersTitle = tr("Profilers"); QString profilersTitle = tr("Profilers");
launchMenu->addSeparator()->setText(profilersTitle); launchMenu->addSeparator()->setText(profilersTitle);
launchOfflineMenu->addSeparator()->setText(profilersTitle);
for (auto profiler : APPLICATION->profilers().values()) for (auto profiler : APPLICATION->profilers().values())
{ {
QAction *profilerAction = launchMenu->addAction(profiler->name()); QAction *profilerAction = launchMenu->addAction(profiler->name());
QAction *profilerOfflineAction = launchOfflineMenu->addAction(profiler->name()); QAction *profilerOfflineAction = launchMenu->addAction(profiler->name() + " Offline");
QString error; QString error;
if (!profiler->check(&error)) if (!profiler->check(&error))
{ {
@ -1297,7 +1285,6 @@ void MainWindow::updateToolsMenu()
} }
} }
ui->actionLaunchInstance->setMenu(launchMenu); ui->actionLaunchInstance->setMenu(launchMenu);
ui->actionLaunchInstanceOffline->setMenu(launchOfflineMenu);
} }
void MainWindow::repopulateAccountsMenu() void MainWindow::repopulateAccountsMenu()