summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc')
-rw-r--r--examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc69
1 files changed, 53 insertions, 16 deletions
diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
index e57ec80ec..2ca4bfc45 100644
--- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
+++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
@@ -43,6 +43,7 @@
forward in the web page browsing history.
\li Multi-tab area for displaying web content within tabs.
\li Status bar for displaying hovered links.
+ \li A simple download manager.
\endlist
The web content can be opened in new tabs or separate windows. HTTP and
@@ -52,13 +53,13 @@
\section1 Class Hierarchy
- We start with sketching a diagram of the classes that we are going to
+ We start with sketching a diagram of the main classes that we are going to
implement:
\image simplebrowser-model.png
\list
- \li \c{Browser} is a singleton class managing the application windows.
+ \li \c{Browser} is a class managing the application windows.
\li \c{BrowserWindow} is a \l QMainWindow showing the menu, a navigation
bar, \c {TabWidget}, and a status bar.
\li \c{TabWidget} is a \l QTabWidget and contains one or multiple
@@ -68,11 +69,19 @@
\li \c{WebPage} is a \l QWebEnginePage that represents website content.
\endlist
+ Additionally, we will implement some auxiliary classes:
+
+ \list
+ \li \c{WebPopupWindow} is a \l QWidget for showing popup windows.
+ \li \c{DownloadManagerWidget} is a \l QWidget implementing the downloads
+ list.
+ \endlist
+
\section1 Creating the Browser Main Window
- This example supports multiple main windows that are owned by a
- \c Browser singleton object. This class could also be used for further
- functionality, such as downloading files, bookmarks, and history managers.
+ This example supports multiple main windows that are owned by a \c Browser
+ object. This class also owns the \c DownloadManagerWidget and could be used
+ for further functionality, such as bookmarks and history managers.
In \c main.cpp, we create the first \c BrowserWindow instance and add it
to the \c Browser object. If no arguments are passed on the command line,
@@ -104,6 +113,8 @@
\quotefromfile webenginewidgets/simplebrowser/tabwidget.cpp
\skipto TabWidget::createTab(
\printuntil }
+ \skipto TabWidget::createBackgroundTab(
+ \printuntil }
In \c TabWidget::setupView(), we make sure that the \c TabWidget always forwards
the signals of the currently selected \c WebView:
@@ -225,20 +236,14 @@
\section1 Opening a Web Page
- This section describes the workflow for opening a new page.
- When the user enters a URL in the navigation bar and presses \uicontrol Enter,
- \c QLineEdit::returnPressed is emitted, which lets \c BrowserWindow
- load the requested page:
+ This section describes the workflow for opening a new page. When the user
+ enters a URL in the navigation bar and presses \uicontrol Enter, the \c
+ QLineEdit::returnPressed signal is emitted and the new URL is then handed
+ over to \c TabWidget::setUrl:
\quotefromfile webenginewidgets/simplebrowser/browserwindow.cpp
\skipto connect(m_urlLineEdit
- \printuntil });
-
- The \c loadPage() method calls the \c setUrl() method of \c TabWidget:
-
- \skipto void BrowserWindow::loadPage(const QUrl
- \printuntil }
- \printline }
+ \printline connect
The call is forwarded to the currently selected tab:
@@ -249,4 +254,36 @@
The \c setUrl() method of \c WebView just forwards the \c url to the associated \c WebPage,
which in turn starts the downloading of the page's content in the background.
+
+ \section1 Managing Downloads
+
+ Downloads are associated with a \l QWebEngineProfile. Whenever a download is
+ triggered on a web page the \l QWebEngineProfile::downloadRequested signal is
+ emitted with a \l QWebEngineDownloadItem, which in this example is forwarded
+ to \c DownloadManagerWidget::downloadRequested:
+
+ \quotefromfile webenginewidgets/simplebrowser/browser.cpp
+ \skipto Browser::Browser
+ \printuntil /^\}/
+
+ This method prompts the user for a file name (with a pre-filled suggestion)
+ and starts the download (unless the user cancels the \uicontrol {Save As}
+ dialog):
+
+ \quotefromfile webenginewidgets/simplebrowser/downloadmanagerwidget.cpp
+ \skipto DownloadManagerWidget::downloadRequested
+ \printuntil /^\}/
+
+ The \l QWebEngineDownloadItem object will periodically emit the \l
+ {QWebEngineDownloadItem::}{downloadProgress} signal to notify potential
+ observers of the download progress and the \l
+ {QWebEngineDownloadItem::}{stateChanged} signal when the download is
+ finished or when an error occurs. See \c downloadmanagerwidget.cpp for an
+ example of how these signals can be handled.
+
+ \section1 Licensing
+
+ All icons used in the example, with the exception of \c{AppLogoColor.png},
+ originate from the public domain
+ \l{http://tango.freedesktop.org/Tango_Icon_Library}{Tango Icon Library}.
*/