Skip to content

Commit 9464e7f

Browse files
author
Allan Sandfeld Jensen
committed
Remove new API added in 5.7
Return the API to what it was in 5.6 Change-Id: I25e7f321802cfd69017120d5645e93c6e0d2fd32 Reviewed-by: Peter Varga <[email protected]> Reviewed-by: Joerg Bornemann <[email protected]>
1 parent 49f2cb3 commit 9464e7f

File tree

132 files changed

+1000
-5854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+1000
-5854
lines changed

examples/webengine/quicknanobrowser/BrowserWindow.qml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ ApplicationWindow {
8484
property alias errorPageEnabled: errorPageEnabled.checked;
8585
property alias pluginsEnabled: pluginsEnabled.checked;
8686
property alias fullScreenSupportEnabled: fullScreenSupportEnabled.checked;
87-
property alias autoLoadIconsForPage: autoLoadIconsForPage.checked;
88-
property alias touchIconsEnabled: touchIconsEnabled.checked;
8987
}
9088

9189
Action {
@@ -237,7 +235,6 @@ ApplicationWindow {
237235
z: 2
238236
id: faviconImage
239237
width: 16; height: 16
240-
sourceSize: Qt.size(width, height)
241238
source: currentWebView && currentWebView.icon
242239
}
243240
style: TextFieldStyle {
@@ -297,19 +294,6 @@ ApplicationWindow {
297294
checked: (currentWebView.profile.httpCacheType == WebEngineProfile.DiskHttpCache)
298295
onToggled: currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache
299296
}
300-
MenuItem {
301-
id: autoLoadIconsForPage
302-
text: "Icons On"
303-
checkable: true
304-
checked: WebEngine.settings.autoLoadIconsForPage
305-
}
306-
MenuItem {
307-
id: touchIconsEnabled
308-
text: "Touch Icons On"
309-
checkable: true
310-
checked: WebEngine.settings.touchIconsEnabled
311-
enabled: autoLoadIconsForPage.checked
312-
}
313297
}
314298
}
315299
}
@@ -381,8 +365,6 @@ ApplicationWindow {
381365
settings.errorPageEnabled: appSettings.errorPageEnabled
382366
settings.pluginsEnabled: appSettings.pluginsEnabled
383367
settings.fullScreenSupportEnabled: appSettings.fullScreenSupportEnabled
384-
settings.autoLoadIconsForPage: appSettings.autoLoadIconsForPage
385-
settings.touchIconsEnabled: appSettings.touchIconsEnabled
386368

387369
onCertificateError: {
388370
error.defer()

examples/webenginewidgets/demobrowser/browserapplication.cpp

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#include <QtNetwork/QLocalServer>
7373
#include <QtNetwork/QLocalSocket>
7474
#include <QtNetwork/QNetworkProxy>
75+
#include <QtNetwork/QNetworkReply>
7576
#include <QtNetwork/QSslSocket>
7677

7778
#include <QWebEngineProfile>
@@ -296,21 +297,6 @@ void BrowserApplication::loadSettings()
296297

297298
defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString());
298299
defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString());
299-
300-
switch (settings.value(QLatin1String("faviconDownloadMode"), 1).toInt()) {
301-
case 0:
302-
defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
303-
break;
304-
case 1:
305-
defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
306-
defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, false);
307-
break;
308-
case 2:
309-
defaultSettings->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
310-
defaultSettings->setAttribute(QWebEngineSettings::TouchIconsEnabled, true);
311-
break;
312-
}
313-
314300
settings.endGroup();
315301
settings.beginGroup(QLatin1String("cookies"));
316302

@@ -525,6 +511,10 @@ QNetworkAccessManager *BrowserApplication::networkAccessManager()
525511
{
526512
if (!s_networkAccessManager) {
527513
s_networkAccessManager = new QNetworkAccessManager();
514+
connect(s_networkAccessManager, &QNetworkAccessManager::authenticationRequired,
515+
BrowserApplication::instance(), &BrowserApplication::authenticationRequired);
516+
connect(s_networkAccessManager, &QNetworkAccessManager::proxyAuthenticationRequired,
517+
BrowserApplication::instance(), &BrowserApplication::proxyAuthenticationRequired);
528518
}
529519
return s_networkAccessManager;
530520
}
@@ -583,3 +573,68 @@ void BrowserApplication::setPrivateBrowsing(bool privateBrowsing)
583573
}
584574
emit privateBrowsingChanged(privateBrowsing);
585575
}
576+
577+
void BrowserApplication::setLastAuthenticator(QAuthenticator *authenticator)
578+
{
579+
m_lastAuthenticator = QAuthenticator(*authenticator);
580+
}
581+
582+
void BrowserApplication::setLastProxyAuthenticator(QAuthenticator *authenticator)
583+
{
584+
m_lastProxyAuthenticator = QAuthenticator(*authenticator);
585+
}
586+
587+
void BrowserApplication::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
588+
{
589+
if (m_lastAuthenticator.isNull())
590+
return;
591+
592+
593+
Q_ASSERT(m_lastAuthenticator.option("key").isValid());
594+
QByteArray lastKey = m_lastAuthenticator.option("key").toByteArray();
595+
QByteArray key = BrowserApplication::authenticationKey(reply->url(), authenticator->realm());
596+
597+
if (lastKey == key)
598+
*authenticator = m_lastAuthenticator;
599+
}
600+
601+
void BrowserApplication::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
602+
{
603+
if (m_lastProxyAuthenticator.isNull())
604+
return;
605+
606+
QNetworkProxy::ProxyType proxyType = proxy.type();
607+
if (proxyType != QNetworkProxy::HttpProxy || proxyType != QNetworkProxy::HttpCachingProxy)
608+
return;
609+
610+
Q_ASSERT(m_lastProxyAuthenticator.option("host").isValid());
611+
QByteArray lastKey = m_lastProxyAuthenticator.option("key").toByteArray();
612+
QByteArray key = BrowserApplication::proxyAuthenticationKey(proxy, authenticator->realm());
613+
614+
if (lastKey == key)
615+
*authenticator = m_lastAuthenticator;
616+
}
617+
618+
// TODO: Remove these functions (QTBUG-47967)
619+
QByteArray BrowserApplication::authenticationKey(const QUrl &url, const QString &realm)
620+
{
621+
QUrl copy = url;
622+
copy.setFragment(realm);
623+
return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery);
624+
}
625+
626+
QByteArray BrowserApplication::proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm)
627+
{
628+
QString host = QString("%1:%2").arg(proxy.hostName()).arg(proxy.port());
629+
return BrowserApplication::proxyAuthenticationKey(proxy.user(), host, realm);
630+
}
631+
632+
QByteArray BrowserApplication::proxyAuthenticationKey(const QString &user, const QString &host, const QString &realm)
633+
{
634+
QUrl key;
635+
key.setScheme(QLatin1String("proxy-http"));
636+
key.setUserName(user);
637+
key.setHost(host);
638+
key.setFragment(realm);
639+
return "auth:" + key.toEncoded();
640+
}

examples/webenginewidgets/demobrowser/browserapplication.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
QT_BEGIN_NAMESPACE
6464
class QLocalServer;
6565
class QNetworkAccessManager;
66+
class QNetworkProxy;
67+
class QNetworkReply;
6668
class QWebEngineProfile;
6769
QT_END_NAMESPACE
6870

@@ -91,6 +93,14 @@ class BrowserApplication : public QApplication
9193
bool canRestoreSession() const;
9294
bool privateBrowsing() const { return m_privateBrowsing; }
9395

96+
void setLastAuthenticator(QAuthenticator *);
97+
void setLastProxyAuthenticator(QAuthenticator *);
98+
99+
// TODO: Remove these functions (QTBUG-47967)
100+
static QByteArray authenticationKey(const QUrl &, const QString &);
101+
static QByteArray proxyAuthenticationKey(const QNetworkProxy &, const QString &);
102+
static QByteArray proxyAuthenticationKey(const QString &, const QString &, const QString &);
103+
94104
static HistoryManager *historyManager();
95105
static CookieJar *cookieJar();
96106
static DownloadManager *downloadManager();
@@ -107,6 +117,8 @@ public slots:
107117
void lastWindowClosed();
108118
void quitBrowser();
109119
void setPrivateBrowsing(bool);
120+
void authenticationRequired(QNetworkReply *, QAuthenticator *);
121+
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *);
110122

111123
signals:
112124
void privateBrowsingChanged(bool);

examples/webenginewidgets/demobrowser/browsermainwindow.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "chasewidget.h"
5757
#include "downloadmanager.h"
5858
#include "history.h"
59-
#include "printtopdfdialog.h"
6059
#include "settings.h"
6160
#include "tabwidget.h"
6261
#include "toolbarsearch.h"
@@ -313,10 +312,8 @@ void BrowserMainWindow::setupMenu()
313312
#if defined(QWEBENGINEPAGE_PRINT)
314313
fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview()));
315314
fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print);
316-
#endif
317-
fileMenu->addAction(tr("&Print to PDF..."), this, SLOT(slotFilePrintToPDF()));
318315
fileMenu->addSeparator();
319-
316+
#endif
320317
QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing()));
321318
action->setCheckable(true);
322319
action->setChecked(BrowserApplication::instance()->privateBrowsing());
@@ -717,36 +714,6 @@ void BrowserMainWindow::slotFilePrint()
717714
#endif
718715
}
719716

720-
void BrowserMainWindow::slotHandlePdfPrinted(const QByteArray& result)
721-
{
722-
if (!result.size())
723-
return;
724-
725-
QFile file(m_printerOutputFileName);
726-
727-
m_printerOutputFileName.clear();
728-
if (!file.open(QFile::WriteOnly))
729-
return;
730-
731-
file.write(result.data(), result.size());
732-
file.close();
733-
}
734-
735-
void BrowserMainWindow::slotFilePrintToPDF()
736-
{
737-
if (!currentTab() || !m_printerOutputFileName.isEmpty())
738-
return;
739-
740-
QFileInfo info(QStringLiteral("printout.pdf"));
741-
PrintToPdfDialog *dialog = new PrintToPdfDialog(info.absoluteFilePath(), this);
742-
dialog->setWindowTitle(tr("Print to PDF"));
743-
if (dialog->exec() != QDialog::Accepted || dialog->filePath().isEmpty())
744-
return;
745-
746-
m_printerOutputFileName = dialog->filePath();
747-
currentTab()->page()->printToPdf(invoke(this, &BrowserMainWindow::slotHandlePdfPrinted), dialog->pageLayout());
748-
}
749-
750717
#if defined(QWEBENGINEPAGE_PRINT)
751718
void BrowserMainWindow::printRequested(QWebEngineFrame *frame)
752719
{

examples/webenginewidgets/demobrowser/browsermainwindow.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ private slots:
109109
void slotFileOpen();
110110
void slotFilePrintPreview();
111111
void slotFilePrint();
112-
void slotFilePrintToPDF();
113112
void slotPrivateBrowsing();
114113
void slotFileSaveAs();
115114
void slotEditFind();
@@ -138,7 +137,6 @@ private slots:
138137
void slotOpenActionUrl(QAction *action);
139138
void slotShowWindow();
140139
void slotSwapFocus();
141-
void slotHandlePdfPrinted(const QByteArray&);
142140

143141
#if defined(QWEBENGINEPAGE_PRINT)
144142
void printRequested(QWebEngineFrame *frame);
@@ -181,7 +179,6 @@ private slots:
181179
QIcon m_stopIcon;
182180

183181
QString m_lastSearch;
184-
QString m_printerOutputFileName;
185182
friend class BrowserApplication;
186183
};
187184

examples/webenginewidgets/demobrowser/demobrowser.pro

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ FORMS += \
1515
downloads.ui \
1616
history.ui \
1717
passworddialog.ui \
18-
printtopdfdialog.ui \
1918
proxy.ui \
20-
savepagedialog.ui \
2119
settings.ui
2220

2321
HEADERS += \
@@ -33,8 +31,6 @@ HEADERS += \
3331
fullscreennotification.h \
3432
history.h \
3533
modelmenu.h \
36-
printtopdfdialog.h \
37-
savepagedialog.h \
3834
searchlineedit.h \
3935
settings.h \
4036
squeezelabel.h \
@@ -57,8 +53,6 @@ SOURCES += \
5753
fullscreennotification.cpp \
5854
history.cpp \
5955
modelmenu.cpp \
60-
printtopdfdialog.cpp \
61-
savepagedialog.cpp \
6256
searchlineedit.cpp \
6357
settings.cpp \
6458
squeezelabel.cpp \

0 commit comments

Comments
 (0)