mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +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/stylesheetutility.h"
|
||||
#include "blackcore/context/contextaudio.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/icons.h"
|
||||
@@ -32,8 +33,7 @@
|
||||
#include <QRadioButton>
|
||||
#include <QtGlobal>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class QWidget;
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackCore;
|
||||
@@ -57,6 +57,7 @@ CSwiftCore::CSwiftCore(QWidget *parent) :
|
||||
m_mwaStatusBar = nullptr;
|
||||
|
||||
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);
|
||||
|
||||
this->initLogDisplay();
|
||||
@@ -154,11 +155,23 @@ void CSwiftCore::initAudio()
|
||||
|
||||
void CSwiftCore::restart()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
ui->pb_Restart->setEnabled(false);
|
||||
const QStringList args = this->getRestartCmdArgs();
|
||||
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
|
||||
{
|
||||
if (ui->rb_AudioOnCore->isChecked()) { return "--coreaudio"; }
|
||||
|
||||
@@ -79,6 +79,9 @@ private:
|
||||
//! Restart with new arguments
|
||||
void restart();
|
||||
|
||||
//! Disconnect from network
|
||||
void disconnectFromNetwork();
|
||||
|
||||
//! Core mode from radio buttons
|
||||
QString getAudioCmdFromRadioButtons() const;
|
||||
|
||||
@@ -88,7 +91,6 @@ private:
|
||||
QScopedPointer<BlackGui::Components::CCoreSettingsDialog> m_settingsDialog;
|
||||
QScopedPointer<BlackGui::Components::CRawFsdMessagesDialog> m_rawFsdMessageDialog;
|
||||
QScopedPointer<Ui::CSwiftCore> ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -27,8 +27,95 @@
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CCommandInput" name="lep_CommandLineInput"/>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<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 row="0" column="0" colspan="3">
|
||||
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus" native="true">
|
||||
@@ -119,40 +206,6 @@
|
||||
</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 row="1" column="0" rowspan="2" colspan="2">
|
||||
<widget class="QGroupBox" name="gb_DBus">
|
||||
<property name="title">
|
||||
@@ -192,7 +245,7 @@ QTextEdit {
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>26</height>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -249,9 +302,9 @@ QTextEdit {
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CInfoBarStatusComponent</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>blackgui/components/infobarstatuscomponent.h</header>
|
||||
<class>BlackGui::Components::CCommandInput</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>blackgui/components/commandinput.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
@@ -261,15 +314,15 @@ QTextEdit {
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CSystemTrayWindow</class>
|
||||
<extends>QMainWindow</extends>
|
||||
<header>blackgui/systemtraywindow.h</header>
|
||||
<class>BlackGui::Components::CInfoBarStatusComponent</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>blackgui/components/infobarstatuscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCommandInput</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>blackgui/components/commandinput.h</header>
|
||||
<class>BlackGui::CSystemTrayWindow</class>
|
||||
<extends>QMainWindow</extends>
|
||||
<header>blackgui/systemtraywindow.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user