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

Use richtext here

parent a2643834
......@@ -41,7 +41,7 @@ void EnvironmentSettingsRulesPageTest::shouldHaveDefaultValue()
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(lab);
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("plaintext"));
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
QVERIFY(plainText);
QVERIFY(plainText->toPlainText().isEmpty());
QVERIFY(plainText->isReadOnly());
......@@ -50,7 +50,7 @@ void EnvironmentSettingsRulesPageTest::shouldHaveDefaultValue()
void EnvironmentSettingsRulesPageTest::shouldSetRules()
{
EnvironmentSettingsRulesPage w;
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("plaintext"));
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
QString rules = QStringLiteral("Rules for qt\ntest");
w.setRules(rules);
QVERIFY(plainText->toPlainText().endsWith(rules));
......
......@@ -24,9 +24,8 @@
#include <QPainter>
EnvironmentPlainTextEdit::EnvironmentPlainTextEdit(QWidget *parent)
: QPlainTextEdit(parent)
{
: QTextEdit(parent)
{
}
EnvironmentPlainTextEdit::~EnvironmentPlainTextEdit()
......@@ -39,7 +38,7 @@ void EnvironmentPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
if (document()->isEmpty()) {
return;
}
QPlainTextEdit::contextMenuEvent(event);
QTextEdit::contextMenuEvent(event);
}
void EnvironmentPlainTextEdit::paintEvent(QPaintEvent *event)
......@@ -58,7 +57,7 @@ void EnvironmentPlainTextEdit::paintEvent(QPaintEvent *event)
p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, i18n("No rules have been defined in the environment variable \"QT_LOGGING_RULES\"."));
} else {
QPlainTextEdit::paintEvent(event);
QTextEdit::paintEvent(event);
}
}
......
......@@ -21,9 +21,9 @@
#ifndef ENVIRONMENTPLAINTEXTEDIT_H
#define ENVIRONMENTPLAINTEXTEDIT_H
#include <QPlainTextEdit>
#include <QTextEdit>
class QPaintEvent;
class EnvironmentPlainTextEdit : public QPlainTextEdit
class EnvironmentPlainTextEdit : public QTextEdit
{
Q_OBJECT
public:
......
......@@ -30,11 +30,11 @@ EnvironmentSettingsRulesPage::EnvironmentSettingsRulesPage(QWidget *parent)
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(i18n("Rules:"), this);
lab->setObjectName(QStringLiteral("label"));
mPlainTextEdit = new EnvironmentPlainTextEdit(this);
mPlainTextEdit->setReadOnly(true);
mPlainTextEdit->setObjectName(QStringLiteral("plaintext"));
mRichTextEdit = new EnvironmentPlainTextEdit(this);
mRichTextEdit->setReadOnly(true);
mRichTextEdit->setObjectName(QStringLiteral("richtext"));
mainLayout->addWidget(lab);
mainLayout->addWidget(mPlainTextEdit);
mainLayout->addWidget(mRichTextEdit);
}
EnvironmentSettingsRulesPage::~EnvironmentSettingsRulesPage()
......@@ -44,6 +44,7 @@ EnvironmentSettingsRulesPage::~EnvironmentSettingsRulesPage()
void EnvironmentSettingsRulesPage::setRules(const QString &rules)
{
QString information = i18n("These rules cannot be edited with this application. You need to set them in QT_LOGGING_RULES variable directly.");
mPlainTextEdit->setPlainText(information + QLatin1Char('\n') + QLatin1Char('\n') + rules);
const QString information = QStringLiteral("<qt><b>") + i18n("These rules cannot be edited with this application. You need to set them in QT_LOGGING_RULES variable directly.") + QStringLiteral("</b><qt>");
QString newRules = rules;
mRichTextEdit->setHtml(information + QStringLiteral("<br><br>") + newRules.replace(QStringLiteral("\n"), QStringLiteral("<br>")));
}
......@@ -31,7 +31,7 @@ public:
~EnvironmentSettingsRulesPage();
void setRules(const QString &rules);
private:
EnvironmentPlainTextEdit *mPlainTextEdit = nullptr;
EnvironmentPlainTextEdit *mRichTextEdit = nullptr;
};
#endif // ENVIRONMENTSETTINGSRULESPAGE_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