summaryrefslogtreecommitdiff
path: root/examples/webenginewidgets/simplebrowser/doc/src
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2017-06-12 15:57:31 +0200
committerKai Koehne <kai.koehne@qt.io>2017-07-19 10:16:37 +0000
commita71efecbcc6f714d619a922a0eaa665a3c68a3b2 (patch)
tree8d6770e40c83a0b4ef3f6cbff4f7d8a1adf77324 /examples/webenginewidgets/simplebrowser/doc/src
parentae71f77d5f680d8b40c9598321a687318a7ff0b2 (diff)
downloadqtwebengine-a71efecbcc6f714d619a922a0eaa665a3c68a3b2.tar.gz
Update Simple Browser example
- Accept downloads and add a downloads list. - Fix toolbar icons being pixelated on hidpi screens by - enabling attribute AA_UseHighDpiPixmaps, and - replacing the 22x22 icons with 32x32 versions. - Move favicon selection to WebView to reduce duplication. - Replace UrlLineEdit with a standard QLineEdit using a QAction for the favicon and setClearButtonEnabled(true) for the clear button. - Fix bug where the "File -> New Tab" action would create background tabs because the QAction::triggered(bool) signal was connected to the TabWidget::createTab(bool) slot with the bool argument having a completely different meaning between the two. - Make the toolbar unmovable. Nobody wants to move the toolbar. - Add tooltips to toolbar buttons. - Add tooltips to the tab bar (page titles). - Stop adding icons to menu items only to disable them right after. Task-number: QTBUG-60655 Change-Id: I10cc0fa82dbf39281bbdbbf9ef901e1b26402f80 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/doc/src')
-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..6736f8570 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::defaultProfile 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}.
*/