diff --git a/samples/blackgui/guimodeenums.h b/samples/blackgui/guimodeenums.h index 0ac568c6a..dce6638d6 100644 --- a/samples/blackgui/guimodeenums.h +++ b/samples/blackgui/guimodeenums.h @@ -23,7 +23,7 @@ public: enum CoreMode { CoreInGuiProcess, CoreExternal, - CoreExternalVoiceLocal + CoreExternalAudioLocal }; }; diff --git a/samples/blackgui/infowindow.cpp b/samples/blackgui/infowindow.cpp index 755fa0d80..fe94b772e 100644 --- a/samples/blackgui/infowindow.cpp +++ b/samples/blackgui/infowindow.cpp @@ -3,6 +3,7 @@ #include #include + /* * Constructor */ diff --git a/samples/blackgui/introwindow.cpp b/samples/blackgui/introwindow.cpp index d678f2287..b0a2acd0b 100644 --- a/samples/blackgui/introwindow.cpp +++ b/samples/blackgui/introwindow.cpp @@ -1,5 +1,7 @@ #include "introwindow.h" #include "ui_introwindow.h" +#include "blackcore/dbus_server.h" +#include "blackmisc/networkutils.h" #include #include @@ -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 diff --git a/samples/blackgui/introwindow.h b/samples/blackgui/introwindow.h index 7fb9c38f0..81011281d 100644 --- a/samples/blackgui/introwindow.h +++ b/samples/blackgui/introwindow.h @@ -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: diff --git a/samples/blackgui/introwindow.ui b/samples/blackgui/introwindow.ui index 557f2bfcb..b084677fc 100644 --- a/samples/blackgui/introwindow.ui +++ b/samples/blackgui/introwindow.ui @@ -6,8 +6,8 @@ 0 0 - 239 - 260 + 250 + 300 @@ -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; - } @@ -185,7 +188,14 @@ voice included - + + + del.settings + + + + + Qt::Vertical @@ -200,6 +210,27 @@ voice included + + + + + + DBus server + + + + + + + true + + + QComboBox::InsertAtTop + + + + + diff --git a/samples/blackgui/main.cpp b/samples/blackgui/main.cpp index 4a58d5171..fa63cad92 100644 --- a/samples/blackgui/main.cpp +++ b/samples/blackgui/main.cpp @@ -1,6 +1,7 @@ #include "introwindow.h" #include "mainwindow.h" #include "guimodeenums.h" +#include "blackcore/context_runtime_config.h" #include "blackmisc/blackmiscfreefunctions.h" #include #include @@ -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; } diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index eb6371d0b..4c7c08ae5 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -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()) diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 3718e7b33..60852d5aa 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -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; diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 8e62a791e..738bcb2b2 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -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();