From a737b27ce8cac5290a494d9b6ea641a5197797bb Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 3 Mar 2017 05:00:44 +0100 Subject: [PATCH] refs #894, display dot commands HTML help as tooltip (in command line) --- .../components/mainkeypadareacomponent.cpp | 18 ++++++++++++++++-- .../components/mainkeypadareacomponent.h | 12 +++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/blackgui/components/mainkeypadareacomponent.cpp b/src/blackgui/components/mainkeypadareacomponent.cpp index e936cf7b4..d90420106 100644 --- a/src/blackgui/components/mainkeypadareacomponent.cpp +++ b/src/blackgui/components/mainkeypadareacomponent.cpp @@ -7,6 +7,7 @@ * contained in the LICENSE file. */ +#include "blackcore/context/contextapplication.h" #include "blackcore/context/contextaudio.h" #include "blackcore/context/contextnetwork.h" #include "blackcore/context/contextownaircraft.h" @@ -67,6 +68,9 @@ namespace BlackGui connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged); connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::ps_muteChanged); connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine); + + this->ps_setCommandTooltip(); + QTimer::singleShot(15000, this, &CMainKeypadAreaComponent::ps_setCommandTooltip); } CMainKeypadAreaComponent::~CMainKeypadAreaComponent() @@ -88,7 +92,7 @@ namespace BlackGui foreach (int floatingIndex, floatingIndexes) { QPushButton *pb = this->mainInfoAreaToButton(static_cast(floatingIndex)); - if (pb) {pb->setChecked(true); } + if (pb) { pb->setChecked(true); } } Q_UNUSED(dockedIndexes); @@ -99,7 +103,7 @@ namespace BlackGui QPushButton *senderButton = static_cast(QObject::sender()); Q_ASSERT(senderButton); if (!senderButton) { return; } - CMainInfoAreaComponent::InfoArea ia = buttonToMainInfoArea(senderButton); + const CMainInfoAreaComponent::InfoArea ia = buttonToMainInfoArea(senderButton); if (ia != CMainInfoAreaComponent::InfoAreaNone) { Q_ASSERT(senderButton->isCheckable()); @@ -155,9 +159,19 @@ namespace BlackGui { QString c(ui->lep_CommandLineInput->getLastEnteredLineFormatted()); if (c.isEmpty()) { return; } + if (c.toLower().trimmed().contains("help")) + { + this->ps_setCommandTooltip(); + return; + } emit this->commandEntered(c, keypadIdentifier()); } + void CMainKeypadAreaComponent::ps_setCommandTooltip() + { + ui->lep_CommandLineInput->setToolTip(sGui->getIContextApplication()->dotCommandsHtmlHelp()); + } + void CMainKeypadAreaComponent::ps_ownAircraftCockpitChanged(const CSimulatedAircraft &aircraft, const CIdentifier &originator) { Q_UNUSED(originator); diff --git a/src/blackgui/components/mainkeypadareacomponent.h b/src/blackgui/components/mainkeypadareacomponent.h index fedd5dddd..fcdd9ccc6 100644 --- a/src/blackgui/components/mainkeypadareacomponent.h +++ b/src/blackgui/components/mainkeypadareacomponent.h @@ -45,7 +45,7 @@ namespace BlackGui explicit CMainKeypadAreaComponent(QWidget *parent = nullptr); //! Destructor - ~CMainKeypadAreaComponent(); + virtual ~CMainKeypadAreaComponent(); //! Identifier BlackMisc::CIdentifier keypadIdentifier(); @@ -75,12 +75,15 @@ namespace BlackGui //! Button was clicked void ps_buttonSelected(); - //! \copydoc BlackCore::Context::IContextNetwork::connectionStatusChanged - void ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to); - //! Command line entered void ps_commandEntered(); + //! Display help as HTML + void ps_setCommandTooltip(); + + //! \copydoc BlackCore::Context::IContextNetwork::connectionStatusChanged + void ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to); + //! \copydoc BlackCore::Context::IContextOwnAircraft::changedAircraftCockpit void ps_ownAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator); @@ -100,7 +103,6 @@ namespace BlackGui QScopedPointer ui; BlackMisc::CIdentifier m_identifier; }; - } // namespace } // namespace