mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T195, launcher uses DBus UI component and new application arguments functions
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<item>
|
||||
<widget class="QToolBox" name="tb_Launcher">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="tabSpacing">
|
||||
<number>6</number>
|
||||
@@ -92,8 +92,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<height>88</height>
|
||||
<width>392</width>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -123,8 +123,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>199</width>
|
||||
<height>63</height>
|
||||
<width>392</width>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -188,8 +188,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>277</width>
|
||||
<height>244</height>
|
||||
<width>392</width>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -310,97 +310,19 @@
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DBusSession">
|
||||
<property name="text">
|
||||
<string>DBus session server</string>
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_DBusSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DBusSystem">
|
||||
<property name="text">
|
||||
<string>DBus system server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DBusP2P">
|
||||
<property name="text">
|
||||
<string>DBus peer to peer server (P2P)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_DBusServerAddress">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_DBusServerAddressDetails">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="cb_DBusServerAddress">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_DBusServerAddress">
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_DBusServerPort">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="le_DBusServerPort">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>45000</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -565,8 +487,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<height>88</height>
|
||||
<width>392</width>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -843,6 +765,12 @@ p, li { white-space: pre-wrap; }
|
||||
<header>blackgui/components/distributioninfocomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDBusServerAddressSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbusserveraddressselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../blackmisc/blackmisc.qrc"/>
|
||||
|
||||
Reference in New Issue
Block a user