From 9dc287accb48dd5e35d4d2f3cb5d5a0c0c4d2f17 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 16 Oct 2019 13:14:28 +0200 Subject: [PATCH] [AFV] Ref T739, added a dialog for cockpit/audio so CAfvClient can be used in core UI --- .../components/cockpitcomaudiodialog.cpp | 28 ++++ .../components/cockpitcomaudiodialog.h | 40 +++++ .../components/cockpitcomaudiodialog.ui | 147 ++++++++++++++++++ src/swiftcore/swiftcore.cpp | 37 ++--- src/swiftcore/swiftcore.h | 10 +- src/swiftcore/swiftcore.ui | 38 +---- 6 files changed, 240 insertions(+), 60 deletions(-) create mode 100644 src/blackgui/components/cockpitcomaudiodialog.cpp create mode 100644 src/blackgui/components/cockpitcomaudiodialog.h create mode 100644 src/blackgui/components/cockpitcomaudiodialog.ui diff --git a/src/blackgui/components/cockpitcomaudiodialog.cpp b/src/blackgui/components/cockpitcomaudiodialog.cpp new file mode 100644 index 000000000..c24acbd01 --- /dev/null +++ b/src/blackgui/components/cockpitcomaudiodialog.cpp @@ -0,0 +1,28 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "cockpitcomaudiodialog.h" +#include "ui_cockpitcomaudiodialog.h" + +namespace BlackGui +{ + namespace Components + { + CCockpitComAudioDialog::CCockpitComAudioDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CCockpitComAudioDialog) + { + ui->setupUi(this); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); + } + + CCockpitComAudioDialog::~CCockpitComAudioDialog() + { } + + } // ns +} // ns diff --git a/src/blackgui/components/cockpitcomaudiodialog.h b/src/blackgui/components/cockpitcomaudiodialog.h new file mode 100644 index 000000000..b09ef752b --- /dev/null +++ b/src/blackgui/components/cockpitcomaudiodialog.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2019 - let's see if there will be a (C) 2020 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_COCKPITCOMAUDIODIALOG_H +#define BLACKGUI_COMPONENTS_COCKPITCOMAUDIODIALOG_H + +#include "blackgui/blackguiexport.h" +#include + +namespace Ui { class CCockpitComAudioDialog; } +namespace BlackGui +{ + namespace Components + { + //! Cockpit COM component as dialog + class BLACKGUI_EXPORT CCockpitComAudioDialog : public QDialog + { + Q_OBJECT + + public: + //! Ctor + explicit CCockpitComAudioDialog(QWidget *parent = nullptr); + + //! Dtor + virtual ~CCockpitComAudioDialog() override; + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/cockpitcomaudiodialog.ui b/src/blackgui/components/cockpitcomaudiodialog.ui new file mode 100644 index 000000000..d29fd6e7c --- /dev/null +++ b/src/blackgui/components/cockpitcomaudiodialog.ui @@ -0,0 +1,147 @@ + + + CCockpitComAudioDialog + + + + 0 + 0 + 400 + 500 + + + + + 400 + 500 + + + + Audio and cockpit + + + + + + + 0 + 100 + + + + COM + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 0 + 100 + + + + Audio + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + BlackGui::Components::CCockpitComComponent + QFrame +
blackgui/components/cockpitcomcomponent.h
+ 1 +
+ + BlackGui::Components::CAudioDeviceVolumeSetupComponent + QFrame +
blackgui/components/audiodevicevolumesetupcomponent.h
+ 1 +
+
+ + + + bb_CockpitComDialog + accepted() + CCockpitComAudioDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_CockpitComDialog + rejected() + CCockpitComAudioDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/swiftcore/swiftcore.cpp b/src/swiftcore/swiftcore.cpp index 92ce200c8..5cc7d30a4 100644 --- a/src/swiftcore/swiftcore.cpp +++ b/src/swiftcore/swiftcore.cpp @@ -10,6 +10,7 @@ #include "blackgui/components/commandinput.h" #include "blackgui/components/coreinfoareacomponent.h" #include "blackgui/components/coresettingsdialog.h" +#include "blackgui/components/cockpitcomaudiodialog.h" #include "blackgui/components/logcomponent.h" #include "blackgui/components/rawfsdmessagesdialog.h" #include "blackgui/guiapplication.h" @@ -55,14 +56,14 @@ CSwiftCore::CSwiftCore(QWidget *parent) : m_mwaOverlayFrame = nullptr; m_mwaStatusBar = nullptr; - connect(ui->pb_Restart, &QPushButton::clicked, this, &CSwiftCore::restart); + connect(ui->pb_Restart, &QPushButton::clicked, this, &CSwiftCore::restart); + connect(ui->pb_Audio, &QPushButton::clicked, this, &CSwiftCore::audioDialog, Qt::QueuedConnection); connect(ui->pb_DisconnectNetwork, &QPushButton::clicked, this, &CSwiftCore::disconnectFromNetwork); - connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftCore::onStyleSheetsChanged, Qt::QueuedConnection); + connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftCore::onStyleSheetsChanged, Qt::QueuedConnection); this->initLogDisplay(); this->initStyleSheet(); this->initMenus(); - this->initAudio(); // log CStatusMessage m = CStatusMessage(this).info(u"Cmd: %1") << CGuiApplication::arguments().join(" "); @@ -138,28 +139,12 @@ void CSwiftCore::initMenus() connect(ui->menu_RawFsdMessageDialog, &QAction::triggered, this, &CSwiftCore::showRawFsdMessageDialog); } -void CSwiftCore::initAudio() -{ - if (!sGui->getIContextAudio()) { return; } - ui->lbl_AudioRunsWhere->setText(sGui->getIContextAudio()->audioRunsWhereInfo()); - if (sGui->getIContextAudio()->isUsingImplementingObject()) - { - ui->rb_AudioOnCore->setChecked(true); - } - else - { - ui->rb_AudioOnGui->setChecked(true); - } -} - void CSwiftCore::restart() { if (!sGui || sGui->isShuttingDown()) { return; } ui->pb_Restart->setEnabled(false); const QStringList args = this->getRestartCmdArgs(); sGui->restartApplication(args); - - // sGui->restartApplication(args, { "--coreaudio" }); } void CSwiftCore::disconnectFromNetwork() @@ -173,16 +158,18 @@ void CSwiftCore::disconnectFromNetwork() sGui->getIContextNetwork()->disconnectFromNetwork(); } -QString CSwiftCore::getAudioCmdFromRadioButtons() const +void CSwiftCore::audioDialog() { - // if (ui->rb_AudioOnCore->isChecked()) { return QStringLiteral("--coreaudio"); } - return {}; + if (!m_audioDialog) + { + m_audioDialog.reset(new CCockpitComAudioDialog(this)); + } + m_audioDialog->setModal(false); + m_audioDialog->show(); } QStringList CSwiftCore::getRestartCmdArgs() const { - // const QString coreAudio = this->getAudioCmdFromRadioButtons(); - QStringList cmds = ui->comp_DBusSelector->getDBusCmdLineArgs(); - // if (!coreAudio.isEmpty()) { cmds.append(coreAudio); } + const QStringList cmds = ui->comp_DBusSelector->getDBusCmdLineArgs(); return cmds; } diff --git a/src/swiftcore/swiftcore.h b/src/swiftcore/swiftcore.h index 83625b012..cfac81c07 100644 --- a/src/swiftcore/swiftcore.h +++ b/src/swiftcore/swiftcore.h @@ -29,6 +29,7 @@ namespace BlackGui { class CCoreSettingsDialog; class CRawFsdMessagesDialog; + class CCockpitComAudioDialog; } } namespace Ui { class CSwiftCore; } @@ -57,7 +58,6 @@ private: void initLogDisplay(); void initStyleSheet(); void initMenus(); - void initAudio(); //! @} //! Add a message to log UI @@ -81,14 +81,16 @@ private: //! Disconnect from network void disconnectFromNetwork(); - //! Core mode from radio buttons - QString getAudioCmdFromRadioButtons() const; + //! Audio dialog + void audioDialog(); //! Restart CMD args QStringList getRestartCmdArgs() const; - QScopedPointer m_settingsDialog; + QScopedPointer m_settingsDialog; QScopedPointer m_rawFsdMessageDialog; + QScopedPointer m_audioDialog; + QScopedPointer ui; }; diff --git a/src/swiftcore/swiftcore.ui b/src/swiftcore/swiftcore.ui index e2d7fdbde..c34e6fa09 100644 --- a/src/swiftcore/swiftcore.ui +++ b/src/swiftcore/swiftcore.ui @@ -159,9 +159,9 @@ QTextEdit { - + - Audio (requires restart) + Audio/Cockpit @@ -176,30 +176,10 @@ QTextEdit { 4 - - + + - <Audio is where> - - - true - - - - - - - on core side - - - - - - - on GUI side - - - true + audio @@ -283,7 +263,7 @@ QTextEdit { - + :/pastel/icons/pastel/16/wrench-orange.png:/pastel/icons/pastel/16/wrench-orange.png @@ -335,12 +315,8 @@ QTextEdit { lep_CommandLineInput pb_DisconnectNetwork - rb_AudioOnCore - rb_AudioOnGui pb_Restart - - - +