summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@theqtcompany.com>2015-04-17 12:46:28 +0200
committerOrgad Shaneh <orgads@gmail.com>2015-05-21 08:23:16 +0000
commitab2a0d74dec2df08d23e14b5b3ad670d98af435f (patch)
tree02b161b155335a5cfd498fdd2052e86b7c490964
parenta6e1c3cb54dcf419aa3b86ecd24865198906e313 (diff)
downloadqt-creator-ab2a0d74dec2df08d23e14b5b3ad670d98af435f.tar.gz
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>
-rw-r--r--share/qtcreator/themes/dark.creatortheme7
-rw-r--r--share/qtcreator/themes/default.creatortheme7
-rw-r--r--src/libs/utils/theme/theme.h13
-rw-r--r--src/plugins/bookmarks/bookmark.cpp3
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.cpp3
-rw-r--r--src/plugins/bookmarks/bookmarks_global.h1
-rw-r--r--src/plugins/debugger/breakhandler.cpp5
-rw-r--r--src/plugins/debugger/debuggerconstants.h3
-rw-r--r--src/plugins/debugger/debuggerengine.cpp2
-rw-r--r--src/plugins/debugger/disassembleragent.cpp5
-rw-r--r--src/plugins/debugger/sourceagent.cpp3
-rw-r--r--src/plugins/projectexplorer/projectexplorerconstants.h4
-rw-r--r--src/plugins/projectexplorer/taskhub.cpp26
-rw-r--r--src/plugins/texteditor/textmark.cpp30
-rw-r--r--src/plugins/texteditor/textmark.h10
-rw-r--r--src/plugins/texteditor/textmarkregistry.h9
-rw-r--r--src/plugins/valgrind/callgrindtextmark.cpp5
17 files changed, 122 insertions, 14 deletions
diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme
index 0b81d5275f..98004dea07 100644
--- a/share/qtcreator/themes/dark.creatortheme
+++ b/share/qtcreator/themes/dark.creatortheme
@@ -100,6 +100,8 @@ Debugger_WatchItem_ValueNormal=text
Debugger_WatchItem_ValueInvalid=textDisabled
Debugger_WatchItem_ValueChanged=ffbf0303
+Debugger_Breakpoint_TextMarkColor=60ff2020
+
Welcome_BackgroundColorNormal=normalBackground
Welcome_Button_BorderColorNormal=0
Welcome_Button_BorderColorPressed=0
@@ -126,6 +128,11 @@ VcsBase_FileModified_TextColor=ff8ee0ff
VcsBase_FileDeleted_TextColor=fffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500
+Bookmark_TextMarkColor=804040ff
+
+ProjectExplorer_TaskError_TextMarkColor=a0ff4040
+ProjectExplorer_TaskWarn_TextMarkColor=80ffff20
+
[Flags]
ComboBoxDrawTextShadow=false
DerivePaletteFromTheme=true
diff --git a/share/qtcreator/themes/default.creatortheme b/share/qtcreator/themes/default.creatortheme
index 32ebc72fea..6711454e8b 100644
--- a/share/qtcreator/themes/default.creatortheme
+++ b/share/qtcreator/themes/default.creatortheme
@@ -94,6 +94,8 @@ Debugger_WatchItem_ValueNormal=ff000000
Debugger_WatchItem_ValueInvalid=ff8c8c8c
Debugger_WatchItem_ValueChanged=ffc80000
+Debugger_Breakpoint_TextMarkColor=80ff0000
+
Welcome_BackgroundColorNormal=ffffffff
Welcome_Button_BorderColorNormal=ff737373
Welcome_Button_BorderColorPressed=ff333333
@@ -120,6 +122,11 @@ VcsBase_FileModified_TextColor=ff0000ee
VcsBase_FileDeleted_TextColor=ffee0000
VcsBase_FileRenamed_TextColor=ffd77d00
+Bookmark_TextMarkColor=800000ff
+
+ProjectExplorer_TaskError_TextMarkColor=80800000
+ProjectExplorer_TaskWarn_TextMarkColor=80ffff00
+
[Flags]
ComboBoxDrawTextShadow=true
DerivePaletteFromTheme=false
diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h
index a5b0cc9d33..92a57cd0f7 100644
--- a/src/libs/utils/theme/theme.h
+++ b/src/libs/utils/theme/theme.h
@@ -58,6 +58,7 @@ public:
~Theme();
enum Color {
+ InvalidColor,
BackgroundColorAlternate,
BackgroundColorDark,
BackgroundColorHover,
@@ -180,7 +181,17 @@ public:
VcsBase_FileAdded_TextColor,
VcsBase_FileModified_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 {
diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp
index 29c4d83328..70c0352d11 100644
--- a/src/plugins/bookmarks/bookmark.cpp
+++ b/src/plugins/bookmarks/bookmark.cpp
@@ -30,6 +30,7 @@
#include "bookmark.h"
#include "bookmarkmanager.h"
+#include "bookmarks_global.h"
#include <QDebug>
#include <QFileInfo>
@@ -38,7 +39,7 @@
using namespace Bookmarks::Internal;
Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) :
- TextMark(QString(), lineNumber),
+ TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY),
m_manager(manager)
{
setPriority(TextEditor::TextMark::NormalPriority);
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index e4de592623..1d7b08905a 100644
--- a/src/plugins/bookmarks/bookmarkmanager.cpp
+++ b/src/plugins/bookmarks/bookmarkmanager.cpp
@@ -45,6 +45,7 @@
#include <utils/tooltip/tooltip.h>
#include <utils/qtcassert.h>
#include <utils/checkablemessagebox.h>
+#include <utils/theme/theme.h>
#include <QAction>
#include <QContextMenuEvent>
@@ -331,6 +332,8 @@ BookmarkManager::BookmarkManager() :
this, &BookmarkManager::loadBookmarks);
updateActionStatus();
+ Bookmark::setCategoryColor(Constants::BOOKMARKS_TEXT_MARK_CATEGORY,
+ Theme::Bookmarks_TextMarkColor);
}
BookmarkManager::~BookmarkManager()
diff --git a/src/plugins/bookmarks/bookmarks_global.h b/src/plugins/bookmarks/bookmarks_global.h
index 9151937fc0..08d0fc6f74 100644
--- a/src/plugins/bookmarks/bookmarks_global.h
+++ b/src/plugins/bookmarks/bookmarks_global.h
@@ -44,6 +44,7 @@ const char BOOKMARKS_PREVDIR_ACTION[] = "Bookmarks.PreviousDirectory";
const char BOOKMARKS_NEXTDIR_ACTION[] = "Bookmarks.NextDirectory";
const char BOOKMARKS_PREVDOC_ACTION[] = "Bookmarks.PreviousDocument";
const char BOOKMARKS_NEXTDOC_ACTION[] = "Bookmarks.NextDocument";
+const char BOOKMARKS_TEXT_MARK_CATEGORY[] = "Bookmarks.TextMarkCategory";
const char BOOKMARKS_MENU[] = "Bookmarks.Menu";
const char BOOKMARKS_CONTEXT[] = "Bookmarks";
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp
index 21d49a868c..93ee101b89 100644
--- a/src/plugins/debugger/breakhandler.cpp
+++ b/src/plugins/debugger/breakhandler.cpp
@@ -48,6 +48,7 @@
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
+#include <utils/theme/theme.h>
#if USE_BREAK_MODEL_TEST
#include <modeltest.h>
@@ -145,7 +146,7 @@ class BreakpointMarker : public TextEditor::TextMark
{
public:
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());
setPriority(TextEditor::TextMark::NormalPriority);
@@ -253,6 +254,8 @@ BreakHandler::BreakHandler()
: m_syncTimerId(-1)
{
qRegisterMetaType<BreakpointModelId>();
+ TextEditor::TextMark::setCategoryColor(Constants::TEXT_MARK_CATEGORY_BREAKPOINT,
+ Utils::Theme::Debugger_Breakpoint_TextMarkColor);
#if USE_BREAK_MODEL_TEST
new ModelTest(this, 0);
diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h
index 800e81bac1..f0f69da3bd 100644
--- a/src/plugins/debugger/debuggerconstants.h
+++ b/src/plugins/debugger/debuggerconstants.h
@@ -69,6 +69,9 @@ const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo";
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:
const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768;
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index c9234c8fa0..1ec592bc81 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -610,7 +610,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
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->setPriority(TextMark::HighPriority);
}
diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp
index 9269a8aafc..a7df1f215e 100644
--- a/src/plugins/debugger/disassembleragent.cpp
+++ b/src/plugins/debugger/disassembleragent.cpp
@@ -116,7 +116,7 @@ public:
DisassemblerAgentPrivate::DisassemblerAgentPrivate()
: document(0),
- locationMark(QString(), 0),
+ locationMark(QString(), 0, Constants::TEXT_MARK_CATEGORY_LOCATION),
mimeType(_("text/x-qtcreator-generic-asm")),
resetLocationScheduled(false)
{
@@ -352,7 +352,8 @@ void DisassemblerAgent::updateBreakpointMarkers()
const int lineNumber = contents.lineForAddress(address);
if (!lineNumber)
continue;
- TextMark *marker = new TextMark(QString(), lineNumber);
+ TextMark *marker = new TextMark(QString(), lineNumber,
+ Constants::TEXT_MARK_CATEGORY_BREAKPOINT);
marker->setIcon(bp.icon());
marker->setPriority(TextMark::NormalPriority);
d->breakpointMarks.append(marker);
diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp
index 3cf6ccea5b..7fa8562916 100644
--- a/src/plugins/debugger/sourceagent.cpp
+++ b/src/plugins/debugger/sourceagent.cpp
@@ -144,7 +144,8 @@ void SourceAgent::updateLocationMarker()
if (d->engine->stackHandler()->currentFrame().file == d->path) {
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->setPriority(TextMark::HighPriority);
diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h
index 562713dddf..37a346332c 100644
--- a/src/plugins/projectexplorer/projectexplorerconstants.h
+++ b/src/plugins/projectexplorer/projectexplorerconstants.h
@@ -194,6 +194,10 @@ const char TASK_CATEGORY_COMPILE[] = "Task.Category.Compile";
const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem";
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
const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project";
const char QT_PROJECT_WIZARD_CATEGORY_DISPLAY[] = QT_TRANSLATE_NOOP("ProjectExplorer", "Other Project");
diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp
index 59e205c618..07ebff0c4e 100644
--- a/src/plugins/projectexplorer/taskhub.cpp
+++ b/src/plugins/projectexplorer/taskhub.cpp
@@ -29,21 +29,36 @@
****************************************************************************/
#include "taskhub.h"
+#include "projectexplorerconstants.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/ioutputpane.h>
#include <utils/qtcassert.h>
+#include <utils/theme/theme.h>
using namespace ProjectExplorer;
TaskHub *m_instance = 0;
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
{
public:
- TaskMark(unsigned int id, const QString &fileName, int lineNumber, bool visible)
- : TextMark(fileName, lineNumber), m_id(id)
+ TaskMark(unsigned int id, const QString &fileName, int lineNumber, Task::TaskType type, bool visible)
+ : TextMark(fileName, lineNumber, categoryForType(type))
+ , m_id(id)
{
setVisible(visible);
}
@@ -92,6 +107,10 @@ TaskHub::TaskHub()
m_instance = this;
qRegisterMetaType<ProjectExplorer::Task>("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()
@@ -130,7 +149,8 @@ void TaskHub::addTask(Task task)
task.movedLine = task.line;
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->setPriority(TextEditor::TextMark::LowPriority);
task.addMark(mark);
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index 222a0ba06f..e499ada3ba 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -44,12 +44,13 @@ using namespace TextEditor::Internal;
namespace TextEditor {
-TextMark::TextMark(const QString &fileName, int lineNumber)
+TextMark::TextMark(const QString &fileName, int lineNumber, Id category)
: m_baseTextDocument(0),
m_fileName(fileName),
m_lineNumber(lineNumber),
m_priority(NormalPriority),
m_visible(true),
+ m_category(category),
m_widthFactor(1.0)
{
if (!m_fileName.isEmpty())
@@ -116,6 +117,16 @@ void TextMark::setIcon(const QIcon &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()
{
if (m_baseTextDocument)
@@ -144,6 +155,11 @@ void TextMark::setVisible(bool visible)
m_baseTextDocument->updateMark(this);
}
+Id TextMark::category() const
+{
+ return m_category;
+}
+
double TextMark::widthFactor() const
{
return m_widthFactor;
@@ -209,6 +225,18 @@ bool TextMarkRegistry::remove(TextMark *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)
{
auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0);
diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h
index 85726d521c..e91ba41da3 100644
--- a/src/plugins/texteditor/textmark.h
+++ b/src/plugins/texteditor/textmark.h
@@ -33,6 +33,9 @@
#include "texteditor_global.h"
+#include <coreplugin/id.h>
+#include <utils/theme/theme.h>
+
#include <QIcon>
QT_BEGIN_NAMESPACE
@@ -51,7 +54,7 @@ namespace Internal { class TextMarkRegistry; }
class TEXTEDITOR_EXPORT TextMark
{
public:
- TextMark(const QString &fileName, int lineNumber);
+ TextMark(const QString &fileName, int lineNumber, Core::Id category);
virtual ~TextMark();
// determine order on markers on the same line.
@@ -77,6 +80,8 @@ public:
virtual bool isDraggable() const;
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);
// call this if the icon has changed.
void updateMarker();
@@ -84,6 +89,7 @@ public:
void setPriority(Priority prioriy);
bool isVisible() const;
void setVisible(bool isVisible);
+ Core::Id category() const;
double widthFactor() const;
void setWidthFactor(double factor);
@@ -100,6 +106,8 @@ private:
Priority m_priority;
bool m_visible;
QIcon m_icon;
+ QColor m_color;
+ Core::Id m_category;
double m_widthFactor;
};
diff --git a/src/plugins/texteditor/textmarkregistry.h b/src/plugins/texteditor/textmarkregistry.h
index 052627b9af..8231aab051 100644
--- a/src/plugins/texteditor/textmarkregistry.h
+++ b/src/plugins/texteditor/textmarkregistry.h
@@ -33,10 +33,14 @@
#include <utils/fileutils.h>
-#include <QObject>
+#include <QColor>
#include <QHash>
+#include <QObject>
#include <QSet>
+#include <coreplugin/id.h>
+#include <utils/theme/theme.h>
+
namespace Core {
class IEditor;
class IDocument;
@@ -54,12 +58,15 @@ public:
void add(TextMark *mark);
bool remove(TextMark *mark);
+ Utils::Theme::Color categoryColor(Core::Id category);
+ void setCategoryColor(Core::Id category, Utils::Theme::Color color);
private slots:
void editorOpened(Core::IEditor *editor);
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
void allDocumentsRenamed(const QString &oldName, const QString &newName);
private:
QHash<Utils::FileName, QSet<TextMark *> > m_marks;
+ QHash<Core::Id, Utils::Theme::Color> m_colors;
};
} // namespace Internal
diff --git a/src/plugins/valgrind/callgrindtextmark.cpp b/src/plugins/valgrind/callgrindtextmark.cpp
index 064025268e..058871047d 100644
--- a/src/plugins/valgrind/callgrindtextmark.cpp
+++ b/src/plugins/valgrind/callgrindtextmark.cpp
@@ -43,9 +43,12 @@
using namespace Valgrind::Internal;
using namespace Valgrind::Callgrind;
+namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; }
+
CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index,
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);
setWidthFactor(4.0);