aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2022-09-06 13:01:51 +0200
committerDavid Schulz <david.schulz@qt.io>2022-09-07 04:17:37 +0000
commitd8fcaf0a7370800518d6b8b94a4728b5f153b5e5 (patch)
tree7423088afc8c0b8cd0a7ca69c5c3901dffdf5286 /src
parent2f093aec6694d63e3e46a3ce6cd9b98a163b081a (diff)
Editor: paint location marker over everything else
The location marker is updated very regularly and especially while stepping moves one line at a time. Resizing this marker when it enters a line that already contains a marker is visually distracting. To prevent this paint the marker over all other markers in that line. Change-Id: I63ad72384e77eeae4dc6d2e2c2ac77c88da92c56 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/debugger/debuggerengine.cpp1
-rw-r--r--src/plugins/texteditor/textdocument.cpp9
-rw-r--r--src/plugins/texteditor/textdocumentlayout.h1
-rw-r--r--src/plugins/texteditor/texteditor.cpp31
-rw-r--r--src/plugins/texteditor/textmark.cpp10
-rw-r--r--src/plugins/texteditor/textmark.h4
6 files changed, 46 insertions, 10 deletions
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index 47ec70c18e0..828ca013b1d 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -156,6 +156,7 @@ LocationMark::LocationMark(DebuggerEngine *engine, const FilePath &file, int lin
: TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine)
{
setPriority(TextMark::HighPriority);
+ setIsLocationMarker(true);
updateIcon();
}
diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp
index efa89597f19..d866041d2ca 100644
--- a/src/plugins/texteditor/textdocument.cpp
+++ b/src/plugins/texteditor/textdocument.cpp
@@ -983,6 +983,10 @@ bool TextDocument::addMark(TextMark *mark)
// Update document layout
bool fullUpdate = !documentLayout->hasMarks;
documentLayout->hasMarks = true;
+ if (!documentLayout->hasLocationMarker && mark->isLocationMarker()) {
+ documentLayout->hasLocationMarker = true;
+ fullUpdate = true;
+ }
if (fullUpdate)
documentLayout->scheduleUpdate();
else
@@ -1018,6 +1022,11 @@ void TextDocument::removeMarkFromMarksCache(TextMark *mark)
Qt::QueuedConnection);
};
+ if (mark->isLocationMarker()) {
+ documentLayout->hasLocationMarker = false;
+ scheduleLayoutUpdate();
+ }
+
if (d->m_marksCache.isEmpty()) {
documentLayout->hasMarks = false;
scheduleLayoutUpdate();
diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h
index bdbaf44877f..1910c7ed873 100644
--- a/src/plugins/texteditor/textdocumentlayout.h
+++ b/src/plugins/texteditor/textdocumentlayout.h
@@ -203,6 +203,7 @@ public:
int lastSaveRevision = 0;
bool hasMarks = false;
+ bool hasLocationMarker = false;
int m_requiredWidth = 0;
void setRequiredWidth(int width);
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 20c13095b83..af29361ccb8 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -4930,35 +4930,46 @@ void TextEditorWidgetPrivate::paintTextMarks(QPainter &painter, const ExtraAreaP
QList<QIcon> icons;
auto end = marks.crend();
int marksWithIconCount = 0;
+ QIcon overrideIcon;
for (auto it = marks.crbegin(); it != end; ++it) {
if ((*it)->isVisible()) {
const QIcon icon = (*it)->icon();
if (!icon.isNull()) {
- if (icons.size() < 3
- && !Utils::contains(icons, Utils::equal(&QIcon::cacheKey, icon.cacheKey()))) {
- icons << icon;
+ if ((*it)->isLocationMarker()) {
+ overrideIcon = icon;
+ } else {
+ if (icons.size() < 3
+ && !Utils::contains(icons, Utils::equal(&QIcon::cacheKey, icon.cacheKey()))) {
+ icons << icon;
+ }
+ ++marksWithIconCount;
}
- ++marksWithIconCount;
}
}
}
- if (icons.isEmpty())
- return;
-
- painter.save();
- Utils::ExecuteOnDestruction painterRestore([&]() { painter.restore(); });
int size = data.lineSpacing - 1;
int xoffset = 0;
int yoffset = blockBoundingRect.top();
+ painter.save();
+ Utils::ExecuteOnDestruction eod([&painter, size, yoffset, xoffset, overrideIcon]() {
+ if (!overrideIcon.isNull()) {
+ const QRect r(xoffset, yoffset, size, size);
+ overrideIcon.paint(&painter, r, Qt::AlignCenter);
+ }
+ painter.restore();
+ });
+
+ if (icons.isEmpty())
+ return;
+
if (icons.size() == 1) {
const QRect r(xoffset, yoffset, size, size);
icons.first().paint(&painter, r, Qt::AlignCenter);
return;
}
-
size = size / 2;
for (const QIcon &icon : qAsConst(icons)) {
const QRect r(xoffset, yoffset, size, size);
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index 1ca67b597bd..d74aa177593 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -409,6 +409,16 @@ void TextMark::setSettingsPage(Id settingsPage)
m_settingsPage = settingsPage;
}
+bool TextMark::isLocationMarker() const
+{
+ return m_isLocationMarker;
+}
+
+void TextMark::setIsLocationMarker(bool newIsLocationMarker)
+{
+ m_isLocationMarker = newIsLocationMarker;
+}
+
TextMarkRegistry::TextMarkRegistry(QObject *parent)
: QObject(parent)
{
diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h
index ed0816224bc..abeb0b7b419 100644
--- a/src/plugins/texteditor/textmark.h
+++ b/src/plugins/texteditor/textmark.h
@@ -111,6 +111,9 @@ public:
void setActions(const QVector<QAction *> &actions); // Takes ownership
void setActionsProvider(const std::function<QList<QAction *>()> &actionsProvider); // Takes ownership
+ bool isLocationMarker() const;;
+ void setIsLocationMarker(bool newIsLocationMarker);
+
protected:
void setSettingsPage(Utils::Id settingsPage);
@@ -121,6 +124,7 @@ private:
Utils::FilePath m_fileName;
int m_lineNumber = 0;
Priority m_priority = LowPriority;
+ bool m_isLocationMarker = false;
QIcon m_icon;
std::function<QIcon()> m_iconProvider;
std::optional<Utils::Theme::Color> m_color;