File indexing completed on 2025-01-26 04:57:24

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "testselectedtextwebengine.h"
0008 #include "webengineview.h"
0009 #include <QApplication>
0010 #include <QMessageBox>
0011 #include <QPushButton>
0012 #include <QVBoxLayout>
0013 #include <WebEngineViewer/WebEnginePage>
0014 
0015 TestSelectedTextWebEngine::TestSelectedTextWebEngine(QWidget *parent)
0016     : QWidget(parent)
0017 {
0018     auto hboxLayout = new QVBoxLayout(this);
0019     pageView = new WebEngineViewer::WebEngineView(this);
0020     hboxLayout->addWidget(pageView);
0021     auto showSelectedText = new QPushButton(QStringLiteral("Show Selected Text"), this);
0022     connect(showSelectedText, &QPushButton::clicked, this, &TestSelectedTextWebEngine::slotSlowSelectedText);
0023     hboxLayout->addWidget(showSelectedText);
0024 
0025     mEnginePage = new WebEngineViewer::WebEnginePage(this);
0026     // pageView->setPage(mEnginePage);
0027     pageView->load(QUrl(QStringLiteral("http://www.kde.org")));
0028 }
0029 
0030 TestSelectedTextWebEngine::~TestSelectedTextWebEngine() = default;
0031 
0032 void TestSelectedTextWebEngine::slotSlowSelectedText()
0033 {
0034     QMessageBox::information(this, QStringLiteral("selected text"), pageView->selectedText());
0035 }
0036 
0037 int main(int argc, char *argv[])
0038 {
0039     QApplication app(argc, argv);
0040     auto testWebEngine = new TestSelectedTextWebEngine;
0041     testWebEngine->show();
0042     const int ret = app.exec();
0043     return ret;
0044 }
0045 
0046 #include "moc_testselectedtextwebengine.cpp"