// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \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 /^\}/

    \section1 Files and Attributions

    The example uses icons from the Tango Icon Library:

    \table
    \row
        \li \l{stylesheetbrowser-tango}{Tango Icon Library}
        \li Public Domain
    \endtable
*/
