forked from qt-creator/qt-creator
Make TODO plugin theme aware
Use the theme's colors by default and color the text rather than the background of items. Task-number: QTCREATORBUG-17532 Change-Id: I65a2d6da45ce7547b05463a2fb014f8230d0c336 Reviewed-by: Serhii Moroz <frost.asm@gmail.com> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -119,7 +119,6 @@ TextColorHighlight=ffff0000
|
|||||||
TextColorLink=textColorLink
|
TextColorLink=textColorLink
|
||||||
TextColorLinkVisited=textColorLinkVisited
|
TextColorLinkVisited=textColorLinkVisited
|
||||||
TextColorNormal=text
|
TextColorNormal=text
|
||||||
TodoItemTextColor=ff000000
|
|
||||||
ToggleButtonBackgroundColor=shadowBackground
|
ToggleButtonBackgroundColor=shadowBackground
|
||||||
ToolBarBackgroundColor=shadowBackground
|
ToolBarBackgroundColor=shadowBackground
|
||||||
TreeViewArrowColorNormal=hoverBackground
|
TreeViewArrowColorNormal=hoverBackground
|
||||||
|
@@ -111,7 +111,6 @@ TextColorHighlight=ffa0a0a4
|
|||||||
TextColorLink=ff0057ae
|
TextColorLink=ff0057ae
|
||||||
TextColorLinkVisited=ff644a9b
|
TextColorLinkVisited=ff644a9b
|
||||||
TextColorNormal=ff000000
|
TextColorNormal=ff000000
|
||||||
TodoItemTextColor=ff000000
|
|
||||||
ToggleButtonBackgroundColor=ffff0000
|
ToggleButtonBackgroundColor=ffff0000
|
||||||
ToolBarBackgroundColor=ffff0000
|
ToolBarBackgroundColor=ffff0000
|
||||||
TreeViewArrowColorNormal=ffff0000
|
TreeViewArrowColorNormal=ffff0000
|
||||||
|
@@ -124,7 +124,6 @@ TextColorHighlight=ffff0000
|
|||||||
TextColorLink=textColorLink
|
TextColorLink=textColorLink
|
||||||
TextColorLinkVisited=textColorLinkVisited
|
TextColorLinkVisited=textColorLinkVisited
|
||||||
TextColorNormal=text
|
TextColorNormal=text
|
||||||
TodoItemTextColor=ff000000
|
|
||||||
ToggleButtonBackgroundColor=shadowBackground
|
ToggleButtonBackgroundColor=shadowBackground
|
||||||
ToolBarBackgroundColor=shadowBackground
|
ToolBarBackgroundColor=shadowBackground
|
||||||
TreeViewArrowColorNormal=hoverBackground
|
TreeViewArrowColorNormal=hoverBackground
|
||||||
|
@@ -122,7 +122,6 @@ TextColorHighlight=ffff0000
|
|||||||
TextColorLink=ff007af4
|
TextColorLink=ff007af4
|
||||||
TextColorLinkVisited=ffa57aff
|
TextColorLinkVisited=ffa57aff
|
||||||
TextColorNormal=text
|
TextColorNormal=text
|
||||||
TodoItemTextColor=ff000000
|
|
||||||
ToggleButtonBackgroundColor=shadowBackground
|
ToggleButtonBackgroundColor=shadowBackground
|
||||||
ToolBarBackgroundColor=shadowBackground
|
ToolBarBackgroundColor=shadowBackground
|
||||||
TreeViewArrowColorNormal=hoverBackground
|
TreeViewArrowColorNormal=hoverBackground
|
||||||
|
@@ -120,7 +120,6 @@ TextColorHighlight=ffff0000
|
|||||||
TextColorLink=ff007af4
|
TextColorLink=ff007af4
|
||||||
TextColorLinkVisited=ffa57aff
|
TextColorLinkVisited=ffa57aff
|
||||||
TextColorNormal=text
|
TextColorNormal=text
|
||||||
TodoItemTextColor=ff000000
|
|
||||||
ToggleButtonBackgroundColor=shadowBackground
|
ToggleButtonBackgroundColor=shadowBackground
|
||||||
ToolBarBackgroundColor=shadowBackground
|
ToolBarBackgroundColor=shadowBackground
|
||||||
TreeViewArrowColorNormal=hoverBackground
|
TreeViewArrowColorNormal=hoverBackground
|
||||||
|
@@ -119,7 +119,6 @@ public:
|
|||||||
TextColorLink,
|
TextColorLink,
|
||||||
TextColorLinkVisited,
|
TextColorLinkVisited,
|
||||||
TextColorNormal,
|
TextColorNormal,
|
||||||
TodoItemTextColor,
|
|
||||||
ToggleButtonBackgroundColor,
|
ToggleButtonBackgroundColor,
|
||||||
ToolBarBackgroundColor,
|
ToolBarBackgroundColor,
|
||||||
TreeViewArrowColorNormal,
|
TreeViewArrowColorNormal,
|
||||||
|
@@ -31,13 +31,6 @@
|
|||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
// Default todo item background colors
|
|
||||||
const char COLOR_TODO_BG[] = "#ccffcc";
|
|
||||||
const char COLOR_WARNING_BG[] = "#ffffcc";
|
|
||||||
const char COLOR_FIXME_BG[] = "#ffcccc";
|
|
||||||
const char COLOR_BUG_BG[] = "#ffcccc";
|
|
||||||
const char COLOR_NOTE_BG[] = "#e0ebff";
|
|
||||||
|
|
||||||
// Dummy, needs to be changed
|
// Dummy, needs to be changed
|
||||||
const char ICON_TODO[] = ":/todoplugin/images/todo.png";
|
const char ICON_TODO[] = ":/todoplugin/images/todo.png";
|
||||||
|
|
||||||
|
@@ -25,11 +25,12 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
Keyword::Keyword() : color(Qt::white)
|
Keyword::Keyword() : color(Utils::creatorTheme()->color(Utils::Theme::TextColorNormal))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,7 +75,7 @@ void OptionsDialog::addToKeywordsList(const Keyword &keyword)
|
|||||||
QListWidgetItem *item = new QListWidgetItem(
|
QListWidgetItem *item = new QListWidgetItem(
|
||||||
icon(keyword.iconType), keyword.name);
|
icon(keyword.iconType), keyword.name);
|
||||||
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
||||||
item->setBackgroundColor(keyword.color);
|
item->setTextColor(keyword.color);
|
||||||
ui->keywordsList->addItem(item);
|
ui->keywordsList->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item)
|
|||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = item->text();
|
keyword.name = item->text();
|
||||||
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
||||||
keyword.color = item->backgroundColor();
|
keyword.color = item->textColor();
|
||||||
|
|
||||||
QSet<QString> keywordNamesButThis = keywordNames();
|
QSet<QString> keywordNamesButThis = keywordNames();
|
||||||
keywordNamesButThis.remove(keyword.name);
|
keywordNamesButThis.remove(keyword.name);
|
||||||
@@ -127,7 +127,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item)
|
|||||||
item->setIcon(icon(keyword.iconType));
|
item->setIcon(icon(keyword.iconType));
|
||||||
item->setText(keyword.name);
|
item->setText(keyword.name);
|
||||||
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
||||||
item->setBackgroundColor(keyword.color);
|
item->setTextColor(keyword.color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ Settings OptionsDialog::settingsFromUi()
|
|||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = item->text();
|
keyword.name = item->text();
|
||||||
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
||||||
keyword.color = item->backgroundColor();
|
keyword.color = item->textColor();
|
||||||
|
|
||||||
settings.keywords << keyword;
|
settings.keywords << keyword;
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
@@ -110,6 +111,7 @@ void Settings::load(QSettings *settings)
|
|||||||
void Settings::setDefault()
|
void Settings::setDefault()
|
||||||
{
|
{
|
||||||
scanningScope = ScanningScopeCurrentFile;
|
scanningScope = ScanningScopeCurrentFile;
|
||||||
|
Utils::Theme *theme = Utils::creatorTheme();
|
||||||
|
|
||||||
keywords.clear();
|
keywords.clear();
|
||||||
|
|
||||||
@@ -117,27 +119,27 @@ void Settings::setDefault()
|
|||||||
|
|
||||||
keyword.name = QLatin1String("TODO");
|
keyword.name = QLatin1String("TODO");
|
||||||
keyword.iconType = IconType::Todo;
|
keyword.iconType = IconType::Todo;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_TODO_BG));
|
keyword.color = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor);
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("NOTE");
|
keyword.name = QLatin1String("NOTE");
|
||||||
keyword.iconType = IconType::Info;
|
keyword.iconType = IconType::Info;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_NOTE_BG));
|
keyword.color = theme->color(Utils::Theme::OutputPanes_NormalMessageTextColor);
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("FIXME");
|
keyword.name = QLatin1String("FIXME");
|
||||||
keyword.iconType = IconType::Error;
|
keyword.iconType = IconType::Error;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_FIXME_BG));
|
keyword.color = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor);
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("BUG");
|
keyword.name = QLatin1String("BUG");
|
||||||
keyword.iconType = IconType::Bug;
|
keyword.iconType = IconType::Bug;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_BUG_BG));
|
keyword.color = theme->color(Utils::Theme::OutputPanes_ErrorMessageTextColor);
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("WARNING");
|
keyword.name = QLatin1String("WARNING");
|
||||||
keyword.iconType = IconType::Warning;
|
keyword.iconType = IconType::Warning;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_WARNING_BG));
|
keyword.color = theme->color(Utils::Theme::OutputPanes_WarningMessageTextColor);
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keywordsEdited = false;
|
keywordsEdited = false;
|
||||||
|
@@ -80,10 +80,8 @@ QVariant TodoItemsModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
TodoItem item = m_todoItemsList->at(index.row());
|
TodoItem item = m_todoItemsList->at(index.row());
|
||||||
|
|
||||||
if (role == Qt::BackgroundColorRole)
|
|
||||||
return item.color;
|
|
||||||
if (role == Qt::TextColorRole)
|
if (role == Qt::TextColorRole)
|
||||||
return creatorTheme()->color(Theme::TodoItemTextColor);
|
return item.color;
|
||||||
|
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
|
|
||||||
|
@@ -178,7 +178,7 @@ void TodoOutputPane::todoTreeViewClicked(const QModelIndex &index)
|
|||||||
item.text = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data().toString();
|
item.text = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data().toString();
|
||||||
item.file = Utils::FileName::fromUserInput(index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString());
|
item.file = Utils::FileName::fromUserInput(index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString());
|
||||||
item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt();
|
item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt();
|
||||||
item.color = index.data(Qt::BackgroundColorRole).value<QColor>();
|
item.color = index.data(Qt::TextColorRole).value<QColor>();
|
||||||
item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT)
|
item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT)
|
||||||
.data(Qt::UserRole).toInt());
|
.data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user