From 2424c40229581477040dc2c8c35bb28968dbc890 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 13 Aug 2018 02:49:53 +0200 Subject: [PATCH] Ref T301, core now has button to disconnect from network use case: GUI crashes and an emergency disconnect is needed --- src/swiftcore/swiftcore.cpp | 17 ++++- src/swiftcore/swiftcore.h | 4 +- src/swiftcore/swiftcore.ui | 145 ++++++++++++++++++++++++------------ 3 files changed, 117 insertions(+), 49 deletions(-) diff --git a/src/swiftcore/swiftcore.cpp b/src/swiftcore/swiftcore.cpp index 00a8d1574..f157a4048 100644 --- a/src/swiftcore/swiftcore.cpp +++ b/src/swiftcore/swiftcore.cpp @@ -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 #include #include - -class QWidget; +#include 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"; } diff --git a/src/swiftcore/swiftcore.h b/src/swiftcore/swiftcore.h index 9c4b52331..5b348abe5 100644 --- a/src/swiftcore/swiftcore.h +++ b/src/swiftcore/swiftcore.h @@ -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 m_settingsDialog; QScopedPointer m_rawFsdMessageDialog; QScopedPointer ui; - }; #endif // guard diff --git a/src/swiftcore/swiftcore.ui b/src/swiftcore/swiftcore.ui index 3c1066a07..c6fabdf74 100644 --- a/src/swiftcore/swiftcore.ui +++ b/src/swiftcore/swiftcore.ui @@ -27,8 +27,95 @@ 4 - - + + + + Commands + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + dot commands + + + + + + + + + + Network + + + + 4 + + + 4 + + + 9 + + + 4 + + + + + disconnect + + + + + + + + + + Control + + + + 9 + + + 4 + + + 9 + + + 4 + + + + + /** Main window **/ +QTextEdit { + background-color: DimGray; +} + + + restart + + + + + @@ -119,40 +206,6 @@ - - - - Control - - - - 9 - - - 4 - - - 9 - - - 4 - - - - - /** Main window **/ -QTextEdit { - background-color: DimGray; -} - - - restart - - - - - - @@ -192,7 +245,7 @@ QTextEdit { 0 0 450 - 26 + 19 @@ -249,9 +302,9 @@ QTextEdit { - BlackGui::Components::CInfoBarStatusComponent - QWidget -
blackgui/components/infobarstatuscomponent.h
+ BlackGui::Components::CCommandInput + QLineEdit +
blackgui/components/commandinput.h
1
@@ -261,15 +314,15 @@ QTextEdit { 1 - BlackGui::CSystemTrayWindow - QMainWindow -
blackgui/systemtraywindow.h
+ BlackGui::Components::CInfoBarStatusComponent + QWidget +
blackgui/components/infobarstatuscomponent.h
1
- BlackGui::Components::CCommandInput - QLineEdit -
blackgui/components/commandinput.h
+ BlackGui::CSystemTrayWindow + QMainWindow +
blackgui/systemtraywindow.h
1