Commit 3ed60eaa authored by Leandro Melo's avatar Leandro Melo
Browse files

C++ tooltip: Option to integrate Qt docs into tooltips.

parent a4cd9388
......@@ -38,6 +38,7 @@
#include <extensionsystem/pluginmanager.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/displaysettings.h>
#include <debugger/debuggerconstants.h>
#include <utils/htmldocextractor.h>
......@@ -148,7 +149,10 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
QToolTip::hideText();
} else {
if (m_matchingHelpCandidate != -1) {
const QString &contents = getDocContents();
QString contents;
TextEditor::BaseTextEditor *baseEditor = baseTextEditor(editor);
if (baseEditor && baseEditor->displaySettings().m_integrateDocsIntoTooltips)
contents = getDocContents();
if (!contents.isEmpty()) {
m_toolTip = contents;
} else {
......
......@@ -44,6 +44,7 @@ static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenth
static const char * const markTextChangesKey = "MarkTextChanges";
static const char * const autoFoldFirstCommentKey = "AutoFoldFirstComment";
static const char * const centerCursorOnScrollKey = "CenterCursorOnScroll";
static const char * const integrateDocsIntoTooltips = "IntegrateDocsIntoTooltips";
static const char * const groupPostfix = "DisplaySettings";
namespace TextEditor {
......@@ -60,7 +61,8 @@ DisplaySettings::DisplaySettings() :
m_animateMatchingParentheses(true),
m_markTextChanges(true),
m_autoFoldFirstComment(true),
m_centerCursorOnScroll(false)
m_centerCursorOnScroll(false),
m_integrateDocsIntoTooltips(true)
{
}
......@@ -82,6 +84,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
s->setValue(QLatin1String(integrateDocsIntoTooltips), m_integrateDocsIntoTooltips);
s->endGroup();
}
......@@ -106,6 +109,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool();
m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool();
m_integrateDocsIntoTooltips = s->value(group + QLatin1String(integrateDocsIntoTooltips), m_integrateDocsIntoTooltips).toBool();
}
bool DisplaySettings::equals(const DisplaySettings &ds) const
......@@ -122,6 +126,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
&& m_markTextChanges == ds.m_markTextChanges
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
&& m_centerCursorOnScroll == ds.m_centerCursorOnScroll
&& m_integrateDocsIntoTooltips == ds.m_integrateDocsIntoTooltips
;
}
......
......@@ -57,6 +57,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings
bool m_markTextChanges;
bool m_autoFoldFirstComment;
bool m_centerCursorOnScroll;
bool m_integrateDocsIntoTooltips;
bool equals(const DisplaySettings &ds) const;
};
......
......@@ -93,7 +93,8 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent)
<< ' ' << m_d->m_page.animateMatchingParentheses->text()
<< ' ' << m_d->m_page.enableTextWrapping->text()
<< ' ' << m_d->m_page.autoFoldFirstComment->text()
<< ' ' << m_d->m_page.centerOnScroll->text();
<< ' ' << m_d->m_page.centerOnScroll->text()
<< ' ' << m_d->m_page.integrateDocsIntoTooltips->text();
m_d->m_searchKeywords.remove(QLatin1Char('&'));
}
return w;
......@@ -121,6 +122,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
displaySettings.m_markTextChanges = m_d->m_page.markTextChanges->isChecked();
displaySettings.m_autoFoldFirstComment = m_d->m_page.autoFoldFirstComment->isChecked();
displaySettings.m_centerCursorOnScroll = m_d->m_page.centerOnScroll->isChecked();
displaySettings.m_integrateDocsIntoTooltips = m_d->m_page.integrateDocsIntoTooltips->isChecked();
}
void DisplaySettingsPage::settingsToUI()
......@@ -138,6 +140,7 @@ void DisplaySettingsPage::settingsToUI()
m_d->m_page.markTextChanges->setChecked(displaySettings.m_markTextChanges);
m_d->m_page.autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
m_d->m_page.centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll);
m_d->m_page.integrateDocsIntoTooltips->setChecked(displaySettings.m_integrateDocsIntoTooltips);
}
const DisplaySettings &DisplaySettingsPage::displaySettings() const
......
......@@ -96,6 +96,13 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="integrateDocsIntoTooltips">
<property name="text">
<string>Integrate Qt docs into tooltips</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment