Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit cb11adc7 authored by Laurent Montel's avatar Laurent Montel 😁

inform when we don't have text to check

parent 021ffb26
......@@ -27,6 +27,7 @@
#include <QAction>
#include <QTextBlock>
#include <QTextDocument>
#include <QPainter>
GrammarResultTextEdit::GrammarResultTextEdit(QWidget *parent)
: QTextEdit(parent)
......@@ -39,6 +40,36 @@ GrammarResultTextEdit::~GrammarResultTextEdit()
{
}
void GrammarResultTextEdit::paintEvent(QPaintEvent *event)
{
if (document()->isEmpty()) {
const QString label = i18n("Any text to check.");
QPainter p(viewport());
QFont font = p.font();
font.setItalic(true);
p.setFont(font);
if (!mTextColor.isValid()) {
generalPaletteChanged();
}
p.setPen(mTextColor);
p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, label);
} else {
QTextEdit::paintEvent(event);
}
}
void GrammarResultTextEdit::generalPaletteChanged()
{
const QPalette palette = viewport()->palette();
QColor color = palette.text().color();
color.setAlpha(128);
mTextColor = color;
}
void GrammarResultTextEdit::applyGrammarResult(const QVector<GrammarError> &infos)
{
for (const GrammarError &info : infos) {
......@@ -131,7 +162,6 @@ void GrammarResultTextEdit::slotReplaceWord(const MessageComposer::PluginGrammar
i += act.length();
}
}
qDebug() << " We need to update act";
}
}
......
......@@ -38,6 +38,8 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
void paintEvent(QPaintEvent *event) override;
Q_SIGNALS:
void replaceText(const MessageComposer::PluginGrammarAction &act);
void checkAgain();
......@@ -46,6 +48,8 @@ private:
enum TextInfo {
ReplaceFormatInfo = QTextFormat::UserProperty + 1
};
void generalPaletteChanged();
QColor mTextColor;
};
#endif // GRAMMARRESULTTEXTEDIT_H
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