mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +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 <QWidget>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace BlackConfig;
|
using namespace BlackConfig;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
@@ -48,6 +50,7 @@ namespace BlackGui
|
|||||||
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
||||||
|
|
||||||
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||||
if (sGui->getIContextSimulator())
|
if (sGui->getIContextSimulator())
|
||||||
{
|
{
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged);
|
||||||
@@ -74,6 +77,13 @@ namespace BlackGui
|
|||||||
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
||||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointer<CInfoBarStatusComponent> myself(this);
|
||||||
|
QTimer::singleShot(5000, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!myself) { return; }
|
||||||
|
this->updateValues();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CInfoBarStatusComponent::~CInfoBarStatusComponent()
|
CInfoBarStatusComponent::~CInfoBarStatusComponent()
|
||||||
@@ -210,6 +220,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInfoBarStatusComponent::onMapperReady()
|
void CInfoBarStatusComponent::onMapperReady()
|
||||||
{
|
{
|
||||||
|
if (sGui && sGui->isShuttingDown()) { return; }
|
||||||
if (!sGui || !sGui->getIContextSimulator())
|
if (!sGui || !sGui->getIContextSimulator())
|
||||||
{
|
{
|
||||||
ui->led_MapperReady->setOn(false);
|
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()
|
void CInfoBarStatusComponent::updateSpacing()
|
||||||
{
|
{
|
||||||
if (!sGui || !sGui->mainApplicationWidget()) { return; }
|
if (!sGui || sGui->isShuttingDown() || !sGui->mainApplicationWidget()) { return; }
|
||||||
const int w = sGui->mainApplicationWidget()->width();
|
const int w = sGui->mainApplicationWidget()->width();
|
||||||
const int s = (w >= 400) ? 6 : 2;
|
const int s = (w >= 400) ? 6 : 2;
|
||||||
this->setSpacing(s);
|
this->setSpacing(s);
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ namespace BlackGui
|
|||||||
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
|
QScopedPointer<Ui::CInfoBarStatusComponent> ui;
|
||||||
BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged };
|
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
|
//! Simulator connection has been changed
|
||||||
void onSimulatorStatusChanged(int status);
|
void onSimulatorStatusChanged(int status);
|
||||||
|
|
||||||
@@ -74,6 +77,9 @@ namespace BlackGui
|
|||||||
//! Internet accessible?
|
//! Internet accessible?
|
||||||
void onInternetAccessibleChanged(bool access);
|
void onInternetAccessibleChanged(bool access);
|
||||||
|
|
||||||
|
//! Update values
|
||||||
|
void updateValues();
|
||||||
|
|
||||||
//! Update spacing based on main window size
|
//! Update spacing based on main window size
|
||||||
void updateSpacing();
|
void updateSpacing();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -73,6 +74,13 @@ namespace BlackGui
|
|||||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
||||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
||||||
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||||
|
|
||||||
|
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||||
|
QTimer::singleShot(5000, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!myself || !sGui) { return; }
|
||||||
|
this->update();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainKeypadAreaComponent::~CMainKeypadAreaComponent()
|
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);
|
Q_UNUSED(from);
|
||||||
|
|
||||||
@@ -153,12 +161,14 @@ namespace BlackGui
|
|||||||
if (to == INetwork::Connected)
|
if (to == INetwork::Connected)
|
||||||
{
|
{
|
||||||
ui->pb_Connect->setText("Discon."); // full terms some too wide
|
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
|
else
|
||||||
{
|
{
|
||||||
ui->pb_Connect->setText("Connect");
|
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());
|
QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
|
||||||
if (!pb) { return; }
|
if (!pb) { return; }
|
||||||
pb->setEnabled(false);
|
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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
namespace BlackMisc { namespace Simulation { class CSimulatedAircraft; } }
|
namespace BlackMisc { namespace Simulation { class CSimulatedAircraft; } }
|
||||||
namespace Ui { class CMainKeypadAreaComponent; }
|
namespace Ui { class CMainKeypadAreaComponent; }
|
||||||
@@ -96,6 +95,9 @@ namespace BlackGui
|
|||||||
//! Disable button for some (short) time to avoid double click
|
//! Disable button for some (short) time to avoid double click
|
||||||
void disableButtonBriefly();
|
void disableButtonBriefly();
|
||||||
|
|
||||||
|
//! Update values
|
||||||
|
void update();
|
||||||
|
|
||||||
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
|
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
|
||||||
BlackMisc::CIdentifier m_identifier { "MainKeypadAreaComponent", this };
|
BlackMisc::CIdentifier m_identifier { "MainKeypadAreaComponent", this };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,12 +13,6 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Main keypad area</string>
|
<string>Main keypad area</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="vl_MainKeypadArea">
|
<layout class="QVBoxLayout" name="vl_MainKeypadArea">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -204,6 +198,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Connect</string>
|
<string>Connect</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2">
|
<item row="4" column="2">
|
||||||
@@ -361,6 +358,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mute</string>
|
<string>Mute</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4">
|
<item row="3" column="4">
|
||||||
|
|||||||
Reference in New Issue
Block a user