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
This commit is contained in:
Klaus Basan
2018-01-28 04:49:27 +01:00
parent 9a862cab43
commit 5f6f822ccd
2 changed files with 47 additions and 5 deletions

View File

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

View File

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