forked from qt-creator/qt-creator
Editor: Simplify text marks
Moving defaultToolTip and color from TextMarkRegistry to TextMark. Allowing every instance of a TextMark object to define these information. Change-Id: Iec1794372cf902b34d343402074e3999e7f9faf7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,6 +27,9 @@
|
|||||||
#include "bookmarkmanager.h"
|
#include "bookmarkmanager.h"
|
||||||
#include "bookmarks_global.h"
|
#include "bookmarks_global.h"
|
||||||
|
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
|
||||||
@@ -36,8 +39,10 @@ Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) :
|
|||||||
TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY),
|
TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY),
|
||||||
m_manager(manager)
|
m_manager(manager)
|
||||||
{
|
{
|
||||||
|
setColor(Utils::Theme::Bookmarks_TextMarkColor);
|
||||||
|
setIcon(Utils::Icons::BOOKMARK_TEXTEDITOR.icon());
|
||||||
|
setDefaultToolTip(QApplication::translate("BookmarkManager", "Bookmark"));
|
||||||
setPriority(TextEditor::TextMark::NormalPriority);
|
setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
setIcon(m_manager->bookmarkIcon());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bookmark::removedFromEditor()
|
void Bookmark::removedFromEditor()
|
||||||
|
@@ -320,7 +320,6 @@ void BookmarkView::gotoBookmark(const QModelIndex &index)
|
|||||||
////
|
////
|
||||||
|
|
||||||
BookmarkManager::BookmarkManager() :
|
BookmarkManager::BookmarkManager() :
|
||||||
m_bookmarkIcon(Utils::Icons::BOOKMARK_TEXTEDITOR.pixmap()),
|
|
||||||
m_selectionModel(new QItemSelectionModel(this, this))
|
m_selectionModel(new QItemSelectionModel(this, this))
|
||||||
{
|
{
|
||||||
connect(ICore::instance(), &ICore::contextChanged,
|
connect(ICore::instance(), &ICore::contextChanged,
|
||||||
@@ -330,9 +329,6 @@ BookmarkManager::BookmarkManager() :
|
|||||||
this, &BookmarkManager::loadBookmarks);
|
this, &BookmarkManager::loadBookmarks);
|
||||||
|
|
||||||
updateActionStatus();
|
updateActionStatus();
|
||||||
Bookmark::setCategoryColor(Constants::BOOKMARKS_TEXT_MARK_CATEGORY,
|
|
||||||
Theme::Bookmarks_TextMarkColor);
|
|
||||||
Bookmark::setDefaultToolTip(Constants::BOOKMARKS_TEXT_MARK_CATEGORY, tr("Bookmark"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarkManager::~BookmarkManager()
|
BookmarkManager::~BookmarkManager()
|
||||||
|
@@ -52,8 +52,6 @@ public:
|
|||||||
BookmarkManager();
|
BookmarkManager();
|
||||||
~BookmarkManager();
|
~BookmarkManager();
|
||||||
|
|
||||||
QIcon bookmarkIcon() const { return m_bookmarkIcon; }
|
|
||||||
|
|
||||||
void updateBookmark(Bookmark *bookmark);
|
void updateBookmark(Bookmark *bookmark);
|
||||||
void updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName);
|
void updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName);
|
||||||
void deleteBookmark(Bookmark *bookmark); // Does not remove the mark
|
void deleteBookmark(Bookmark *bookmark); // Does not remove the mark
|
||||||
@@ -122,8 +120,6 @@ private:
|
|||||||
|
|
||||||
DirectoryFileBookmarksMap m_bookmarksMap;
|
DirectoryFileBookmarksMap m_bookmarksMap;
|
||||||
|
|
||||||
const QIcon m_bookmarkIcon;
|
|
||||||
|
|
||||||
QList<Bookmark *> m_bookmarksList;
|
QList<Bookmark *> m_bookmarksList;
|
||||||
QItemSelectionModel *m_selectionModel;
|
QItemSelectionModel *m_selectionModel;
|
||||||
};
|
};
|
||||||
|
@@ -46,20 +46,6 @@ namespace Internal {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void initializeTextMarks()
|
|
||||||
{
|
|
||||||
TextEditor::TextMark::setCategoryColor(Core::Id(Constants::CLANG_WARNING),
|
|
||||||
Utils::Theme::ClangCodeModel_Warning_TextMarkColor);
|
|
||||||
TextEditor::TextMark::setCategoryColor(Core::Id(Constants::CLANG_ERROR),
|
|
||||||
Utils::Theme::ClangCodeModel_Error_TextMarkColor);
|
|
||||||
TextEditor::TextMark::setDefaultToolTip(Core::Id(Constants::CLANG_WARNING),
|
|
||||||
QApplication::translate("Clang Code Model Marks",
|
|
||||||
"Code Model Warning"));
|
|
||||||
TextEditor::TextMark::setDefaultToolTip(Core::Id(Constants::CLANG_ERROR),
|
|
||||||
QApplication::translate("Clang Code Model Marks",
|
|
||||||
"Code Model Error"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void addProjectPanelWidget()
|
void addProjectPanelWidget()
|
||||||
{
|
{
|
||||||
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
|
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
|
||||||
@@ -85,7 +71,6 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
|
|||||||
|
|
||||||
CppTools::CppModelManager::instance()->activateClangCodeModel(&m_modelManagerSupportProvider);
|
CppTools::CppModelManager::instance()->activateClangCodeModel(&m_modelManagerSupportProvider);
|
||||||
|
|
||||||
initializeTextMarks();
|
|
||||||
addProjectPanelWidget();
|
addProjectPanelWidget();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -70,7 +71,13 @@ ClangTextMark::ClangTextMark(const QString &fileName,
|
|||||||
, m_diagnostic(diagnostic)
|
, m_diagnostic(diagnostic)
|
||||||
, m_removedFromEditorHandler(removedHandler)
|
, m_removedFromEditorHandler(removedHandler)
|
||||||
{
|
{
|
||||||
setPriority(TextEditor::TextMark::HighPriority);
|
const bool warning = isWarningOrNote(diagnostic.severity());
|
||||||
|
setColor(warning ? Utils::Theme::ClangCodeModel_Warning_TextMarkColor
|
||||||
|
: Utils::Theme::ClangCodeModel_Error_TextMarkColor);
|
||||||
|
setDefaultToolTip(warning ? QApplication::translate("Clang Code Model Marks", "Code Model Warning")
|
||||||
|
: QApplication::translate("Clang Code Model Marks", "Code Model Error"));
|
||||||
|
setPriority(warning ? TextEditor::TextMark::NormalPriority
|
||||||
|
: TextEditor::TextMark::HighPriority);
|
||||||
setIcon(diagnostic.severity());
|
setIcon(diagnostic.severity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setIcon(ClangBackEnd::DiagnosticSeverity severity);
|
void setIcon(ClangBackEnd::DiagnosticSeverity severity);
|
||||||
|
|
||||||
bool addToolTipContent(QLayout *target) override;
|
bool addToolTipContent(QLayout *target) override;
|
||||||
void removedFromEditor() override;
|
void removedFromEditor() override;
|
||||||
|
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
#include <modeltest.h>
|
#include <modeltest.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -156,8 +157,10 @@ public:
|
|||||||
BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber)
|
BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber)
|
||||||
: TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b)
|
: TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b)
|
||||||
{
|
{
|
||||||
setIcon(b->icon());
|
setColor(Theme::Debugger_Breakpoint_TextMarkColor);
|
||||||
|
setDefaultToolTip(QApplication::translate("BreakHandler", "Breakpoint"));
|
||||||
setPriority(TextEditor::TextMark::NormalPriority);
|
setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
|
setIcon(b->icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
void removedFromEditor()
|
void removedFromEditor()
|
||||||
@@ -894,10 +897,6 @@ BreakHandler::BreakHandler()
|
|||||||
: m_syncTimerId(-1)
|
: m_syncTimerId(-1)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<BreakpointModelId>();
|
qRegisterMetaType<BreakpointModelId>();
|
||||||
TextEditor::TextMark::setCategoryColor(Constants::TEXT_MARK_CATEGORY_BREAKPOINT,
|
|
||||||
Theme::Debugger_Breakpoint_TextMarkColor);
|
|
||||||
TextEditor::TextMark::setDefaultToolTip(Constants::TEXT_MARK_CATEGORY_BREAKPOINT,
|
|
||||||
tr("Breakpoint"));
|
|
||||||
|
|
||||||
#if USE_BREAK_MODEL_TEST
|
#if USE_BREAK_MODEL_TEST
|
||||||
new ModelTest(this, 0);
|
new ModelTest(this, 0);
|
||||||
|
@@ -30,6 +30,9 @@
|
|||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -60,6 +63,12 @@ public:
|
|||||||
TextMark(fileName, lineNumber, categoryForType(type)),
|
TextMark(fileName, lineNumber, categoryForType(type)),
|
||||||
m_id(id)
|
m_id(id)
|
||||||
{
|
{
|
||||||
|
setColor(type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor
|
||||||
|
: Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor);
|
||||||
|
setDefaultToolTip(type == Task::Error ? QApplication::translate("TaskHub", "Error")
|
||||||
|
: QApplication::translate("TaskHub", "Warning"));
|
||||||
|
setPriority(type == Task::Error ? TextEditor::TextMark::NormalPriority
|
||||||
|
: TextEditor::TextMark::LowPriority);
|
||||||
setVisible(visible);
|
setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,12 +114,6 @@ TaskHub::TaskHub()
|
|||||||
m_instance = this;
|
m_instance = this;
|
||||||
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
|
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
|
||||||
qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>");
|
qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>");
|
||||||
TaskMark::setCategoryColor(TASK_MARK_ERROR,
|
|
||||||
Utils::Theme::ProjectExplorer_TaskError_TextMarkColor);
|
|
||||||
TaskMark::setCategoryColor(TASK_MARK_WARNING,
|
|
||||||
Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor);
|
|
||||||
TaskMark::setDefaultToolTip(TASK_MARK_ERROR, tr("Error"));
|
|
||||||
TaskMark::setDefaultToolTip(TASK_MARK_WARNING, tr("Warning"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHub::~TaskHub()
|
TaskHub::~TaskHub()
|
||||||
@@ -149,9 +152,8 @@ void TaskHub::addTask(Task task)
|
|||||||
|
|
||||||
if (task.line != -1) {
|
if (task.line != -1) {
|
||||||
auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull());
|
auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull());
|
||||||
mark->setIcon(task.icon);
|
|
||||||
mark->setPriority(TextEditor::TextMark::LowPriority);
|
|
||||||
mark->setToolTip(task.description);
|
mark->setToolTip(task.description);
|
||||||
|
mark->setIcon(task.icon);
|
||||||
task.setMark(mark);
|
task.setMark(mark);
|
||||||
}
|
}
|
||||||
emit m_instance->taskAdded(task);
|
emit m_instance->taskAdded(task);
|
||||||
|
@@ -5771,8 +5771,7 @@ void TextEditorWidgetPrivate::addSearchResultsToScrollBar(QVector<SearchResult>
|
|||||||
|
|
||||||
Highlight markToHighlight(TextMark *mark, int lineNumber)
|
Highlight markToHighlight(TextMark *mark, int lineNumber)
|
||||||
{
|
{
|
||||||
return Highlight(mark->category(), lineNumber,
|
return Highlight(mark->category(), lineNumber, mark->color(),
|
||||||
TextMark::categoryColor(mark->category()),
|
|
||||||
textMarkPrioToScrollBarPrio(mark->priority()));
|
textMarkPrioToScrollBarPrio(mark->priority()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5791,8 +5790,7 @@ void TextEditorWidgetPrivate::updateHighlightScrollBarNow()
|
|||||||
|
|
||||||
// update text marks
|
// update text marks
|
||||||
foreach (TextMark *mark, m_document->marks()) {
|
foreach (TextMark *mark, m_document->marks()) {
|
||||||
Id category = mark->category();
|
if (!mark->isVisible() || !mark->hasColor())
|
||||||
if (!mark->isVisible() || !TextMark::categoryHasColor(category))
|
|
||||||
continue;
|
continue;
|
||||||
const QTextBlock &block = q->document()->findBlockByNumber(mark->lineNumber() - 1);
|
const QTextBlock &block = q->document()->findBlockByNumber(mark->lineNumber() - 1);
|
||||||
if (block.isVisible())
|
if (block.isVisible())
|
||||||
|
@@ -46,11 +46,6 @@ class TextMarkRegistry : public QObject
|
|||||||
public:
|
public:
|
||||||
static void add(TextMark *mark);
|
static void add(TextMark *mark);
|
||||||
static bool remove(TextMark *mark);
|
static bool remove(TextMark *mark);
|
||||||
static Utils::Theme::Color categoryColor(Core::Id category);
|
|
||||||
static bool categoryHasColor(Core::Id category);
|
|
||||||
static void setCategoryColor(Core::Id category, Utils::Theme::Color color);
|
|
||||||
static QString defaultToolTip(Core::Id category);
|
|
||||||
static void setDefaultToolTip(Core::Id category, const QString &toolTip);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextMarkRegistry(QObject *parent);
|
TextMarkRegistry(QObject *parent);
|
||||||
@@ -60,20 +55,16 @@ private:
|
|||||||
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
QHash<Utils::FileName, QSet<TextMark *> > m_marks;
|
QHash<Utils::FileName, QSet<TextMark *> > m_marks;
|
||||||
QHash<Core::Id, Utils::Theme::Color> m_colors;
|
|
||||||
QHash<Core::Id, QString> m_defaultToolTips;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TextMarkRegistry *m_instance = nullptr;
|
TextMarkRegistry *m_instance = nullptr;
|
||||||
|
|
||||||
TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double widthFactor)
|
TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double widthFactor)
|
||||||
: m_baseTextDocument(0),
|
: m_fileName(fileName)
|
||||||
m_fileName(fileName),
|
, m_lineNumber(lineNumber)
|
||||||
m_lineNumber(lineNumber),
|
, m_visible(true)
|
||||||
m_priority(NormalPriority),
|
, m_category(category)
|
||||||
m_visible(true),
|
, m_widthFactor(widthFactor)
|
||||||
m_category(category),
|
|
||||||
m_widthFactor(widthFactor)
|
|
||||||
{
|
{
|
||||||
if (!m_fileName.isEmpty())
|
if (!m_fileName.isEmpty())
|
||||||
TextMarkRegistry::add(this);
|
TextMarkRegistry::add(this);
|
||||||
@@ -134,52 +125,12 @@ void TextMark::updateBlock(const QTextBlock &)
|
|||||||
void TextMark::removedFromEditor()
|
void TextMark::removedFromEditor()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void TextMark::setIcon(const QIcon &icon)
|
|
||||||
{
|
|
||||||
m_icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QIcon &TextMark::icon() const
|
|
||||||
{
|
|
||||||
return m_icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
Theme::Color TextMark::categoryColor(Id category)
|
|
||||||
{
|
|
||||||
return TextMarkRegistry::categoryColor(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextMark::categoryHasColor(Id category)
|
|
||||||
{
|
|
||||||
return TextMarkRegistry::categoryHasColor(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMark::setCategoryColor(Id category, Theme::Color color)
|
|
||||||
{
|
|
||||||
TextMarkRegistry::setCategoryColor(category, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMark::setDefaultToolTip(Id category, const QString &toolTip)
|
|
||||||
{
|
|
||||||
TextMarkRegistry::setDefaultToolTip(category, toolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMark::updateMarker()
|
void TextMark::updateMarker()
|
||||||
{
|
{
|
||||||
if (m_baseTextDocument)
|
if (m_baseTextDocument)
|
||||||
m_baseTextDocument->updateMark(this);
|
m_baseTextDocument->updateMark(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMark::setPriority(Priority priority)
|
|
||||||
{
|
|
||||||
m_priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextMark::Priority TextMark::priority() const
|
|
||||||
{
|
|
||||||
return m_priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextMark::isVisible() const
|
bool TextMark::isVisible() const
|
||||||
{
|
{
|
||||||
return m_visible;
|
return m_visible;
|
||||||
@@ -192,11 +143,6 @@ void TextMark::setVisible(bool visible)
|
|||||||
m_baseTextDocument->updateMark(this);
|
m_baseTextDocument->updateMark(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id TextMark::category() const
|
|
||||||
{
|
|
||||||
return m_category;
|
|
||||||
}
|
|
||||||
|
|
||||||
double TextMark::widthFactor() const
|
double TextMark::widthFactor() const
|
||||||
{
|
{
|
||||||
return m_widthFactor;
|
return m_widthFactor;
|
||||||
@@ -244,7 +190,7 @@ bool TextMark::addToolTipContent(QLayout *target)
|
|||||||
{
|
{
|
||||||
QString text = m_toolTip;
|
QString text = m_toolTip;
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
text = TextMarkRegistry::defaultToolTip(m_category);
|
text = m_defaultToolTip;
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -258,24 +204,16 @@ bool TextMark::addToolTipContent(QLayout *target)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextDocument *TextMark::baseTextDocument() const
|
Theme::Color TextMark::color() const
|
||||||
{
|
{
|
||||||
return m_baseTextDocument;
|
QTC_CHECK(m_hasColor);
|
||||||
|
return m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMark::setBaseTextDocument(TextDocument *baseTextDocument)
|
void TextMark::setColor(const Theme::Color &color)
|
||||||
{
|
{
|
||||||
m_baseTextDocument = baseTextDocument;
|
m_hasColor = true;
|
||||||
}
|
m_color = color;
|
||||||
|
|
||||||
QString TextMark::toolTip() const
|
|
||||||
{
|
|
||||||
return m_toolTip;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMark::setToolTip(const QString &toolTip)
|
|
||||||
{
|
|
||||||
m_toolTip = toolTip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
||||||
@@ -304,37 +242,6 @@ bool TextMarkRegistry::remove(TextMark *mark)
|
|||||||
return instance()->m_marks[FileName::fromString(mark->fileName())].remove(mark);
|
return instance()->m_marks[FileName::fromString(mark->fileName())].remove(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
Theme::Color TextMarkRegistry::categoryColor(Id category)
|
|
||||||
{
|
|
||||||
return instance()->m_colors.value(category, Theme::ProjectExplorer_TaskWarn_TextMarkColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextMarkRegistry::categoryHasColor(Id category)
|
|
||||||
{
|
|
||||||
return instance()->m_colors.contains(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMarkRegistry::setCategoryColor(Id category, Theme::Color newColor)
|
|
||||||
{
|
|
||||||
Theme::Color &color = instance()->m_colors[category];
|
|
||||||
if (color == newColor)
|
|
||||||
return;
|
|
||||||
color = newColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TextMarkRegistry::defaultToolTip(Id category)
|
|
||||||
{
|
|
||||||
return instance()->m_defaultToolTips[category];
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextMarkRegistry::setDefaultToolTip(Id category, const QString &toolTip)
|
|
||||||
{
|
|
||||||
QString &defaultToolTip = instance()->m_defaultToolTips[category];
|
|
||||||
if (defaultToolTip == toolTip)
|
|
||||||
return;
|
|
||||||
defaultToolTip = toolTip;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextMarkRegistry *TextMarkRegistry::instance()
|
TextMarkRegistry *TextMarkRegistry::instance()
|
||||||
{
|
{
|
||||||
if (!m_instance)
|
if (!m_instance)
|
||||||
|
@@ -49,6 +49,7 @@ class TEXTEDITOR_EXPORT TextMark
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextMark(const QString &fileName, int lineNumber, Core::Id category, double widthFactor = 1.0);
|
TextMark(const QString &fileName, int lineNumber, Core::Id category, double widthFactor = 1.0);
|
||||||
|
TextMark() = delete;
|
||||||
virtual ~TextMark();
|
virtual ~TextMark();
|
||||||
|
|
||||||
// determine order on markers on the same line.
|
// determine order on markers on the same line.
|
||||||
@@ -76,41 +77,46 @@ public:
|
|||||||
void addToToolTipLayout(QGridLayout *target);
|
void addToToolTipLayout(QGridLayout *target);
|
||||||
virtual bool addToolTipContent(QLayout *target);
|
virtual bool addToolTipContent(QLayout *target);
|
||||||
|
|
||||||
static Utils::Theme::Color categoryColor(Core::Id category);
|
void setIcon(const QIcon &icon) { m_icon = icon; }
|
||||||
static bool categoryHasColor(Core::Id category);
|
const QIcon &icon() const { return m_icon; }
|
||||||
static void setCategoryColor(Core::Id category, Utils::Theme::Color color);
|
|
||||||
static void setDefaultToolTip(Core::Id category, const QString &toolTip);
|
|
||||||
void setIcon(const QIcon &icon);
|
|
||||||
const QIcon &icon() const;
|
|
||||||
// call this if the icon has changed.
|
// call this if the icon has changed.
|
||||||
void updateMarker();
|
void updateMarker();
|
||||||
Priority priority() const;
|
Priority priority() const { return m_priority;}
|
||||||
void setPriority(Priority prioriy);
|
void setPriority(Priority prioriy) { m_priority = prioriy; }
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
void setVisible(bool isVisible);
|
void setVisible(bool isVisible);
|
||||||
Core::Id category() const;
|
Core::Id category() const { return m_category; }
|
||||||
double widthFactor() const;
|
double widthFactor() const;
|
||||||
void setWidthFactor(double factor);
|
void setWidthFactor(double factor);
|
||||||
|
|
||||||
TextDocument *baseTextDocument() const;
|
Utils::Theme::Color color() const;
|
||||||
void setBaseTextDocument(TextDocument *baseTextDocument);
|
void setColor(const Utils::Theme::Color &color);
|
||||||
|
bool hasColor() const { return m_hasColor; }
|
||||||
|
|
||||||
QString toolTip() const;
|
QString defaultToolTip() const { return m_defaultToolTip; }
|
||||||
void setToolTip(const QString &toolTip);
|
void setDefaultToolTip(const QString &toolTip) { m_defaultToolTip = toolTip; }
|
||||||
|
|
||||||
|
TextDocument *baseTextDocument() const { return m_baseTextDocument; }
|
||||||
|
void setBaseTextDocument(TextDocument *baseTextDocument) { m_baseTextDocument = baseTextDocument; }
|
||||||
|
|
||||||
|
QString toolTip() const { return m_toolTip; }
|
||||||
|
void setToolTip(const QString &toolTip) { m_toolTip = toolTip; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TextMark)
|
Q_DISABLE_COPY(TextMark)
|
||||||
|
|
||||||
TextDocument *m_baseTextDocument;
|
TextDocument *m_baseTextDocument = nullptr;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
int m_lineNumber;
|
int m_lineNumber = 0;
|
||||||
Priority m_priority;
|
Priority m_priority = LowPriority;
|
||||||
bool m_visible;
|
bool m_visible = false;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QColor m_color;
|
Utils::Theme::Color m_color;
|
||||||
|
bool m_hasColor = false;
|
||||||
Core::Id m_category;
|
Core::Id m_category;
|
||||||
double m_widthFactor;
|
double m_widthFactor = 1.0;
|
||||||
QString m_toolTip;
|
QString m_toolTip;
|
||||||
|
QString m_defaultToolTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
Reference in New Issue
Block a user