1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
This file is part of KMail.
SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
*/
#include "recipientseditortest.h"
#include <MessageComposer/RecipientsEditor>
#include <QDebug>
#include <KMessageBox>
#include <QApplication>
#include <QCommandLineParser>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTextEdit>
using namespace MessageComposer;
Composer::Composer(QWidget *parent)
: QWidget(parent)
, mRecipients(new RecipientsEditor(this))
{
auto topLayout = new QGridLayout(this);
topLayout->setContentsMargins(4, 4, 4, 4);
topLayout->setSpacing(4);
auto label = new QLabel(QStringLiteral("From:"), this);
topLayout->addWidget(label, 0, 0);
auto edit = new QLineEdit(this);
topLayout->addWidget(edit, 0, 1);
topLayout->addWidget(mRecipients, 1, 0, 1, 2);
qDebug() << "SIZEHINT:" << mRecipients->sizeHint();
// mRecipients->setFixedHeight( 10 );
auto editor = new QTextEdit(this);
topLayout->addWidget(editor, 2, 0, 1, 2);
topLayout->setRowStretch(2, 1);
auto button = new QPushButton(QStringLiteral("&Close"), this);
topLayout->addWidget(button, 3, 0, 1, 2);
connect(button, &QPushButton::clicked, this, &Composer::slotClose);
}
void Composer::slotClose()
{
#if 0
QString text;
text += "<qt>";
Recipient::List recipients = mRecipients->recipients();
Recipient::List::ConstIterator it;
for (it = recipients.begin(); it != recipients.end(); ++it) {
text += "<b>" + (*it).typeLabel() + ":</b> " + (*it).email() + "<br/>";
}
text += "</qt>";
KMessageBox::information(this, text);
#endif
close();
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
QObject::connect(&app, &QApplication::lastWindowClosed, &app, &QApplication::quit);
QWidget *wid = new Composer(nullptr);
wid->show();
int ret = app.exec();
delete wid;
return ret;
}
#include "moc_recipientseditortest.cpp"
|