Commit ab2a0d74 authored by David Schulz's avatar David Schulz Committed by Orgad Shaneh
Browse files

TextEditor: Sort text marks in categories.



Also adding a color for each category.

Change-Id: I3627d13913951a95804b5a816f087a822c01bd86
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent a6e1c3cb
......@@ -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
......
......@@ -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
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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()
......
......@@ -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";
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
};
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment