remotecontentwidget.cpp 1.37 KB
Newer Older
1
2
3
4
5
6
7
8
/*
   SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "remotecontentwidget.h"

Laurent Montel's avatar
Laurent Montel committed
9
10
#include <KLocalizedString>
#include <QCheckBox>
Laurent Montel's avatar
Laurent Montel committed
11
#include <QFormLayout>
Laurent Montel's avatar
Laurent Montel committed
12
13
14
#include <QLabel>
#include <QLineEdit>

15
16
17
using namespace MessageViewer;
RemoteContentWidget::RemoteContentWidget(QWidget *parent)
    : QWidget(parent)
Laurent Montel's avatar
Laurent Montel committed
18
    , mLineEdit(new QLineEdit(this))
Laurent Montel's avatar
Laurent Montel committed
19
    , mStatusCheckBox(new QCheckBox(i18n("Authorized"), this))
20
{
Laurent Montel's avatar
Laurent Montel committed
21
    auto mainLayout = new QFormLayout(this);
22
23
24
    mainLayout->setObjectName(QStringLiteral("mainLayout"));
    mainLayout->setContentsMargins({});

Laurent Montel's avatar
Laurent Montel committed
25
    mLineEdit->setObjectName(QStringLiteral("mLineEdit"));
Laurent Montel's avatar
Laurent Montel committed
26
    mainLayout->addRow(i18n("Url"), mLineEdit);
Laurent Montel's avatar
Laurent Montel committed
27
28
29

    mStatusCheckBox->setObjectName(QStringLiteral("mStatusCheckBox"));
    mainLayout->addRow(mStatusCheckBox);
30
31
32
33
34
}

RemoteContentWidget::~RemoteContentWidget()
{
}
35
36
37

RemoteContentInfo RemoteContentWidget::info() const
{
Laurent Montel's avatar
Laurent Montel committed
38
39
    RemoteContentInfo info;
    info.setUrl(mLineEdit->text());
Laurent Montel's avatar
Laurent Montel committed
40
    info.setStatus(mStatusCheckBox->isChecked() ? RemoteContentInfo::RemoteContentInfoStatus::Authorized : RemoteContentInfo::RemoteContentInfoStatus::Blocked);
Laurent Montel's avatar
Laurent Montel committed
41
    return info;
42
}
Laurent Montel's avatar
Laurent Montel committed
43
44
45

void RemoteContentWidget::setInfo(const RemoteContentInfo &info)
{
Laurent Montel's avatar
Laurent Montel committed
46
    mLineEdit->setText(info.url());
Laurent Montel's avatar
Laurent Montel committed
47
    mStatusCheckBox->setChecked(info.status() == RemoteContentInfo::RemoteContentInfoStatus::Authorized);
Laurent Montel's avatar
Laurent Montel committed
48
}