mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Ref T215, fixed text message sending from keypad command line
* context menu delete history * signals to relay messages which are not "dot" commands
This commit is contained in:
@@ -38,15 +38,19 @@ namespace BlackGui
|
||||
{
|
||||
const QString c(this->getLastEnteredLineFormatted());
|
||||
if (c.isEmpty()) { return; }
|
||||
if (c.toLower().contains("help"))
|
||||
{
|
||||
this->setCommandTooltip();
|
||||
return;
|
||||
}
|
||||
if (c.startsWith('.'))
|
||||
{
|
||||
if (c.toLower().contains("help"))
|
||||
{
|
||||
this->setCommandTooltip();
|
||||
return;
|
||||
}
|
||||
emit this->commandEntered(c, this->identifier());
|
||||
}
|
||||
else
|
||||
{
|
||||
emit this->textEntered(c, this->identifier());
|
||||
}
|
||||
}
|
||||
|
||||
void CCommandInput::setCommandTooltip()
|
||||
|
||||
@@ -45,6 +45,9 @@ namespace BlackGui
|
||||
//! Command was entered
|
||||
void commandEntered(const QString &command, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
//! Text entered (which is not a command)
|
||||
void textEntered(const QString &command, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
private:
|
||||
//! Basic command validation
|
||||
void validateCommand();
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace BlackGui
|
||||
// command line
|
||||
ui->lep_CommandLineInput->setIdentifier(m_identifier);
|
||||
connect(ui->lep_CommandLineInput, &CCommandInput::commandEntered, this, &CMainKeypadAreaComponent::commandEntered);
|
||||
connect(ui->lep_CommandLineInput, &CCommandInput::textEntered, this, &CMainKeypadAreaComponent::textEntered);
|
||||
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::connectionStatusChanged);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
||||
|
||||
@@ -54,9 +54,12 @@ namespace BlackGui
|
||||
//! Change opacity 0..30
|
||||
void changedOpacity(int opacity);
|
||||
|
||||
//! Command was entered
|
||||
//! \copydoc CCommandInput::commandEntered
|
||||
void commandEntered(const QString &commandLine, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
//! \copydoc CCommandInput::commandEntered
|
||||
void textEntered(const QString &commandLine, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
//! Connect was pressed
|
||||
void connectPressed();
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace BlackGui
|
||||
ui->le_textMessages->setVisible(false);
|
||||
ui->tvp_TextMessagesAll->setResizeMode(CTextMessageView::ResizingAuto);
|
||||
|
||||
// le_textMessages is the own line edit
|
||||
bool c = connect(ui->le_textMessages, &QLineEdit::returnPressed, this, &CTextMessageComponent::textMessageEntered);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
||||
c = connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::onChangedAircraftCockpit);
|
||||
@@ -204,7 +205,7 @@ namespace BlackGui
|
||||
// private message
|
||||
const CCallsign cs = textMessage.getSenderCallsign();
|
||||
if (cs.isEmpty()) return false;
|
||||
QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet());
|
||||
const QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet());
|
||||
if (!tab) { return false; }
|
||||
return ui->tw_TextMessages->currentWidget() == tab;
|
||||
}
|
||||
@@ -380,13 +381,13 @@ namespace BlackGui
|
||||
// is this a command?
|
||||
if (!cl.startsWith("."))
|
||||
{
|
||||
// build a command line
|
||||
// build a command line -> e.g. ".msg 122.8 fooBar"
|
||||
cl = this->textMessageToCommand(cl);
|
||||
}
|
||||
|
||||
// relay the command
|
||||
if (cl.isEmpty()) { return; }
|
||||
emit commandEntered(cl, componentIdentifier());
|
||||
emit this->commandEntered(cl, this->componentIdentifier());
|
||||
}
|
||||
|
||||
QString CTextMessageComponent::textMessageToCommand(const QString &enteredLine)
|
||||
@@ -453,9 +454,9 @@ namespace BlackGui
|
||||
this->displayTextMessage(sentMessage);
|
||||
}
|
||||
|
||||
bool CTextMessageComponent::handleGlobalCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
bool CTextMessageComponent::handleGlobalCommandLineText(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
if (originator == componentIdentifier()) { return false; }
|
||||
if (originator == this->componentIdentifier()) { return false; }
|
||||
if (commandLine.isEmpty() || commandLine.startsWith(".")) { return false; }
|
||||
|
||||
// no "dot" command input
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackGui
|
||||
void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;
|
||||
|
||||
//! Command line was entered
|
||||
void commandEntered(const QString commandLine, const BlackMisc::CIdentifier &orignator);
|
||||
void commandEntered(const QString commandLine, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
public slots:
|
||||
//! Text messages received
|
||||
@@ -73,7 +73,8 @@ namespace BlackGui
|
||||
void onTextMessageSent(const BlackMisc::Network::CTextMessage &sentMessage);
|
||||
|
||||
//! Used to allow direct input from global command line when visible
|
||||
bool handleGlobalCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator);
|
||||
//! \remark takes the messages, turns it into a ".msg" command, and emits it
|
||||
bool handleGlobalCommandLineText(const QString &commandLine, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
//! Display the tab for given callsign
|
||||
void showCorrespondingTab(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
<widget class="BlackGui::Components::CSettingsTextMessageInlineComponent" name="comp_Settings"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_textMessages">
|
||||
<widget class="BlackGui::CLineEditHistory" name="le_textMessages">
|
||||
<property name="toolTip">
|
||||
<string>command line (e.g. ".com1", ".x", ".msg com1")</string>
|
||||
</property>
|
||||
@@ -259,6 +259,11 @@
|
||||
<header>blackgui/components/settingstextmessageinlinecomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLineEditHistory</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>blackgui/lineedithistory.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tw_TextMessages</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user