summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2017-07-21 14:31:21 +0200
committerDavid Schulz <david.schulz@qt.io>2017-07-25 12:00:49 +0000
commit5294c68c98037ece64b13e1b262c30f0ce8fd3e4 (patch)
treeea23b36b5a216776b115497816165623ff03e3ca
parent3ec59b46df3a5f12d3348a9f435de3b0093ee89b (diff)
downloadqt-creator-5294c68c98037ece64b13e1b262c30f0ce8fd3e4.tar.gz
TextEditor: Add display settings page link to annotation tool tips
Change-Id: I453127693dd1e0b30918333ac6866ac2fca4baa6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp4
-rw-r--r--src/plugins/texteditor/displaysettings.cpp18
-rw-r--r--src/plugins/texteditor/displaysettings.h3
-rw-r--r--src/plugins/texteditor/texteditor.cpp47
4 files changed, 49 insertions, 23 deletions
diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
index 6b0f995ece..e29f72ae9e 100644
--- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
+++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
@@ -47,6 +47,7 @@
#include <cpptools/editordocumenthandle.h>
#include <texteditor/convenience.h>
+#include <texteditor/displaysettings.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditorconstants.h>
@@ -274,6 +275,9 @@ void ClangEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint line,
= m_diagnosticManager.diagnosticsAt(line, column);
target->addWidget(ClangDiagnosticWidget::create(diagnostics, ClangDiagnosticWidget::ToolTip));
+ auto link = TextEditor::DisplaySettings::createAnnotationSettingsLink();
+ target->addWidget(link);
+ target->setAlignment(link, Qt::AlignRight);
}
void ClangEditorDocumentProcessor::editorDocumentTimerRestarted()
diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp
index 3d2eb5c084..410283a7f6 100644
--- a/src/plugins/texteditor/displaysettings.cpp
+++ b/src/plugins/texteditor/displaysettings.cpp
@@ -25,6 +25,12 @@
#include "displaysettings.h"
+#include "texteditorconstants.h"
+
+#include <coreplugin/icore.h>
+#include <utils/tooltip/tooltip.h>
+
+#include <QLabel>
#include <QSettings>
#include <QString>
@@ -131,7 +137,17 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
&& m_displayAnnotations == ds.m_displayAnnotations
&& m_annotationAlignment == ds.m_annotationAlignment
&& m_minimalAnnotationContent == ds.m_minimalAnnotationContent
- ;
+ ;
+}
+
+QLabel *DisplaySettings::createAnnotationSettingsLink()
+{
+ auto *label = new QLabel("<i><a href>Annotation Settings</a></i>", Core::ICore::mainWindow());
+ QObject::connect(label, &QLabel::linkActivated, []() {
+ Utils::ToolTip::hideImmediately();
+ Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_DISPLAY_SETTINGS);
+ });
+ return label;
}
} // namespace TextEditor
diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h
index 326f9aad06..41cebc0c6a 100644
--- a/src/plugins/texteditor/displaysettings.h
+++ b/src/plugins/texteditor/displaysettings.h
@@ -31,6 +31,7 @@
QT_BEGIN_NAMESPACE
class QSettings;
+class QLabel;
QT_END_NAMESPACE
namespace TextEditor {
@@ -72,6 +73,8 @@ public:
int m_minimalAnnotationContent = 15;
bool equals(const DisplaySettings &ds) const;
+
+ static QLabel *createAnnotationSettingsLink();
};
inline bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); }
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index bb58b6659c..d2990d1f2a 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -46,6 +46,7 @@
#include "tabsettings.h"
#include "textdocument.h"
#include "textdocumentlayout.h"
+#include "texteditorconstants.h"
#include "texteditoroverlay.h"
#include "refactoroverlay.h"
#include "texteditorsettings.h"
@@ -3291,30 +3292,32 @@ bool TextEditorWidgetPrivate::processAnnotaionTooltipRequest(const QTextBlock &b
return false;
for (const AnnotationRect &annotationRect : m_annotationRects[block.blockNumber()]) {
- if (annotationRect.rect.contains(pos)) {
- auto layout = new QGridLayout;
- layout->setContentsMargins(0, 0, 0, 0);
- layout->setSpacing(2);
- annotationRect.mark->addToToolTipLayout(layout);
- TextMarks marks = blockUserData->marks();
- if (marks.size() > 1) {
- QFrame* separator = new QFrame();
- separator->setFrameShape(QFrame::HLine);
- layout->addWidget(separator, 2, 0, 1, layout->columnCount());
- layout->addWidget(new QLabel(tr("Other annotations:")), 3, 0, 1,
- layout->columnCount());
-
- Utils::sort(marks, [](const TextMark* mark1, const TextMark* mark2){
- return mark1->priority() > mark2->priority();
- });
- for (const TextMark *mark : Utils::asConst(marks)) {
- if (mark != annotationRect.mark)
- mark->addToToolTipLayout(layout);
- }
+ if (!annotationRect.rect.contains(pos))
+ continue;
+
+ auto layout = new QGridLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+ annotationRect.mark->addToToolTipLayout(layout);
+ TextMarks marks = blockUserData->marks();
+ if (marks.size() > 1) {
+ QFrame* separator = new QFrame();
+ separator->setFrameShape(QFrame::HLine);
+ layout->addWidget(separator, layout->rowCount(), 0, 1, -1);
+ layout->addWidget(new QLabel(tr("Other annotations:")), layout->rowCount(), 0, 1, -1);
+
+ Utils::sort(marks, [](const TextMark* mark1, const TextMark* mark2){
+ return mark1->priority() > mark2->priority();
+ });
+ for (const TextMark *mark : Utils::asConst(marks)) {
+ if (mark != annotationRect.mark)
+ mark->addToToolTipLayout(layout);
}
- ToolTip::show(q->mapToGlobal(pos), layout, q);
- return true;
}
+ layout->addWidget(DisplaySettings::createAnnotationSettingsLink(),
+ layout->rowCount(), 0, 1, -1, Qt::AlignRight);
+ ToolTip::show(q->mapToGlobal(pos), layout, q);
+ return true;
}
return false;
}