From 191c6603dab5d8e72cf45c543e7c0779f908f390 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 7 Aug 2024 12:50:19 +0200 Subject: [PATCH] Axivion: Fix changing highlighting of issues So far we are only fetching line markers for newly opened documents. So, only re-opening a file updates the appearance of text marks stored for a document. This patch allows to remove an already set color of the mark which in turn is responsible for highlighting the marks on the scrollbar. Toggling the respective setting now updates existing marks. Change-Id: I95f65b8c48cb1f125740b88e7f744398b72ee92b Reviewed-by: Mohammad Mehdi Salem Naraghi Reviewed-by: Jarek Kobus --- src/plugins/axivion/axivionplugin.cpp | 24 ++++++++++++++++++++++++ src/plugins/texteditor/textmark.cpp | 6 ++++++ src/plugins/texteditor/textmark.h | 1 + 3 files changed, 31 insertions(+) diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index 7fc8a15cf3d..6b26ddeee1c 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -219,6 +219,7 @@ public: void onDocumentOpened(IDocument *doc); void onDocumentClosed(IDocument * doc); void clearAllMarks(); + void updateExistingMarks(); void handleIssuesForFile(const Dto::FileViewDto &fileView); void fetchIssueInfo(const QString &id); void setIssueDetails(const QString &issueDetailsHtml); @@ -313,6 +314,8 @@ AxivionPluginPrivate::AxivionPluginPrivate() connect(&m_networkAccessManager, &QNetworkAccessManager::sslErrors, this, &AxivionPluginPrivate::handleSslErrors); #endif // ssl + connect(&settings().highlightMarks, &BoolAspect::changed, + this, &AxivionPluginPrivate::updateExistingMarks); } void AxivionPluginPrivate::handleSslErrors(QNetworkReply *reply, const QList &errors) @@ -930,6 +933,27 @@ void AxivionPluginPrivate::clearAllMarks() onDocumentClosed(doc); } +void AxivionPluginPrivate::updateExistingMarks() // update whether highlight marks or not +{ + static Theme::Color color = Theme::Color(Theme::Bookmarks_TextMarkColor); // FIXME! + const bool colored = settings().highlightMarks(); + + const QList openDocuments = DocumentModel::openedDocuments(); + for (IDocument *doc : openDocuments) { + if (auto textDoc = qobject_cast(doc)) { + const TextMarks textMarks = textDoc->marks(); + for (TextEditor::TextMark *mark : textMarks) { + if (mark->category().id != s_axivionTextMarkId) + continue; + if (colored) + mark->setColor(color); + else + mark->unsetColor(); + } + } + } +} + void AxivionPluginPrivate::onDocumentOpened(IDocument *doc) { if (!doc || !m_currentProjectInfo || !m_project || !m_project->isKnownFile(doc->filePath())) diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 459d0ca27c1..a7a7288d8ce 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -406,6 +406,12 @@ void TextMark::setColor(const Theme::Color &color) updateMarker(); } +void TextMark::unsetColor() +{ + m_color.reset(); + updateMarker(); +} + void TextMark::setLineAnnotation(const QString &lineAnnotation) { m_lineAnnotation = lineAnnotation; diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index 1c6d6785865..0aab492c004 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -99,6 +99,7 @@ public: std::optional color() const; void setColor(const Utils::Theme::Color &color); + void unsetColor(); QString defaultToolTip() const { return m_defaultToolTip; } void setDefaultToolTip(const QString &toolTip) { m_defaultToolTip = toolTip; }