init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
47
Telegram/ThirdParty/kcoreaddons/tests/ktexttohtmltest.cpp
vendored
Normal file
47
Telegram/ThirdParty/kcoreaddons/tests/ktexttohtmltest.cpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KTextToHTML>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMainWindow>
|
||||
#include <QTextBrowser>
|
||||
#include <QTimer>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
auto *window = new QMainWindow;
|
||||
|
||||
auto *mainWidget = new QWidget;
|
||||
window->setCentralWidget(mainWidget);
|
||||
|
||||
auto *layout = new QHBoxLayout;
|
||||
mainWidget->setLayout(layout);
|
||||
|
||||
auto *plaintextEditor = new QTextEdit;
|
||||
plaintextEditor->setAcceptRichText(false);
|
||||
layout->addWidget(plaintextEditor);
|
||||
|
||||
auto *htmlView = new QTextBrowser;
|
||||
layout->addWidget(htmlView);
|
||||
|
||||
auto *updateTimer = new QTimer(&app);
|
||||
updateTimer->setSingleShot(true);
|
||||
updateTimer->setInterval(1000);
|
||||
QObject::connect(updateTimer, &QTimer::timeout, plaintextEditor, [plaintextEditor, htmlView]() {
|
||||
const QString html = KTextToHTML::convertToHtml(plaintextEditor->toPlainText(), KTextToHTML::Options());
|
||||
htmlView->setHtml(html);
|
||||
});
|
||||
|
||||
QObject::connect(plaintextEditor, &QTextEdit::textChanged, updateTimer, qOverload<>(&QTimer::start));
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user