mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
[UI] Internals page
* changed to callsign completer (combobox too long) * allow to display own parts
This commit is contained in:
committed by
Mat Sutcliffe
parent
ea4a8f2462
commit
000d0da92a
@@ -8,15 +8,19 @@
|
||||
|
||||
#include "callsigncompleter.h"
|
||||
#include "ui_callsigncompleter.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/led.h"
|
||||
#include "blackgui/uppercasevalidator.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackcore/context/contextownaircraft.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
|
||||
#include <QStringListModel>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
@@ -83,7 +87,26 @@ namespace BlackGui
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!sGui->getIContextNetwork()) { return; }
|
||||
if (completer()->wasUpdatedWithinTime(1500)) { return; } // avoid context call via DBus
|
||||
const CCallsignSet validCallsigns = sGui->getIContextNetwork()->getAircraftInRangeCallsigns();
|
||||
CCallsignSet validCallsigns;
|
||||
if (m_onlyWithParts)
|
||||
{
|
||||
//! \todo KB 2020-04 transfers allaircraft via DBus
|
||||
validCallsigns = sGui->getIContextNetwork()->getAircraftInRange().getCallsignsWithSynchronizedParts();
|
||||
}
|
||||
else
|
||||
{
|
||||
validCallsigns = sGui->getIContextNetwork()->getAircraftInRangeCallsigns();
|
||||
}
|
||||
|
||||
if (m_addOwnCallsign && sGui->getIContextOwnAircraft())
|
||||
{
|
||||
const CCallsign ownCs = sGui->getIContextOwnAircraft()->getOwnAircraft().getCallsign();
|
||||
if (!ownCs.isEmpty())
|
||||
{
|
||||
validCallsigns.insert(ownCs);
|
||||
}
|
||||
}
|
||||
|
||||
const QStringList modelData = validCallsigns.getCallsignStrings(true);
|
||||
completer()->updateData(modelData, 2000);
|
||||
ui->led_Status->setTriState(500);
|
||||
@@ -109,7 +132,7 @@ namespace BlackGui
|
||||
|
||||
void CCallsignCompleter::onChangedConnectionStatus(const CConnectionStatus &from, const CConnectionStatus &to)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
Q_UNUSED(from)
|
||||
const bool connected = to.isConnected();
|
||||
ui->led_Status->setOn(connected);
|
||||
ui->le_Callsign->clear();
|
||||
|
||||
@@ -55,6 +55,12 @@ namespace BlackGui
|
||||
//! Set read only
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
//! Add own callsign
|
||||
void addOwnCallsign(bool add) { m_addOwnCallsign = add; }
|
||||
|
||||
//! Only with parts
|
||||
void onlyWithParts(bool partsOnly) { m_onlyWithParts = partsOnly; }
|
||||
|
||||
signals:
|
||||
//! Changed callsign entered
|
||||
void validChangedCallsignEntered();
|
||||
@@ -80,6 +86,9 @@ namespace BlackGui
|
||||
BlackMisc::CDigestSignal m_dsEditingFinished { this, &CCallsignCompleter::editingFinishedDigest, 500, 3 };
|
||||
BlackMisc::CDigestSignal m_dsValidCallsignEntered { this, &CCallsignCompleter::validCallsignEnteredDigest, 500, 3 };
|
||||
QString m_lastValue;
|
||||
|
||||
bool m_addOwnCallsign = false;
|
||||
bool m_onlyWithParts = false;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -61,7 +61,6 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tw_Internals->setCurrentIndex(0);
|
||||
ui->comp_RemoteAircraftSelector->indicatePartsEnabled(true);
|
||||
ui->editor_AircraftParts->showSetButton(false);
|
||||
|
||||
ui->le_TxtMsgFrom->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
|
||||
@@ -71,6 +70,7 @@ namespace BlackGui
|
||||
connect(ui->pb_SendAircraftPartsGui, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts);
|
||||
connect(ui->pb_SendAircraftPartsJson, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts);
|
||||
connect(ui->pb_CurrentParts, &QPushButton::released, this, &CInternalsComponent::setCurrentParts);
|
||||
connect(ui->pb_OwnParts, &QPushButton::released, this, &CInternalsComponent::displayOwnParts);
|
||||
|
||||
connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
|
||||
connect(ui->cb_DebugContextApplication, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
|
||||
@@ -94,7 +94,7 @@ namespace BlackGui
|
||||
connect(ui->pb_NetworkUpdate, &QPushButton::released, this, &CInternalsComponent::networkStatistics);
|
||||
connect(ui->cb_NetworkStatistics, &QCheckBox::stateChanged, this, &CInternalsComponent::onNetworkStatisticsToggled);
|
||||
|
||||
connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::selectorChanged);
|
||||
connect(ui->comp_RemoteAircraftCompleter, &CCallsignCompleter::validCallsignEnteredDigest, this, &CInternalsComponent::onCallsignChanged);
|
||||
|
||||
if (sGui && sGui->isSupportingCrashpad())
|
||||
{
|
||||
@@ -109,6 +109,7 @@ namespace BlackGui
|
||||
ui->cb_CrashDumpUpload->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->comp_RemoteAircraftCompleter->addOwnCallsign(true);
|
||||
this->contextFlagsToGui();
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ namespace BlackGui
|
||||
CLogMessage(this).validationError(u"Cannot send aircraft parts, network not connected");
|
||||
return;
|
||||
}
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftSelector->getSelectedCallsign());
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError(u"No valid callsign selected");
|
||||
@@ -168,7 +169,7 @@ namespace BlackGui
|
||||
void CInternalsComponent::setCurrentParts()
|
||||
{
|
||||
if (!sGui->getIContextNetwork()->isConnected()) { return; }
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftSelector->getSelectedCallsign());
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign());
|
||||
if (callsign.isEmpty()) { return; }
|
||||
|
||||
const CAircraftPartsList partsList = sGui->getIContextNetwork()->getRemoteAircraftParts(callsign);
|
||||
@@ -288,7 +289,10 @@ namespace BlackGui
|
||||
|
||||
void CInternalsComponent::requestPartsFromNetwork()
|
||||
{
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftSelector->getSelectedCallsign());
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!sGui->getIContextNetwork()) { return; }
|
||||
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError(u"No valid callsign selected");
|
||||
@@ -308,16 +312,28 @@ namespace BlackGui
|
||||
});
|
||||
}
|
||||
|
||||
void CInternalsComponent::selectorChanged()
|
||||
void CInternalsComponent::onCallsignChanged()
|
||||
{
|
||||
this->setCurrentParts();
|
||||
}
|
||||
|
||||
void CInternalsComponent::displayOwnParts()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!sGui->getIContextOwnAircraft()) { return; }
|
||||
|
||||
const CSimulatedAircraft myAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
||||
const CCallsign cs = myAircraft.getCallsign();
|
||||
const CAircraftParts parts = myAircraft.getParts();
|
||||
ui->comp_RemoteAircraftCompleter->setCallsign(cs);
|
||||
ui->editor_AircraftParts->setAircraftParts(parts);
|
||||
}
|
||||
|
||||
void CInternalsComponent::displayLogInSimulator()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!sGui->getIContextSimulator()) { return; }
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftSelector->getSelectedCallsign());
|
||||
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError(u"No valid callsign selected");
|
||||
|
||||
@@ -66,8 +66,11 @@ namespace BlackGui
|
||||
//! Request parts (aka aircraft config) from network
|
||||
void requestPartsFromNetwork();
|
||||
|
||||
//! Selector has been changed
|
||||
void selectorChanged();
|
||||
//! Completer has been changed
|
||||
void onCallsignChanged();
|
||||
|
||||
//! Display own parts
|
||||
void displayOwnParts();
|
||||
|
||||
//! Log in simulator
|
||||
void displayLogInSimulator();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>306</width>
|
||||
<width>326</width>
|
||||
<height>690</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -476,7 +476,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="BlackGui::Components::CRemoteAircraftSelector" name="comp_RemoteAircraftSelector">
|
||||
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_RemoteAircraftCompleter">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -500,6 +500,13 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_OwnParts">
|
||||
<property name="text">
|
||||
<string>own parts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Parts">
|
||||
<property name="orientation">
|
||||
@@ -722,18 +729,18 @@
|
||||
<header>blackgui/editors/aircraftpartsform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CRemoteAircraftSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/remoteaircraftselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CRawFsdMessagesComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/rawfsdmessagescomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCallsignCompleter</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/callsigncompleter.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tw_Internals</tabstop>
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace BlackGui
|
||||
namespace Components
|
||||
{
|
||||
//! Select a remote aircraft
|
||||
//! \deprecated list gets too long with many aircraft
|
||||
//! \remark CCallsignCompleter as a better alternative
|
||||
class BLACKGUI_EXPORT CRemoteAircraftSelector : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -39,7 +41,7 @@ namespace BlackGui
|
||||
explicit CRemoteAircraftSelector(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CRemoteAircraftSelector();
|
||||
virtual ~CRemoteAircraftSelector() override;
|
||||
|
||||
//! Selected callsign
|
||||
BlackMisc::Aviation::CCallsign getSelectedCallsign() const;
|
||||
|
||||
Reference in New Issue
Block a user