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:
Klaus Basan
2014-04-12 03:05:36 +02:00
parent 9f2e3a7c9d
commit b2acd3e476
9 changed files with 102 additions and 58 deletions

View File

@@ -23,7 +23,7 @@ public:
enum CoreMode {
CoreInGuiProcess,
CoreExternal,
CoreExternalVoiceLocal
CoreExternalAudioLocal
};
};

View File

@@ -3,6 +3,7 @@
#include <QTimer>
#include <QDesktopWidget>
/*
* Constructor
*/

View File

@@ -1,5 +1,7 @@
#include "introwindow.h"
#include "ui_introwindow.h"
#include "blackcore/dbus_server.h"
#include "blackmisc/networkutils.h"
#include <QDesktopServices>
#include <QUrl>
@@ -12,6 +14,10 @@ CIntroWindow::CIntroWindow(QWidget *parent) :
{
ui->setupUi(this);
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
{
if (this->ui->rb_WindowNormal->isChecked()) return GuiModes::WindowNormal;
if (this->ui->rb_WindowFrameless->isChecked()) return GuiModes::WindowFrameless;
qFatal("Illegal GUI status (window mode");
return GuiModes::WindowNormal; // just for compiler warning
if (this->ui->rb_WindowFrameless->isChecked())
return GuiModes::WindowFrameless;
else
return GuiModes::WindowNormal;
}
/*
@@ -35,13 +41,20 @@ GuiModes::WindowMode CIntroWindow::getWindowMode() const
*/
GuiModes::CoreMode CIntroWindow::getCoreMode() const
{
if (this->ui->rb_CoreExternal->isChecked())return GuiModes::CoreExternal;
if (this->ui->rb_CoreExternalVoiceLocal->isChecked()) return GuiModes::CoreExternalVoiceLocal;
if (this->ui->rb_CoreInGuiProcess->isChecked()) return GuiModes::CoreInGuiProcess;
qFatal("Illegal GUI status (core mode");
return GuiModes::CoreExternal; // just for compiler warning
if (this->ui->rb_CoreExternalVoiceLocal->isChecked())
return GuiModes::CoreExternalAudioLocal;
else if (this->ui->rb_CoreInGuiProcess->isChecked())
return GuiModes::CoreInGuiProcess;
else
return GuiModes::CoreExternal;
}
/*
* DBus server address
*/
QString CIntroWindow::getDBusAddress() const
{
return this->ui->cb_DBusServer->currentText();
}
/*
* Button clicked

View File

@@ -20,33 +20,23 @@ class CIntroWindow : public QDialog
Q_OBJECT
public:
/*!
* \brief Constructor
* \param parent widget
*/
//! \brief Constructor
explicit CIntroWindow(QWidget *parent = nullptr);
/*!
* Destructor
*/
//! Destructor
~CIntroWindow();
/*!
* \brief Selected window mode
* \see GuiModes::WindowMode
*/
//! Selected window mode
GuiModes::WindowMode getWindowMode() const;
/*!
* \brief Get core mode
* \see GuiModes::CoreMode
*/
//! Get core mode
GuiModes::CoreMode getCoreMode() const;
//! select DBus address/mode
QString getDBusAddress() const;
private slots:
/*!
* \brief Button has been clicked
*/
//! Button has been clicked
void buttonClicked() const;
private:

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>239</width>
<height>260</height>
<width>250</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,14 +26,14 @@
}
QPushButton {
background-color: rgba(255, 255, 0, 175);
color: black;
border-style: solid;
border-width:1px;
border-radius: 5px;
border-color: green;
margin: 3px;
padding: 3px;
background-color: rgba(255, 255, 0, 175);
color: black;
border-style: solid;
border-width:1px;
border-radius: 5px;
border-color: green;
margin: 3px;
padding: 3px;
}
QRadioButton {
@@ -46,19 +46,22 @@ QGroupBox {
margin-top: 2ex; /* leave space at the top for the title */
}
QComboBox {
background-color: black;
border: 1px solid yellow;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left; /* position at the top center */
padding: 0 0px;
subcontrol-origin: margin;
subcontrol-position: top left; /* position at the top center */
padding: 0 0px;
margin: 0px;
background-color: black;
background-color: black;
}
#lbl_Icon {
max-height: 128;
max-width: 128;
}</string>
</property>
<property name="sizeGripEnabled">
@@ -185,7 +188,14 @@ voice included</string>
</widget>
</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">
<enum>Qt::Vertical</enum>
</property>
@@ -200,6 +210,27 @@ voice included</string>
</layout>
</widget>
</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>
</item>
<item>

View File

@@ -1,6 +1,7 @@
#include "introwindow.h"
#include "mainwindow.h"
#include "guimodeenums.h"
#include "blackcore/context_runtime_config.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include <QtGlobal>
#include <QApplication>
@@ -39,6 +40,7 @@ int main(int argc, char *argv[])
// Dialog to decide external or internal core
CIntroWindow intro;
BlackCore::CRuntimeConfig runtimeConfig;
if (intro.exec() == QDialog::Rejected)
{
return 0;
@@ -47,13 +49,26 @@ int main(int argc, char *argv[])
{
coreMode = intro.getCoreMode();
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();
// show window
MainWindow w(windowMode);
w.show();
w.init(coreMode); // object is complete by now
w.init(runtimeConfig); // object is complete by now
int r = a.exec();
return r;
}

View File

@@ -31,7 +31,6 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_modelAtcListOnline(nullptr), m_modelAtcListBooked(nullptr), m_modelTrafficServerList(nullptr), m_modelAircraftsInRange(nullptr),
m_modelAllUsers(nullptr), m_modelUsersVoiceCom1(nullptr), m_modelUsersVoiceCom2(nullptr), m_modelSettingsHotKeys(nullptr),
// contexts and runtime
m_coreMode(GuiModes::CoreExternal),
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
// timers
@@ -404,7 +403,9 @@ void MainWindow::updateGuiStatusInformation()
QString network("unavailable");
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
@@ -423,7 +424,6 @@ void MainWindow::updateGuiStatusInformation()
// update status fields
this->ui->le_StatusNetworkContext->setText(network);
this->ui->le_StatusAudioContext->setText(voice);
this->ui->cb_StatusWithDBus->setCheckState(this->m_coreMode ? Qt::Checked : Qt::Unchecked);
// Connected button
if (this->m_contextNetworkAvailable && this->m_rt->getIContextNetwork()->isConnected())

View File

@@ -54,7 +54,7 @@ public:
~MainWindow();
//! Init data
void init(GuiModes::CoreMode coreMode);
void init(const BlackCore::CRuntimeConfig &runtimeConfig);
//! Graceful shutdown
void gracefulShutdown();
@@ -112,7 +112,6 @@ private:
BlackGui::CKeyboardKeyListModel *m_modelSettingsHotKeys;
// contexts
GuiModes::CoreMode m_coreMode;
bool m_coreAvailable;
bool m_contextNetworkAvailable;
bool m_contextAudioAvailable;

View File

@@ -27,10 +27,9 @@ using namespace BlackGui;
/*
* Init data
*/
void MainWindow::init(GuiModes::CoreMode coreMode)
void MainWindow::init(const CRuntimeConfig &runtimeConfig)
{
if (this->m_init) return;
this->m_coreMode = coreMode;
// with frameless window, we shift menu and statusbar into central widget
// 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);
// context
this->m_rt.reset(
this->m_coreMode != GuiModes::CoreInGuiProcess ?
new CRuntime(CRuntimeConfig::remote(), this) :
new CRuntime(CRuntimeConfig::local(), this)
);
this->m_rt.reset(new CRuntime(runtimeConfig, this));
// wire GUI signals
this->initGuiSignals();