File indexing completed on 2025-03-09 04:54:37

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "remotecontentwidget.h"
0008 #include "remotecontentstatustypecombobox.h"
0009 
0010 #include <KLocalizedString>
0011 #include <QCheckBox>
0012 #include <QHBoxLayout>
0013 #include <QLabel>
0014 #include <QLineEdit>
0015 
0016 using namespace MessageViewer;
0017 RemoteContentWidget::RemoteContentWidget(QWidget *parent)
0018     : QWidget(parent)
0019     , mLineEdit(new QLineEdit(this))
0020     , mStatusComboBox(new RemoteContentStatusTypeComboBox(this))
0021 {
0022     auto mainLayout = new QHBoxLayout(this);
0023     mainLayout->setObjectName(QLatin1StringView("mainLayout"));
0024     mainLayout->setContentsMargins({});
0025 
0026     mLineEdit->setObjectName(QLatin1StringView("mLineEdit"));
0027     mLineEdit->setClearButtonEnabled(true);
0028     auto label = new QLabel(i18n("Domain:"), this);
0029     mainLayout->addWidget(label);
0030     mainLayout->addWidget(mLineEdit);
0031 
0032     mStatusComboBox->setObjectName(QLatin1StringView("mStatusComboBox"));
0033     mainLayout->addWidget(mStatusComboBox);
0034     connect(mLineEdit, &QLineEdit::textChanged, this, &RemoteContentWidget::slotTextChanged);
0035 }
0036 
0037 RemoteContentWidget::~RemoteContentWidget() = default;
0038 
0039 void RemoteContentWidget::slotTextChanged(const QString &url)
0040 {
0041     Q_EMIT updateOkButton(!url.trimmed().isEmpty());
0042 }
0043 
0044 RemoteContentInfo RemoteContentWidget::info() const
0045 {
0046     RemoteContentInfo info;
0047     info.setUrl(mLineEdit->text());
0048     info.setStatus(mStatusComboBox->status());
0049     return info;
0050 }
0051 
0052 void RemoteContentWidget::setInfo(const RemoteContentInfo &info)
0053 {
0054     mLineEdit->setText(info.url());
0055     mStatusComboBox->setStatus(info.status());
0056 }
0057 
0058 #include "moc_remotecontentwidget.cpp"