Allow to disable tooltip by dot command ".tooltip"

This commit is contained in:
Klaus Basan
2019-04-04 00:09:29 +02:00
committed by Mat Sutcliffe
parent d247d40358
commit 6296feac19
3 changed files with 31 additions and 22 deletions

View File

@@ -42,27 +42,30 @@ namespace BlackGui
{
if (sGui->getIContextSimulator())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CCommandInput::onSimulatorPluginChanged);
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CCommandInput::onSimulatorPluginChanged, Qt::QueuedConnection);
}
if (sGui->getIContextNetwork())
{
connect(sGui->getIContextNetwork(), &IContextNetwork::connectedServerChanged, this, &CCommandInput::onConnectedServerChanged);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectedServerChanged, this, &CCommandInput::onConnectedServerChanged, Qt::QueuedConnection);
}
}
connect(this, &CCommandInput::returnPressed, this, &CCommandInput::validateCommand);
}
void CCommandInput::showToolTip(bool show)
{
m_showToolTip = show;
this->setCommandToolTip();
}
void CCommandInput::validateCommand()
{
const QString c(this->getLastEnteredLineFormatted());
if (c.isEmpty()) { return; }
if (c.startsWith('.'))
{
if (c.contains("help", Qt::CaseInsensitive))
{
this->setCommandTooltip();
return;
}
if (c.contains("help", Qt::CaseInsensitive)) { this->setCommandToolTip(); return; }
if (c.contains("tooltip", Qt::CaseInsensitive)) { this->showToolTip(!m_showToolTip); return; }
emit this->commandEntered(c, this->identifier());
}
else
@@ -71,12 +74,19 @@ namespace BlackGui
}
}
void CCommandInput::setCommandTooltip()
void CCommandInput::setCommandToolTip()
{
const bool context = (sGui && sGui->getIContextApplication());
this->setToolTip(context ?
sGui->getIContextApplication()->dotCommandsHtmlHelp() :
CSimpleCommandParser::commandsHtmlHelp());
if (m_showToolTip)
{
this->setToolTip(context ?
sGui->getIContextApplication()->dotCommandsHtmlHelp() :
CSimpleCommandParser::commandsHtmlHelp());
}
else
{
this->setToolTip("");
}
}
void CCommandInput::onSimulatorPluginChanged(const CSimulatorPluginInfo &info)