forked from qt-creator/qt-creator
TextEditor: Add display settings page link to annotation tool tips
Change-Id: I453127693dd1e0b30918333ac6866ac2fca4baa6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
#include <cpptools/editordocumenthandle.h>
|
#include <cpptools/editordocumenthandle.h>
|
||||||
|
|
||||||
#include <texteditor/convenience.h>
|
#include <texteditor/convenience.h>
|
||||||
|
#include <texteditor/displaysettings.h>
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
@@ -274,6 +275,9 @@ void ClangEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint line,
|
|||||||
= m_diagnosticManager.diagnosticsAt(line, column);
|
= m_diagnosticManager.diagnosticsAt(line, column);
|
||||||
|
|
||||||
target->addWidget(ClangDiagnosticWidget::create(diagnostics, ClangDiagnosticWidget::ToolTip));
|
target->addWidget(ClangDiagnosticWidget::create(diagnostics, ClangDiagnosticWidget::ToolTip));
|
||||||
|
auto link = TextEditor::DisplaySettings::createAnnotationSettingsLink();
|
||||||
|
target->addWidget(link);
|
||||||
|
target->setAlignment(link, Qt::AlignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangEditorDocumentProcessor::editorDocumentTimerRestarted()
|
void ClangEditorDocumentProcessor::editorDocumentTimerRestarted()
|
||||||
|
@@ -25,6 +25,12 @@
|
|||||||
|
|
||||||
#include "displaysettings.h"
|
#include "displaysettings.h"
|
||||||
|
|
||||||
|
#include "texteditorconstants.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -131,7 +137,17 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
|
|||||||
&& m_displayAnnotations == ds.m_displayAnnotations
|
&& m_displayAnnotations == ds.m_displayAnnotations
|
||||||
&& m_annotationAlignment == ds.m_annotationAlignment
|
&& m_annotationAlignment == ds.m_annotationAlignment
|
||||||
&& m_minimalAnnotationContent == ds.m_minimalAnnotationContent
|
&& 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
|
} // namespace TextEditor
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
class QLabel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -72,6 +73,8 @@ public:
|
|||||||
int m_minimalAnnotationContent = 15;
|
int m_minimalAnnotationContent = 15;
|
||||||
|
|
||||||
bool equals(const DisplaySettings &ds) const;
|
bool equals(const DisplaySettings &ds) const;
|
||||||
|
|
||||||
|
static QLabel *createAnnotationSettingsLink();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); }
|
inline bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); }
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#include "tabsettings.h"
|
#include "tabsettings.h"
|
||||||
#include "textdocument.h"
|
#include "textdocument.h"
|
||||||
#include "textdocumentlayout.h"
|
#include "textdocumentlayout.h"
|
||||||
|
#include "texteditorconstants.h"
|
||||||
#include "texteditoroverlay.h"
|
#include "texteditoroverlay.h"
|
||||||
#include "refactoroverlay.h"
|
#include "refactoroverlay.h"
|
||||||
#include "texteditorsettings.h"
|
#include "texteditorsettings.h"
|
||||||
@@ -3291,30 +3292,32 @@ bool TextEditorWidgetPrivate::processAnnotaionTooltipRequest(const QTextBlock &b
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (const AnnotationRect &annotationRect : m_annotationRects[block.blockNumber()]) {
|
for (const AnnotationRect &annotationRect : m_annotationRects[block.blockNumber()]) {
|
||||||
if (annotationRect.rect.contains(pos)) {
|
if (!annotationRect.rect.contains(pos))
|
||||||
auto layout = new QGridLayout;
|
continue;
|
||||||
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){
|
auto layout = new QGridLayout;
|
||||||
return mark1->priority() > mark2->priority();
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
});
|
layout->setSpacing(2);
|
||||||
for (const TextMark *mark : Utils::asConst(marks)) {
|
annotationRect.mark->addToToolTipLayout(layout);
|
||||||
if (mark != annotationRect.mark)
|
TextMarks marks = blockUserData->marks();
|
||||||
mark->addToToolTipLayout(layout);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user