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

/*!
    \example pdfviewer
    \meta installpath pdfwidgets
    \ingroup qtpdf-examples
    \examplecategory {User Interface Components}

    \title PDF Viewer Widget Example
    \brief A widget-based PDF viewer that allows scrolling through the pages.

    \image pdfviewer.png

    \e {PDF Viewer} demonstrates how to use the QPdfView class to render
    PDF documents and the QPdfPageNavigator class to navigate them.

    \QC and the integrated \QD were used to create the
    example UI and to connect it to the code. This affects the code, which
    might be somewhat different to what you would typically write by hand.
    For more information about using \QD, see
    \l{\QD Manual} and \l{\QC: Tutorial: Qt Widgets application}.

    \include examples-run.qdocinc

    \section1 Creating the Main Window

    The MainWindow class inherits the QMainWindow class:

    \quotefromfile pdfviewer/mainwindow.h
    \skipto public
    \printuntil ~MainWindow()

    The class declares public and private slots that match the actions of the
    selectors:

    \printuntil on_actionForward_triggered()

    The actual layout of the main window is specified in a \c{.ui} file. The
    widgets and actions are available at runtime in the \c ui member variable.

    \printuntil Ui::

    The \c m_zoomSelector variable holds the zoom selector and the
    \c m_pageSelector holds the page selector. The \c m_document
    variable is an instance of the QPdfDocument class that contains
    the PDF document.

    \printuntil }

    The actual setup of the different objects is done in the MainWindow
    constructor:

    \quotefromfile pdfviewer/mainwindow.cpp
    \skipto MainWindow
    \printuntil {

    The constructor first calls \c setupUi() to construct most of the main window
    according to the UI file. The zoom and page selectors need to be added to
    the toolbar via \l QToolBar::insertWidget(), because that cannot be done
    in a UI file:

    \printuntil insertWidget(ui->actionForward, m_pageSelector);

    We connect relevant signals to the page selector spinbox and the browser-style
    back and forward buttons:

    \printuntil forwardAvailableChanged

    We connect the \c zoomModeChanged and \c zoomFactor changed signals of the
    PDF view to the functions that reset the zoom selector:

    \printuntil reset()

    We then load the PDF document to the viewer:

    \dots
    \skipto pdfView
    \printuntil ;

    Finally, we connect the \c zoomFactorChanged signal to the function that
    sets the value of the zoom selector:

    \printuntil }

    \section1 Files and Attributions
*/
