mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
[AFV] Ref T739, added a dialog for cockpit/audio so CAfvClient can be used in core UI
This commit is contained in:
28
src/blackgui/components/cockpitcomaudiodialog.cpp
Normal file
28
src/blackgui/components/cockpitcomaudiodialog.cpp
Normal file
@@ -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
|
||||
40
src/blackgui/components/cockpitcomaudiodialog.h
Normal file
40
src/blackgui/components/cockpitcomaudiodialog.h
Normal file
@@ -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 <QDialog>
|
||||
|
||||
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::CCockpitComAudioDialog> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
147
src/blackgui/components/cockpitcomaudiodialog.ui
Normal file
147
src/blackgui/components/cockpitcomaudiodialog.ui
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CCockpitComAudioDialog</class>
|
||||
<widget class="QDialog" name="CCockpitComAudioDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Audio and cockpit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_CockpitComDialog">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Com">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>COM</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CCockpitComComponent" name="comp_Com">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Audio">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Audio</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAudioDeviceVolumeSetupComponent" name="comp_Audio">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_CockpitComDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCockpitComComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/cockpitcomcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CAudioDeviceVolumeSetupComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/audiodevicevolumesetupcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_CockpitComDialog</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CCockpitComAudioDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_CockpitComDialog</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CCockpitComAudioDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
||||
QScopedPointer<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
||||
QScopedPointer<BlackGui::Components::CRawFsdMessagesDialog> m_rawFsdMessageDialog;
|
||||
QScopedPointer<BlackGui::Components::CCockpitComAudioDialog> m_audioDialog;
|
||||
|
||||
QScopedPointer<Ui::CSwiftCore> ui;
|
||||
};
|
||||
|
||||
|
||||
@@ -159,9 +159,9 @@ QTextEdit {
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="gb_Audio">
|
||||
<widget class="QGroupBox" name="gb_AudioAndCockpit">
|
||||
<property name="title">
|
||||
<string>Audio (requires restart)</string>
|
||||
<string>Audio/Cockpit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Audio">
|
||||
<property name="leftMargin">
|
||||
@@ -176,30 +176,10 @@ QTextEdit {
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_AudioRunsWhere">
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_Audio">
|
||||
<property name="text">
|
||||
<string><Audio is where></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_AudioOnCore">
|
||||
<property name="text">
|
||||
<string>on core side</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_AudioOnGui">
|
||||
<property name="text">
|
||||
<string>on GUI side</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>audio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -283,7 +263,7 @@ QTextEdit {
|
||||
</widget>
|
||||
<action name="menu_SettingsDialog">
|
||||
<property name="icon">
|
||||
<iconset resource="../blackmisc/blackmisc.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/pastel/icons/pastel/16/wrench-orange.png</normaloff>:/pastel/icons/pastel/16/wrench-orange.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -335,12 +315,8 @@ QTextEdit {
|
||||
<tabstops>
|
||||
<tabstop>lep_CommandLineInput</tabstop>
|
||||
<tabstop>pb_DisconnectNetwork</tabstop>
|
||||
<tabstop>rb_AudioOnCore</tabstop>
|
||||
<tabstop>rb_AudioOnGui</tabstop>
|
||||
<tabstop>pb_Restart</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user