11 #include <QStringBuilder>
17 #include "ui_infobarstatuscomponent.h"
32 using namespace swift::config;
34 using namespace swift::core::context;
37 using namespace swift::misc::audio;
38 using namespace swift::misc::network;
42 CInfoBarStatusComponent::CInfoBarStatusComponent(QWidget *parent)
47 this->adjustTextSize();
52 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Need sGui");
56 &CInfoBarStatusComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
58 &CInfoBarStatusComponent::onMapperReady);
61 this->onMapperReady();
68 &CInfoBarStatusComponent::onNetworkConnectionChanged, Qt::QueuedConnection);
76 ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
80 &CInfoBarStatusComponent::onOutputMuteChanged, Qt::QueuedConnection);
82 &CInfoBarStatusComponent::onAudioStarted, Qt::QueuedConnection);
84 &CInfoBarStatusComponent::onAudioStopped, Qt::QueuedConnection);
92 QPointer<CInfoBarStatusComponent> myself(
this);
101 void CInfoBarStatusComponent::initLeds()
103 this->updateSpacing();
105 ui->led_DBus->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"DBus connected",
"DBus disconnected",
107 ui->led_Network->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"Network connected",
108 "Network disconnected", 14);
109 ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Blue, shape,
110 "Simulator running",
"Simulator disconnected",
"Simulator connected", 14);
111 ui->led_MapperReady->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Blue, shape,
"Mapper ready",
112 "Mappings not yet loaded",
"Mappings not yet loaded", 14);
114 shape = CLedWidget::Rounded;
115 ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"Ptt",
"Silence", 18);
116 ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"On",
"Muted", 18);
119 void CInfoBarStatusComponent::adjustTextSize()
135 if (this->layout()) { this->layout()->setSpacing(spacing); }
140 QFrame::resizeEvent(event);
144 void CInfoBarStatusComponent::onSimulatorStatusChanged(
int status)
147 const ISimulator::SimulatorStatus simStatus =
static_cast<ISimulator::SimulatorStatus
>(status);
148 if (simStatus.testFlag(ISimulator::Connected))
152 ISimulator::statusToString(simStatus));
154 if (simStatus.testFlag(ISimulator::Paused))
156 ui->led_Simulator->setTriState();
157 ui->led_Simulator->setTriStateToolTip(s);
159 else if (simStatus.testFlag(ISimulator::Simulating))
161 ui->led_Simulator->setOn(
true);
162 ui->led_Simulator->setOnToolTip(s);
167 ui->led_Simulator->setTriState();
168 ui->led_Simulator->setTriStateToolTip(s);
171 else { ui->led_Simulator->setOn(
false); }
174 this->onMapperReady();
182 case CConnectionStatus::Disconnected: ui->led_Network->setOn(
false);
break;
183 case CConnectionStatus::Connected:
184 ui->led_Network->setOn(
true);
187 case CConnectionStatus::Connecting: ui->led_Network->setTriStateColor(CLedWidget::Yellow);
break;
188 default: ui->led_Network->setOn(
false);
break;
192 void CInfoBarStatusComponent::onOutputMuteChanged(
bool muted)
194 const bool on = !muted && isAudioAvailableAndNotMuted();
195 ui->led_Audio->setOn(on);
202 this->updateValues();
205 void CInfoBarStatusComponent::onAudioStopped() { this->updateValues(); }
207 void CInfoBarStatusComponent::onMapperReady()
212 ui->led_MapperReady->setOn(
false);
217 const bool on = (models > 0);
218 ui->led_MapperReady->setOn(on);
221 const QString m = QStringLiteral(
"Mapper with %1 models").arg(models);
222 ui->led_MapperReady->setToolTip(m);
226 void CInfoBarStatusComponent::onPttChanged(
bool enabled) { ui->led_Ptt->setOn(enabled); }
228 void CInfoBarStatusComponent::updateValues()
248 ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
251 void CInfoBarStatusComponent::updateSpacing()
255 const int s = (w >= 400) ? 6 : 2;
259 bool CInfoBarStatusComponent::isAudioAvailableAndNotMuted()
const context::IContextApplication * getIContextApplication() const
Direct access to contexts if a CCoreFacade has been initialized.
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
const context::CContextAudioBase * getCContextAudioBase() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isOutputMuted() const
Volume.
bool isAudioStarted() const
Is audio started?
bool isUsingImplementingObject() const
Using local implementing object?
virtual swift::misc::network::CServer getConnectedServer() const =0
Server which is connected, if not connected empty default object.
virtual bool isConnected() const =0
Network connected?
virtual swift::misc::simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const =0
Simulator info, currently loaded plugin.
virtual int getModelSetCount() const =0
Number of installed models in simulator eco system.
virtual ISimulator::SimulatorStatus getSimulatorStatus() const =0
Simulator combined status.
static QWidget * mainApplicationWidget()
Main application window widget.
static void setElidedText(QLabel *label, const QString &text, Qt::TextElideMode mode=Qt::ElideMiddle)
Set elided text.
Info bar displaying status (Network, Simulator, DBus)
virtual ~CInfoBarStatusComponent()
Destructor.
void setDBusTooltip(const QString &tooltip)
Tooltip for DBus.
void transponderModeChanged()
Mode changed.
void setDBusStatus(bool dbus)
DBus used?
void setSpacing(int spacing)
Set the spacing.
virtual void resizeEvent(QResizeEvent *event)
void changed()
value has been changed
void inputSignal()
Received input signal, or manually trigger.
Value object encapsulating information of a audio device.
Value object encapsulating information about a connection status.
ConnectionStatus getConnectionStatus() const
Get status.
const QString & getName() const
Get name.
const QString & getDescription() const
Description.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...