Messagelib

remotecontentwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "remotecontentwidget.h"
8#include "remotecontentstatustypecombobox.h"
9
10#include <KLocalizedString>
11#include <QCheckBox>
12#include <QHBoxLayout>
13#include <QLabel>
14#include <QLineEdit>
15
16using namespace MessageViewer;
17RemoteContentWidget::RemoteContentWidget(QWidget *parent)
18 : QWidget(parent)
19 , mLineEdit(new QLineEdit(this))
20 , mStatusComboBox(new RemoteContentStatusTypeComboBox(this))
21{
22 auto mainLayout = new QHBoxLayout(this);
23 mainLayout->setObjectName(QLatin1StringView("mainLayout"));
24 mainLayout->setContentsMargins({});
25
26 mLineEdit->setObjectName(QLatin1StringView("mLineEdit"));
27 mLineEdit->setClearButtonEnabled(true);
28 auto label = new QLabel(i18n("Domain:"), this);
29 mainLayout->addWidget(label);
30 mainLayout->addWidget(mLineEdit);
31
32 mStatusComboBox->setObjectName(QLatin1StringView("mStatusComboBox"));
33 mainLayout->addWidget(mStatusComboBox);
34 connect(mLineEdit, &QLineEdit::textChanged, this, &RemoteContentWidget::slotTextChanged);
35}
36
37RemoteContentWidget::~RemoteContentWidget() = default;
38
39void RemoteContentWidget::slotTextChanged(const QString &url)
40{
41 Q_EMIT updateOkButton(!url.trimmed().isEmpty());
42}
43
44RemoteContentInfo RemoteContentWidget::info() const
45{
47 info.setUrl(mLineEdit->text());
48 info.setStatus(mStatusComboBox->status());
49 return info;
50}
51
52void RemoteContentWidget::setInfo(const RemoteContentInfo &info)
53{
54 mLineEdit->setText(info.url());
55 mStatusComboBox->setStatus(info.status());
56}
57
58#include "moc_remotecontentwidget.cpp"
The RemoteContentInfo class.
QString i18n(const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
void textChanged(const QString &text)
Q_EMITQ_EMIT
bool isEmpty() const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:37:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.