Commit d3d96068 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Use colors from KColorScheme



Instead of hard-coding colors, use colors from KColorScheme.

- Colors for showing line changes are still hard-coded. Not sure what to
use for them. If I use the KColorScheme colors for these, then you there
is no difference between 'M' / +12 -5 colors. This may be okay for some,
and for others not. I personally like having a little bit of difference
in colors. So, if you have any suggestions to improve this, do let me know
Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>


(cherry picked from commit 7f029368)
parent 39d85f0a
......@@ -11,6 +11,7 @@
#include <QSyntaxHighlighter>
#include <QVBoxLayout>
#include <KColorScheme>
#include <KLocalizedString>
class BadLengthHighlighter : public QSyntaxHighlighter
......@@ -27,14 +28,15 @@ public:
if (text.length() < badLength) {
return;
}
setFormat(badLength, text.length() - badLength, Qt::red);
setFormat(badLength, text.length() - badLength, red);
}
private:
int badLength = 0;
const QColor red = KColorScheme().foreground(KColorScheme::NegativeText).color();
};
static void changeTextColorToRed(QLineEdit *lineEdit)
static void changeTextColorToRed(QLineEdit *lineEdit, const QColor &red)
{
if (!lineEdit)
return;
......@@ -47,7 +49,7 @@ static void changeTextColorToRed(QLineEdit *lineEdit)
QInputMethodEvent::AttributeType type = QInputMethodEvent::TextFormat;
QTextCharFormat fmt;
fmt.setForeground(Qt::red);
fmt.setForeground(red);
QVariant format = fmt;
attributes.append(QInputMethodEvent::Attribute(type, start, len, format));
......@@ -142,12 +144,12 @@ bool GitCommitDialog::signoff() const
void GitCommitDialog::updateLineSizeLabel()
{
static constexpr auto red = QColor(237, 21, 21); // Breeze Danger Red
const QColor red = KColorScheme().foreground(KColorScheme::NegativeText).color();
int len = m_le.text().length();
if (len < 52) {
m_leLen.setText(i18nc("Number of characters", "%1 / 52", QString::number(len)));
} else {
changeTextColorToRed(&m_le);
changeTextColorToRed(&m_le, red);
m_leLen.setText(i18nc("Number of characters", "<span style=\"color:%1;\">%2</span> / 52", red.name(), QString::number(len)));
}
}
......@@ -5,6 +5,7 @@
*/
#include "gitstatusmodel.h"
#include <KColorScheme>
#include <QDebug>
#include <QFileInfo>
#include <QFont>
......@@ -150,9 +151,9 @@ QVariant GitStatusModel::data(const QModelIndex &index, int role) const
}
} else if (role == Qt::ForegroundRole) {
if (index.column() == 1 && rootIndex > 0) {
return QColor(218, 68, 83); // Breeze Fg Negative
return KColorScheme().foreground(KColorScheme::NegativeText).color();
} else if (index.column() == 1 && rootIndex == 0) {
return QColor(39, 174, 96); // Breeze Fg Positive
return KColorScheme().foreground(KColorScheme::PositiveText).color();
}
}
}
......
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