File indexing completed on 2024-10-27 04:50:59

0001 /*
0002    SPDX-FileCopyrightText: 2022 Sandro Knauß <knauss@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "nearexpirywarning.h"
0008 
0009 #include <QDebug>
0010 
0011 NearExpiryWarning::NearExpiryWarning(QWidget *parent)
0012     : KMessageWidget(parent)
0013 {
0014     setPosition(KMessageWidget::Header);
0015     setVisible(false);
0016     setCloseButtonVisible(true);
0017     setWordWrap(true);
0018     clearInfo();
0019 }
0020 
0021 NearExpiryWarning::~NearExpiryWarning() = default;
0022 
0023 void NearExpiryWarning::addInfo(const QString &msg)
0024 {
0025     setText(text() + (text().isEmpty() ? QString() : QStringLiteral("\n")) + QStringLiteral("<p>") + msg + QStringLiteral("</p>"));
0026 }
0027 
0028 void NearExpiryWarning::setWarning(bool warning)
0029 {
0030     if (warning) {
0031         setMessageType(Warning);
0032     } else {
0033         setMessageType(Information);
0034     }
0035 }
0036 
0037 void NearExpiryWarning::clearInfo()
0038 {
0039     setWarning(false);
0040     setText(QString());
0041 }
0042 
0043 #include "moc_nearexpirywarning.cpp"