Ref T731, Ref T739, adjusted launcher to only support "STANDALONE" and "DISTRIBUTED"

* the audio on core/GUI modes are no longer valid
* aligned the core mode enum
This commit is contained in:
Klaus Basan
2019-10-05 23:46:55 +02:00
committed by Mat Sutcliffe
parent bcd97c3a60
commit 9ddb55e79f
6 changed files with 84 additions and 120 deletions

View File

@@ -22,22 +22,24 @@ namespace BlackCore
//! Core runs how and where?
enum CoreMode
{
CoreInGuiProcess,
CoreExternal
Standalone,
Distributed
};
//! String to core mode
static CoreMode stringToCoreMode(const QString &m)
{
QString cm(m.toLower().trimmed());
if (cm.isEmpty()) { return CoreInGuiProcess; }
if (m == coreModeToString(CoreInGuiProcess)) { return CoreInGuiProcess; }
if (m == coreModeToString(CoreExternal)) { return CoreExternal; }
if (cm.isEmpty()) { return Standalone; }
if (m == coreModeToString(Standalone)) { return Standalone; }
if (m == coreModeToString(Distributed)) { return Distributed; }
// some alternative names
if (cm.contains("external")) { return CoreExternal; }
if (cm.contains("gui")) { return CoreInGuiProcess; }
return CoreInGuiProcess;
if (cm.contains("distribute")) { return Distributed; }
if (cm.contains("standalone")) { return Standalone; }
if (cm.contains("external")) { return Distributed; }
if (cm.contains("gui")) { return Standalone; }
return Standalone;
}
//! Core mode as string
@@ -45,8 +47,8 @@ namespace BlackCore
{
switch (mode)
{
case CoreInGuiProcess: return QStringLiteral("coreinguiprocess");
case CoreExternal: return QStringLiteral("coreexternal");
case Standalone: return QStringLiteral("standalone");
case Distributed: return QStringLiteral("distributed");
}
return {};
}

View File

@@ -37,8 +37,7 @@ namespace BlackCore
enum CoreMode
{
Standalone,
CoreWithAudioOnGui,
CoreWithAudioOnCore,
Distributed
};
//! Default constructor

View File

@@ -37,7 +37,7 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
// Valid combination?
if (!coreModeStr.isEmpty())
{
if (coreMode == CoreModes::CoreInGuiProcess && !dBusAddress.isEmpty())
if (coreMode == CoreModes::Standalone && !dBusAddress.isEmpty())
{
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
error(u"Inconsistent pair DBus: '%1' and core: '%2'")
@@ -50,13 +50,13 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
CStatusMessageList msgs;
if (!dBusAddress.isEmpty() && coreModeStr.isEmpty())
{
coreMode = CoreModes::CoreExternal; // default
coreMode = CoreModes::Distributed; // default
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
info(u"No DBus address, setting core mode: '%1'")
<< CoreModes::coreModeToString(coreMode);
msgs.push_back(m);
}
else if (dBusAddress.isEmpty() && coreMode == CoreModes::CoreExternal)
else if (dBusAddress.isEmpty() && coreMode == CoreModes::Distributed)
{
dBusAddress = CDBusServer::sessionBusAddress(); // a possible default
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
@@ -68,11 +68,11 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
CCoreFacadeConfig runtimeConfig;
switch (coreMode)
{
case CoreModes::CoreExternal:
case CoreModes::Distributed:
runtimeConfig = CCoreFacadeConfig::remote(dBusAddress);
break;
default:
case CoreModes::CoreInGuiProcess:
case CoreModes::Standalone:
runtimeConfig = CCoreFacadeConfig::local(dBusAddress);
break;
}

View File

@@ -44,7 +44,7 @@ private:
QCommandLineOption m_cmdFacadeMode
{
{ "c" , "core" },
QCoreApplication::translate("main", "Core mode: (e)xternal, (g)ui (in GUI process), (l)ocalaudio (external, but local audio)."),
QCoreApplication::translate("main", "Core mode: (d)istributed, (s)tandalone."),
"coremode"
}; //!< Facade startup mode
};

View File

@@ -67,9 +67,8 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
connect(ui->tb_ConfigurationWizard, &QToolButton::pressed, this, &CSwiftLauncher::startWizard);
connect(ui->tb_Launcher, &QToolBox::currentChanged, this, &CSwiftLauncher::tabChanged);
connect(ui->rb_SwiftCoreAudioOnCore, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased, Qt::QueuedConnection);
connect(ui->rb_SwiftCoreAudioOnGui, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased, Qt::QueuedConnection);
connect(ui->rb_SwiftStandalone, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased, Qt::QueuedConnection);
connect(ui->rb_SwiftDistributed, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased, Qt::QueuedConnection);
connect(ui->rb_SwiftStandalone, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased, Qt::QueuedConnection);
connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::updateInfoAvailable, this, &CSwiftLauncher::updateInfoAvailable, Qt::QueuedConnection);
connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::newerPilotClientAvailable, this, &CSwiftLauncher::setHeaderInfo, Qt::QueuedConnection);
@@ -83,7 +82,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
connect(ui->pb_P3DConfigDirs, &QPushButton::released, this, &CSwiftLauncher::showSimulatorConfigDirs, Qt::QueuedConnection);
const QShortcut *logPageShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(showLogPage()));
Q_UNUSED(logPageShortCut);
Q_UNUSED(logPageShortCut)
// periodically check
connect(&m_checkTimer, &QTimer::timeout, this, &CSwiftLauncher::checkRunningApplicationsAndCore);
@@ -124,12 +123,11 @@ CEnableForFramelessWindow::WindowMode CSwiftLauncher::getWindowMode() const
CoreModes::CoreMode CSwiftLauncher::getCoreMode() const
{
if (ui->rb_SwiftStandalone->isChecked()) { return CoreModes::CoreInGuiProcess; }
if (ui->rb_SwiftCoreAudioOnCore->isChecked()) { return CoreModes::CoreExternal; }
if (ui->rb_SwiftCoreAudioOnGui->isChecked()) { return CoreModes::CoreExternal; }
if (ui->rb_SwiftStandalone->isChecked()) { return CoreModes::Standalone; }
if (ui->rb_SwiftDistributed->isChecked()) { return CoreModes::Distributed; }
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong mode");
return CoreModes::CoreInGuiProcess;
return CoreModes::Standalone;
}
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
@@ -258,8 +256,7 @@ bool CSwiftLauncher::setSwiftCoreExecutable()
if (!sGui || sGui->isShuttingDown()) { return false; }
this->saveSetup();
QStringList args = ui->comp_DBusSelector->getDBusCmdLineArgs();
if (ui->rb_SwiftCoreAudioOnCore->isChecked()) { args.append("--coreaudio"); }
if (ui->cb_resetWindow->isChecked()) { args.append("--resetsize"); }
if (ui->cb_resetWindow->isChecked()) { args.append("--resetsize"); }
m_executableArgs = sGui->argumentsJoined(args);
m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftCoreExecutableName());
@@ -338,9 +335,8 @@ void CSwiftLauncher::setDefaults()
ui->rb_WindowNormal->setChecked(!setup.useFramelessWindow());
const CLauncherSetup::CoreMode mode = setup.getCoreMode();
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone ? true : false);
ui->rb_SwiftCoreAudioOnCore->setChecked(mode == CLauncherSetup::CoreWithAudioOnCore ? true : false);
ui->rb_SwiftCoreAudioOnGui->setChecked(mode == CLauncherSetup::CoreWithAudioOnGui ? true : false);
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone ? true : false);
ui->rb_SwiftDistributed->setChecked(mode == CLauncherSetup::Distributed ? true : false);
}
void CSwiftLauncher::saveSetup()
@@ -350,16 +346,12 @@ void CSwiftLauncher::saveSetup()
if (!dBus.isEmpty()) { setup.setDBusAddress(dBus); }
setup.setFramelessWindow(ui->rb_WindowFrameless->isChecked());
setup.setCoreMode(CLauncherSetup::Standalone);
if (ui->rb_SwiftCoreAudioOnCore->isChecked())
if (ui->rb_SwiftDistributed->isChecked())
{
setup.setCoreMode(CLauncherSetup::CoreWithAudioOnCore);
}
else if (ui->rb_SwiftCoreAudioOnGui->isChecked())
{
setup.setCoreMode(CLauncherSetup::CoreWithAudioOnGui);
setup.setCoreMode(CLauncherSetup::Distributed);
}
const CStatusMessage msg = m_setup.set(setup);
Q_UNUSED(msg);
Q_UNUSED(msg)
}
bool CSwiftLauncher::warnAboutOtherSwiftApplications()
@@ -425,7 +417,7 @@ void CSwiftLauncher::startButtonPressed()
}
else if (sender == ui->tb_SwiftCore)
{
if (this->isStandaloneGuiSelected()) { ui->rb_SwiftCoreAudioOnGui->setChecked(true); }
if (this->isStandaloneGuiSelected()) { ui->rb_SwiftDistributed->setChecked(true); }
ui->tb_SwiftCore->setEnabled(false);
m_startCoreWaitCycles = 2;
if (this->setSwiftCoreExecutable())
@@ -451,7 +443,7 @@ void CSwiftLauncher::dbusServerModeSelected(bool selected)
{
if (!selected) { return; }
if (!this->isStandaloneGuiSelected()) { return; }
ui->rb_SwiftCoreAudioOnGui->setChecked(true);
ui->rb_SwiftDistributed->setChecked(true);
}
void CSwiftLauncher::showStatusMessage(const CStatusMessage &msg)
@@ -508,10 +500,10 @@ void CSwiftLauncher::checkRunningApplicationsAndCore()
if (m_startGuiWaitCycles > 0) { m_startGuiWaitCycles--; }
const CApplicationInfoList runningApps = sGui->getRunningApplications();
const bool foundLocalCore = runningApps.containsApplication(CApplicationInfo::PilotClientCore);
const bool foundLocalMappingTool = runningApps.containsApplication(CApplicationInfo::MappingTool);
const bool foundLocalCore = runningApps.containsApplication(CApplicationInfo::PilotClientCore);
const bool foundLocalMappingTool = runningApps.containsApplication(CApplicationInfo::MappingTool);
const bool foundLocalPilotClientGui = runningApps.containsApplication(CApplicationInfo::PilotClientGui);
const bool standalone = ui->rb_SwiftStandalone->isChecked();
const bool standalone = ui->rb_SwiftStandalone->isChecked();
ui->tb_SwiftCore->setEnabled(!standalone && !foundLocalCore && m_startCoreWaitCycles < 1);
ui->tb_SwiftMappingTool->setEnabled(!foundLocalMappingTool && m_startMappingToolWaitCycles < 1);
@@ -537,7 +529,7 @@ void CSwiftLauncher::onStyleSheetsChanged()
void CSwiftLauncher::onDBusEditingFinished()
{
ui->rb_SwiftCoreAudioOnGui->setChecked(true);
ui->rb_SwiftDistributed->setChecked(true);
}
void CSwiftLauncher::onCoreModeReleased()

View File

@@ -88,7 +88,7 @@
<item>
<widget class="QToolBox" name="tb_Launcher">
<property name="currentIndex">
<number>4</number>
<number>2</number>
</property>
<property name="tabSpacing">
<number>6</number>
@@ -225,7 +225,7 @@
<attribute name="label">
<string>&amp;Core mode</string>
</attribute>
<layout class="QGridLayout" name="gl_CoreMode" columnstretch="10,14,14">
<layout class="QGridLayout" name="gl_CoreMode" columnstretch="0,0">
<property name="leftMargin">
<number>4</number>
</property>
@@ -241,33 +241,17 @@
<property name="spacing">
<number>4</number>
</property>
<item row="1" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbl_AudioGui">
<property name="text">
<string>Audio on GUI side</string>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="rb_SwiftCoreAudioOnGui">
<widget class="QRadioButton" name="rb_SwiftDistributed">
<property name="text">
<string>GUI and core</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_CoreMode</string>
</attribute>
</widget>
</item>
<item row="0" column="2" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="rb_SwiftCoreAudioOnCore">
<property name="text">
<string>GUI and core</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_CoreMode</string>
</attribute>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="rb_SwiftStandalone">
<property name="text">
<string>standalone</string>
</property>
<property name="checked">
<bool>true</bool>
<string>GUI and core (distributed)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_CoreMode</string>
@@ -284,23 +268,6 @@
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbl_AudioGui">
<property name="text">
<string>Audio on GUI side</string>
</property>
</widget>
</item>
<item row="2" column="2" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbl_SwiftCoreAudioIcon">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="swiftlauncher.qrc">:/launcher/icons/swiftGUIandCore115x85.png</pixmap>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbl_SwiftStandaloneIcon">
<property name="text">
@@ -311,15 +278,40 @@
</property>
</widget>
</item>
<item row="1" column="2" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="lbl_AudioCore">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="rb_SwiftStandalone">
<property name="text">
<string>Audio on core side</string>
<string>standalone</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_CoreMode</string>
</attribute>
</widget>
</item>
<item row="3" column="1" colspan="2">
<item row="4" column="0" colspan="2">
<spacer name="vs_CoreButtomSpace">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2" alignment="Qt::AlignRight">
<widget class="QGroupBox" name="gb_DBusServer">
<property name="minimumSize">
<size>
<width>225</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>DBus (swift core/GUI, NOT XSwiftBus)</string>
</property>
@@ -358,25 +350,6 @@
</layout>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QWidget" name="wi_CoreButtonSpace" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="vs_CoreButtomSpace">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_Updates">
@@ -648,7 +621,7 @@
<string>swift GUI</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/own/icons/own/swift3D/sw3DBlue-256.png</normaloff>:/own/icons/own/swift3D/sw3DBlue-256.png</iconset>
</property>
<property name="iconSize">
@@ -668,7 +641,7 @@
<string>swift core</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/own/icons/own/swift3D/sw3DOrange-256.png</normaloff>:/own/icons/own/swift3D/sw3DOrange-256.png</iconset>
</property>
<property name="iconSize">
@@ -688,7 +661,7 @@
<string>mapping tool</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/own/icons/own/swift3D/sw3DGreen-256.png</normaloff>:/own/icons/own/swift3D/sw3DGreen-256.png</iconset>
</property>
<property name="iconSize">
@@ -705,7 +678,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/misc/icons/misc/toolWizard128.png</normaloff>:/misc/icons/misc/toolWizard128.png</iconset>
</property>
<property name="iconSize">
@@ -725,7 +698,7 @@
<string>goto swift database</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/own/icons/own/swift3D/sw3DGreen-256.png</normaloff>:/own/icons/own/swift3D/sw3DGreen-256.png</iconset>
</property>
<property name="iconSize">
@@ -827,7 +800,7 @@
<string>back to main</string>
</property>
<property name="icon">
<iconset resource="../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/diagona/icons/diagona/icons/arrow-180.png</normaloff>:/diagona/icons/diagona/icons/arrow-180.png</iconset>
</property>
<property name="shortcut">
@@ -895,8 +868,7 @@
<tabstop>rb_WindowNormal</tabstop>
<tabstop>rb_WindowFrameless</tabstop>
<tabstop>rb_SwiftStandalone</tabstop>
<tabstop>rb_SwiftCoreAudioOnGui</tabstop>
<tabstop>rb_SwiftCoreAudioOnCore</tabstop>
<tabstop>rb_SwiftDistributed</tabstop>
<tabstop>sa_DataUpdates</tabstop>
<tabstop>tb_SwiftGui</tabstop>
<tabstop>tb_SwiftCore</tabstop>
@@ -906,7 +878,6 @@
<tabstop>tb_BackToMain</tabstop>
</tabstops>
<resources>
<include location="../blackmisc/blackmisc.qrc"/>
<include location="swiftlauncher.qrc"/>
</resources>
<connections/>