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:
Klaus Basan
2018-08-13 02:49:53 +02:00
parent f3c7015cfb
commit 2424c40229
3 changed files with 117 additions and 49 deletions

View File

@@ -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"; }