mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
refs #335, implemented the functionality for main keypad area,
old keypad was removed from main window
This commit is contained in:
committed by
Roland Winklmeier
parent
e45087c933
commit
3351791016
@@ -9,6 +9,10 @@
|
||||
|
||||
#include "mainkeypadareacomponent.h"
|
||||
#include "ui_mainkeypadareacomponent.h"
|
||||
#include "blackcore/context_audio.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -33,18 +37,63 @@ namespace BlackGui
|
||||
connect(this->ui->pb_MainTextMessages, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_MainUsers, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_MainWeather, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
|
||||
// non info areas
|
||||
connect(this->ui->pb_Connect, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_CockpitIdent, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_Opacity050, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_Opacity100, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_SoundMaxVolume, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
connect(this->ui->pb_SoundMute, &QPushButton::pressed, this, &CMainKeypadAreaComponent::ps_buttonPressed);
|
||||
|
||||
// command line
|
||||
this->connect(this->ui->le_CommandLineInput, &QLineEdit::returnPressed, this, &CMainKeypadAreaComponent::ps_commandEntered);
|
||||
}
|
||||
|
||||
CMainKeypadAreaComponent::~CMainKeypadAreaComponent()
|
||||
{ }
|
||||
|
||||
void CMainKeypadAreaComponent::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::ps_connectionStatusChanged);
|
||||
connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged);
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::ps_buttonPressed()
|
||||
{
|
||||
const QObject *sender = QObject::sender();
|
||||
CMainInfoAreaComponent::InfoArea ia = buttonToMainInfoArea(sender);
|
||||
if (ia != CMainInfoAreaComponent::InfoAreaNone)
|
||||
{
|
||||
emit selectMainInfoAreaDockWidget(ia);
|
||||
emit selectedMainInfoAreaDockWidget(ia);
|
||||
return;
|
||||
}
|
||||
else if (sender == this->ui->pb_CockpitIdent && this->getIContextOwnAircraft())
|
||||
{
|
||||
emit identPressed();
|
||||
}
|
||||
else if (sender == this->ui->pb_Opacity050)
|
||||
{
|
||||
emit changedOpacity(50);
|
||||
}
|
||||
else if (sender == this->ui->pb_Opacity100)
|
||||
{
|
||||
emit changedOpacity(100);
|
||||
}
|
||||
else if (sender == this->ui->pb_SoundMaxVolume && this->getIContextAudio())
|
||||
{
|
||||
this->getIContextAudio()->setVolumes(100, 100);
|
||||
}
|
||||
else if (sender == this->ui->pb_SoundMute && this->getIContextAudio())
|
||||
{
|
||||
bool mute = this->getIContextAudio()->isMuted();
|
||||
this->getIContextAudio()->setMute(!mute);
|
||||
}
|
||||
else if (sender == this->ui->pb_Connect)
|
||||
{
|
||||
emit connectPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +102,47 @@ namespace BlackGui
|
||||
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::ps_connectionStatusChanged(uint from, uint to, const QString &message)
|
||||
{
|
||||
INetwork::ConnectionStatus statusFrom = static_cast<INetwork::ConnectionStatus>(from);
|
||||
INetwork::ConnectionStatus statusTo = static_cast<INetwork::ConnectionStatus>(to);
|
||||
|
||||
Q_UNUSED(statusFrom);
|
||||
Q_UNUSED(message);
|
||||
|
||||
// Connected button
|
||||
if (statusTo == INetwork::Connected)
|
||||
{
|
||||
this->ui->pb_Connect->setText("Disconnect");
|
||||
this->ui->pb_Connect->setStyleSheet("background-color: green");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->pb_Connect->setText("Connect");
|
||||
this->ui->pb_Connect->setStyleSheet("background-color: ");
|
||||
}
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::ps_commandEntered()
|
||||
{
|
||||
QString c = this->ui->le_CommandLineInput->text().trimmed();
|
||||
if (c.isEmpty()) return;
|
||||
emit this->commandEntered(c);
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged(const CAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
Q_UNUSED(originator);
|
||||
if (aircraft.getTransponder().getTransponderMode() == CTransponder::StateIdent)
|
||||
{
|
||||
this->ui->pb_CockpitIdent->setStyleSheet("background-color: yellow");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->pb_CockpitIdent->setStyleSheet("");
|
||||
}
|
||||
}
|
||||
|
||||
CMainInfoAreaComponent::InfoArea CMainKeypadAreaComponent::buttonToMainInfoArea(const QObject *button) const
|
||||
{
|
||||
if (button == ui->pb_MainAircrafts) return CMainInfoAreaComponent::InfoAreaAircrafts;
|
||||
@@ -69,5 +159,11 @@ namespace BlackGui
|
||||
return CMainInfoAreaComponent::InfoAreaNone;
|
||||
}
|
||||
|
||||
Aviation::CAircraft CMainKeypadAreaComponent::getOwnAircraft() const
|
||||
{
|
||||
if (!this->getIContextOwnAircraft()) { return CAircraft(); }
|
||||
return this->getIContextOwnAircraft()->getOwnAircraft();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user