summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/demobrowser
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/demobrowser
parent4f2e66f9d898e9c11a7ad6e552d0d47bb15d4051 (diff)
parent981e38d2dc82c047c6ad8ec19427d3ac7434dc3c (diff)
Merge remote-tracking branch 'origin/5.6' into devwip/47-based
Diffstat (limited to 'examples/webenginewidgets/demobrowser')
-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
4 files changed, 21 insertions, 29 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();