diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 0be757b80c..aa9c1ffdfb 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -15,7 +15,7 @@ #include #endif -AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { +AutoTester::AutoTester(QWidget* parent) : QMainWindow(parent) { _ui.setupUi(this); _ui.checkBoxInteractiveMode->setChecked(true); @@ -65,7 +65,7 @@ void AutoTester::on_createAllRecursiveScriptsButton_clicked() { } void AutoTester::on_createTestsButton_clicked() { - _test->createTests(); + _test->createTests(); } void AutoTester::on_createMDFileButton_clicked() { @@ -130,7 +130,7 @@ void AutoTester::on_createXMLScriptRadioButton_clicked() { void AutoTester::downloadImage(const QUrl& url) { _downloaders.emplace_back(new Downloader(url, this)); - connect(_downloaders[_index], SIGNAL (downloaded()), _signalMapper, SLOT (map())); + connect(_downloaders[_index], SIGNAL(downloaded()), _signalMapper, SLOT(map())); _signalMapper->setMapping(_downloaders[_index], _index); @@ -156,7 +156,7 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director downloadImage(imageURL); } - connect(_signalMapper, SIGNAL (mapped(int)), this, SLOT (saveImage(int))); + connect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveImage(int))); } void AutoTester::saveImage(int index) { @@ -174,7 +174,7 @@ void AutoTester::saveImage(int index) { ++_numberOfImagesDownloaded; if (_numberOfImagesDownloaded == _numberOfImagesToDownload) { - disconnect(_signalMapper, SIGNAL (mapped(int)), this, SLOT (saveImage(int))); + disconnect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveImage(int))); _test->finishTestsEvaluation(_isRunningFromCommandline, _ui.checkBoxInteractiveMode->isChecked(), _ui.progressBar); } else { _ui.progressBar->setValue(_numberOfImagesDownloaded); @@ -186,14 +186,14 @@ void AutoTester::about() { } void AutoTester::content() { + helpWindow.show(); } void AutoTester::setUserText(const QString& user) { _ui.userTextEdit->setText(user); } -QString AutoTester::getSelectedUser() -{ +QString AutoTester::getSelectedUser() { return _ui.userTextEdit->toPlainText(); } diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 75acff0de0..e29da5b716 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -18,6 +18,8 @@ #include "../Downloader.h" #include "../Test.h" +#include "HelpWindow.h" + class AutoTester : public QMainWindow { Q_OBJECT @@ -85,6 +87,8 @@ private: int _index { 0 }; bool _isRunningFromCommandline { false }; + + HelpWindow helpWindow; }; #endif // hifi_AutoTester_h \ No newline at end of file diff --git a/tools/auto-tester/src/ui/HelpWindow.cpp b/tools/auto-tester/src/ui/HelpWindow.cpp new file mode 100644 index 0000000000..c6f3fcd2ee --- /dev/null +++ b/tools/auto-tester/src/ui/HelpWindow.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "helpwindow.h" +#include "previewpage.h" +#include "ui_helpwindow.h" + +#include +#include +#include +#include +#include +#include + +HelpWindow::HelpWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::HelpWindow) +{ + ui->setupUi(this); + ui->editor->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); + ui->preview->setContextMenuPolicy(Qt::NoContextMenu); + + PreviewPage *page = new PreviewPage(this); + ui->preview->setPage(page); + + connect(ui->editor, &QPlainTextEdit::textChanged, + [this]() { m_content.setText(ui->editor->toPlainText()); }); + + QWebChannel *channel = new QWebChannel(this); + channel->registerObject(QStringLiteral("content"), &m_content); + page->setWebChannel(channel); + + ui->preview->setUrl(QUrl("qrc:/index.html")); + + connect(ui->actionNew, &QAction::triggered, this, &HelpWindow::onFileNew); + connect(ui->actionOpen, &QAction::triggered, this, &HelpWindow::onFileOpen); + connect(ui->actionSave, &QAction::triggered, this, &HelpWindow::onFileSave); + connect(ui->actionSaveAs, &QAction::triggered, this, &HelpWindow::onFileSaveAs); + connect(ui->actionExit, &QAction::triggered, this, &HelpWindow::onExit); + + connect(ui->editor->document(), &QTextDocument::modificationChanged, + ui->actionSave, &QAction::setEnabled); + + QFile defaultTextFile(":/default.md"); + defaultTextFile.open(QIODevice::ReadOnly); + ui->editor->setPlainText(defaultTextFile.readAll()); +} + +HelpWindow::~HelpWindow() +{ + delete ui; +} + +void HelpWindow::openFile(const QString &path) +{ + QFile f(path); + if (!f.open(QIODevice::ReadOnly)) { + QMessageBox::warning(this, windowTitle(), + tr("Could not open file %1: %2").arg( + QDir::toNativeSeparators(path), f.errorString())); + return; + } + m_filePath = path; + ui->editor->setPlainText(f.readAll()); +} + +bool HelpWindow::isModified() const +{ + return ui->editor->document()->isModified(); +} + +void HelpWindow::onFileNew() +{ + if (isModified()) { + QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(), + tr("You have unsaved changes. Do you want to create a new document anyway?")); + if (button != QMessageBox::Yes) + return; + } + + m_filePath.clear(); + ui->editor->setPlainText(tr("## New document")); + ui->editor->document()->setModified(false); +} + +void HelpWindow::onFileOpen() +{ + if (isModified()) { + QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(), + tr("You have unsaved changes. Do you want to open a new document anyway?")); + if (button != QMessageBox::Yes) + return; + } + + QString path = QFileDialog::getOpenFileName(this, + tr("Open MarkDown File"), "", tr("MarkDown File (*.md)")); + if (path.isEmpty()) + return; + + openFile(path); +} + +void HelpWindow::onFileSave() +{ + if (m_filePath.isEmpty()) { + onFileSaveAs(); + return; + } + + QFile f(m_filePath); + if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { + QMessageBox::warning(this, windowTitle(), + tr("Could not write to file %1: %2").arg( + QDir::toNativeSeparators(m_filePath), f.errorString())); + return; + } + QTextStream str(&f); + str << ui->editor->toPlainText(); + + ui->editor->document()->setModified(false); +} + +void HelpWindow::onFileSaveAs() +{ + QString path = QFileDialog::getSaveFileName(this, + tr("Save MarkDown File"), "", tr("MarkDown File (*.md, *.markdown)")); + if (path.isEmpty()) + return; + m_filePath = path; + onFileSave(); +} + +void HelpWindow::onExit() +{ + if (isModified()) { + QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(), + tr("You have unsaved changes. Do you want to exit anyway?")); + if (button != QMessageBox::Yes) + return; + } + close(); +} diff --git a/tools/auto-tester/src/ui/HelpWindow.h b/tools/auto-tester/src/ui/HelpWindow.h new file mode 100644 index 0000000000..7b4c99c9a3 --- /dev/null +++ b/tools/auto-tester/src/ui/HelpWindow.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "document.h" + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class HelpWindow; +} +QT_END_NAMESPACE + +class HelpWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit HelpWindow(QWidget *parent = nullptr); + ~HelpWindow(); + + void openFile(const QString &path); + +private slots: + void onFileNew(); + void onFileOpen(); + void onFileSave(); + void onFileSaveAs(); + void onExit(); + +private: + bool isModified() const; + + Ui::HelpWindow *ui; + QString m_filePath; + Document m_content; +}; + +#endif // MAINWINDOW_H diff --git a/tools/auto-tester/src/ui/HelpWindow.ui b/tools/auto-tester/src/ui/HelpWindow.ui new file mode 100644 index 0000000000..774e1a8651 --- /dev/null +++ b/tools/auto-tester/src/ui/HelpWindow.ui @@ -0,0 +1,115 @@ + + + HelpWindow + + + + 0 + 0 + 800 + 600 + + + + MarkDown Editor + + + + + + + Qt::Horizontal + + + + + + + + + + + 0 + 0 + 800 + 26 + + + + + &File + + + + + + + + + + + + + + &Open... + + + Open document + + + Ctrl+O + + + + + &Save + + + Save current document + + + Ctrl+S + + + + + E&xit + + + Exit editor + + + Ctrl+Q + + + + + Save &As... + + + Save document under different name + + + + + &New + + + Create new document + + + Ctrl+N + + + + + + QWebEngineView + QWidget +
qwebengineview.h
+ 1 +
+
+ + +
diff --git a/tools/auto-tester/src/ui/document.cpp b/tools/auto-tester/src/ui/document.cpp new file mode 100644 index 0000000000..20e6b6be9a --- /dev/null +++ b/tools/auto-tester/src/ui/document.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "document.h" + +void Document::setText(const QString &text) +{ + if (text == m_text) + return; + m_text = text; + emit textChanged(m_text); +} diff --git a/tools/auto-tester/src/ui/document.h b/tools/auto-tester/src/ui/document.h new file mode 100644 index 0000000000..785ce228f2 --- /dev/null +++ b/tools/auto-tester/src/ui/document.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DOCUMENT_H +#define DOCUMENT_H + +#include +#include + +class Document : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged FINAL) +public: + explicit Document(QObject *parent = nullptr) : QObject(parent) {} + + void setText(const QString &text); + +signals: + void textChanged(const QString &text); + +private: + QString m_text; +}; + +#endif // DOCUMENT_H diff --git a/tools/auto-tester/src/ui/previewpage.cpp b/tools/auto-tester/src/ui/previewpage.cpp new file mode 100644 index 0000000000..1d81d700c0 --- /dev/null +++ b/tools/auto-tester/src/ui/previewpage.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "previewpage.h" + +#include + +bool PreviewPage::acceptNavigationRequest(const QUrl &url, + QWebEnginePage::NavigationType /*type*/, + bool /*isMainFrame*/) +{ + // Only allow qrc:/index.html. + if (url.scheme() == QString("qrc")) + return true; + QDesktopServices::openUrl(url); + return false; +} diff --git a/tools/auto-tester/src/ui/previewpage.h b/tools/auto-tester/src/ui/previewpage.h new file mode 100644 index 0000000000..eb7d7ab00f --- /dev/null +++ b/tools/auto-tester/src/ui/previewpage.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PREVIEWPAGE_H +#define PREVIEWPAGE_H + +#include + +class PreviewPage : public QWebEnginePage +{ + Q_OBJECT +public: + explicit PreviewPage(QObject *parent = nullptr) : QWebEnginePage(parent) {} + +protected: + bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); +}; + +#endif // PREVIEWPAGE_H