refs #335, implemented the functionality for main keypad area,

old keypad was removed from main window
This commit is contained in:
Klaus Basan
2014-10-25 00:20:27 +02:00
committed by Roland Winklmeier
parent e45087c933
commit 3351791016
3 changed files with 173 additions and 26 deletions

View File

@@ -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

View File

@@ -12,9 +12,12 @@
#ifndef BLACKGUI_MAINKEYPADAREACOMPONENT_H
#define BLACKGUI_MAINKEYPADAREACOMPONENT_H
#include "maininfoareacomponent.h"
#include "enableforruntime.h"
#include "blackmisc/avaircraft.h"
#include <QFrame>
#include <QScopedPointer>
#include "maininfoareacomponent.h"
namespace Ui { class CMainKeypadAreaComponent; }
namespace BlackGui
@@ -24,7 +27,9 @@ namespace BlackGui
//! Main keypad area as used with main info area
//! \sa CMainInfoAreaComponent
class CMainKeypadAreaComponent : public QFrame
class CMainKeypadAreaComponent :
public QFrame,
public CEnableForRuntime
{
Q_OBJECT
@@ -38,7 +43,23 @@ namespace BlackGui
signals:
//! Button to select main info area has been pressed
//! \sa CMainInfoAreaComponent
void selectMainInfoAreaDockWidget(CMainInfoAreaComponent::InfoArea infoArea);
void selectedMainInfoAreaDockWidget(CMainInfoAreaComponent::InfoArea infoArea);
//! Change opacity 0..30
void changedOpacity(int opacity);
//! Command was entered
void commandEntered(const QString &commandLine);
//! Connect was pressed
void connectPressed();
//! Ident pressed
void identPressed();
protected:
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
virtual void runtimeHasBeenSet() override;
private slots:
//! Button was clicked
@@ -47,10 +68,22 @@ namespace BlackGui
//! Button was double clicked
void ps_buttonDoubleClicked();
//! \copydoc BlackCore::IContextNetwork::connectionStatusChanged
void ps_connectionStatusChanged(uint from, uint to, const QString &message);
//! Command line entered
void ps_commandEntered();
//! \copydoc BlackCore::IContextOwnAircraft::changedAircraftCockpit
void ps_ownAircraftCockpitChanged(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator);
private:
// if button is info area, identify it
//! If button is info area, identify it
CMainInfoAreaComponent::InfoArea buttonToMainInfoArea(const QObject *button) const;
//! Own aircraft
BlackMisc::Aviation::CAircraft getOwnAircraft() const;
QScopedPointer<Ui::CMainKeypadAreaComponent> ui;
};

View File

@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>144</height>
<width>389</width>
<height>122</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
<string>Main keypad area</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@@ -51,7 +51,7 @@
<number>2</number>
</property>
<property name="topMargin">
<number>6</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
@@ -80,7 +80,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -89,7 +89,7 @@
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="pb_MainKeypadOpacity050">
<widget class="QPushButton" name="pb_Opacity050">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -105,7 +105,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -114,7 +114,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_MainConnect">
<widget class="QPushButton" name="pb_Connect">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -124,7 +124,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -137,7 +137,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="statusTip">
@@ -149,7 +149,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pb_MainKeypadOpacity100">
<widget class="QPushButton" name="pb_Opacity100">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -165,7 +165,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -184,7 +184,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -203,7 +203,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -213,6 +213,12 @@
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pb_MainUsers">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Users</string>
</property>
@@ -229,7 +235,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -239,6 +245,12 @@
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pb_CockpitIdent">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Ident</string>
</property>
@@ -255,7 +267,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -265,6 +277,12 @@
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_MainSimulator">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Simulator</string>
</property>
@@ -281,7 +299,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -300,7 +318,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -319,7 +337,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">
@@ -338,7 +356,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
@@ -360,7 +378,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
<height>16777215</height>
</size>
</property>
<property name="text">