Commit 5be4ef67 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add test apps

parent 8597aace
Pipeline #25580 passed with stage
in 6 minutes and 29 seconds
......@@ -21,3 +21,8 @@ target_link_libraries(showemoticonunicodetab_gui ${showemoticonunicodetab_gui_LI
add_executable(testgeneratehtmlbuildergui_gui testgeneratehtmlbuildergui.cpp)
set(testgeneratehtmlbuildergui_gui_LIBS KF5PimTextEdit Qt5::Widgets )
target_link_libraries(testgeneratehtmlbuildergui_gui ${testgeneratehtmlbuildergui_gui_LIBS})
#####
add_executable(testgenerateplaintextbuilder_gui testgenerateplaintextbuildergui.cpp)
set(testgenerateplaintextbuilder_gui_LIBS KF5PimTextEdit Qt5::Widgets )
target_link_libraries(testgenerateplaintextbuilder_gui ${testgenerateplaintextbuilder_gui_LIBS})
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "testgenerateplaintextbuildergui.h"
#include <QVBoxLayout>
#include <QApplication>
#include <QLabel>
#include <QTextEdit>
#include <QPushButton>
#include <KPIMTextEdit/PlainTextMarkupBuilder>
#include <KPIMTextEdit/MarkupDirector>
TestGeneratePlainTextBuilderGui::TestGeneratePlainTextBuilderGui(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(QStringLiteral("html text"), this);
mainLayout->addWidget(lab);
QTextEdit *htmlEdit = new QTextEdit(this);
htmlEdit->setAcceptRichText(false);
mainLayout->addWidget(htmlEdit);
QPushButton *generateHtmlFromQTextEditButton = new QPushButton(QStringLiteral("Generate HTML"), this);
mainLayout->addWidget(generateHtmlFromQTextEditButton);
lab = new QLabel(QStringLiteral("Generate Html"), this);
mainLayout->addWidget(lab);
QTextEdit *generatedHtml = new QTextEdit(this);
generatedHtml->setAcceptRichText(false);
generatedHtml->setReadOnly(true);
mainLayout->addWidget(generatedHtml);
lab = new QLabel(QStringLiteral("Plaintext from Grantlee to TextEdit"), this);
mainLayout->addWidget(lab);
QTextEdit *generatedPlainTextFromGrantleeToTextEdit = new QTextEdit(this);
generatedPlainTextFromGrantleeToTextEdit->setAcceptRichText(false);
generatedPlainTextFromGrantleeToTextEdit->setReadOnly(true);
mainLayout->addWidget(generatedPlainTextFromGrantleeToTextEdit);
connect(generateHtmlFromQTextEditButton, &QPushButton::clicked, this, [=]{
generatedHtml->setHtml(htmlEdit->toPlainText());
auto hb = new KPIMTextEdit::PlainTextMarkupBuilder();
auto md = new KPIMTextEdit::MarkupDirector(hb);
md->processDocument(generatedHtml->document());
auto result = hb->getResult();
delete md;
delete hb;
generatedPlainTextFromGrantleeToTextEdit->setPlainText(result);
});
}
TestGeneratePlainTextBuilderGui::~TestGeneratePlainTextBuilderGui()
{
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TestGeneratePlainTextBuilderGui window;
window.show();
return app.exec();
}
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef TestGeneratePlainTextBuilderGui_H
#define TestGeneratePlainTextBuilderGui_H
#include <QWidget>
class TestGeneratePlainTextBuilderGui : public QWidget
{
Q_OBJECT
public:
explicit TestGeneratePlainTextBuilderGui(QWidget *parent = nullptr);
~TestGeneratePlainTextBuilderGui();
};
#endif // TestGeneratePlainTextBuilderGui_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment