forked from qt-creator/qt-creator
Git: Centralize color name resolution
Change-Id: I1984dd7d8ebb7e11480311a37aa094af44efb9aa Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
0d4b33a769
commit
19d1c0c597
@@ -390,11 +390,7 @@ ShowController::ShowController(IDocument *document, const QString &id)
|
|||||||
|
|
||||||
const auto onDescriptionSetup = [this, id](Process &process) {
|
const auto onDescriptionSetup = [this, id](Process &process) {
|
||||||
process.setCodec(gitClient().encoding(GitClient::EncodingCommit, workingDirectory()));
|
process.setCodec(gitClient().encoding(GitClient::EncodingCommit, workingDirectory()));
|
||||||
const QString authorName = GitClient::styleColorName(TextEditor::C_LOG_AUTHOR_NAME);
|
const ColorNames colors = GitClient::colorNames();
|
||||||
const QString commitDate = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_DATE);
|
|
||||||
const QString commitHash = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_HASH);
|
|
||||||
const QString commitSubject = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
|
|
||||||
const QString decoration = GitClient::styleColorName(TextEditor::C_LOG_DECORATION);
|
|
||||||
|
|
||||||
const QString showFormat = QStringLiteral(
|
const QString showFormat = QStringLiteral(
|
||||||
"--pretty=format:"
|
"--pretty=format:"
|
||||||
@@ -402,7 +398,8 @@ ShowController::ShowController(IDocument *document, const QString &id)
|
|||||||
"Author: %C(%3)%aN <%aE>%Creset, %C(%4)%ad (%ar)%Creset%n"
|
"Author: %C(%3)%aN <%aE>%Creset, %C(%4)%ad (%ar)%Creset%n"
|
||||||
"Committer: %C(%3)%cN <%cE>%Creset, %C(%4)%cd (%cr)%Creset%n"
|
"Committer: %C(%3)%cN <%cE>%Creset, %C(%4)%cd (%cr)%Creset%n"
|
||||||
"%n%C(%5)%s%Creset%n%n%b"
|
"%n%C(%5)%s%Creset%n%n%b"
|
||||||
).arg(commitHash, decoration, authorName, commitDate, commitSubject);
|
).arg(colors.hash, colors.decoration, colors.author,
|
||||||
|
colors.date, colors.subject);
|
||||||
setupCommand(process, {"show", "-s", colorOption, showFormat, id});
|
setupCommand(process, {"show", "-s", colorOption, showFormat, id});
|
||||||
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
||||||
setDescription(Tr::tr("Waiting for data..."));
|
setDescription(Tr::tr("Waiting for data..."));
|
||||||
@@ -688,11 +685,7 @@ public:
|
|||||||
|
|
||||||
QStringList graphArguments() const
|
QStringList graphArguments() const
|
||||||
{
|
{
|
||||||
const QString authorName = GitClient::styleColorName(TextEditor::C_LOG_AUTHOR_NAME);
|
const ColorNames colors = GitClient::colorNames();
|
||||||
const QString commitDate = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_DATE);
|
|
||||||
const QString commitHash = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_HASH);
|
|
||||||
const QString commitSubject = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
|
|
||||||
const QString decoration = GitClient::styleColorName(TextEditor::C_LOG_DECORATION);
|
|
||||||
|
|
||||||
const QString formatArg = QStringLiteral(
|
const QString formatArg = QStringLiteral(
|
||||||
"--pretty=format:"
|
"--pretty=format:"
|
||||||
@@ -701,7 +694,7 @@ public:
|
|||||||
"%C(%3)%aN%Creset "
|
"%C(%3)%aN%Creset "
|
||||||
"%C(%4)%s%Creset "
|
"%C(%4)%s%Creset "
|
||||||
"%C(%5)%ci%Creset"
|
"%C(%5)%ci%Creset"
|
||||||
).arg(commitHash, decoration, authorName, commitSubject, commitDate);
|
).arg(colors.hash, colors.decoration, colors.author, colors.subject, colors.date);
|
||||||
|
|
||||||
QStringList graphArgs = {graphOption, "--oneline", "--topo-order"};
|
QStringList graphArgs = {graphOption, "--oneline", "--topo-order"};
|
||||||
|
|
||||||
@@ -1024,11 +1017,7 @@ static QStringList normalLogArguments()
|
|||||||
if (!gitHasRgbColors())
|
if (!gitHasRgbColors())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const QString authorName = GitClient::styleColorName(TextEditor::C_LOG_AUTHOR_NAME);
|
ColorNames colors = GitClient::colorNames();
|
||||||
const QString commitDate = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_DATE);
|
|
||||||
const QString commitHash = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_HASH);
|
|
||||||
const QString commitSubject = GitClient::styleColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
|
|
||||||
const QString decoration = GitClient::styleColorName(TextEditor::C_LOG_DECORATION);
|
|
||||||
|
|
||||||
const QString logArgs = QStringLiteral(
|
const QString logArgs = QStringLiteral(
|
||||||
"--pretty=format:"
|
"--pretty=format:"
|
||||||
@@ -1036,7 +1025,7 @@ static QStringList normalLogArguments()
|
|||||||
"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)%w(0,4,4)%s%Creset%n%n%b"
|
"%C(%5)%w(0,4,4)%s%Creset%n%n%b"
|
||||||
).arg(commitHash, decoration, authorName, commitDate, commitSubject);
|
).arg(colors.hash, colors.decoration, colors.author, colors.date, colors.subject);
|
||||||
|
|
||||||
return {logArgs};
|
return {logArgs};
|
||||||
}
|
}
|
||||||
@@ -3785,6 +3774,18 @@ IEditor *GitClient::openShowEditor(const FilePath &workingDirectory, const QStri
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorNames GitClient::colorNames()
|
||||||
|
{
|
||||||
|
ColorNames result;
|
||||||
|
result.author = styleColorName(TextEditor::C_LOG_AUTHOR_NAME);
|
||||||
|
result.date = styleColorName(TextEditor::C_LOG_COMMIT_DATE);
|
||||||
|
result.hash = styleColorName(TextEditor::C_LOG_COMMIT_HASH);
|
||||||
|
result.decoration = styleColorName(TextEditor::C_LOG_DECORATION);
|
||||||
|
result.subject = styleColorName(TextEditor::C_LOG_COMMIT_SUBJECT);
|
||||||
|
result.body = styleColorName(TextEditor::C_TEXT);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // Git::Internal
|
} // Git::Internal
|
||||||
|
|
||||||
#include "gitclient.moc"
|
#include "gitclient.moc"
|
||||||
|
@@ -33,6 +33,16 @@ class GitBaseDiffEditorController;
|
|||||||
class GitSubmitEditorPanelData;
|
class GitSubmitEditorPanelData;
|
||||||
class Stash;
|
class Stash;
|
||||||
|
|
||||||
|
struct ColorNames
|
||||||
|
{
|
||||||
|
QString author;
|
||||||
|
QString date;
|
||||||
|
QString hash;
|
||||||
|
QString decoration;
|
||||||
|
QString subject;
|
||||||
|
QString body;
|
||||||
|
};
|
||||||
|
|
||||||
enum StatusMode
|
enum StatusMode
|
||||||
{
|
{
|
||||||
ShowAll = 0,
|
ShowAll = 0,
|
||||||
@@ -343,6 +353,7 @@ public:
|
|||||||
const VcsBase::CommandHandler &handler) const;
|
const VcsBase::CommandHandler &handler) const;
|
||||||
|
|
||||||
static QString styleColorName(TextEditor::TextStyle style);
|
static QString styleColorName(TextEditor::TextStyle style);
|
||||||
|
static ColorNames colorNames();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static GitSettings &settings();
|
static GitSettings &settings();
|
||||||
|
Reference in New Issue
Block a user