From 5f6f822ccdb784e4ac2c2088ea00912a93ef168b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 28 Jan 2018 04:49:27 +0100 Subject: [PATCH] Ref T231, Ref T236, Ref T238 help for "dot commands" will be refreshed * an new simulator can cause a changed help * we update the help based on context signals now --- src/blackgui/components/commandinput.cpp | 37 +++++++++++++++++++++--- src/blackgui/components/commandinput.h | 15 +++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/blackgui/components/commandinput.cpp b/src/blackgui/components/commandinput.cpp index 59d4b6161..2f385d130 100644 --- a/src/blackgui/components/commandinput.cpp +++ b/src/blackgui/components/commandinput.cpp @@ -10,9 +10,14 @@ #include "blackgui/components/commandinput.h" #include "blackgui/guiapplication.h" #include "blackcore/context/contextapplication.h" +#include "blackcore/context/contextsimulator.h" +#include "blackcore/context/contextnetwork.h" #include "blackmisc/simplecommandparser.h" using namespace BlackMisc; +using namespace BlackMisc::Network; +using namespace BlackMisc::Simulation; +using namespace BlackCore::Context; namespace BlackGui { @@ -27,11 +32,19 @@ namespace BlackGui this->setPlaceholderText(".dot commands"); } + QTimer::singleShot(5000, &m_dsCommandTooltip, &CDigestSignal::inputSignal); + if (sGui && sGui->supportsContexts()) + { + if (sGui->getIContextSimulator()) + { + connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CCommandInput::onSimulatorPluginChanged); + } + if (sGui->getIContextNetwork()) + { + connect(sGui->getIContextNetwork(), &IContextNetwork::connectedServerChanged, this, &CCommandInput::onConnectedServerChanged); + } + } connect(this, &CCommandInput::returnPressed, this, &CCommandInput::validateCommand); - - // set tooltip: shorty after, and later when application is initialized - QTimer::singleShot(5000, this, &CCommandInput::setCommandTooltip); - QTimer::singleShot(30000, this, &CCommandInput::setCommandTooltip); } void CCommandInput::validateCommand() @@ -60,5 +73,21 @@ namespace BlackGui sGui->getIContextApplication()->dotCommandsHtmlHelp() : CSimpleCommandParser::commandsHtmlHelp()); } + + void CCommandInput::onSimulatorPluginChanged(const CSimulatorPluginInfo &info) + { + Q_UNUSED(info); + + // different simulators have different commands + m_dsCommandTooltip.inputSignal(); + } + + void CCommandInput::onConnectedServerChanged(const Network::CServer &server) + { + Q_UNUSED(server); + + // commands of network + m_dsCommandTooltip.inputSignal(); + } } // ns } // ns diff --git a/src/blackgui/components/commandinput.h b/src/blackgui/components/commandinput.h index 054c13899..799ddd7c4 100644 --- a/src/blackgui/components/commandinput.h +++ b/src/blackgui/components/commandinput.h @@ -14,6 +14,7 @@ #include "blackgui/lineedithistory.h" #include "blackgui/blackguiexport.h" +#include "blackmisc/digestsignal.h" #include "blackmisc/identifiable.h" #include "blackmisc/identifier.h" @@ -22,7 +23,11 @@ #include class QWidget; - +namespace BlackMisc +{ + namespace Network { class CServer; } + namespace Simulation { class CSimulatorPluginInfo; } +} namespace BlackGui { namespace Components @@ -54,6 +59,14 @@ namespace BlackGui //! Command tooltip void setCommandTooltip(); + + //! Simulator plugin loaded / unloaded (default info) + void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info); + + //! Connected network server has been changed + void onConnectedServerChanged(const BlackMisc::Network::CServer &server); + + BlackMisc::CDigestSignal m_dsCommandTooltip { this, &CCommandInput::setCommandTooltip, 5000, 2 }; }; } // ns } // ns