mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 22:29:13 +08:00
Ref T301, core now has button to disconnect from network
use case: GUI crashes and an emergency disconnect is needed
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/stylesheetutility.h"
|
#include "blackgui/stylesheetutility.h"
|
||||||
#include "blackcore/context/contextaudio.h"
|
#include "blackcore/context/contextaudio.h"
|
||||||
|
#include "blackcore/context/contextnetwork.h"
|
||||||
#include "blackcore/corefacade.h"
|
#include "blackcore/corefacade.h"
|
||||||
#include "blackmisc/dbusserver.h"
|
#include "blackmisc/dbusserver.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
@@ -32,8 +33,7 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QMessageBox>
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
@@ -57,6 +57,7 @@ CSwiftCore::CSwiftCore(QWidget *parent) :
|
|||||||
m_mwaStatusBar = 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_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->initLogDisplay();
|
||||||
@@ -154,11 +155,23 @@ void CSwiftCore::initAudio()
|
|||||||
|
|
||||||
void CSwiftCore::restart()
|
void CSwiftCore::restart()
|
||||||
{
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
ui->pb_Restart->setEnabled(false);
|
ui->pb_Restart->setEnabled(false);
|
||||||
const QStringList args = this->getRestartCmdArgs();
|
const QStringList args = this->getRestartCmdArgs();
|
||||||
sGui->restartApplication(args, { "--coreaudio" });
|
sGui->restartApplication(args, { "--coreaudio" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSwiftCore::disconnectFromNetwork()
|
||||||
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
if (!sGui->getIContextNetwork()) { return; }
|
||||||
|
if (!sGui->getIContextNetwork()->isConnected()) { return; }
|
||||||
|
|
||||||
|
const QMessageBox::StandardButton reply = QMessageBox::question(this, "Disconnect", "Disconnect from network?", QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (reply != QMessageBox::Yes) { return; }
|
||||||
|
sGui->getIContextNetwork()->disconnectFromNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
QString CSwiftCore::getAudioCmdFromRadioButtons() const
|
QString CSwiftCore::getAudioCmdFromRadioButtons() const
|
||||||
{
|
{
|
||||||
if (ui->rb_AudioOnCore->isChecked()) { return "--coreaudio"; }
|
if (ui->rb_AudioOnCore->isChecked()) { return "--coreaudio"; }
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ private:
|
|||||||
//! Restart with new arguments
|
//! Restart with new arguments
|
||||||
void restart();
|
void restart();
|
||||||
|
|
||||||
|
//! Disconnect from network
|
||||||
|
void disconnectFromNetwork();
|
||||||
|
|
||||||
//! Core mode from radio buttons
|
//! Core mode from radio buttons
|
||||||
QString getAudioCmdFromRadioButtons() const;
|
QString getAudioCmdFromRadioButtons() const;
|
||||||
|
|
||||||
@@ -88,7 +91,6 @@ private:
|
|||||||
QScopedPointer<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
QScopedPointer<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
||||||
QScopedPointer<BlackGui::Components::CRawFsdMessagesDialog> m_rawFsdMessageDialog;
|
QScopedPointer<BlackGui::Components::CRawFsdMessagesDialog> m_rawFsdMessageDialog;
|
||||||
QScopedPointer<Ui::CSwiftCore> ui;
|
QScopedPointer<Ui::CSwiftCore> ui;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -27,8 +27,95 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="5" column="0" colspan="3">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="BlackGui::Components::CCommandInput" name="lep_CommandLineInput"/>
|
<widget class="QGroupBox" name="gb_Commands">
|
||||||
|
<property name="title">
|
||||||
|
<string>Commands</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_Commands">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="BlackGui::Components::CCommandInput" name="lep_CommandLineInput">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>dot commands</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QGroupBox" name="gb_Network">
|
||||||
|
<property name="title">
|
||||||
|
<string>Network</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="hl_Network">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QPushButton" name="pb_DisconnectNetwork">
|
||||||
|
<property name="text">
|
||||||
|
<string>disconnect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2" alignment="Qt::AlignBottom">
|
||||||
|
<widget class="QGroupBox" name="gb_Controls">
|
||||||
|
<property name="title">
|
||||||
|
<string>Control</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_Controls">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QPushButton" name="pb_Restart">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">/** Main window **/
|
||||||
|
QTextEdit {
|
||||||
|
background-color: DimGray;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>restart</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="3">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus" native="true">
|
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus" native="true">
|
||||||
@@ -119,40 +206,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2" alignment="Qt::AlignBottom">
|
|
||||||
<widget class="QGroupBox" name="gb_Controls">
|
|
||||||
<property name="title">
|
|
||||||
<string>Control</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="vl_Controls">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<item alignment="Qt::AlignRight">
|
|
||||||
<widget class="QPushButton" name="pb_Restart">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">/** Main window **/
|
|
||||||
QTextEdit {
|
|
||||||
background-color: DimGray;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>restart</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" rowspan="2" colspan="2">
|
<item row="1" column="0" rowspan="2" colspan="2">
|
||||||
<widget class="QGroupBox" name="gb_DBus">
|
<widget class="QGroupBox" name="gb_DBus">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -192,7 +245,7 @@ QTextEdit {
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>26</height>
|
<height>19</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_File">
|
<widget class="QMenu" name="menu_File">
|
||||||
@@ -249,9 +302,9 @@ QTextEdit {
|
|||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::Components::CInfoBarStatusComponent</class>
|
<class>BlackGui::Components::CCommandInput</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header>blackgui/components/infobarstatuscomponent.h</header>
|
<header>blackgui/components/commandinput.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
@@ -261,15 +314,15 @@ QTextEdit {
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::CSystemTrayWindow</class>
|
<class>BlackGui::Components::CInfoBarStatusComponent</class>
|
||||||
<extends>QMainWindow</extends>
|
<extends>QWidget</extends>
|
||||||
<header>blackgui/systemtraywindow.h</header>
|
<header>blackgui/components/infobarstatuscomponent.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::Components::CCommandInput</class>
|
<class>BlackGui::CSystemTrayWindow</class>
|
||||||
<extends>QLineEdit</extends>
|
<extends>QMainWindow</extends>
|
||||||
<header>blackgui/components/commandinput.h</header>
|
<header>blackgui/systemtraywindow.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
Reference in New Issue
Block a user