Messagelib

remotecontentwidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2021 Laurent Montel <[email protected]>
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 
16 using namespace MessageViewer;
17 RemoteContentWidget::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(QStringLiteral("mainLayout"));
24  mainLayout->setContentsMargins({});
25 
26  mLineEdit->setObjectName(QStringLiteral("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(QStringLiteral("mStatusComboBox"));
33  mainLayout->addWidget(mStatusComboBox);
34  connect(mLineEdit, &QLineEdit::textChanged, this, &RemoteContentWidget::slotTextChanged);
35 }
36 
37 RemoteContentWidget::~RemoteContentWidget() = default;
38 
39 void RemoteContentWidget::slotTextChanged(const QString &url)
40 {
41  Q_EMIT updateOkButton(!url.trimmed().isEmpty());
42 }
43 
44 RemoteContentInfo RemoteContentWidget::info() const
45 {
46  RemoteContentInfo info;
47  info.setUrl(mLineEdit->text());
48  info.setStatus(mStatusComboBox->status());
49  return info;
50 }
51 
52 void RemoteContentWidget::setInfo(const RemoteContentInfo &info)
53 {
54  mLineEdit->setText(info.url());
55  mStatusComboBox->setStatus(info.status());
56 }
The RemoteContentInfo class.
void textChanged(const QString &text)
QString label(StandardShortcut id)
bool isEmpty() const const
QString trimmed() const const
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.