mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Ref T301, keypad and infobar init themself and can be re-connect (to core)
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <QWidget>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackCore;
|
||||
@@ -48,6 +50,7 @@ namespace BlackGui
|
||||
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
||||
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
if (sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged);
|
||||
@@ -74,6 +77,13 @@ namespace BlackGui
|
||||
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
||||
}
|
||||
|
||||
QPointer<CInfoBarStatusComponent> myself(this);
|
||||
QTimer::singleShot(5000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->updateValues();
|
||||
});
|
||||
}
|
||||
|
||||
CInfoBarStatusComponent::~CInfoBarStatusComponent()
|
||||
@@ -210,6 +220,7 @@ namespace BlackGui
|
||||
|
||||
void CInfoBarStatusComponent::onMapperReady()
|
||||
{
|
||||
if (sGui && sGui->isShuttingDown()) { return; }
|
||||
if (!sGui || !sGui->getIContextSimulator())
|
||||
{
|
||||
ui->led_MapperReady->setOn(false);
|
||||
@@ -245,9 +256,45 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::updateValues()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
IContextSimulator *simCon = sGui->getIContextSimulator();
|
||||
if (sGui->getIContextSimulator())
|
||||
{
|
||||
|
||||
this->onSimulatorStatusChanged(simCon->getSimulatorStatus());
|
||||
if (simCon->getModelSetCount() > 0)
|
||||
{
|
||||
this->onMapperReady();
|
||||
}
|
||||
}
|
||||
|
||||
if (sGui->getIContextNetwork())
|
||||
{
|
||||
ui->led_Network->setOn(sGui->getIContextNetwork()->isConnected());
|
||||
}
|
||||
|
||||
if (sGui->getIContextApplication())
|
||||
{
|
||||
ui->led_DBus->setOn(sGui->getIContextApplication()->isUsingImplementingObject());
|
||||
}
|
||||
|
||||
// audio context can be empty depending on which side it is called
|
||||
if (sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject())
|
||||
{
|
||||
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->led_Audio->setOn(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::updateSpacing()
|
||||
{
|
||||
if (!sGui || !sGui->mainApplicationWidget()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->mainApplicationWidget()) { return; }
|
||||
const int w = sGui->mainApplicationWidget()->width();
|
||||
const int s = (w >= 400) ? 6 : 2;
|
||||
this->setSpacing(s);
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
|
||||
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged };
|
||||
|
||||
//! Init the LEDs
|
||||
void initLeds();
|
||||
|
||||
//! Simulator connection has been changed
|
||||
void onSimulatorStatusChanged(int status);
|
||||
|
||||
@@ -74,6 +77,9 @@ namespace BlackGui
|
||||
//! Internet accessible?
|
||||
void onInternetAccessibleChanged(bool access);
|
||||
|
||||
//! Update values
|
||||
void updateValues();
|
||||
|
||||
//! Update spacing based on main window size
|
||||
void updateSpacing();
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -73,6 +74,13 @@ namespace BlackGui
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
||||
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||
|
||||
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||
QTimer::singleShot(5000, this, [ = ]
|
||||
{
|
||||
if (!myself || !sGui) { return; }
|
||||
this->update();
|
||||
});
|
||||
}
|
||||
|
||||
CMainKeypadAreaComponent::~CMainKeypadAreaComponent()
|
||||
@@ -145,7 +153,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
|
||||
void CMainKeypadAreaComponent::connectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
|
||||
@@ -153,12 +161,14 @@ namespace BlackGui
|
||||
if (to == INetwork::Connected)
|
||||
{
|
||||
ui->pb_Connect->setText("Discon."); // full terms some too wide
|
||||
ui->pb_Connect->setStyleSheet("background-color: green");
|
||||
ui->pb_Connect->setChecked(true);
|
||||
// moved to stylesheet: ui->pb_Connect->setStyleSheet("background-color: green");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pb_Connect->setText("Connect");
|
||||
ui->pb_Connect->setStyleSheet("background-color: ");
|
||||
ui->pb_Connect->setChecked(false);
|
||||
// moved to stylesheet: ui->pb_Connect->setStyleSheet("background-color: ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +252,26 @@ namespace BlackGui
|
||||
QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
|
||||
if (!pb) { return; }
|
||||
pb->setEnabled(false);
|
||||
QTimer::singleShot(750, [pb] { pb->setEnabled(true); });
|
||||
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||
QTimer::singleShot(750, [ = ]
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !myself) { return; }
|
||||
pb->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::update()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
||||
if (sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject())
|
||||
{
|
||||
this->muteChanged(sGui->getIContextAudio()->isMuted());
|
||||
}
|
||||
|
||||
if (sGui->getIContextNetwork() && sGui->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->connectionStatusChanged(INetwork::Connected, INetwork::Connected);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <QString>
|
||||
|
||||
class QPushButton;
|
||||
class QWidget;
|
||||
|
||||
namespace BlackMisc { namespace Simulation { class CSimulatedAircraft; } }
|
||||
namespace Ui { class CMainKeypadAreaComponent; }
|
||||
@@ -96,6 +95,9 @@ namespace BlackGui
|
||||
//! Disable button for some (short) time to avoid double click
|
||||
void disableButtonBriefly();
|
||||
|
||||
//! Update values
|
||||
void update();
|
||||
|
||||
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
|
||||
BlackMisc::CIdentifier m_identifier { "MainKeypadAreaComponent", this };
|
||||
};
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
<property name="windowTitle">
|
||||
<string>Main keypad area</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_MainKeypadArea">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -204,6 +198,9 @@
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
@@ -361,6 +358,9 @@
|
||||
<property name="text">
|
||||
<string>Mute</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
|
||||
Reference in New Issue
Block a user