Git: Port colorful log to text colors

Fixes: QTCREATORBUG-24198
Change-Id: Icde06da5ac848fb0f7faf02a8e55fb26136f318c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Andre Hartmann
2020-07-01 21:31:09 +02:00
committed by André Hartmann
parent e3312205ed
commit c9eedbe0f3
17 changed files with 74 additions and 58 deletions

View File

@@ -57,6 +57,11 @@
<style name="DiffDestLine" background="#588a2c"/> <style name="DiffDestLine" background="#588a2c"/>
<style name="DiffDestChar" foreground="#2e2f30" background="#7cc33e"/> <style name="DiffDestChar" foreground="#2e2f30" background="#7cc33e"/>
<style name="LogChangeLine" foreground="#d65645"/> <style name="LogChangeLine" foreground="#d65645"/>
<style name="LogAuthorName" foreground="#ceffe5"/>
<style name="LogCommitDate" foreground="#00ff00"/>
<style name="LogCommitHash" foreground="#ff0000"/>
<style name="LogCommitSubject" foreground="#d6cf9a"/>
<style name="LogDecoration" foreground="#ff00ff"/>
<style name="Warning" underlineColor="#d6c545" underlineStyle="SingleUnderline"/> <style name="Warning" underlineColor="#d6c545" underlineStyle="SingleUnderline"/>
<style name="WarningContext" underlineColor="#d6c545" underlineStyle="DotLine"/> <style name="WarningContext" underlineColor="#d6c545" underlineStyle="DotLine"/>
<style name="Error" underlineColor="#d65645" underlineStyle="SingleUnderline"/> <style name="Error" underlineColor="#d65645" underlineStyle="SingleUnderline"/>

View File

@@ -58,4 +58,9 @@
<style name="DiffDestLine" background="#2d8c2d"/> <style name="DiffDestLine" background="#2d8c2d"/>
<style name="DiffDestChar" foreground="#000000" background="#41c341"/> <style name="DiffDestChar" foreground="#000000" background="#41c341"/>
<style name="LogChangeLine" foreground="#808000"/> <style name="LogChangeLine" foreground="#808000"/>
<style name="LogAuthorName" foreground="#ceffe5"/>
<style name="LogCommitDate" foreground="#00ff00"/>
<style name="LogCommitHash" foreground="#ff0000"/>
<style name="LogCommitSubject" foreground="#d6cf9a"/>
<style name="LogDecoration" foreground="#ff00ff"/>
</style-scheme> </style-scheme>

View File

@@ -66,5 +66,10 @@
<style name="DiffDestLine" background="#277027"/> <style name="DiffDestLine" background="#277027"/>
<style name="DiffDestChar" background="#339d33"/> <style name="DiffDestChar" background="#339d33"/>
<style name="LogChangeLine" foreground="#dcdc00"/> <style name="LogChangeLine" foreground="#dcdc00"/>
<style name="LogAuthorName" foreground="#ceffe5"/>
<style name="LogCommitDate" foreground="#00ff00"/>
<style name="LogCommitHash" foreground="#ff0000"/>
<style name="LogCommitSubject" foreground="#d6cf9a"/>
<style name="LogDecoration" foreground="#ff00ff"/>
</style-scheme> </style-scheme>

View File

@@ -62,5 +62,11 @@
<style name="DiffSourceChar" foreground="#000000" background="#c34141"/> <style name="DiffSourceChar" foreground="#000000" background="#c34141"/>
<style name="DiffDestLine" background="#2d8c2d"/> <style name="DiffDestLine" background="#2d8c2d"/>
<style name="DiffDestChar" foreground="#000000" background="#41c341"/> <style name="DiffDestChar" foreground="#000000" background="#41c341"/>
<style name="LogChangeLine" foreground="#dcdc00"/>
<style name="LogAuthorName" foreground="#ceffe5"/>
<style name="LogCommitDate" foreground="#00ff00"/>
<style name="LogCommitHash" foreground="#ff0000"/>
<style name="LogCommitSubject" foreground="#d6cf9a"/>
<style name="LogDecoration" foreground="#ff00ff"/>
<style name="Declaration"/> <style name="Declaration"/>
</style-scheme> </style-scheme>

View File

@@ -63,6 +63,11 @@
<style name="DiffDestLine" background="#dfffdf"/> <style name="DiffDestLine" background="#dfffdf"/>
<style name="DiffDestChar" background="#afffaf"/> <style name="DiffDestChar" background="#afffaf"/>
<style name="LogChangeLine" foreground="#c00000"/> <style name="LogChangeLine" foreground="#c00000"/>
<style name="LogAuthorName" foreground="#ceffe5"/>
<style name="LogCommitDate" foreground="#00ff00"/>
<style name="LogCommitHash" foreground="#ff0000"/>
<style name="LogCommitSubject" foreground="#d6cf9a"/>
<style name="LogDecoration" foreground="#ff00ff"/>
<style name="Warning" underlineColor="#b58900" underlineStyle="SingleUnderline"/> <style name="Warning" underlineColor="#b58900" underlineStyle="SingleUnderline"/>
<style name="WarningContext" underlineColor="#b58900" underlineStyle="DotLine"/> <style name="WarningContext" underlineColor="#b58900" underlineStyle="DotLine"/>
<style name="Error" underlineColor="#dc322f" underlineStyle="SingleUnderline"/> <style name="Error" underlineColor="#dc322f" underlineStyle="SingleUnderline"/>

View File

@@ -223,12 +223,6 @@ VcsBase_FileDeleted_TextColor=ffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500 VcsBase_FileRenamed_TextColor=ffffa500
VcsBase_FileUnmerged_TextColor=ffff4040 VcsBase_FileUnmerged_TextColor=ffff4040
Git_AuthorName_TextColor=ceffe5
Git_CommitDate_TextColor=00ff00
Git_CommitHash_TextColor=ff0000
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ff8080ff Bookmarks_TextMarkColor=ff8080ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -214,12 +214,6 @@ VcsBase_FileDeleted_TextColor=ff800000
VcsBase_FileRenamed_TextColor=ffd77d00 VcsBase_FileRenamed_TextColor=ffd77d00
VcsBase_FileUnmerged_TextColor=ffee0000 VcsBase_FileUnmerged_TextColor=ffee0000
Git_AuthorName_TextColor=007af4
Git_CommitDate_TextColor=006600
Git_CommitHash_TextColor=ff0000
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ffa0a0ff Bookmarks_TextMarkColor=ffa0a0ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -227,12 +227,6 @@ VcsBase_FileDeleted_TextColor=fffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500 VcsBase_FileRenamed_TextColor=ffffa500
VcsBase_FileUnmerged_TextColor=ffff4040 VcsBase_FileUnmerged_TextColor=ffff4040
Git_AuthorName_TextColor=ceffe5
Git_CommitDate_TextColor=00ff00
Git_CommitHash_TextColor=ff4343
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ff8080ff Bookmarks_TextMarkColor=ff8080ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -227,12 +227,6 @@ VcsBase_FileDeleted_TextColor=fffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500 VcsBase_FileRenamed_TextColor=ffffa500
VcsBase_FileUnmerged_TextColor=ffff4040 VcsBase_FileUnmerged_TextColor=ffff4040
Git_AuthorName_TextColor=ceffe5
Git_CommitDate_TextColor=00ff00
Git_CommitHash_TextColor=ff4343
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ff8080ff Bookmarks_TextMarkColor=ff8080ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -223,12 +223,6 @@ VcsBase_FileDeleted_TextColor=ff800000
VcsBase_FileRenamed_TextColor=ffd77d00 VcsBase_FileRenamed_TextColor=ffd77d00
VcsBase_FileUnmerged_TextColor=ffee0000 VcsBase_FileUnmerged_TextColor=ffee0000
Git_AuthorName_TextColor=007af4
Git_CommitDate_TextColor=006600
Git_CommitHash_TextColor=ff0000
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ffa0a0ff Bookmarks_TextMarkColor=ffa0a0ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -221,12 +221,6 @@ VcsBase_FileDeleted_TextColor=ff800000
VcsBase_FileRenamed_TextColor=ffd77d00 VcsBase_FileRenamed_TextColor=ffd77d00
VcsBase_FileUnmerged_TextColor=ffee0000 VcsBase_FileUnmerged_TextColor=ffee0000
Git_AuthorName_TextColor=007af4
Git_CommitDate_TextColor=006600
Git_CommitHash_TextColor=ff0000
Git_CommitSubject_TextColor=text
Git_Decoration_TextColor=ff00ff
Bookmarks_TextMarkColor=ffa0a0ff Bookmarks_TextMarkColor=ffa0a0ff
TextEditor_SearchResult_ScrollBarColor=ff00c000 TextEditor_SearchResult_ScrollBarColor=ff00c000

View File

@@ -279,13 +279,6 @@ public:
VcsBase_FileRenamed_TextColor, VcsBase_FileRenamed_TextColor,
VcsBase_FileUnmerged_TextColor, VcsBase_FileUnmerged_TextColor,
/* Git Plugin */
Git_AuthorName_TextColor,
Git_CommitDate_TextColor,
Git_CommitHash_TextColor,
Git_CommitSubject_TextColor,
Git_Decoration_TextColor,
/* Bookmarks Plugin */ /* Bookmarks Plugin */
Bookmarks_TextMarkColor, Bookmarks_TextMarkColor,

View File

@@ -570,6 +570,17 @@ static bool gitHasRgbColors()
return gitVersion >= 0x020300U; return gitVersion >= 0x020300U;
} }
static QString logColorName(TextEditor::TextStyle style)
{
using namespace TextEditor;
const ColorScheme &scheme = TextEditorSettings::fontSettings().colorScheme();
QColor color = scheme.formatFor(style).foreground();
if (!color.isValid())
color = scheme.formatFor(C_TEXT).foreground();
return color.name();
};
class GitLogArgumentsWidget : public BaseGitLogArgumentsWidget class GitLogArgumentsWidget : public BaseGitLogArgumentsWidget
{ {
Q_OBJECT Q_OBJECT
@@ -603,12 +614,11 @@ public:
QStringList graphArguments() const QStringList graphArguments() const
{ {
auto colorName = [](Theme::Color color) { return creatorTheme()->color(color).name(); }; const QString authorName = logColorName(TextEditor::C_LOG_AUTHOR_NAME);
const QString authorName = colorName(Theme::Git_AuthorName_TextColor); const QString commitDate = logColorName(TextEditor::C_LOG_COMMIT_DATE);
const QString commitDate = colorName(Theme::Git_CommitDate_TextColor); const QString commitHash = logColorName(TextEditor::C_LOG_COMMIT_HASH);
const QString commitHash = colorName(Theme::Git_CommitHash_TextColor); const QString commitSubject = logColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
const QString commitSubject = colorName(Theme::Git_CommitSubject_TextColor); const QString decoration = logColorName(TextEditor::C_LOG_DECORATION);
const QString decoration = colorName(Theme::Git_Decoration_TextColor);
const QString formatArg = QStringLiteral( const QString formatArg = QStringLiteral(
"--pretty=format:" "--pretty=format:"
@@ -1051,19 +1061,18 @@ static QStringList normalLogArguments()
if (!gitHasRgbColors()) if (!gitHasRgbColors())
return {}; return {};
auto colorName = [](Theme::Color color) { return creatorTheme()->color(color).name(); }; const QString authorName = logColorName(TextEditor::C_LOG_AUTHOR_NAME);
const QString authorName = colorName(Theme::Git_AuthorName_TextColor); const QString commitDate = logColorName(TextEditor::C_LOG_COMMIT_DATE);
const QString commitDate = colorName(Theme::Git_CommitDate_TextColor); const QString commitHash = logColorName(TextEditor::C_LOG_COMMIT_HASH);
const QString commitHash = colorName(Theme::Git_CommitHash_TextColor); const QString commitSubject = logColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
const QString commitSubject = colorName(Theme::Git_CommitSubject_TextColor); const QString decoration = logColorName(TextEditor::C_LOG_DECORATION);
const QString decoration = colorName(Theme::Git_Decoration_TextColor);
const QString logArgs = QStringLiteral( const QString logArgs = QStringLiteral(
"--pretty=format:" "--pretty=format:"
"commit %C(%1)%H%Creset %C(%2)%d%Creset%n" "commit %C(%1)%H%Creset %C(%2)%d%Creset%n"
"Author: %C(%3)%an <%ae>%Creset%n" "Author: %C(%3)%an <%ae>%Creset%n"
"Date: %C(%4)%cD%Creset%n%n" "Date: %C(%4)%cD%Creset%n%n"
"%C(%5)%s%Creset%n%n%b%n" "%C(%5)%w(0,4,4)%s%Creset%n%n%b"
).arg(commitHash, decoration, authorName, commitDate, commitSubject); ).arg(commitHash, decoration, authorName, commitDate, commitSubject);
return {logArgs}; return {logArgs};

View File

@@ -101,7 +101,7 @@ inline bool operator!=(const Format &f1, const Format &f2) { return !f1.equals(f
/*! A color scheme combines a set of formats for different highlighting /*! A color scheme combines a set of formats for different highlighting
categories. It also provides saving and loading of the scheme to a file. categories. It also provides saving and loading of the scheme to a file.
*/ */
class ColorScheme class TEXTEDITOR_EXPORT ColorScheme
{ {
public: public:
void setDisplayName(const QString &name) void setDisplayName(const QString &name)

View File

@@ -97,6 +97,11 @@ const char *nameForStyle(TextStyle style)
case C_DIFF_DEST_CHAR: return "DiffDestChar"; case C_DIFF_DEST_CHAR: return "DiffDestChar";
case C_LOG_CHANGE_LINE: return "LogChangeLine"; case C_LOG_CHANGE_LINE: return "LogChangeLine";
case C_LOG_AUTHOR_NAME: return "LogAuthorName";
case C_LOG_COMMIT_DATE: return "LogCommitDate";
case C_LOG_COMMIT_HASH: return "LogCommitHash";
case C_LOG_COMMIT_SUBJECT: return "LogCommitSubject";
case C_LOG_DECORATION: return "LogDecoration";
case C_ERROR: return "Error"; case C_ERROR: return "Error";
case C_ERROR_CONTEXT: return "ErrorContext"; case C_ERROR_CONTEXT: return "ErrorContext";

View File

@@ -97,6 +97,11 @@ enum TextStyle : quint8 {
C_DIFF_DEST_CHAR, C_DIFF_DEST_CHAR,
C_LOG_CHANGE_LINE, C_LOG_CHANGE_LINE,
C_LOG_AUTHOR_NAME,
C_LOG_COMMIT_DATE,
C_LOG_COMMIT_HASH,
C_LOG_COMMIT_SUBJECT,
C_LOG_DECORATION,
C_WARNING, C_WARNING,
C_WARNING_CONTEXT, C_WARNING_CONTEXT,

View File

@@ -303,7 +303,21 @@ FormatDescriptions TextEditorSettingsPrivate::initialFormats()
formatDescr.emplace_back(C_LOG_CHANGE_LINE, tr("Log Change Line"), formatDescr.emplace_back(C_LOG_CHANGE_LINE, tr("Log Change Line"),
tr("Applied to lines describing changes in VCS log."), tr("Applied to lines describing changes in VCS log."),
Format(QColor(192, 0, 0), QColor())); Format(QColor(192, 0, 0), QColor()));
formatDescr.emplace_back(C_LOG_AUTHOR_NAME, tr("Log Author Name"),
tr("Applied to author names in VCS log."),
Format(QColor("#007af4"), QColor()));
formatDescr.emplace_back(C_LOG_COMMIT_DATE, tr("Log Commit Date"),
tr("Applied to commit dates in VCS log."),
Format(QColor("#006600"), QColor()));
formatDescr.emplace_back(C_LOG_COMMIT_HASH, tr("Log Commit Hash"),
tr("Applied to commit hashes in VCS log."),
Format(QColor("#ff0000"), QColor()));
formatDescr.emplace_back(C_LOG_DECORATION, tr("Log Decoration"),
tr("Applied to commit decorations in VCS log."),
Format(QColor("#ff00ff"), QColor()));
formatDescr.emplace_back(C_LOG_COMMIT_SUBJECT, tr("Log Commit Subject"),
tr("Applied to commit subjects in VCS log."),
Format{QColor{}, QColor{}});
// Mixin categories // Mixin categories
formatDescr.emplace_back(C_ERROR, formatDescr.emplace_back(C_ERROR,