mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
refs #205, added selection for DBus server to intro window
* changed init of main window to CRuntimeConfig, btw. makes 8 in https://dev.vatsim-germany.org/issues/199 redundant * coreMode in main window gone * mode for external / local audio
This commit is contained in:
@@ -23,7 +23,7 @@ public:
|
|||||||
enum CoreMode {
|
enum CoreMode {
|
||||||
CoreInGuiProcess,
|
CoreInGuiProcess,
|
||||||
CoreExternal,
|
CoreExternal,
|
||||||
CoreExternalVoiceLocal
|
CoreExternalAudioLocal
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "introwindow.h"
|
#include "introwindow.h"
|
||||||
#include "ui_introwindow.h"
|
#include "ui_introwindow.h"
|
||||||
|
#include "blackcore/dbus_server.h"
|
||||||
|
#include "blackmisc/networkutils.h"
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@@ -12,6 +14,10 @@ CIntroWindow::CIntroWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
this->ui->cb_DBusServer->addItem(BlackCore::CDBusServer::sessionDBusServer());
|
||||||
|
this->ui->cb_DBusServer->addItem(BlackCore::CDBusServer::systemDBusServer());
|
||||||
|
this->ui->cb_DBusServer->addItems(BlackMisc::CNetworkUtils::getKnownIpAddresses());
|
||||||
|
this->ui->cb_DBusServer->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -24,10 +30,10 @@ CIntroWindow::~CIntroWindow() { }
|
|||||||
*/
|
*/
|
||||||
GuiModes::WindowMode CIntroWindow::getWindowMode() const
|
GuiModes::WindowMode CIntroWindow::getWindowMode() const
|
||||||
{
|
{
|
||||||
if (this->ui->rb_WindowNormal->isChecked()) return GuiModes::WindowNormal;
|
if (this->ui->rb_WindowFrameless->isChecked())
|
||||||
if (this->ui->rb_WindowFrameless->isChecked()) return GuiModes::WindowFrameless;
|
return GuiModes::WindowFrameless;
|
||||||
qFatal("Illegal GUI status (window mode");
|
else
|
||||||
return GuiModes::WindowNormal; // just for compiler warning
|
return GuiModes::WindowNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -35,13 +41,20 @@ GuiModes::WindowMode CIntroWindow::getWindowMode() const
|
|||||||
*/
|
*/
|
||||||
GuiModes::CoreMode CIntroWindow::getCoreMode() const
|
GuiModes::CoreMode CIntroWindow::getCoreMode() const
|
||||||
{
|
{
|
||||||
if (this->ui->rb_CoreExternal->isChecked())return GuiModes::CoreExternal;
|
if (this->ui->rb_CoreExternalVoiceLocal->isChecked())
|
||||||
if (this->ui->rb_CoreExternalVoiceLocal->isChecked()) return GuiModes::CoreExternalVoiceLocal;
|
return GuiModes::CoreExternalAudioLocal;
|
||||||
if (this->ui->rb_CoreInGuiProcess->isChecked()) return GuiModes::CoreInGuiProcess;
|
else if (this->ui->rb_CoreInGuiProcess->isChecked())
|
||||||
qFatal("Illegal GUI status (core mode");
|
return GuiModes::CoreInGuiProcess;
|
||||||
return GuiModes::CoreExternal; // just for compiler warning
|
else
|
||||||
|
return GuiModes::CoreExternal;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* DBus server address
|
||||||
|
*/
|
||||||
|
QString CIntroWindow::getDBusAddress() const
|
||||||
|
{
|
||||||
|
return this->ui->cb_DBusServer->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Button clicked
|
* Button clicked
|
||||||
|
|||||||
@@ -20,33 +20,23 @@ class CIntroWindow : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! \brief Constructor
|
||||||
* \brief Constructor
|
|
||||||
* \param parent widget
|
|
||||||
*/
|
|
||||||
explicit CIntroWindow(QWidget *parent = nullptr);
|
explicit CIntroWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
/*!
|
//! Destructor
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~CIntroWindow();
|
~CIntroWindow();
|
||||||
|
|
||||||
/*!
|
//! Selected window mode
|
||||||
* \brief Selected window mode
|
|
||||||
* \see GuiModes::WindowMode
|
|
||||||
*/
|
|
||||||
GuiModes::WindowMode getWindowMode() const;
|
GuiModes::WindowMode getWindowMode() const;
|
||||||
|
|
||||||
/*!
|
//! Get core mode
|
||||||
* \brief Get core mode
|
|
||||||
* \see GuiModes::CoreMode
|
|
||||||
*/
|
|
||||||
GuiModes::CoreMode getCoreMode() const;
|
GuiModes::CoreMode getCoreMode() const;
|
||||||
|
|
||||||
|
//! select DBus address/mode
|
||||||
|
QString getDBusAddress() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/*!
|
//! Button has been clicked
|
||||||
* \brief Button has been clicked
|
|
||||||
*/
|
|
||||||
void buttonClicked() const;
|
void buttonClicked() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>239</width>
|
<width>250</width>
|
||||||
<height>260</height>
|
<height>300</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -26,14 +26,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPushButton {
|
QPushButton {
|
||||||
background-color: rgba(255, 255, 0, 175);
|
background-color: rgba(255, 255, 0, 175);
|
||||||
color: black;
|
color: black;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width:1px;
|
border-width:1px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border-color: green;
|
border-color: green;
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRadioButton {
|
QRadioButton {
|
||||||
@@ -46,19 +46,22 @@ QGroupBox {
|
|||||||
margin-top: 2ex; /* leave space at the top for the title */
|
margin-top: 2ex; /* leave space at the top for the title */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QComboBox {
|
||||||
|
background-color: black;
|
||||||
|
border: 1px solid yellow;
|
||||||
|
}
|
||||||
|
|
||||||
QGroupBox::title {
|
QGroupBox::title {
|
||||||
subcontrol-origin: margin;
|
subcontrol-origin: margin;
|
||||||
subcontrol-position: top left; /* position at the top center */
|
subcontrol-position: top left; /* position at the top center */
|
||||||
padding: 0 0px;
|
padding: 0 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
#lbl_Icon {
|
#lbl_Icon {
|
||||||
max-height: 128;
|
max-height: 128;
|
||||||
max-width: 128;
|
max-width: 128;
|
||||||
|
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeGripEnabled">
|
<property name="sizeGripEnabled">
|
||||||
@@ -185,7 +188,14 @@ voice included</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<widget class="QPushButton" name="pb_DeleteSettingsFile">
|
||||||
|
<property name="text">
|
||||||
|
<string>del.settings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="vs_InfoSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -200,6 +210,27 @@ voice included</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_DBusServer">
|
||||||
|
<property name="text">
|
||||||
|
<string>DBus server</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_DBusServer">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::InsertAtTop</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "introwindow.h"
|
#include "introwindow.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "guimodeenums.h"
|
#include "guimodeenums.h"
|
||||||
|
#include "blackcore/context_runtime_config.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -39,6 +40,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Dialog to decide external or internal core
|
// Dialog to decide external or internal core
|
||||||
CIntroWindow intro;
|
CIntroWindow intro;
|
||||||
|
BlackCore::CRuntimeConfig runtimeConfig;
|
||||||
if (intro.exec() == QDialog::Rejected)
|
if (intro.exec() == QDialog::Rejected)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -47,13 +49,26 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
coreMode = intro.getCoreMode();
|
coreMode = intro.getCoreMode();
|
||||||
windowMode = intro.getWindowMode();
|
windowMode = intro.getWindowMode();
|
||||||
|
QString dbusAddress = BlackCore::CDBusServer::fixAddressToDBusAddress(intro.getDBusAddress());
|
||||||
|
switch (windowMode)
|
||||||
|
{
|
||||||
|
case GuiModes::CoreExternal:
|
||||||
|
runtimeConfig = BlackCore::CRuntimeConfig::remote(dbusAddress);
|
||||||
|
break;
|
||||||
|
case GuiModes::CoreInGuiProcess:
|
||||||
|
runtimeConfig = BlackCore::CRuntimeConfig::local(dbusAddress);
|
||||||
|
break;
|
||||||
|
case GuiModes::CoreExternalAudioLocal:
|
||||||
|
runtimeConfig = BlackCore::CRuntimeConfig::remoteLocalAudio(dbusAddress);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
intro.close();
|
intro.close();
|
||||||
|
|
||||||
// show window
|
// show window
|
||||||
MainWindow w(windowMode);
|
MainWindow w(windowMode);
|
||||||
w.show();
|
w.show();
|
||||||
w.init(coreMode); // object is complete by now
|
w.init(runtimeConfig); // object is complete by now
|
||||||
int r = a.exec();
|
int r = a.exec();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
|
|||||||
m_modelAtcListOnline(nullptr), m_modelAtcListBooked(nullptr), m_modelTrafficServerList(nullptr), m_modelAircraftsInRange(nullptr),
|
m_modelAtcListOnline(nullptr), m_modelAtcListBooked(nullptr), m_modelTrafficServerList(nullptr), m_modelAircraftsInRange(nullptr),
|
||||||
m_modelAllUsers(nullptr), m_modelUsersVoiceCom1(nullptr), m_modelUsersVoiceCom2(nullptr), m_modelSettingsHotKeys(nullptr),
|
m_modelAllUsers(nullptr), m_modelUsersVoiceCom1(nullptr), m_modelUsersVoiceCom2(nullptr), m_modelSettingsHotKeys(nullptr),
|
||||||
// contexts and runtime
|
// contexts and runtime
|
||||||
m_coreMode(GuiModes::CoreExternal),
|
|
||||||
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
|
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
@@ -404,7 +403,9 @@ void MainWindow::updateGuiStatusInformation()
|
|||||||
QString network("unavailable");
|
QString network("unavailable");
|
||||||
if (this->m_contextNetworkAvailable)
|
if (this->m_contextNetworkAvailable)
|
||||||
{
|
{
|
||||||
network = this->m_rt->getIContextNetwork()->usingLocalObjects() ? "local" : now;
|
bool dbus = !this->m_rt->getIContextNetwork()->usingLocalObjects();
|
||||||
|
network = dbus ? now : "local";
|
||||||
|
this->ui->cb_StatusWithDBus->setChecked(dbus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle voice, mute
|
// handle voice, mute
|
||||||
@@ -423,7 +424,6 @@ void MainWindow::updateGuiStatusInformation()
|
|||||||
// update status fields
|
// update status fields
|
||||||
this->ui->le_StatusNetworkContext->setText(network);
|
this->ui->le_StatusNetworkContext->setText(network);
|
||||||
this->ui->le_StatusAudioContext->setText(voice);
|
this->ui->le_StatusAudioContext->setText(voice);
|
||||||
this->ui->cb_StatusWithDBus->setCheckState(this->m_coreMode ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
// Connected button
|
// Connected button
|
||||||
if (this->m_contextNetworkAvailable && this->m_rt->getIContextNetwork()->isConnected())
|
if (this->m_contextNetworkAvailable && this->m_rt->getIContextNetwork()->isConnected())
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
//! Init data
|
//! Init data
|
||||||
void init(GuiModes::CoreMode coreMode);
|
void init(const BlackCore::CRuntimeConfig &runtimeConfig);
|
||||||
|
|
||||||
//! Graceful shutdown
|
//! Graceful shutdown
|
||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
@@ -112,7 +112,6 @@ private:
|
|||||||
BlackGui::CKeyboardKeyListModel *m_modelSettingsHotKeys;
|
BlackGui::CKeyboardKeyListModel *m_modelSettingsHotKeys;
|
||||||
|
|
||||||
// contexts
|
// contexts
|
||||||
GuiModes::CoreMode m_coreMode;
|
|
||||||
bool m_coreAvailable;
|
bool m_coreAvailable;
|
||||||
bool m_contextNetworkAvailable;
|
bool m_contextNetworkAvailable;
|
||||||
bool m_contextAudioAvailable;
|
bool m_contextAudioAvailable;
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ using namespace BlackGui;
|
|||||||
/*
|
/*
|
||||||
* Init data
|
* Init data
|
||||||
*/
|
*/
|
||||||
void MainWindow::init(GuiModes::CoreMode coreMode)
|
void MainWindow::init(const CRuntimeConfig &runtimeConfig)
|
||||||
{
|
{
|
||||||
if (this->m_init) return;
|
if (this->m_init) return;
|
||||||
this->m_coreMode = coreMode;
|
|
||||||
|
|
||||||
// with frameless window, we shift menu and statusbar into central widget
|
// with frameless window, we shift menu and statusbar into central widget
|
||||||
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
|
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
|
||||||
@@ -168,11 +167,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
|||||||
if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this);
|
if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this);
|
||||||
|
|
||||||
// context
|
// context
|
||||||
this->m_rt.reset(
|
this->m_rt.reset(new CRuntime(runtimeConfig, this));
|
||||||
this->m_coreMode != GuiModes::CoreInGuiProcess ?
|
|
||||||
new CRuntime(CRuntimeConfig::remote(), this) :
|
|
||||||
new CRuntime(CRuntimeConfig::local(), this)
|
|
||||||
);
|
|
||||||
|
|
||||||
// wire GUI signals
|
// wire GUI signals
|
||||||
this->initGuiSignals();
|
this->initGuiSignals();
|
||||||
|
|||||||
Reference in New Issue
Block a user