Ref T121, check if Internet is accessible

* in case the internet provider is down, this is not detected
* extended test to detect if access is possible
* in case of downtime this indicated in status component
This commit is contained in:
Klaus Basan
2017-08-05 20:05:07 +02:00
committed by Mathew Sutcliffe
parent b70fb70d60
commit f3847bd33c
20 changed files with 176 additions and 92 deletions

View File

@@ -46,21 +46,22 @@ namespace BlackGui
this->initLeds();
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::ps_customAudioContextMenuRequested);
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
if (sGui->getIContextSimulator())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::ps_onSimulatorStatusChanged);
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::ps_onMapperReady);
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged);
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::onMapperReady);
connect(sGui, &CGuiApplication::internetAccessibleChanged, this, &CInfoBarStatusComponent::onInternetAccessibleChanged);
// initial values
this->ps_onMapperReady();
this->ps_onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
this->onMapperReady();
this->onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
}
if (sGui->getIContextNetwork())
{
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::ps_onNetworkConnectionChanged);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::onNetworkConnectionChanged);
}
if (sGui->getIContextApplication())
@@ -71,7 +72,7 @@ namespace BlackGui
if (sGui->getIContextAudio())
{
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::ps_onMuteChanged);
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
}
}
@@ -89,6 +90,7 @@ namespace BlackGui
shape = CLedWidget::Rounded;
ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18);
ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18);
this->onInternetAccessibleChanged(sGui->isInternetAccessible());
}
void CInfoBarStatusComponent::setDBusStatus(bool dbus)
@@ -101,7 +103,7 @@ namespace BlackGui
ui->led_DBus->setOnToolTip(tooltip);
}
void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(int status)
void CInfoBarStatusComponent::onSimulatorStatusChanged(int status)
{
ISimulator::SimulatorStatus simStatus = static_cast<ISimulator::SimulatorStatus>(status);
if (simStatus.testFlag(ISimulator::Connected))
@@ -112,7 +114,6 @@ namespace BlackGui
ISimulator::statusToString(simStatus)
);
if (simStatus.testFlag(ISimulator::Paused))
{
ui->led_Simulator->setTriState();
@@ -136,10 +137,10 @@ namespace BlackGui
}
// simulator status has impact on model set available
this->ps_onMapperReady();
this->onMapperReady();
}
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
void CInfoBarStatusComponent::onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
{
Q_UNUSED(from);
@@ -164,11 +165,11 @@ namespace BlackGui
}
}
void CInfoBarStatusComponent::ps_customAudioContextMenuRequested(const QPoint &position)
void CInfoBarStatusComponent::onCustomAudioContextMenuRequested(const QPoint &position)
{
QWidget *sender = qobject_cast<QWidget *>(QWidget::sender());
Q_ASSERT(sender);
QPoint globalPosition = sender->mapToGlobal(position);
const QWidget *sender = qobject_cast<QWidget *>(QWidget::sender());
Q_ASSERT_X(sender, Q_FUNC_INFO, "Missing sender");
const QPoint globalPosition = sender->mapToGlobal(position);
QMenu menuAudio(this);
menuAudio.addAction("Toogle mute");
@@ -178,7 +179,7 @@ namespace BlackGui
menuAudio.addAction("Mixer");
}
QAction *selectedItem = menuAudio.exec(globalPosition);
const QAction *selectedItem = menuAudio.exec(globalPosition);
if (selectedItem)
{
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
@@ -194,12 +195,12 @@ namespace BlackGui
}
}
void CInfoBarStatusComponent::ps_onMuteChanged(bool muted)
void CInfoBarStatusComponent::onMuteChanged(bool muted)
{
ui->led_Audio->setOn(!muted);
}
void CInfoBarStatusComponent::ps_onMapperReady()
void CInfoBarStatusComponent::onMapperReady()
{
if (!sGui || !sGui->getIContextSimulator())
{
@@ -212,14 +213,28 @@ namespace BlackGui
ui->led_MapperReady->setOn(on);
if (on)
{
QString m = QString("Mapper with %1 models").arg(models);
const QString m = QString("Mapper with %1 models").arg(models);
ui->led_MapperReady->setToolTip(m);
}
}
void CInfoBarStatusComponent::ps_onPttChanged(bool enabled)
void CInfoBarStatusComponent::onPttChanged(bool enabled)
{
ui->led_Ptt->setOn(enabled);
}
void CInfoBarStatusComponent::onInternetAccessibleChanged(bool access)
{
if (access)
{
ui->led_Network->setOffColor(CLedWidget::Black);
ui->led_Network->setOffToolTip("Network disconnected");
}
else
{
ui->led_Network->setOffColor(CLedWidget::Red);
ui->led_Network->setOffToolTip("No network/internet access");
}
}
} // namespace
} // namespace

View File

@@ -25,14 +25,12 @@ class QPoint;
class QWidget;
namespace Ui { class CInfoBarStatusComponent; }
namespace BlackGui
{
namespace Components
{
//! Info bar displaying status (Network, Simulator, DBus)
class BLACKGUI_EXPORT CInfoBarStatusComponent :
public QFrame
class BLACKGUI_EXPORT CInfoBarStatusComponent : public QFrame
{
Q_OBJECT
@@ -41,7 +39,7 @@ namespace BlackGui
explicit CInfoBarStatusComponent(QWidget *parent = nullptr);
//!Destructor
~CInfoBarStatusComponent();
virtual ~CInfoBarStatusComponent();
//! Init the LEDs
void initLeds();
@@ -54,27 +52,29 @@ namespace BlackGui
private:
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::ps_onPttChanged };
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged };
private slots:
//! Simulator connection has been changed
void ps_onSimulatorStatusChanged(int status);
void onSimulatorStatusChanged(int status);
//! Network connection has been changed
void ps_onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
void onNetworkConnectionChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
//! Context menu requested
void ps_customAudioContextMenuRequested(const QPoint &position);
void onCustomAudioContextMenuRequested(const QPoint &position);
//! Mute changed
void ps_onMuteChanged(bool muted);
void onMuteChanged(bool muted);
//! Mapper is ready
void ps_onMapperReady();
void onMapperReady();
//! Ptt button changed
void ps_onPttChanged(bool enabled);
void onPttChanged(bool enabled);
//! Internet accessible?
void onInternetAccessibleChanged(bool access);
};
}
}
} // ns
} // ns
#endif // guard

View File

@@ -205,9 +205,9 @@ namespace BlackGui
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
}
void CGuiApplication::ps_startupCompleted()
void CGuiApplication::startupCompleted()
{
CApplication::ps_startupCompleted();
CApplication::startupCompleted();
if (this->m_splashScreen)
{
this->m_splashScreen->close();

View File

@@ -194,7 +194,7 @@ namespace BlackGui
protected slots:
//! Startup competed
virtual void ps_startupCompleted() override;
virtual void startupCompleted() override;
protected:
//! \name print messages generated during parsing / cmd handling