summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-14 12:29:28 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-14 12:29:54 +0200
commit9be23eb946580519b2b0600cc854ec8050b90659 (patch)
tree63ccf0e565f346a0788d937b004e01d2ec029b5e /examples/webenginewidgets
parent4f2e66f9d898e9c11a7ad6e552d0d47bb15d4051 (diff)
parent981e38d2dc82c047c6ad8ec19427d3ac7434dc3c (diff)
Merge remote-tracking branch 'origin/5.6' into devwip/47-based
Diffstat (limited to 'examples/webenginewidgets')
-rw-r--r--examples/webenginewidgets/demobrowser/demobrowser.pro2
-rw-r--r--examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc6
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp39
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h3
-rw-r--r--examples/webenginewidgets/fancybrowser/doc/src/fancybrowser.qdoc22
5 files changed, 32 insertions, 40 deletions
diff --git a/examples/webenginewidgets/demobrowser/demobrowser.pro b/examples/webenginewidgets/demobrowser/demobrowser.pro
index 0893fe649..14347de71 100644
--- a/examples/webenginewidgets/demobrowser/demobrowser.pro
+++ b/examples/webenginewidgets/demobrowser/demobrowser.pro
@@ -75,7 +75,7 @@ win32 {
mac {
ICON = demobrowser.icns
QMAKE_INFO_PLIST = Info_mac.plist
- TARGET = Browser
+ TARGET = Demobrowser
}
EXAMPLE_FILES = Info_mac.plist demobrowser.icns demobrowser.ico demobrowser.rc
diff --git a/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc
index 1264606db..ba61dd79d 100644
--- a/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc
+++ b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc
@@ -26,13 +26,13 @@
****************************************************************************/
/*!
- \example demobrowser
+ \example webenginewidgets/demobrowser
\title WebEngine Demo Browser Example
\ingroup webengine-widgetexamples
\brief A demo browser based on Qt WebEngine Widgets
- The Demo Browser example shows the \l{Qt WebEngine Widgets} module in action,
- providing a little Web browser application with support for tabs.
+ \e {Demo Browser} demonstrates how to use the \l{Qt WebEngine Widgets C++ Classes}
+ {Qt WebEngine C++ classes} to develop a small Web browser application with support for tabs.
\image browser-demo.png
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index 4532683b5..9e08426f1 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -223,7 +223,7 @@ TabWidget::TabWidget(QWidget *parent)
setElideMode(Qt::ElideRight);
connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab()));
- connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
+ connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(requestCloseTab(int)));
connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int)));
connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int)));
connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int)));
@@ -241,7 +241,7 @@ TabWidget::TabWidget(QWidget *parent)
m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this);
m_closeTabAction->setShortcuts(QKeySequence::Close);
m_closeTabAction->setIconVisibleInMenu(false);
- connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab()));
+ connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(requestCloseTab()));
m_nextTabAction = new QAction(tr("Show Next Tab"), this);
QList<QKeySequence> shortcuts;
@@ -552,12 +552,8 @@ void TabWidget::windowCloseRequested()
WebPage *webPage = qobject_cast<WebPage*>(sender());
WebView *webView = qobject_cast<WebView*>(webPage->view());
int index = webViewIndex(webView);
- if (index >= 0) {
- if (count() == 1)
- webView->webPage()->mainWindow()->close();
- else
- closeTab(index);
- }
+ if (index >= 0)
+ closeTab(index);
}
void TabWidget::closeOtherTabs(int index)
@@ -582,30 +578,25 @@ void TabWidget::cloneTab(int index)
}
// When index is -1 index chooses the current tab
-void TabWidget::closeTab(int index)
+void TabWidget::requestCloseTab(int index)
{
if (index < 0)
index = currentIndex();
if (index < 0 || index >= count())
return;
+ WebView *tab = webView(index);
+ if (!tab)
+ return;
+ tab->page()->triggerAction(QWebEnginePage::RequestClose);
+}
+
+void TabWidget::closeTab(int index)
+{
+ if (index < 0 || index >= count())
+ return;
bool hasFocus = false;
if (WebView *tab = webView(index)) {
-#if defined(QWEBENGINEPAGE_ISMODIFIED)
- if (tab->isModified()) {
- QMessageBox closeConfirmation(tab);
- closeConfirmation.setWindowFlags(Qt::Sheet);
- closeConfirmation.setWindowTitle(tr("Do you really want to close this page?"));
- closeConfirmation.setInformativeText(tr("You have modified this page and when closing it you would lose the modification.\n"
- "Do you really want to close this page?\n"));
- closeConfirmation.setIcon(QMessageBox::Question);
- closeConfirmation.addButton(QMessageBox::Yes);
- closeConfirmation.addButton(QMessageBox::No);
- closeConfirmation.setEscapeButton(QMessageBox::No);
- if (closeConfirmation.exec() == QMessageBox::No)
- return;
- }
-#endif
hasFocus = tab->hasFocus();
if (m_profile == QWebEngineProfile::defaultProfile()) {
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index f6c4edba2..0f2a20c34 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -196,7 +196,8 @@ public slots:
void loadUrlInCurrentTab(const QUrl &url);
WebView *newTab(bool makeCurrent = true);
void cloneTab(int index = -1);
- void closeTab(int index = -1);
+ void requestCloseTab(int index = -1);
+ void closeTab(int index);
void closeOtherTabs(int index);
void reloadTab(int index = -1);
void reloadAllTabs();
diff --git a/examples/webenginewidgets/fancybrowser/doc/src/fancybrowser.qdoc b/examples/webenginewidgets/fancybrowser/doc/src/fancybrowser.qdoc
index e6c6ada34..b798e4832 100644
--- a/examples/webenginewidgets/fancybrowser/doc/src/fancybrowser.qdoc
+++ b/examples/webenginewidgets/fancybrowser/doc/src/fancybrowser.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \example fancybrowser
+ \example webenginewidgets/fancybrowser
\title WebEngine Fancy Browser Example
\ingroup webengine-widgetexamples
\brief Demonstrates how to use browse web and manipulate content
@@ -48,7 +48,7 @@
The \c MainWindow class inherits QMainWindow. It implements a number of
slots to perform actions on both the application and on the web content.
- \snippet fancybrowser/mainwindow.h 1
+ \snippet webenginewidgets/fancybrowser/mainwindow.h 1
We also declare a QString that contains the jQuery, a QWebView
that displays the web content, and a QLineEdit that acts as the
@@ -58,7 +58,7 @@
We start by implementing the constructor.
- \snippet fancybrowser/mainwindow.cpp 1
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 1
The first part of the constructor sets the value of \c progress to
0. This value will be used later in the code to visualize the
@@ -68,7 +68,7 @@
content. The jQuery library is a JavaScript library that provides different
functions for manipulating HTML.
- \snippet fancybrowser/mainwindow.cpp 2
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 2
The second part of the constructor creates a QWebView and connects
slots to the views signals. Furthermore, we create a QLineEdit as
@@ -77,13 +77,13 @@
QLineEdit to a QToolbar together with a set of navigation actions
from QWebView::pageAction.
- \snippet fancybrowser/mainwindow.cpp 3
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 3
The third and last part of the constructor implements two QMenus and assigns
a set of actions to them. The last line sets the QWebView as the central
widget in the QMainWindow.
- \snippet fancybrowser/mainwindow.cpp 4
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 4
When the page is loaded, \c adjustLocation() updates the address
bar; \c adjustLocation() is triggered by the \c loadFinished()
@@ -92,13 +92,13 @@
the new web page has finished loading, \c adjustLocation() will be
run once more to update the address bar.
- \snippet fancybrowser/mainwindow.cpp 5
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 5
\c adjustTitle() sets the window title and displays the loading
progress. This slot is triggered by the \c titleChanged() signal
in QWebView.
- \snippet fancybrowser/mainwindow.cpp 6
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 6
When a web page has loaded, \c finishLoading() is triggered by the
\c loadFinished() signal in QWebView. \c finishLoading() then updates the
@@ -113,7 +113,7 @@
that the images of the newly loaded page respect the state of the toggle
action.
- \snippet fancybrowser/mainwindow.cpp 7
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 7
The first jQuery-based function, \c highlightAllLinks(), is designed to
highlight all links in the current webpage. The JavaScript code looks
@@ -121,14 +121,14 @@
For each such element, the background color is set to be yellow by
using CSS.
- \snippet fancybrowser/mainwindow.cpp 8
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 8
The \c rotateImages() function rotates the images on the current
web page. This JavaScript code relies on CSS transforms and
looks up all \e {img} elements and rotates the images 180 degrees
and then back again.
- \snippet fancybrowser/mainwindow.cpp 9
+ \snippet webenginewidgets/fancybrowser/mainwindow.cpp 9
The remaining four methods remove different elements from the current web
page. \c removeGifImages() removes all GIF images on the page by looking up