MCPcopy Create free account
hub / github.com/KDE/kate / changeTextColorToRed

Function changeTextColorToRed

addons/project/gitcommitdialog.cpp:42–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40};
41
42static void changeTextColorToRed(QLineEdit *lineEdit, const QColor &red)
43{
44 if (!lineEdit) {
45 return;
46 }
47
48 // Everything > 52 = red color
49 QList<QInputMethodEvent::Attribute> attributes;
50 if (lineEdit->text().length() > 52) {
51 int start = 52 - lineEdit->cursorPosition();
52 int len = lineEdit->text().length() - start;
53 QInputMethodEvent::AttributeType type = QInputMethodEvent::TextFormat;
54
55 QTextCharFormat fmt;
56 fmt.setForeground(red);
57 QVariant format = fmt;
58
59 attributes.append(QInputMethodEvent::Attribute(type, start, len, format));
60 }
61 QInputMethodEvent event(QString(), attributes);
62 QCoreApplication::sendEvent(lineEdit, &event);
63}
64
65GitCommitDialog::GitCommitDialog(const QString &lastCommit, QWidget *parent, Qt::WindowFlags f)
66 : QDialog(parent, f)

Callers 1

updateLineSizeLabelMethod · 0.85

Calls 2

textMethod · 0.80
QStringClass · 0.50

Tested by

no test coverage detected