forked from qt-creator/qt-creator
Fix wrong context help if tool tip was not shown for focus widget
The tool tip never has focus, so it cannot become the IContext that is checked for context help. So, integrate the help id into Utils::ToolTip and check the tool tip first when checking for context help. As a side effect the [F1] button and help id for the tool tip is now also available for use outside of the text editors. Task-number: QTCREATORBUG-5345 Change-Id: Id975703caf161d1183c247e8ad8bb693b90fd306 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
|
Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 590 B |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
@@ -55,6 +55,17 @@ QTipLabel::QTipLabel(QWidget *parent) :
|
|||||||
QLabel(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
|
QLabel(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void QTipLabel::setHelpId(const QString &id)
|
||||||
|
{
|
||||||
|
m_helpId = id;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QTipLabel::helpId() const
|
||||||
|
{
|
||||||
|
return m_helpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorTip::ColorTip(QWidget *parent)
|
ColorTip::ColorTip(QWidget *parent)
|
||||||
: QTipLabel(parent)
|
: QTipLabel(parent)
|
||||||
@@ -88,9 +99,9 @@ bool ColorTip::canHandleContentReplacement(int typeId) const
|
|||||||
return typeId == ToolTip::ColorContent;
|
return typeId == ToolTip::ColorContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColorTip::equals(int typeId, const QVariant &other) const
|
bool ColorTip::equals(int typeId, const QVariant &other, const QString &otherHelpId) const
|
||||||
{
|
{
|
||||||
return typeId == ToolTip::ColorContent && other == m_color;
|
return typeId == ToolTip::ColorContent && otherHelpId == helpId() && other == m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTip::paintEvent(QPaintEvent *event)
|
void ColorTip::paintEvent(QPaintEvent *event)
|
||||||
@@ -131,7 +142,12 @@ void TextTip::setContent(const QVariant &content)
|
|||||||
|
|
||||||
void TextTip::configure(const QPoint &pos, QWidget *w)
|
void TextTip::configure(const QPoint &pos, QWidget *w)
|
||||||
{
|
{
|
||||||
|
if (helpId().isEmpty())
|
||||||
setText(m_text);
|
setText(m_text);
|
||||||
|
else
|
||||||
|
setText(QString::fromLatin1("<table><tr><td valign=middle>%1</td><td> "
|
||||||
|
"<img src=\":/utils/tooltip/images/f1.png\"></td>"
|
||||||
|
"</tr></table>").arg(m_text));
|
||||||
|
|
||||||
// Make it look good with the default ToolTip font on Mac, which has a small descent.
|
// Make it look good with the default ToolTip font on Mac, which has a small descent.
|
||||||
QFontMetrics fm(font());
|
QFontMetrics fm(font());
|
||||||
@@ -166,9 +182,9 @@ int TextTip::showTime() const
|
|||||||
return 10000 + 40 * qMax(0, m_text.size() - 100);
|
return 10000 + 40 * qMax(0, m_text.size() - 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextTip::equals(int typeId, const QVariant &other) const
|
bool TextTip::equals(int typeId, const QVariant &other, const QString &otherHelpId) const
|
||||||
{
|
{
|
||||||
return typeId == ToolTip::TextContent && other.toString() == m_text;
|
return typeId == ToolTip::TextContent && otherHelpId == helpId() && other.toString() == m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextTip::paintEvent(QPaintEvent *event)
|
void TextTip::paintEvent(QPaintEvent *event)
|
||||||
@@ -245,9 +261,10 @@ bool WidgetTip::canHandleContentReplacement(int typeId) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WidgetTip::equals(int typeId, const QVariant &other) const
|
bool WidgetTip::equals(int typeId, const QVariant &other, const QString &otherHelpId) const
|
||||||
{
|
{
|
||||||
return typeId == ToolTip::WidgetContent && other.value<QWidget *>() == m_widget;
|
return typeId == ToolTip::WidgetContent && otherHelpId == helpId()
|
||||||
|
&& other.value<QWidget *>() == m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to include it here to force it to be inside the namespaces
|
// need to include it here to force it to be inside the namespaces
|
||||||
|
|||||||
@@ -56,7 +56,12 @@ public:
|
|||||||
virtual int showTime() const = 0;
|
virtual int showTime() const = 0;
|
||||||
virtual void configure(const QPoint &pos, QWidget *w) = 0;
|
virtual void configure(const QPoint &pos, QWidget *w) = 0;
|
||||||
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
virtual bool canHandleContentReplacement(int typeId) const = 0;
|
||||||
virtual bool equals(int typeId, const QVariant &other) const = 0;
|
virtual bool equals(int typeId, const QVariant &other, const QString &helpId) const = 0;
|
||||||
|
virtual void setHelpId(const QString &id);
|
||||||
|
virtual QString helpId() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_helpId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextTip : public QTipLabel
|
class TextTip : public QTipLabel
|
||||||
@@ -68,7 +73,7 @@ public:
|
|||||||
virtual void configure(const QPoint &pos, QWidget *w);
|
virtual void configure(const QPoint &pos, QWidget *w);
|
||||||
virtual bool canHandleContentReplacement(int typeId) const;
|
virtual bool canHandleContentReplacement(int typeId) const;
|
||||||
virtual int showTime() const;
|
virtual int showTime() const;
|
||||||
virtual bool equals(int typeId, const QVariant &other) const;
|
virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const;
|
||||||
virtual void paintEvent(QPaintEvent *event);
|
virtual void paintEvent(QPaintEvent *event);
|
||||||
virtual void resizeEvent(QResizeEvent *event);
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
@@ -85,7 +90,7 @@ public:
|
|||||||
virtual void configure(const QPoint &pos, QWidget *w);
|
virtual void configure(const QPoint &pos, QWidget *w);
|
||||||
virtual bool canHandleContentReplacement(int typeId) const;
|
virtual bool canHandleContentReplacement(int typeId) const;
|
||||||
virtual int showTime() const { return 4000; }
|
virtual int showTime() const { return 4000; }
|
||||||
virtual bool equals(int typeId, const QVariant &other) const;
|
virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const;
|
||||||
virtual void paintEvent(QPaintEvent *event);
|
virtual void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -105,7 +110,7 @@ public:
|
|||||||
virtual void configure(const QPoint &pos, QWidget *w);
|
virtual void configure(const QPoint &pos, QWidget *w);
|
||||||
virtual bool canHandleContentReplacement(int typeId) const;
|
virtual bool canHandleContentReplacement(int typeId) const;
|
||||||
virtual int showTime() const { return 30000; }
|
virtual int showTime() const { return 30000; }
|
||||||
virtual bool equals(int typeId, const QVariant &other) const;
|
virtual bool equals(int typeId, const QVariant &other, const QString &otherHelpId) const;
|
||||||
virtual bool isInteractive() const { return true; }
|
virtual bool isInteractive() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -66,28 +66,28 @@ ToolTip *ToolTip::instance()
|
|||||||
return &tooltip;
|
return &tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::show(const QPoint &pos, const QString &content, QWidget *w, const QRect &rect)
|
void ToolTip::show(const QPoint &pos, const QString &content, QWidget *w, const QString &helpId, const QRect &rect)
|
||||||
{
|
{
|
||||||
if (content.isEmpty())
|
if (content.isEmpty())
|
||||||
instance()->hideTipWithDelay();
|
instance()->hideTipWithDelay();
|
||||||
else
|
else
|
||||||
instance()->showInternal(pos, QVariant(content), TextContent, w, rect);
|
instance()->showInternal(pos, QVariant(content), TextContent, w, helpId, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::show(const QPoint &pos, const QColor &color, QWidget *w, const QRect &rect)
|
void ToolTip::show(const QPoint &pos, const QColor &color, QWidget *w, const QString &helpId, const QRect &rect)
|
||||||
{
|
{
|
||||||
if (!color.isValid())
|
if (!color.isValid())
|
||||||
instance()->hideTipWithDelay();
|
instance()->hideTipWithDelay();
|
||||||
else
|
else
|
||||||
instance()->showInternal(pos, QVariant(color), ColorContent, w, rect);
|
instance()->showInternal(pos, QVariant(color), ColorContent, w, helpId, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::show(const QPoint &pos, QWidget *content, QWidget *w, const QRect &rect)
|
void ToolTip::show(const QPoint &pos, QWidget *content, QWidget *w, const QString &helpId, const QRect &rect)
|
||||||
{
|
{
|
||||||
if (!content)
|
if (!content)
|
||||||
instance()->hideTipWithDelay();
|
instance()->hideTipWithDelay();
|
||||||
else
|
else
|
||||||
instance()->showInternal(pos, QVariant::fromValue(content), WidgetContent, w, rect);
|
instance()->showInternal(pos, QVariant::fromValue(content), WidgetContent, w, helpId, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::move(const QPoint &pos, QWidget *w)
|
void ToolTip::move(const QPoint &pos, QWidget *w)
|
||||||
@@ -111,10 +111,15 @@ bool ToolTip::pinToolTip(QWidget *w, QWidget *parent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ToolTip::contextHelpId()
|
||||||
|
{
|
||||||
|
return instance()->m_tip ? instance()->m_tip->helpId() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
bool ToolTip::acceptShow(const QVariant &content,
|
bool ToolTip::acceptShow(const QVariant &content,
|
||||||
int typeId,
|
int typeId,
|
||||||
const QPoint &pos,
|
const QPoint &pos,
|
||||||
QWidget *w,
|
QWidget *w, const QString &helpId,
|
||||||
const QRect &rect)
|
const QRect &rect)
|
||||||
{
|
{
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
@@ -123,8 +128,9 @@ bool ToolTip::acceptShow(const QVariant &content,
|
|||||||
QPoint localPos = pos;
|
QPoint localPos = pos;
|
||||||
if (w)
|
if (w)
|
||||||
localPos = w->mapFromGlobal(pos);
|
localPos = w->mapFromGlobal(pos);
|
||||||
if (tipChanged(localPos, content, typeId, w)) {
|
if (tipChanged(localPos, content, typeId, w, helpId)) {
|
||||||
m_tip->setContent(content);
|
m_tip->setContent(content);
|
||||||
|
m_tip->setHelpId(helpId);
|
||||||
setUp(pos, w, rect);
|
setUp(pos, w, rect);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -155,9 +161,10 @@ void ToolTip::setUp(const QPoint &pos, QWidget *w, const QRect &rect)
|
|||||||
m_showTimer.start(m_tip->showTime());
|
m_showTimer.start(m_tip->showTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTip::tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w) const
|
bool ToolTip::tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w,
|
||||||
|
const QString &helpId) const
|
||||||
{
|
{
|
||||||
if (!m_tip->equals(typeId, content) || m_widget != w)
|
if (!m_tip->equals(typeId, content, helpId) || m_widget != w)
|
||||||
return true;
|
return true;
|
||||||
if (!m_rect.isNull())
|
if (!m_rect.isNull())
|
||||||
return !m_rect.contains(pos);
|
return !m_rect.contains(pos);
|
||||||
@@ -220,12 +227,13 @@ void ToolTip::hideTipImmediately()
|
|||||||
m_showTimer.stop();
|
m_showTimer.stop();
|
||||||
m_hideDelayTimer.stop();
|
m_hideDelayTimer.stop();
|
||||||
qApp->removeEventFilter(this);
|
qApp->removeEventFilter(this);
|
||||||
|
emit hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
|
void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
|
||||||
int typeId, QWidget *w, const QRect &rect)
|
int typeId, QWidget *w, const QString &helpId, const QRect &rect)
|
||||||
{
|
{
|
||||||
if (acceptShow(content, typeId, pos, w, rect)) {
|
if (acceptShow(content, typeId, pos, w, helpId, rect)) {
|
||||||
QWidget *target = 0;
|
QWidget *target = 0;
|
||||||
if (HostOsInfo::isWindowsHost())
|
if (HostOsInfo::isWindowsHost())
|
||||||
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
|
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
|
||||||
@@ -244,10 +252,12 @@ void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_tip->setContent(content);
|
m_tip->setContent(content);
|
||||||
|
m_tip->setHelpId(helpId);
|
||||||
setUp(pos, w, rect);
|
setUp(pos, w, rect);
|
||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
showTip();
|
showTip();
|
||||||
}
|
}
|
||||||
|
emit shown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::placeTip(const QPoint &pos, QWidget *w)
|
void ToolTip::placeTip(const QPoint &pos, QWidget *w)
|
||||||
|
|||||||
@@ -75,9 +75,12 @@ public:
|
|||||||
|
|
||||||
static ToolTip *instance();
|
static ToolTip *instance();
|
||||||
|
|
||||||
static void show(const QPoint &pos, const QString &content, QWidget *w = 0, const QRect &rect = QRect());
|
static void show(const QPoint &pos, const QString &content, QWidget *w = 0,
|
||||||
static void show(const QPoint &pos, const QColor &color, QWidget *w = 0, const QRect &rect = QRect());
|
const QString &helpId = QString(), const QRect &rect = QRect());
|
||||||
static void show(const QPoint &pos, QWidget *content, QWidget *w = 0, const QRect &rect = QRect());
|
static void show(const QPoint &pos, const QColor &color, QWidget *w = 0,
|
||||||
|
const QString &helpId = QString(), const QRect &rect = QRect());
|
||||||
|
static void show(const QPoint &pos, QWidget *content, QWidget *w = 0,
|
||||||
|
const QString &helpId = QString(), const QRect &rect = QRect());
|
||||||
static void move(const QPoint &pos, QWidget *w);
|
static void move(const QPoint &pos, QWidget *w);
|
||||||
static void hide();
|
static void hide();
|
||||||
static bool isVisible();
|
static bool isVisible();
|
||||||
@@ -88,12 +91,21 @@ public:
|
|||||||
// using WidgetContent
|
// using WidgetContent
|
||||||
static bool pinToolTip(QWidget *w, QWidget *parent);
|
static bool pinToolTip(QWidget *w, QWidget *parent);
|
||||||
|
|
||||||
|
static QString contextHelpId();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void shown();
|
||||||
|
void hidden();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showInternal(const QPoint &pos, const QVariant &content, int typeId, QWidget *w, const QRect &rect);
|
void showInternal(const QPoint &pos, const QVariant &content, int typeId, QWidget *w,
|
||||||
|
const QString &helpId, const QRect &rect);
|
||||||
void hideTipImmediately();
|
void hideTipImmediately();
|
||||||
bool acceptShow(const QVariant &content, int typeId, const QPoint &pos, QWidget *w, const QRect &rect);
|
bool acceptShow(const QVariant &content, int typeId, const QPoint &pos, QWidget *w,
|
||||||
|
const QString &helpId, const QRect &rect);
|
||||||
void setUp(const QPoint &pos, QWidget *w, const QRect &rect);
|
void setUp(const QPoint &pos, QWidget *w, const QRect &rect);
|
||||||
bool tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w) const;
|
bool tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w,
|
||||||
|
const QString &helpId) const;
|
||||||
void setTipRect(QWidget *w, const QRect &rect);
|
void setTipRect(QWidget *w, const QRect &rect);
|
||||||
void placeTip(const QPoint &pos, QWidget *w);
|
void placeTip(const QPoint &pos, QWidget *w);
|
||||||
void showTip();
|
void showTip();
|
||||||
@@ -104,6 +116,7 @@ private:
|
|||||||
QRect m_rect;
|
QRect m_rect;
|
||||||
QTimer m_showTimer;
|
QTimer m_showTimer;
|
||||||
QTimer m_hideDelayTimer;
|
QTimer m_hideDelayTimer;
|
||||||
|
QString m_helpId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -14,5 +14,6 @@
|
|||||||
<file>images/progressindicator_small.png</file>
|
<file>images/progressindicator_small.png</file>
|
||||||
<file>images/progressindicator_small@2x.png</file>
|
<file>images/progressindicator_small@2x.png</file>
|
||||||
<file>images/triangle_vert.png</file>
|
<file>images/triangle_vert.png</file>
|
||||||
|
<file>tooltip/images/f1.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -528,19 +528,20 @@ void ICore::raiseWindow(QWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICore::updateAdditionalContexts(const Context &remove, const Context &add)
|
void ICore::updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
|
ContextPriority priority)
|
||||||
{
|
{
|
||||||
m_mainwindow->updateAdditionalContexts(remove, add);
|
m_mainwindow->updateAdditionalContexts(remove, add, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICore::addAdditionalContext(const Context &context)
|
void ICore::addAdditionalContext(const Context &context, ContextPriority priority)
|
||||||
{
|
{
|
||||||
m_mainwindow->updateAdditionalContexts(Context(), context);
|
m_mainwindow->updateAdditionalContexts(Context(), context, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICore::removeAdditionalContext(const Context &context)
|
void ICore::removeAdditionalContext(const Context &context)
|
||||||
{
|
{
|
||||||
m_mainwindow->updateAdditionalContexts(context, Context());
|
m_mainwindow->updateAdditionalContexts(context, Context(), ContextPriority::Low);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICore::addContextObject(IContext *context)
|
void ICore::addContextObject(IContext *context)
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ class CORE_EXPORT ICore : public QObject
|
|||||||
~ICore();
|
~ICore();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class ContextPriority {
|
||||||
|
High,
|
||||||
|
Low
|
||||||
|
};
|
||||||
|
|
||||||
// This should only be used to acccess the signals, so it could
|
// This should only be used to acccess the signals, so it could
|
||||||
// theoretically return an QObject *. For source compatibility
|
// theoretically return an QObject *. For source compatibility
|
||||||
// it returns a ICore.
|
// it returns a ICore.
|
||||||
@@ -107,8 +112,10 @@ public:
|
|||||||
static IContext *currentContextObject();
|
static IContext *currentContextObject();
|
||||||
// Adds and removes additional active contexts, these contexts are appended
|
// Adds and removes additional active contexts, these contexts are appended
|
||||||
// to the currently active contexts.
|
// to the currently active contexts.
|
||||||
static void updateAdditionalContexts(const Context &remove, const Context &add);
|
static void updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
static void addAdditionalContext(const Context &context);
|
ContextPriority priority = ContextPriority::Low);
|
||||||
|
static void addAdditionalContext(const Context &context,
|
||||||
|
ContextPriority priority = ContextPriority::Low);
|
||||||
static void removeAdditionalContext(const Context &context);
|
static void removeAdditionalContext(const Context &context);
|
||||||
static void addContextObject(IContext *context);
|
static void addContextObject(IContext *context);
|
||||||
static void removeContextObject(IContext *context);
|
static void removeContextObject(IContext *context);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ enum { debugMainWindow = 0 };
|
|||||||
MainWindow::MainWindow() :
|
MainWindow::MainWindow() :
|
||||||
AppMainWindow(),
|
AppMainWindow(),
|
||||||
m_coreImpl(new ICore(this)),
|
m_coreImpl(new ICore(this)),
|
||||||
m_additionalContexts(Constants::C_GLOBAL),
|
m_lowPrioAdditionalContexts(Constants::C_GLOBAL),
|
||||||
m_settingsDatabase(new SettingsDatabase(QFileInfo(PluginManager::settings()->fileName()).path(),
|
m_settingsDatabase(new SettingsDatabase(QFileInfo(PluginManager::settings()->fileName()).path(),
|
||||||
QLatin1String("QtCreator"),
|
QLatin1String("QtCreator"),
|
||||||
this)),
|
this)),
|
||||||
@@ -985,23 +985,27 @@ void MainWindow::writeSettings()
|
|||||||
m_navigationWidget->saveSettings(settings);
|
m_navigationWidget->saveSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add)
|
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
|
ICore::ContextPriority priority)
|
||||||
{
|
{
|
||||||
foreach (const Id id, remove) {
|
foreach (const Id id, remove) {
|
||||||
if (!id.isValid())
|
if (!id.isValid())
|
||||||
continue;
|
continue;
|
||||||
|
int index = m_lowPrioAdditionalContexts.indexOf(id);
|
||||||
int index = m_additionalContexts.indexOf(id);
|
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
m_additionalContexts.removeAt(index);
|
m_lowPrioAdditionalContexts.removeAt(index);
|
||||||
|
index = m_highPrioAdditionalContexts.indexOf(id);
|
||||||
|
if (index != -1)
|
||||||
|
m_highPrioAdditionalContexts.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const Id id, add) {
|
foreach (const Id id, add) {
|
||||||
if (!id.isValid())
|
if (!id.isValid())
|
||||||
continue;
|
continue;
|
||||||
|
Context &cref = (priority == ICore::ContextPriority::High ? m_highPrioAdditionalContexts
|
||||||
if (!m_additionalContexts.contains(id))
|
: m_lowPrioAdditionalContexts);
|
||||||
m_additionalContexts.prepend(id);
|
if (!cref.contains(id))
|
||||||
|
cref.prepend(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContext();
|
updateContext();
|
||||||
@@ -1009,12 +1013,12 @@ void MainWindow::updateAdditionalContexts(const Context &remove, const Context &
|
|||||||
|
|
||||||
void MainWindow::updateContext()
|
void MainWindow::updateContext()
|
||||||
{
|
{
|
||||||
Context contexts;
|
Context contexts = m_highPrioAdditionalContexts;
|
||||||
|
|
||||||
foreach (IContext *context, m_activeContext)
|
foreach (IContext *context, m_activeContext)
|
||||||
contexts.add(context->context());
|
contexts.add(context->context());
|
||||||
|
|
||||||
contexts.add(m_additionalContexts);
|
contexts.add(m_lowPrioAdditionalContexts);
|
||||||
|
|
||||||
Context uniquecontexts;
|
Context uniquecontexts;
|
||||||
for (int i = 0; i < contexts.size(); ++i) {
|
for (int i = 0; i < contexts.size(); ++i) {
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ public:
|
|||||||
IContext * currentContextObject() const;
|
IContext * currentContextObject() const;
|
||||||
QStatusBar *statusBar() const;
|
QStatusBar *statusBar() const;
|
||||||
|
|
||||||
void updateAdditionalContexts(const Context &remove, const Context &add);
|
void updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
|
ICore::ContextPriority priority);
|
||||||
|
|
||||||
void setSuppressNavigationWidget(bool suppress);
|
void setSuppressNavigationWidget(bool suppress);
|
||||||
|
|
||||||
@@ -151,7 +152,8 @@ private:
|
|||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
ICore *m_coreImpl;
|
ICore *m_coreImpl;
|
||||||
Context m_additionalContexts;
|
Context m_highPrioAdditionalContexts;
|
||||||
|
Context m_lowPrioAdditionalContexts;
|
||||||
SettingsDatabase *m_settingsDatabase;
|
SettingsDatabase *m_settingsDatabase;
|
||||||
mutable QPrinter *m_printer;
|
mutable QPrinter *m_printer;
|
||||||
WindowSupport *m_windowSupport;
|
WindowSupport *m_windowSupport;
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ void CppHoverHandler::decorateToolTip()
|
|||||||
prefix = QLatin1String("enum ");
|
prefix = QLatin1String("enum ");
|
||||||
setToolTip(prefix + help.helpId());
|
setToolTip(prefix + help.helpId());
|
||||||
}
|
}
|
||||||
addF1ToToolTip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -101,6 +102,7 @@
|
|||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
|
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
|
||||||
|
static const char kToolTipHelpContext[] = "Help.ToolTip";
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -169,6 +171,13 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
connect(HelpManager::instance(), SIGNAL(collectionFileChanged()), this,
|
connect(HelpManager::instance(), SIGNAL(collectionFileChanged()), this,
|
||||||
SLOT(setupHelpEngineIfNeeded()));
|
SLOT(setupHelpEngineIfNeeded()));
|
||||||
|
|
||||||
|
connect(ToolTip::instance(), &ToolTip::shown, ICore::instance(), []() {
|
||||||
|
ICore::addAdditionalContext(Context(kToolTipHelpContext), ICore::ContextPriority::High);
|
||||||
|
});
|
||||||
|
connect(ToolTip::instance(), &ToolTip::hidden,ICore::instance(), []() {
|
||||||
|
ICore::removeAdditionalContext(Context(kToolTipHelpContext));
|
||||||
|
});
|
||||||
|
|
||||||
Command *cmd;
|
Command *cmd;
|
||||||
QAction *action;
|
QAction *action;
|
||||||
|
|
||||||
@@ -185,7 +194,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
||||||
|
|
||||||
action = new QAction(tr("Context Help"), this);
|
action = new QAction(tr("Context Help"), this);
|
||||||
cmd = ActionManager::registerAction(action, Help::Constants::CONTEXT_HELP);
|
cmd = ActionManager::registerAction(action, Help::Constants::CONTEXT_HELP,
|
||||||
|
Context(kToolTipHelpContext, Core::Constants::C_GLOBAL));
|
||||||
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(showContextHelp()));
|
connect(action, SIGNAL(triggered()), this, SLOT(showContextHelp()));
|
||||||
@@ -560,17 +570,21 @@ static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
|
|||||||
void HelpPlugin::showContextHelp()
|
void HelpPlugin::showContextHelp()
|
||||||
{
|
{
|
||||||
// Find out what to show
|
// Find out what to show
|
||||||
QMap<QString, QUrl> links;
|
QString contextHelpId = Utils::ToolTip::contextHelpId();
|
||||||
QString idFromContext;
|
IContext *context = ICore::currentContextObject();
|
||||||
if (IContext *context = ICore::currentContextObject()) {
|
if (contextHelpId.isEmpty() && context)
|
||||||
idFromContext = context->contextHelpId();
|
contextHelpId = context->contextHelpId();
|
||||||
links = HelpManager::linksForIdentifier(idFromContext);
|
|
||||||
// Maybe the id is already an URL
|
// get the viewer after getting the help id,
|
||||||
if (links.isEmpty() && LocalHelpManager::isValidUrl(idFromContext))
|
// because a new window might be opened and therefore focus be moved
|
||||||
links.insert(idFromContext, idFromContext);
|
HelpViewer *viewer = viewerForContextHelp();
|
||||||
}
|
QTC_ASSERT(viewer, return);
|
||||||
|
|
||||||
|
QMap<QString, QUrl> links = HelpManager::linksForIdentifier(contextHelpId);
|
||||||
|
// Maybe the id is already an URL
|
||||||
|
if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId))
|
||||||
|
links.insert(contextHelpId, contextHelpId);
|
||||||
|
|
||||||
if (HelpViewer *viewer = viewerForContextHelp()) {
|
|
||||||
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
QUrl source = findBestLink(links, &m_contextHelpHighlightId);
|
||||||
if (!source.isValid()) {
|
if (!source.isValid()) {
|
||||||
// No link found or no context object
|
// No link found or no context object
|
||||||
@@ -581,7 +595,7 @@ void HelpPlugin::showContextHelp()
|
|||||||
"<font color=\"%3\">No documentation available.</font>"
|
"<font color=\"%3\">No documentation available.</font>"
|
||||||
"</center></body></html>")
|
"</center></body></html>")
|
||||||
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name())
|
||||||
.arg(idFromContext)
|
.arg(contextHelpId)
|
||||||
.arg(creatorTheme()->color(Theme::TextColorNormal).name()));
|
.arg(creatorTheme()->color(Theme::TextColorNormal).name()));
|
||||||
} else {
|
} else {
|
||||||
const QUrl &oldSource = viewer->source();
|
const QUrl &oldSource = viewer->source();
|
||||||
@@ -595,7 +609,6 @@ void HelpPlugin::showContextHelp()
|
|||||||
ICore::raiseWindow(viewer);
|
ICore::raiseWindow(viewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPlugin::activateIndex()
|
void HelpPlugin::activateIndex()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,13 +82,6 @@ void BaseHoverHandler::appendToolTip(const QString &extension)
|
|||||||
m_toolTip.append(extension);
|
m_toolTip.append(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseHoverHandler::addF1ToToolTip()
|
|
||||||
{
|
|
||||||
m_toolTip = QString::fromLatin1("<table><tr><td valign=middle>%1</td><td> "
|
|
||||||
"<img src=\":/texteditor/images/f1.png\"></td>"
|
|
||||||
"</tr></table>").arg(m_toolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseHoverHandler::setIsDiagnosticTooltip(bool isDiagnosticTooltip)
|
void BaseHoverHandler::setIsDiagnosticTooltip(bool isDiagnosticTooltip)
|
||||||
{
|
{
|
||||||
m_diagnosticTooltip = isDiagnosticTooltip;
|
m_diagnosticTooltip = isDiagnosticTooltip;
|
||||||
@@ -133,7 +126,6 @@ void BaseHoverHandler::decorateToolTip()
|
|||||||
if (!contents.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
setToolTip(toolTip().toHtmlEscaped());
|
setToolTip(toolTip().toHtmlEscaped());
|
||||||
appendToolTip(contents);
|
appendToolTip(contents);
|
||||||
addF1ToToolTip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +135,9 @@ void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoi
|
|||||||
if (m_toolTip.isEmpty())
|
if (m_toolTip.isEmpty())
|
||||||
Utils::ToolTip::hide();
|
Utils::ToolTip::hide();
|
||||||
else
|
else
|
||||||
Utils::ToolTip::show(point, m_toolTip, editorWidget);
|
Utils::ToolTip::show(point, m_toolTip, editorWidget, m_lastHelpItemIdentified.isValid()
|
||||||
|
? m_lastHelpItemIdentified.helpId()
|
||||||
|
: QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ protected:
|
|||||||
void appendToolTip(const QString &extension);
|
void appendToolTip(const QString &extension);
|
||||||
const QString &toolTip() const;
|
const QString &toolTip() const;
|
||||||
|
|
||||||
void addF1ToToolTip();
|
|
||||||
|
|
||||||
void setIsDiagnosticTooltip(bool isDiagnosticTooltip);
|
void setIsDiagnosticTooltip(bool isDiagnosticTooltip);
|
||||||
bool isDiagnosticTooltip() const;
|
bool isDiagnosticTooltip() const;
|
||||||
|
|
||||||
|
|||||||
@@ -3127,7 +3127,7 @@ bool TextEditorWidget::viewportEvent(QEvent *event)
|
|||||||
RefactorMarker refactorMarker = d->m_refactorOverlay->markerAt(pos);
|
RefactorMarker refactorMarker = d->m_refactorOverlay->markerAt(pos);
|
||||||
if (refactorMarker.isValid() && !refactorMarker.tooltip.isEmpty()) {
|
if (refactorMarker.isValid() && !refactorMarker.tooltip.isEmpty()) {
|
||||||
ToolTip::show(he->globalPos(), refactorMarker.tooltip,
|
ToolTip::show(he->globalPos(), refactorMarker.tooltip,
|
||||||
viewport(), refactorMarker.rect);
|
viewport(), QString(), refactorMarker.rect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,5 @@
|
|||||||
<file>images/finddirectory.png</file>
|
<file>images/finddirectory.png</file>
|
||||||
<file>images/refactormarker.png</file>
|
<file>images/refactormarker.png</file>
|
||||||
<file>images/snippet.png</file>
|
<file>images/snippet.png</file>
|
||||||
<file>images/f1.png</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user