mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Allow to disable tooltip by dot command ".tooltip"
This commit is contained in:
committed by
Mat Sutcliffe
parent
d247d40358
commit
6296feac19
@@ -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)
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network { class CServer; }
|
||||
@@ -33,7 +32,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Specialized line edit for command inputs
|
||||
class BLACKGUI_EXPORT CCommandInput :
|
||||
public BlackGui::CLineEditHistory,
|
||||
public CLineEditHistory,
|
||||
public BlackMisc::CIdentifiable
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -42,8 +41,8 @@ namespace BlackGui
|
||||
//! Constructor
|
||||
CCommandInput(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CCommandInput() {}
|
||||
//! Show tooltip
|
||||
void showToolTip(bool show);
|
||||
|
||||
signals:
|
||||
//! Command was entered
|
||||
@@ -57,7 +56,7 @@ namespace BlackGui
|
||||
void validateCommand();
|
||||
|
||||
//! Command tooltip
|
||||
void setCommandTooltip();
|
||||
void setCommandToolTip();
|
||||
|
||||
//! Simulator plugin loaded / unloaded (default info)
|
||||
void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
@@ -65,7 +64,8 @@ namespace BlackGui
|
||||
//! Connected network server has been changed
|
||||
void onConnectedServerChanged(const BlackMisc::Network::CServer &server);
|
||||
|
||||
BlackMisc::CDigestSignal m_dsCommandTooltip { this, &CCommandInput::setCommandTooltip, 5000, 2 };
|
||||
bool m_showToolTip = true;
|
||||
BlackMisc::CDigestSignal m_dsCommandTooltip { this, &CCommandInput::setCommandToolTip, 5000, 2 };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <QSet>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -168,14 +168,13 @@ namespace BlackMisc
|
||||
|
||||
static const QString cmdCol(QString().fill('-', 20));
|
||||
static const QString textCol(QString().fill('-', 40));
|
||||
rows += "<tr>" + rowHeader.arg("command", "synopsis", "command", "synopsis") + "</tr>\n";
|
||||
rows += "<tr>" + rowHeader.arg(cmdCol, textCol, cmdCol, textCol) + "</tr>\n";
|
||||
rows += u"<tr>" % rowHeader.arg("command", "synopsis", "command", "synopsis") % u"</tr>\n" %
|
||||
u"<tr>" % rowHeader.arg(cmdCol, textCol, cmdCol, textCol) % u"</tr>\n";
|
||||
|
||||
for (int i = 0; i < cmds.size(); i++)
|
||||
{
|
||||
CommandHtmlHelp help = cmds[i];
|
||||
rows += "<tr>";
|
||||
rows += row.arg(help.command, help.help);
|
||||
rows += u"<tr>" % row.arg(help.command, help.help);
|
||||
i++;
|
||||
if (i < cmds.size())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user