remotecontentwidget.cpp 1.42 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
#include <QFormLayout>
Laurent Montel's avatar
Laurent Montel committed
10
11
12
#include <QLabel>
#include <KLocalizedString>
#include <QLineEdit>
Laurent Montel's avatar
Laurent Montel committed
13
#include <QCheckBox>
Laurent Montel's avatar
Laurent Montel committed
14

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
35
}

RemoteContentWidget::~RemoteContentWidget()
{

}
36
37
38

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

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