File indexing completed on 2022-11-29 20:24:01

0001 /*
0002     SPDX-FileCopyrightText: 2015-2022 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "environmentsettingsrulespage.h"
0009 #include "environmentplaintextedit.h"
0010 #include <KLocalizedString>
0011 #include <QLabel>
0012 #include <QVBoxLayout>
0013 
0014 EnvironmentSettingsRulesPage::EnvironmentSettingsRulesPage(QWidget *parent)
0015     : QWidget(parent)
0016     , mRichTextEdit(new EnvironmentPlainTextEdit(this))
0017 {
0018     auto mainLayout = new QVBoxLayout(this);
0019     auto lab = new QLabel(i18n("Rules:"), this);
0020     lab->setObjectName(QStringLiteral("label"));
0021     mRichTextEdit->setReadOnly(true);
0022     mRichTextEdit->setObjectName(QStringLiteral("richtext"));
0023     mainLayout->addWidget(lab);
0024     mainLayout->addWidget(mRichTextEdit);
0025 }
0026 
0027 EnvironmentSettingsRulesPage::~EnvironmentSettingsRulesPage() = default;
0028 
0029 void EnvironmentSettingsRulesPage::setRules(const QString &rules)
0030 {
0031     const QString information = QLatin1String("<qt><b>")
0032         + i18n("These rules cannot be edited with this application. You need to set them in QT_LOGGING_RULES variable directly.") + QLatin1String("</b><qt>");
0033     QString newRules = rules;
0034     mRichTextEdit->setHtml(information + i18n("Current rules:") + QStringLiteral("<br>") + newRules.replace(QLatin1Char('\n'), QLatin1String("<br>")));
0035 }