From 3f1ce362b7695436e2979823393a54e3e793caa9 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Wed, 26 Apr 2017 10:59:48 +0200 Subject: Add StyleSheet Browser example Demonstrates how to inject and remove stylesheets using the user scripts API. Change-Id: If498365897618f873fa96d7a7b04a370e196618e Reviewed-by: Leena Miettinen Reviewed-by: Allan Sandfeld Jensen --- .../doc/images/stylesheetbrowser.png | Bin 0 -> 45161 bytes .../doc/src/stylesheetbrowser.qdoc | 58 ++++++ .../webenginewidgets/stylesheetbrowser/main.cpp | 57 ++++++ .../stylesheetbrowser/mainwindow.cpp | 127 ++++++++++++++ .../stylesheetbrowser/mainwindow.h | 74 ++++++++ .../stylesheetbrowser/mainwindow.ui | 89 ++++++++++ .../stylesheetbrowser/stylesheetbrowser.pro | 23 +++ .../stylesheetbrowser/stylesheetbrowser.qrc | 5 + .../stylesheetbrowser/stylesheetdialog.cpp | 132 ++++++++++++++ .../stylesheetbrowser/stylesheetdialog.h | 71 ++++++++ .../stylesheetbrowser/stylesheetdialog.ui | 195 +++++++++++++++++++++ .../stylesheetbrowser/view-refresh.png | Bin 0 -> 1364 bytes examples/webenginewidgets/webenginewidgets.pro | 3 +- 13 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png create mode 100644 examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc create mode 100644 examples/webenginewidgets/stylesheetbrowser/main.cpp create mode 100644 examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp create mode 100644 examples/webenginewidgets/stylesheetbrowser/mainwindow.h create mode 100644 examples/webenginewidgets/stylesheetbrowser/mainwindow.ui create mode 100644 examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro create mode 100644 examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc create mode 100644 examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp create mode 100644 examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h create mode 100644 examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui create mode 100644 examples/webenginewidgets/stylesheetbrowser/view-refresh.png diff --git a/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png b/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png new file mode 100644 index 000000000..32c7c43ed Binary files /dev/null and b/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png differ diff --git a/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc b/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc new file mode 100644 index 000000000..c5506a623 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example webenginewidgets/stylesheetbrowser + \title WebEngine StyleSheet Browser Example + \ingroup webengine-widgetexamples + \brief Demonstrates how to inject CSS into web pages using user scripts + + \image stylesheetbrowser.png + + \e {StyleSheet Browser} demonstrates how to use the \l{Qt WebEngine Widgets C++ Classes} + {Qt WebEngine C++ classes} to inject user stylesheets into web pages. + + \include examples-run.qdocinc + + \section1 Working With Stylesheets + + We use JavaScript to create and append CSS elements to the documents. + After declaring the script source, QWebEnginePage::runJavaScript() can run it + immediately and apply newly created styles on the current content of the web view. + Encapsulating the script into a QWebEngineScript and adding it to the script collection + of QWebEnginePage makes its effect permanent. + + \quotefromfile webenginewidgets/stylesheetbrowser/mainwindow.cpp + \skipto MainWindow::insertStyleSheet + \printuntil /^\}/ + + Removing stylesheets can be done similarly: + + \quotefromfile webenginewidgets/stylesheetbrowser/mainwindow.cpp + \skipto MainWindow::removeStyleSheet + \printuntil /^\}/ +*/ diff --git a/examples/webenginewidgets/stylesheetbrowser/main.cpp b/examples/webenginewidgets/stylesheetbrowser/main.cpp new file mode 100644 index 000000000..c353a704b --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the demonstration applications 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication::setOrganizationName("The Qt Company"); + QCoreApplication::setOrganizationDomain("www.qt.io"); + QCoreApplication::setApplicationName("StyleSheet Browser"); + + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication a(argc, argv); + MainWindow w(QUrl("http://qt.io")); + w.show(); + return a.exec(); +} diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp b/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp new file mode 100644 index 000000000..01697e8e4 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the demonstration applications 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include "stylesheetdialog.h" + +MainWindow::MainWindow(const QUrl &url) : + QMainWindow(), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + connect(ui->urlBar, &QLineEdit::returnPressed, this, &MainWindow::urlEntered); + connect(ui->webEngineView, &QWebEngineView::urlChanged, this, &MainWindow::urlChanged); + connect(ui->settingsButton, &QPushButton::clicked, this, &MainWindow::showStyleSheetsDialog); + connect(ui->reloadButton, &QPushButton::clicked, this, &MainWindow::reloadRequested); + + QSettings settings; + settings.beginGroup("styleSheets"); + QStringList styleSheets = settings.allKeys(); + for (auto name : qAsConst(styleSheets)) + insertStyleSheet(name, settings.value(name, QString()).toString(), false); + settings.endGroup(); + + ui->webEngineView->setUrl(url); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::insertStyleSheet(const QString &name, const QString &source, bool immediately) +{ + QWebEngineScript script; + QString s = QString::fromLatin1("(function() {"\ + " css = document.createElement('style');"\ + " css.type = 'text/css';"\ + " css.id = '%1';"\ + " document.head.appendChild(css);"\ + " css.innerText = '%2';"\ + "})()").arg(name).arg(source.simplified()); + if (immediately) + ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld); + + script.setName(name); + script.setSourceCode(s); + script.setInjectionPoint(QWebEngineScript::DocumentReady); + script.setRunsOnSubFrames(true); + script.setWorldId(QWebEngineScript::ApplicationWorld); + ui->webEngineView->page()->scripts().insert(script); +} + +void MainWindow::removeStyleSheet(const QString &name, bool immediately) +{ + QString s = QString::fromLatin1("(function() {"\ + " var element = document.getElementById('%1');"\ + " element.outerHTML = '';"\ + " delete element;"\ + "})()").arg(name); + if (immediately) + ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld); + + QWebEngineScript script = ui->webEngineView->page()->scripts().findScript(name); + ui->webEngineView->page()->scripts().remove(script); +} + +void MainWindow::urlEntered() +{ + ui->webEngineView->setUrl(QUrl::fromUserInput(ui->urlBar->text())); +} + +void MainWindow::urlChanged(const QUrl &url) +{ + ui->urlBar->setText(url.toString()); +} + +void MainWindow::showStyleSheetsDialog() +{ + StylesheetDialog *dialog = new StylesheetDialog(this); + dialog->show(); +} + +void MainWindow::reloadRequested() +{ + ui->webEngineView->reload(); +} diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.h b/examples/webenginewidgets/stylesheetbrowser/mainwindow.h new file mode 100644 index 000000000..a6ee6a44f --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/mainwindow.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the demonstration applications 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(const QUrl &url); + ~MainWindow(); + + void insertStyleSheet(const QString &name, const QString &source, bool immediately); + void removeStyleSheet(const QString &name, bool immediately); + +private slots: + void urlEntered(); + void urlChanged(const QUrl &url); + void showStyleSheetsDialog(); + void reloadRequested(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui b/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui new file mode 100644 index 000000000..f9c1af969 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui @@ -0,0 +1,89 @@ + + + MainWindow + + + + 0 + 0 + 713 + 455 + + + + StyleSheet Browser + + + false + + + + + + + + + + + + + + + + + + + Ctrl+R + + + + :/view-refresh.png:/view-refresh.png + + + + + + + Settings + + + + + + + + + + + about:blank + + + + + + + + + + + + + 0 + 0 + 713 + 20 + + + + + + + + QWebEngineView + QWidget +
QtWebEngineWidgets/QWebEngineView
+
+
+ + +
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro b/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro new file mode 100644 index 000000000..c5f1080e3 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +TARGET = stylesheetbrowser +QT += webenginewidgets +CONFIG += c++11 + +HEADERS += \ + mainwindow.h \ + stylesheetdialog.h + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + stylesheetdialog.cpp + +FORMS += \ + mainwindow.ui \ + stylesheetdialog.ui + +RESOURCES += stylesheetbrowser.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/stylesheetbrowser +INSTALLS += target diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc b/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc new file mode 100644 index 000000000..8805f2c53 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc @@ -0,0 +1,5 @@ + + + view-refresh.png + + diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp new file mode 100644 index 000000000..65c50bfb3 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the demonstration applications 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "stylesheetdialog.h" +#include "ui_stylesheetdialog.h" + +StylesheetDialog::StylesheetDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::StylesheetDialog) +{ + ui->setupUi(this); + + connect(ui->styleSheetList, &QListWidget::currentItemChanged, this, &StylesheetDialog::currentStyleSheetChanged); + connect(ui->fileNameEdit, &QLineEdit::textChanged, this, &StylesheetDialog::fileNameChanged); + + connect(ui->addButton, &QPushButton::clicked, this, &StylesheetDialog::addButtonClicked); + connect(ui->removeButton, &QPushButton::clicked, this, &StylesheetDialog::removeButtonClicked); + + QSettings settings; + settings.beginGroup("styleSheets"); + for (auto name : settings.allKeys()) + new QListWidgetItem(name, ui->styleSheetList); + settings.endGroup(); +} + +StylesheetDialog::~StylesheetDialog() +{ + delete ui; +} + +void StylesheetDialog::currentStyleSheetChanged(QListWidgetItem *current, QListWidgetItem *previous) +{ + if (!previous) { + // Select the first item on startup + ui->styleSheetList->setCurrentItem(current); + } + + if (!current) { + ui->fileNameEdit->setText(QString()); + ui->sourceCodeEdit->setPlainText(QString()); + return; + } + + QSettings settings; + settings.beginGroup("styleSheets"); + ui->fileNameEdit->setText(current->text()); + ui->sourceCodeEdit->setPlainText(settings.value(current->text(), QString()).toString()); + settings.endGroup(); +} + +void StylesheetDialog::fileNameChanged(const QString &text) +{ + QList items = ui->styleSheetList->findItems(text, Qt::MatchFixedString); + if (items.size()) + ui->addButton->setEnabled(false); + else + ui->addButton->setEnabled(true); +} + +void StylesheetDialog::addButtonClicked() +{ + new QListWidgetItem(ui->fileNameEdit->text(), ui->styleSheetList); + + MainWindow *window = static_cast(parent()); + const QString name = ui->fileNameEdit->text(); + const QString source = ui->sourceCodeEdit->toPlainText(); + window->insertStyleSheet(name, source, true); + + QSettings settings; + settings.beginGroup("styleSheets"); + settings.setValue(name, source); + settings.endGroup(); + + ui->addButton->setEnabled(false); +} + +void StylesheetDialog::removeButtonClicked() +{ + if (ui->styleSheetList->selectedItems().isEmpty()) + return; + + MainWindow *window = static_cast(parent()); + QSettings settings; + settings.beginGroup("styleSheets"); + + QListWidgetItem *item = ui->styleSheetList->selectedItems().first(); + const QString name = item->text(); + window->removeStyleSheet(name, true); + settings.remove(name); + delete item; + + settings.endGroup(); +} diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h new file mode 100644 index 000000000..3b21350c7 --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the demonstration applications 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STYLESHEETDIALOG_H +#define STYLESHEETDIALOG_H + +#include +#include + +namespace Ui { +class StylesheetDialog; +} + +class StylesheetDialog : public QDialog +{ + Q_OBJECT + +public: + explicit StylesheetDialog(QWidget *parent = 0); + ~StylesheetDialog(); + +private slots: + void currentStyleSheetChanged(QListWidgetItem *current, QListWidgetItem *previous); + void fileNameChanged(const QString &text); + + void addButtonClicked(); + void removeButtonClicked(); + +private: + Ui::StylesheetDialog *ui; +}; + +#endif // STYLESHEETDIALOG_H diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui new file mode 100644 index 000000000..3e70ce89a --- /dev/null +++ b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui @@ -0,0 +1,195 @@ + + + StylesheetDialog + + + Qt::ApplicationModal + + + + 0 + 0 + 547 + 431 + + + + + 0 + 0 + + + + + 547 + 431 + + + + + 547 + 431 + + + + Stylesheets + + + true + + + + + + + 0 + 0 + + + + + + 9 + 9 + 511 + 371 + + + + + QLayout::SetDefaultConstraint + + + + + + + + + + + + + 0 + 0 + + + + Stylesheet name: + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Source code: + + + + + + + + Courier New + 10 + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + StylesheetDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + StylesheetDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/examples/webenginewidgets/stylesheetbrowser/view-refresh.png b/examples/webenginewidgets/stylesheetbrowser/view-refresh.png new file mode 100644 index 000000000..cab4d02c7 Binary files /dev/null and b/examples/webenginewidgets/stylesheetbrowser/view-refresh.png differ diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro index 353104d6a..4e4ca868b 100644 --- a/examples/webenginewidgets/webenginewidgets.pro +++ b/examples/webenginewidgets/webenginewidgets.pro @@ -6,7 +6,8 @@ SUBDIRS += \ cookiebrowser \ demobrowser \ markdowneditor \ - simplebrowser + simplebrowser \ + stylesheetbrowser contains(WEBENGINE_CONFIG, use_spellchecker):!cross_compile { !contains(WEBENGINE_CONFIG, use_native_spellchecker) { -- cgit v1.2.3