TextEditor: Sort text marks in categories.

Also adding a color for each category.

Change-Id: I3627d13913951a95804b5a816f087a822c01bd86
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
David Schulz
2015-04-17 12:46:28 +02:00
committed by Orgad Shaneh
parent a6e1c3cb54
commit ab2a0d74de
17 changed files with 122 additions and 14 deletions

View File

@@ -100,6 +100,8 @@ Debugger_WatchItem_ValueNormal=text
Debugger_WatchItem_ValueInvalid=textDisabled Debugger_WatchItem_ValueInvalid=textDisabled
Debugger_WatchItem_ValueChanged=ffbf0303 Debugger_WatchItem_ValueChanged=ffbf0303
Debugger_Breakpoint_TextMarkColor=60ff2020
Welcome_BackgroundColorNormal=normalBackground Welcome_BackgroundColorNormal=normalBackground
Welcome_Button_BorderColorNormal=0 Welcome_Button_BorderColorNormal=0
Welcome_Button_BorderColorPressed=0 Welcome_Button_BorderColorPressed=0
@@ -126,6 +128,11 @@ VcsBase_FileModified_TextColor=ff8ee0ff
VcsBase_FileDeleted_TextColor=fffff6c6c VcsBase_FileDeleted_TextColor=fffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500 VcsBase_FileRenamed_TextColor=ffffa500
Bookmark_TextMarkColor=804040ff
ProjectExplorer_TaskError_TextMarkColor=a0ff4040
ProjectExplorer_TaskWarn_TextMarkColor=80ffff20
[Flags] [Flags]
ComboBoxDrawTextShadow=false ComboBoxDrawTextShadow=false
DerivePaletteFromTheme=true DerivePaletteFromTheme=true

View File

@@ -94,6 +94,8 @@ Debugger_WatchItem_ValueNormal=ff000000
Debugger_WatchItem_ValueInvalid=ff8c8c8c Debugger_WatchItem_ValueInvalid=ff8c8c8c
Debugger_WatchItem_ValueChanged=ffc80000 Debugger_WatchItem_ValueChanged=ffc80000
Debugger_Breakpoint_TextMarkColor=80ff0000
Welcome_BackgroundColorNormal=ffffffff Welcome_BackgroundColorNormal=ffffffff
Welcome_Button_BorderColorNormal=ff737373 Welcome_Button_BorderColorNormal=ff737373
Welcome_Button_BorderColorPressed=ff333333 Welcome_Button_BorderColorPressed=ff333333
@@ -120,6 +122,11 @@ VcsBase_FileModified_TextColor=ff0000ee
VcsBase_FileDeleted_TextColor=ffee0000 VcsBase_FileDeleted_TextColor=ffee0000
VcsBase_FileRenamed_TextColor=ffd77d00 VcsBase_FileRenamed_TextColor=ffd77d00
Bookmark_TextMarkColor=800000ff
ProjectExplorer_TaskError_TextMarkColor=80800000
ProjectExplorer_TaskWarn_TextMarkColor=80ffff00
[Flags] [Flags]
ComboBoxDrawTextShadow=true ComboBoxDrawTextShadow=true
DerivePaletteFromTheme=false DerivePaletteFromTheme=false

View File

@@ -58,6 +58,7 @@ public:
~Theme(); ~Theme();
enum Color { enum Color {
InvalidColor,
BackgroundColorAlternate, BackgroundColorAlternate,
BackgroundColorDark, BackgroundColorDark,
BackgroundColorHover, BackgroundColorHover,
@@ -180,7 +181,17 @@ public:
VcsBase_FileAdded_TextColor, VcsBase_FileAdded_TextColor,
VcsBase_FileModified_TextColor, VcsBase_FileModified_TextColor,
VcsBase_FileDeleted_TextColor, VcsBase_FileDeleted_TextColor,
VcsBase_FileRenamed_TextColor VcsBase_FileRenamed_TextColor,
/* Bookmarks Plugin */
Bookmarks_TextMarkColor,
/* Debugger Plugin */
Debugger_Breakpoint_TextMarkColor,
/* ProjectExplorer Plugin */
ProjectExplorer_TaskError_TextMarkColor,
ProjectExplorer_TaskWarn_TextMarkColor
}; };
enum Gradient { enum Gradient {

View File

@@ -30,6 +30,7 @@
#include "bookmark.h" #include "bookmark.h"
#include "bookmarkmanager.h" #include "bookmarkmanager.h"
#include "bookmarks_global.h"
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
@@ -38,7 +39,7 @@
using namespace Bookmarks::Internal; using namespace Bookmarks::Internal;
Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) : Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) :
TextMark(QString(), lineNumber), TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY),
m_manager(manager) m_manager(manager)
{ {
setPriority(TextEditor::TextMark::NormalPriority); setPriority(TextEditor::TextMark::NormalPriority);

View File

@@ -45,6 +45,7 @@
#include <utils/tooltip/tooltip.h> #include <utils/tooltip/tooltip.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/checkablemessagebox.h> #include <utils/checkablemessagebox.h>
#include <utils/theme/theme.h>
#include <QAction> #include <QAction>
#include <QContextMenuEvent> #include <QContextMenuEvent>
@@ -331,6 +332,8 @@ BookmarkManager::BookmarkManager() :
this, &BookmarkManager::loadBookmarks); this, &BookmarkManager::loadBookmarks);
updateActionStatus(); updateActionStatus();
Bookmark::setCategoryColor(Constants::BOOKMARKS_TEXT_MARK_CATEGORY,
Theme::Bookmarks_TextMarkColor);
} }
BookmarkManager::~BookmarkManager() BookmarkManager::~BookmarkManager()

View File

@@ -44,6 +44,7 @@ const char BOOKMARKS_PREVDIR_ACTION[] = "Bookmarks.PreviousDirectory";
const char BOOKMARKS_NEXTDIR_ACTION[] = "Bookmarks.NextDirectory"; const char BOOKMARKS_NEXTDIR_ACTION[] = "Bookmarks.NextDirectory";
const char BOOKMARKS_PREVDOC_ACTION[] = "Bookmarks.PreviousDocument"; const char BOOKMARKS_PREVDOC_ACTION[] = "Bookmarks.PreviousDocument";
const char BOOKMARKS_NEXTDOC_ACTION[] = "Bookmarks.NextDocument"; const char BOOKMARKS_NEXTDOC_ACTION[] = "Bookmarks.NextDocument";
const char BOOKMARKS_TEXT_MARK_CATEGORY[] = "Bookmarks.TextMarkCategory";
const char BOOKMARKS_MENU[] = "Bookmarks.Menu"; const char BOOKMARKS_MENU[] = "Bookmarks.Menu";
const char BOOKMARKS_CONTEXT[] = "Bookmarks"; const char BOOKMARKS_CONTEXT[] = "Bookmarks";

View File

@@ -48,6 +48,7 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/theme/theme.h>
#if USE_BREAK_MODEL_TEST #if USE_BREAK_MODEL_TEST
#include <modeltest.h> #include <modeltest.h>
@@ -145,7 +146,7 @@ class BreakpointMarker : public TextEditor::TextMark
{ {
public: public:
BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber) BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber)
: TextMark(fileName, lineNumber), m_bp(b) : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b)
{ {
setIcon(b->icon()); setIcon(b->icon());
setPriority(TextEditor::TextMark::NormalPriority); setPriority(TextEditor::TextMark::NormalPriority);
@@ -253,6 +254,8 @@ BreakHandler::BreakHandler()
: m_syncTimerId(-1) : m_syncTimerId(-1)
{ {
qRegisterMetaType<BreakpointModelId>(); qRegisterMetaType<BreakpointModelId>();
TextEditor::TextMark::setCategoryColor(Constants::TEXT_MARK_CATEGORY_BREAKPOINT,
Utils::Theme::Debugger_Breakpoint_TextMarkColor);
#if USE_BREAK_MODEL_TEST #if USE_BREAK_MODEL_TEST
new ModelTest(this, 0); new ModelTest(this, 0);

View File

@@ -69,6 +69,9 @@ const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo"; const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo";
const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime"; const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime";
const char TEXT_MARK_CATEGORY_BREAKPOINT[] = "Debugger.Mark.Breakpoint";
const char TEXT_MARK_CATEGORY_LOCATION[] = "Debugger.Mark.Location";
// Run Configuration Aspect defaults: // Run Configuration Aspect defaults:
const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768; const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768;

View File

@@ -610,7 +610,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true); editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
if (loc.needsMarker()) { if (loc.needsMarker()) {
d->m_locationMark.reset(new TextMark(file, line)); d->m_locationMark.reset(new TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION));
d->m_locationMark->setIcon(Internal::locationMarkIcon()); d->m_locationMark->setIcon(Internal::locationMarkIcon());
d->m_locationMark->setPriority(TextMark::HighPriority); d->m_locationMark->setPriority(TextMark::HighPriority);
} }

View File

@@ -116,7 +116,7 @@ public:
DisassemblerAgentPrivate::DisassemblerAgentPrivate() DisassemblerAgentPrivate::DisassemblerAgentPrivate()
: document(0), : document(0),
locationMark(QString(), 0), locationMark(QString(), 0, Constants::TEXT_MARK_CATEGORY_LOCATION),
mimeType(_("text/x-qtcreator-generic-asm")), mimeType(_("text/x-qtcreator-generic-asm")),
resetLocationScheduled(false) resetLocationScheduled(false)
{ {
@@ -352,7 +352,8 @@ void DisassemblerAgent::updateBreakpointMarkers()
const int lineNumber = contents.lineForAddress(address); const int lineNumber = contents.lineForAddress(address);
if (!lineNumber) if (!lineNumber)
continue; continue;
TextMark *marker = new TextMark(QString(), lineNumber); TextMark *marker = new TextMark(QString(), lineNumber,
Constants::TEXT_MARK_CATEGORY_BREAKPOINT);
marker->setIcon(bp.icon()); marker->setIcon(bp.icon());
marker->setPriority(TextMark::NormalPriority); marker->setPriority(TextMark::NormalPriority);
d->breakpointMarks.append(marker); d->breakpointMarks.append(marker);

View File

@@ -144,7 +144,8 @@ void SourceAgent::updateLocationMarker()
if (d->engine->stackHandler()->currentFrame().file == d->path) { if (d->engine->stackHandler()->currentFrame().file == d->path) {
int lineNumber = d->engine->stackHandler()->currentFrame().line; int lineNumber = d->engine->stackHandler()->currentFrame().line;
d->locationMark = new TextMark(QString(), lineNumber); d->locationMark = new TextMark(QString(), lineNumber,
Constants::TEXT_MARK_CATEGORY_LOCATION);
d->locationMark->setIcon(locationMarkIcon()); d->locationMark->setIcon(locationMarkIcon());
d->locationMark->setPriority(TextMark::HighPriority); d->locationMark->setPriority(TextMark::HighPriority);

View File

@@ -194,6 +194,10 @@ const char TASK_CATEGORY_COMPILE[] = "Task.Category.Compile";
const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem";
const char TASK_CATEGORY_DEPLOYMENT[] = "Task.Category.Deploy"; const char TASK_CATEGORY_DEPLOYMENT[] = "Task.Category.Deploy";
// Task mark categories
const char TASK_MARK_WARNING[] = "Task.Mark.Warning";
const char TASK_MARK_ERROR[] = "Task.Mark.Error";
// Wizard categories // Wizard categories
const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project"; const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project";
const char QT_PROJECT_WIZARD_CATEGORY_DISPLAY[] = QT_TRANSLATE_NOOP("ProjectExplorer", "Other Project"); const char QT_PROJECT_WIZARD_CATEGORY_DISPLAY[] = QT_TRANSLATE_NOOP("ProjectExplorer", "Other Project");

View File

@@ -29,21 +29,36 @@
****************************************************************************/ ****************************************************************************/
#include "taskhub.h" #include "taskhub.h"
#include "projectexplorerconstants.h"
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/ioutputpane.h> #include <coreplugin/ioutputpane.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/theme/theme.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
TaskHub *m_instance = 0; TaskHub *m_instance = 0;
QSet<Core::Id> TaskHub::m_registeredCategories; QSet<Core::Id> TaskHub::m_registeredCategories;
static Core::Id categoryForType(Task::TaskType type)
{
switch (type) {
case Task::Error:
return Constants::TASK_MARK_ERROR;
case Task::Warning:
return Constants::TASK_MARK_WARNING;
default:
return Core::Id();
}
}
class TaskMark : public TextEditor::TextMark class TaskMark : public TextEditor::TextMark
{ {
public: public:
TaskMark(unsigned int id, const QString &fileName, int lineNumber, bool visible) TaskMark(unsigned int id, const QString &fileName, int lineNumber, Task::TaskType type, bool visible)
: TextMark(fileName, lineNumber), m_id(id) : TextMark(fileName, lineNumber, categoryForType(type))
, m_id(id)
{ {
setVisible(visible); setVisible(visible);
} }
@@ -92,6 +107,10 @@ 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(Constants::TASK_MARK_ERROR,
Utils::Theme::ProjectExplorer_TaskError_TextMarkColor);
TaskMark::setCategoryColor(Constants::TASK_MARK_WARNING,
Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor);
} }
TaskHub::~TaskHub() TaskHub::~TaskHub()
@@ -130,7 +149,8 @@ void TaskHub::addTask(Task task)
task.movedLine = task.line; task.movedLine = task.line;
if (task.line != -1 && !task.file.isEmpty()) { if (task.line != -1 && !task.file.isEmpty()) {
TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull()); TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line,
task.type, !task.icon.isNull());
mark->setIcon(task.icon); mark->setIcon(task.icon);
mark->setPriority(TextEditor::TextMark::LowPriority); mark->setPriority(TextEditor::TextMark::LowPriority);
task.addMark(mark); task.addMark(mark);

View File

@@ -44,12 +44,13 @@ using namespace TextEditor::Internal;
namespace TextEditor { namespace TextEditor {
TextMark::TextMark(const QString &fileName, int lineNumber) TextMark::TextMark(const QString &fileName, int lineNumber, Id category)
: m_baseTextDocument(0), : m_baseTextDocument(0),
m_fileName(fileName), m_fileName(fileName),
m_lineNumber(lineNumber), m_lineNumber(lineNumber),
m_priority(NormalPriority), m_priority(NormalPriority),
m_visible(true), m_visible(true),
m_category(category),
m_widthFactor(1.0) m_widthFactor(1.0)
{ {
if (!m_fileName.isEmpty()) if (!m_fileName.isEmpty())
@@ -116,6 +117,16 @@ void TextMark::setIcon(const QIcon &icon)
m_icon = icon; m_icon = icon;
} }
Theme::Color TextMark::categoryColor(Id category)
{
return TextEditorPlugin::baseTextMarkRegistry()->categoryColor(category);
}
void TextMark::setCategoryColor(Id category, Theme::Color color)
{
TextEditorPlugin::baseTextMarkRegistry()->setCategoryColor(category, color);
}
void TextMark::updateMarker() void TextMark::updateMarker()
{ {
if (m_baseTextDocument) if (m_baseTextDocument)
@@ -144,6 +155,11 @@ 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;
@@ -209,6 +225,18 @@ bool TextMarkRegistry::remove(TextMark *mark)
return m_marks[FileName::fromString(mark->fileName())].remove(mark); return m_marks[FileName::fromString(mark->fileName())].remove(mark);
} }
Theme::Color TextMarkRegistry::categoryColor(Id category)
{
return m_colors.contains(category) ? m_colors[category] : Theme::InvalidColor;
}
void TextMarkRegistry::setCategoryColor(Id category, Theme::Color color)
{
if (m_colors[category] == color)
return;
m_colors[category] = color;
}
void TextMarkRegistry::editorOpened(IEditor *editor) void TextMarkRegistry::editorOpened(IEditor *editor)
{ {
auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0); auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0);

View File

@@ -33,6 +33,9 @@
#include "texteditor_global.h" #include "texteditor_global.h"
#include <coreplugin/id.h>
#include <utils/theme/theme.h>
#include <QIcon> #include <QIcon>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -51,7 +54,7 @@ namespace Internal { class TextMarkRegistry; }
class TEXTEDITOR_EXPORT TextMark class TEXTEDITOR_EXPORT TextMark
{ {
public: public:
TextMark(const QString &fileName, int lineNumber); TextMark(const QString &fileName, int lineNumber, Core::Id category);
virtual ~TextMark(); virtual ~TextMark();
// determine order on markers on the same line. // determine order on markers on the same line.
@@ -77,6 +80,8 @@ public:
virtual bool isDraggable() const; virtual bool isDraggable() const;
virtual void dragToLine(int lineNumber); virtual void dragToLine(int lineNumber);
static Utils::Theme::Color categoryColor(Core::Id category);
static void setCategoryColor(Core::Id category, Utils::Theme::Color color);
void setIcon(const QIcon &icon); void setIcon(const QIcon &icon);
// call this if the icon has changed. // call this if the icon has changed.
void updateMarker(); void updateMarker();
@@ -84,6 +89,7 @@ public:
void setPriority(Priority prioriy); void setPriority(Priority prioriy);
bool isVisible() const; bool isVisible() const;
void setVisible(bool isVisible); void setVisible(bool isVisible);
Core::Id category() const;
double widthFactor() const; double widthFactor() const;
void setWidthFactor(double factor); void setWidthFactor(double factor);
@@ -100,6 +106,8 @@ private:
Priority m_priority; Priority m_priority;
bool m_visible; bool m_visible;
QIcon m_icon; QIcon m_icon;
QColor m_color;
Core::Id m_category;
double m_widthFactor; double m_widthFactor;
}; };

View File

@@ -33,10 +33,14 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <QObject> #include <QColor>
#include <QHash> #include <QHash>
#include <QObject>
#include <QSet> #include <QSet>
#include <coreplugin/id.h>
#include <utils/theme/theme.h>
namespace Core { namespace Core {
class IEditor; class IEditor;
class IDocument; class IDocument;
@@ -54,12 +58,15 @@ public:
void add(TextMark *mark); void add(TextMark *mark);
bool remove(TextMark *mark); bool remove(TextMark *mark);
Utils::Theme::Color categoryColor(Core::Id category);
void setCategoryColor(Core::Id category, Utils::Theme::Color color);
private slots: private slots:
void editorOpened(Core::IEditor *editor); void editorOpened(Core::IEditor *editor);
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName); void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
void allDocumentsRenamed(const QString &oldName, const QString &newName); void allDocumentsRenamed(const QString &oldName, const QString &newName);
private: private:
QHash<Utils::FileName, QSet<TextMark *> > m_marks; QHash<Utils::FileName, QSet<TextMark *> > m_marks;
QHash<Core::Id, Utils::Theme::Color> m_colors;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -43,9 +43,12 @@
using namespace Valgrind::Internal; using namespace Valgrind::Internal;
using namespace Valgrind::Callgrind; using namespace Valgrind::Callgrind;
namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; }
CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index, CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index,
const QString &fileName, int lineNumber) const QString &fileName, int lineNumber)
: TextEditor::TextMark(fileName, lineNumber), m_modelIndex(index) : TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY)
, m_modelIndex(index)
{ {
setPriority(TextEditor::TextMark::HighPriority); setPriority(TextEditor::TextMark::HighPriority);
setWidthFactor(4.0); setWidthFactor(4.0);