diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 0d2144e3a..136a5e01b 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -14,6 +14,7 @@ #include "blackgui/guiapplication.h" #include "blackgui/stylesheetutility.h" #include "blackcore/context/contextapplicationproxy.h" +#include "blackcore/vatsim/networkvatlib.h" #include "blackcore/setupreader.h" #include "blackmisc/network/networkutils.h" #include "blackmisc/dbusserver.h" @@ -37,6 +38,7 @@ using namespace BlackGui::Components; using namespace BlackCore; using namespace BlackCore::Context; using namespace BlackCore::Data; +using namespace BlackCore::Vatsim; using namespace BlackMisc; using namespace BlackMisc::Network; @@ -59,7 +61,6 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftLauncher::ps_onStyleSheetsChanged); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(ps_showLogPage())); - ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this)); // default from settings this->setDefaults(); @@ -108,16 +109,6 @@ CoreModes::CoreMode CSwiftLauncher::getCoreMode() const return CoreModes::CoreInGuiProcess; } -QString CSwiftLauncher::getDBusAddress() const -{ - if (ui->rb_DBusSession->isChecked()) { return CDBusServer::sessionBusAddress(); } - if (ui->rb_DBusSystem->isChecked()) { return CDBusServer::systemBusAddress(); } - return CDBusServer::p2pAddress( - ui->cb_DBusServerAddress->currentText() + ":" + - ui->le_DBusServerPort->text() - ); -} - void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event) { if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); } @@ -167,7 +158,6 @@ void CSwiftLauncher::init() this->initStyleSheet(); this->initLogDisplay(); - this->initDBusGui(); ui->lbl_HeaderInfo->setVisible(false); ui->sw_SwiftLauncher->setCurrentWidget(ui->pg_SwiftLauncherMain); @@ -212,23 +202,6 @@ void CSwiftLauncher::loadAbout() ui->tbr_About->setHtml(htmlFixed); } -void CSwiftLauncher::initDBusGui() -{ - ui->cb_DBusServerAddress->addItems(CNetworkUtils::getKnownLocalIpV4Addresses()); - ui->cb_DBusServerAddress->setCurrentIndex(0); - - connect(ui->cb_DBusServerAddress, &QComboBox::currentTextChanged, this, &CSwiftLauncher::ps_dbusServerAddressSelectionChanged); - connect(ui->rb_DBusP2P, &QRadioButton::clicked, this, &CSwiftLauncher::ps_dbusServerModeSelected); - connect(ui->rb_DBusSession, &QRadioButton::clicked, this, &CSwiftLauncher::ps_dbusServerModeSelected); - connect(ui->rb_DBusSystem, &QRadioButton::clicked, this, &CSwiftLauncher::ps_dbusServerModeSelected); - - // normally no system Bus on Windows - if (CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::isStableBranch()) - { - ui->rb_DBusSystem->setEnabled(false); - } -} - void CSwiftLauncher::initLogDisplay() { CLogHandler::instance()->install(true); @@ -255,21 +228,13 @@ void CSwiftLauncher::setHeaderInfo(const QString &newVersionAvailable) void CSwiftLauncher::startSwiftCore() { this->saveSetup(); - const QString dBus(this->getDBusAddress()); - - QStringList args( - { - "--start", - "--dbus", dBus - }); - + QStringList args = ui->comp_DBusSelector->getDBusCmdLineArgs(); if (ui->rb_SwiftCoreAudioOnCore->isChecked()) { args.append("--coreaudio"); } - args.append(sGui->inheritedArguments(true)); - m_executableArgs = args; + m_executableArgs = sGui->argumentsJoined(args); m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftCoreExecutableName()); this->startDetached(); } @@ -277,13 +242,12 @@ void CSwiftLauncher::startSwiftCore() void CSwiftLauncher::setSwiftDataExecutable() { m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftDataExecutableName()); - m_executableArgs = sGui->inheritedArguments(false); + m_executableArgs = sGui->argumentsJoined({}, CNetworkVatlib::vatlibArguments()); } bool CSwiftLauncher::setSwiftGuiExecutable() { m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftGuiExecutableName()); - QStringList args { "--core", CoreModes::coreModeToString(getCoreMode()), @@ -293,25 +257,22 @@ bool CSwiftLauncher::setSwiftGuiExecutable() this->saveSetup(); if (!this->isStandaloneGuiSelected()) { - const QString dBus(this->getDBusAddress()); + const QString dBus(ui->comp_DBusSelector->getDBusAddress()); + args.append(ui->comp_DBusSelector->getDBusCmdLineArgs()); this->saveSetup(); - args.append("--dbus"); - args.append(dBus); // already converted QString msg; if (!CSwiftLauncher::canConnectSwiftOnDBusServer(dBus, msg)) { - static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() })); - const CStatusMessage m(cats, CStatusMessage::SeverityError, - "DBus server for '" + this->getDBusAddress() + "' can not be connected.\n\n" + + const CStatusMessage m(this, CStatusMessage::SeverityError, + "DBus server for '" + dBus + "' can not be connected.\n\n" + "Likely the core is not running or is not reachable.\n\n" + - "Details: " + msg); + "Details: " + msg, true); this->ps_showStatusMessage(m); return false; } } - args.append(sGui->inheritedArguments(true)); - m_executableArgs = args; + m_executableArgs = sGui->argumentsJoined(args); return true; } @@ -330,18 +291,7 @@ void CSwiftLauncher::setDefaults() { const CLauncherSetup setup(m_setup.get()); const QString dbus(setup.getDBusAddress().toLower().trimmed()); - if (dbus.isEmpty() || dbus.startsWith("session")) - { - ui->rb_DBusSession->setChecked(true); - } - else if (dbus.startsWith("sys")) - { - ui->rb_DBusSystem->setChecked(true); - } - else - { - ui->rb_DBusP2P->setChecked(true); - } + ui->comp_DBusSelector->set(dbus); if (setup.useFramelessWindow()) { ui->rb_WindowFrameless->setChecked(true); @@ -363,7 +313,7 @@ void CSwiftLauncher::setDefaults() void CSwiftLauncher::saveSetup() { CLauncherSetup setup = m_setup.get(); - const QString dBus(this->getDBusAddress()); + const QString dBus(ui->comp_DBusSelector->getDBusAddress()); if (!dBus.isEmpty()) { setup.setDBusAddress(dBus); } setup.setFramelessWindow(ui->rb_WindowFrameless->isChecked()); setup.setCoreMode(CLauncherSetup::Standalone); @@ -431,16 +381,6 @@ void CSwiftLauncher::ps_startButtonPressed() } } -void CSwiftLauncher::ps_dbusServerAddressSelectionChanged(const QString ¤tText) -{ - Q_UNUSED(currentText); - if (this->isStandaloneGuiSelected()) - { - ui->rb_SwiftCoreAudioOnGui->setChecked(true); - } - ui->rb_DBusP2P->setChecked(true); -} - void CSwiftLauncher::ps_dbusServerModeSelected(bool selected) { if (!selected) { return; } diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index d434ef8ed..4903d3462 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -93,9 +93,6 @@ private: //! Get core mode BlackCore::CoreModes::CoreMode getCoreMode() const; - //! select DBus address/mode - QString getDBusAddress() const; - //! Selected window mode BlackGui::CEnableForFramelessWindow::WindowMode getWindowMode() const; @@ -105,9 +102,6 @@ private: //! style sheets void initStyleSheet(); - //! combobox for DBus - void initDBusGui(); - //! Log display void initLogDisplay(); @@ -158,9 +152,6 @@ private slots: //! Start button pressed void ps_startButtonPressed(); - //! Changed selection - void ps_dbusServerAddressSelectionChanged(const QString ¤tText); - //! DBus server mode selected void ps_dbusServerModeSelected(bool selected); diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index c0ad6fba9..0b73f3e05 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -82,7 +82,7 @@ - 3 + 2 6 @@ -92,8 +92,8 @@ 0 0 - 98 - 88 + 392 + 349 @@ -123,8 +123,8 @@ 0 0 - 199 - 63 + 392 + 349 @@ -188,8 +188,8 @@ 0 0 - 277 - 244 + 392 + 349 @@ -310,97 +310,19 @@ 4 - - - DBus session server + + + + 0 + 50 + - - true - - - - - - - DBus system server - - - - - - - DBus peer to peer server (P2P) - - - - - QFrame::StyledPanel QFrame::Raised - - - 20 - - - 0 - - - 20 - - - 0 - - - - - - 0 - 0 - - - - true - - - - - - - Address: - - - Qt::LinksAccessibleByMouse - - - - - - - Port: - - - - - - - - 80 - 16777215 - - - - 45000 - - - 5 - - - - @@ -565,8 +487,8 @@ 0 0 - 98 - 88 + 392 + 349 @@ -843,6 +765,12 @@ p, li { white-space: pre-wrap; }
blackgui/components/distributioninfocomponent.h
1 + + BlackGui::Components::CDBusServerAddressSelector + QFrame +
blackgui/components/dbusserveraddressselector.h
+ 1 +