diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-20 16:01:37 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-20 16:04:42 +0100 |
commit | 1f474fcc4cd47a85ce8d99f07d18b46ef2af5898 (patch) | |
tree | d4e52b5ac98343b4c2417d622164bf320d781a59 /src/webengine | |
parent | 4cc28c7c89f794d469f5e8f778ff05effe8c646f (diff) | |
parent | 1173d48149a8133b607894b67e1ec32de68e21e8 (diff) |
Merge branch '5.6' into dev
Change-Id: I05fe27b8321944cf68cc96dfa9dfcaeb54c8c8cd
Diffstat (limited to 'src/webengine')
18 files changed, 161 insertions, 71 deletions
diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h index 6f54528d4..7deeac932 100644 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ b/src/webengine/api/qquickwebenginecertificateerror_p.h @@ -62,7 +62,6 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject { Q_PROPERTY(Error error READ error) Q_PROPERTY(QString description READ description) Q_PROPERTY(bool overridable READ overridable) - Q_ENUMS(Error) public: @@ -82,6 +81,7 @@ public: CertificateWeakKey = -211, CertificateNameConstraintViolation = -212, }; + Q_ENUM(Error) QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0); ~QQuickWebEngineCertificateError(); diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index 9a30eb4ca..d0be2f99a 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -69,7 +69,7 @@ public: DownloadCancelled, DownloadInterrupted }; - Q_ENUMS(DownloadState) + Q_ENUM(DownloadState) Q_PROPERTY(quint32 id READ id CONSTANT FINAL) Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged) diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp index 893df7f46..6e20c0a46 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest.cpp +++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp @@ -69,7 +69,7 @@ QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destinati } /*! - \qmlproperty bool WebEngineNewViewRequest::isUserInitiated + \qmlproperty bool WebEngineNewViewRequest::userInitiated Whether this window request was directly triggered as the result of a keyboard or mouse event. Use this property to block possibly unwanted \e popups. diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index b4e0d173c..1ed15aec2 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -67,8 +67,6 @@ class QWebEngineCookieStoreClient; class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject { Q_OBJECT - Q_ENUMS(HttpCacheType); - Q_ENUMS(PersistentCookiesPolicy); Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL) Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL) Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL) @@ -86,12 +84,14 @@ public: MemoryHttpCache, DiskHttpCache }; + Q_ENUM(HttpCacheType) enum PersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies }; + Q_ENUM(PersistentCookiesPolicy) QString storageName() const; void setStorageName(const QString &name); diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h index de91134ef..c9d6f5d26 100644 --- a/src/webengine/api/qquickwebenginescript_p.h +++ b/src/webengine/api/qquickwebenginescript_p.h @@ -59,8 +59,6 @@ class QQuickWebEngineView; class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineScript : public QObject { Q_OBJECT - Q_ENUMS(InjectionPoint) - Q_ENUMS(ScriptWorldId) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged) Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged) @@ -75,12 +73,14 @@ public: DocumentReady, DocumentCreation }; + Q_ENUM(InjectionPoint) enum ScriptWorldId { MainWorld = 0, ApplicationWorld, UserWorld }; + Q_ENUM(ScriptWorldId) QQuickWebEngineScript(); ~QQuickWebEngineScript(); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index e82ec6d48..c08a5d897 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -72,7 +72,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged) Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged) Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged) - Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1) + // FIXME(QTBUG-40043): Mark fullScreenSupportEnabled with REVISION 1 + Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged) // FIXME: add back REVISION when QTBUG-40043 has been fixed. Q_PROPERTY(bool screenCaptureEnabled READ screenCaptureEnabled WRITE setScreenCaptureEnabled NOTIFY screenCaptureEnabledChanged /* REVISION 2 */) Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged) @@ -125,7 +126,8 @@ signals: void hyperlinkAuditingEnabledChanged(); void errorPageEnabledChanged(); void pluginsEnabledChanged(); - Q_REVISION(1) void fullScreenSupportEnabledChanged(); + // FIXME(QTBUG-40043): Mark fullScreenSupportEnabledChanged with Q_REVISION(1) + void fullScreenSupportEnabledChanged(); // FIXME: add back Q_REVISION when QTBUG-40043 has been fixed. void screenCaptureEnabledChanged(); void defaultTextEncodingChanged(); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index aa450003c..f266fdce6 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -67,6 +67,7 @@ #include <QClipboard> #include <QGuiApplication> +#include <QLoggingCategory> #include <QMimeData> #include <QQmlComponent> #include <QQmlContext> @@ -534,7 +535,29 @@ bool QQuickWebEngineViewPrivate::isFullScreenMode() const void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) { Q_Q(QQuickWebEngineView); - Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); + if (q->receivers(SIGNAL(javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString))) > 0) { + Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); + return; + } + + static QLoggingCategory loggingCategory("js", QtWarningMsg); + const QByteArray file = sourceID.toUtf8(); + QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName()); + + switch (level) { + case JavaScriptConsoleMessageLevel::Info: + if (loggingCategory.isInfoEnabled()) + logger.info().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::Warning: + if (loggingCategory.isWarningEnabled()) + logger.warning().noquote() << message; + break; + case JavaScriptConsoleMessageLevel::Error: + if (loggingCategory.isCriticalEnabled()) + logger.critical().noquote() << message; + break; + } } void QQuickWebEngineViewPrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller) @@ -656,11 +679,25 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent } Q_Q(QQuickWebEngineView); + + // memorize what webChannel we had for the previous adapter + QQmlWebChannel *qmlWebChannel = NULL; + if (adapter) + qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel()); + // This throws away the WebContentsAdapter that has been used until now. // All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter. adapter = webContents; adapter->initialize(this); + // associate the webChannel with the new adapter + if (qmlWebChannel) + adapter->setWebChannel(qmlWebChannel); + + // re-bind the userscrips to the new adapter + Q_FOREACH (QQuickWebEngineScript *script, m_userScripts) + script->d_func()->bind(browserContextAdapter()->userScriptController(), adapter.data()); + // Emit signals for values that might be different from the previous WebContentsAdapter. emit q->titleChanged(); emit q->urlChanged(); @@ -1454,5 +1491,3 @@ void QQuickWebEngineViewport::setDevicePixelRatio(qreal devicePixelRatio) QT_END_NAMESPACE -#include "moc_qquickwebengineview_p.cpp" -#include "moc_qquickwebengineview_p_p.cpp" diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index a17c7bd43..4c4192b4c 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -115,16 +115,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL) #endif - Q_ENUMS(NavigationRequestAction); - Q_ENUMS(NavigationType); - Q_ENUMS(LoadStatus); - Q_ENUMS(ErrorDomain); - Q_ENUMS(NewViewDestination); - Q_ENUMS(Feature); - Q_ENUMS(JavaScriptConsoleMessageLevel); - Q_ENUMS(RenderProcessTerminationStatus); Q_FLAGS(FindFlags); - Q_ENUMS(WebAction); public: QQuickWebEngineView(QQuickItem *parent = 0); @@ -155,6 +146,7 @@ public: // we can expose extra actions in experimental. IgnoreRequest = 0xFF }; + Q_ENUM(NavigationRequestAction) // must match WebContentsAdapterClient::NavigationType enum NavigationType { @@ -165,6 +157,7 @@ public: ReloadNavigation, OtherNavigation }; + Q_ENUM(NavigationType) enum LoadStatus { LoadStartedStatus, @@ -172,6 +165,7 @@ public: LoadSucceededStatus, LoadFailedStatus }; + Q_ENUM(LoadStatus) enum ErrorDomain { NoErrorDomain, @@ -182,6 +176,7 @@ public: FtpErrorDomain, DnsErrorDomain }; + Q_ENUM(ErrorDomain) enum NewViewDestination { NewViewInWindow, @@ -189,6 +184,7 @@ public: NewViewInDialog, NewViewInBackgroundTab }; + Q_ENUM(NewViewDestination) enum Feature { MediaAudioCapture, @@ -196,6 +192,7 @@ public: MediaAudioVideoCapture, Geolocation }; + Q_ENUM(Feature) enum WebAction { NoWebAction = - 1, @@ -239,6 +236,7 @@ public: WebActionCount }; + Q_ENUM(WebAction) // must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel enum JavaScriptConsoleMessageLevel { @@ -246,6 +244,7 @@ public: WarningMessageLevel, ErrorMessageLevel }; + Q_ENUM(JavaScriptConsoleMessageLevel) // must match WebContentsAdapterClient::RenderProcessTerminationStatus enum RenderProcessTerminationStatus { @@ -254,6 +253,7 @@ public: CrashedTerminationStatus, KilledTerminationStatus }; + Q_ENUM(RenderProcessTerminationStatus) enum FindFlag { FindBackward = 1, diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index 34a66291e..2987f1fca 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -35,6 +35,11 @@ \title Chrome DevTools */ +/*! + \externalpage https://developers.google.com/web/tools/javascript/console/console-write + \title Chrome console API +*/ + /* This prevents autolinking of each occurrence of 'WebEngine' To link to the WebEngine QML type, use explicit linking: diff --git a/src/webengine/doc/src/qtwebengine-devtools.qdoc b/src/webengine/doc/src/qtwebengine-debugging.qdoc index ee87214e1..bffcd1669 100644 --- a/src/webengine/doc/src/qtwebengine-devtools.qdoc +++ b/src/webengine/doc/src/qtwebengine-debugging.qdoc @@ -26,8 +26,24 @@ ****************************************************************************/ /*! - \page qtwebengine-devtools.html - \title Qt WebEngine Web Developer Tools + \page qtwebengine-debugging.html + \title Qt WebEngine Debugging and Profiling + + \section1 Console Logging + + JavaScript executed inside Qt WebEngine can use the + \l{Chrome console API} to log information to a console. The logging messages + are forwarded to Qt's logging facilities inside a \c js + \l{QLoggingCategory}{logging category}. However, only warning and fatal + messages are printed by default. To change this, you either have to set custom + rules for the \c js category, or provide custom message handlers + by reimplementing \l{QWebEnginePage::javaScriptConsoleMessage()}, or + connecting to \l{WebEngineView::javaScriptConsoleMessage()}. + + All messages can also be accessed through the Qt WebEngine developer + tools. + + \section1 Qt WebEngine Developer Tools The Qt WebEngine module provides web developer tools that make it easy to inspect and debug layout and performance issues of any web content. diff --git a/src/webengine/doc/src/qtwebengine-index.qdoc b/src/webengine/doc/src/qtwebengine-index.qdoc index e67bd43fd..671425e75 100644 --- a/src/webengine/doc/src/qtwebengine-index.qdoc +++ b/src/webengine/doc/src/qtwebengine-index.qdoc @@ -70,7 +70,7 @@ \list \li \l{Qt WebEngine Overview} \li \l{Qt WebEngine Platform Notes} - \li \l{Qt WebEngine Web Developer Tools} + \li \l{Qt WebEngine Debugging and Profiling} \li \l{Porting from Qt WebKit to Qt WebEngine} \endlist diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index 7ab29e324..cfe731c01 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -67,6 +67,12 @@ specification than Qt WebKit. However, Qt WebEngine is thus heavier than Qt WebKit and does not provide direct access to the network stack and the HTML document through C++ APIs. + Please note that Qt WebEngine is based on Chromium, but does not contain or use any services + or add-ons that might be part of the Chrome browser that is built and delivered by Google. + You can find more detailed information about the differences between Chromium and Chrome in this + \l{https://chromium.googlesource.com/chromium/src/+/master/docs/chromium_browser_vs_google_chrome.md}{overview} + that is part of the documentation in the \l {Chromium Project} upstream source tree. + Chromium is tightly integrated to the \l{Qt Quick Scene Graph}{Qt Quick scene graph}, which is based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides you with one-pass compositing of web content and all the Qt Quick UI. The integration to Chromium is transparent diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index f230ba261..d1b4e722b 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -434,7 +434,10 @@ \a level indicates the severity of the event that triggered the message, that is, whether it was triggered by an error or a less severe event. - The corresponding handler is \c onJavaScriptConsoleMessage. + The corresponding handler is \c onJavaScriptConsoleMessage. If no handler is specified, + the view will log the messages into a \c js \l{QLoggingCategory}{logging category}. + + \sa{Console Logging} */ /*! diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index 2025ce588..c59dfb450 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -79,7 +79,7 @@ public: tr("Cannot create a separate instance of WebEngineDownloadItem")); qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest")); qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); - qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); + // FIXME(QTBUG-40043): qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider); qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory", tr("Cannot create a separate instance of NavigationHistory")); diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index 1e577bf51..7a310d268 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -488,8 +488,10 @@ Module { exports: ["QtWebEngine/FullScreenRequest 1.1"] isCreatable: false exportMetaObjectRevisions: [0] + Property { name: "origin"; type: "QUrl"; isReadonly: true } Property { name: "toggleOn"; type: "bool"; isReadonly: true } Method { name: "accept" } + Method { name: "reject" } } Component { name: "QQuickWebEngineHistory" @@ -609,11 +611,7 @@ Module { name: "downloadFinished" Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true } } - Method { - name: "setCookieStoreClient" - revision: 1 - Parameter { name: "client"; type: "QWebEngineCookieStoreClient"; isPointer: true } - } + Method { name: "cookieStoreClient"; revision: 1; type: "QWebEngineCookieStoreClient*" } } Component { name: "QQuickWebEngineScript" @@ -832,7 +830,8 @@ Module { "DownloadMediaToDisk": 25, "InspectElement": 26, "ExitFullScreen": 27, - "WebActionCount": 28 + "RequestClose": 28, + "WebActionCount": 29 } } Enum { @@ -953,6 +952,7 @@ Module { Parameter { name: "terminationStatus"; type: "RenderProcessTerminationStatus" } Parameter { name: "exitCode"; type: "int" } } + Signal { name: "windowCloseRequested"; revision: 2 } Method { name: "runJavaScript" Parameter { type: "string" } diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webengine/ui/AuthenticationDialog.qml index 46e2e3151..441235980 100644 --- a/src/webengine/ui/AuthenticationDialog.qml +++ b/src/webengine/ui/AuthenticationDialog.qml @@ -35,71 +35,88 @@ ****************************************************************************/ // FIXME: authentication missing in Qt Quick Dialogs atm. Make our own for now. +import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.0 -import QtQuick 2.5 +import QtQuick.Window 2.2 -ApplicationWindow { +Window { signal accepted(string user, string password); signal rejected; - property alias text: message.text; + property alias text: message.text - width: 350 - height: 100 + title: qsTr("Authentication Required") flags: Qt.Dialog + modality: Qt.WindowModal - title: "Authentication Required" + width: minimumWidth + height: minimumHeight + minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins + minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins + + SystemPalette { id: palette; colorGroup: SystemPalette.Active } + color: palette.window function open() { show(); } + function acceptDialog() { + accepted(userField.text, passwordField.text); + close(); + } + ColumnLayout { - anchors.fill: parent; - anchors.margins: 4; + id: rootLayout + anchors.fill: parent + anchors.margins: 4 + property int doubleMargins: anchors.margins * 2 Text { id: message; - Layout.fillWidth: true; + color: palette.windowText } - RowLayout { + GridLayout { + columns: 2 Label { - text: "Username:" + text: qsTr("Username:") + color: palette.windowText } TextField { - id: userField; - Layout.fillWidth: true; + id: userField + focus: true + Layout.fillWidth: true + onAccepted: acceptDialog() } - } - RowLayout { Label { - text: "Password:" + text: qsTr("Password:") + color: palette.windowText } TextField { - id: passwordField; - Layout.fillWidth: true; - echoMode: TextInput.Password; + id: passwordField + Layout.fillWidth: true + echoMode: TextInput.Password + onAccepted: acceptDialog() } } + Item { + Layout.fillHeight: true + } RowLayout { Layout.alignment: Qt.AlignRight - spacing: 8; + spacing: 8 Button { - text: "Log In" + id: cancelButton + text: qsTr("&Cancel") onClicked: { - accepted(userField.text, passwordField.text); + rejected(); close(); - destroy(); } } Button { - text: "Cancel" - onClicked: { - rejected(); - close(); - destroy(); - } + text: qsTr("&Log In") + isDefault: true + onClicked: acceptDialog() } } } - } diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index f60cfb1a7..2e686b1b1 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -245,19 +245,19 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d switch (dialogController->type()) { case WebContentsAdapterClient::AlertDialog: dialogComponentType = AlertDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Alert - %1").arg(m_view->url().toString()); + title = tr("Javascript Alert - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::ConfirmDialog: dialogComponentType = ConfirmDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Confirm - %1").arg(m_view->url().toString()); + title = tr("Javascript Confirm - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::PromptDialog: dialogComponentType = PromptDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Javascript Prompt - %1").arg(m_view->url().toString()); + title = tr("Javascript Prompt - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::UnloadDialog: dialogComponentType = ConfirmDialog; - title = QCoreApplication::translate("UIDelegatesManager", "Are you sure you want to leave this page?"); + title = tr("Are you sure you want to leave this page?"); break; case WebContentsAdapterClient::InternalAuthorizationDialog: dialogComponentType = ConfirmDialog; @@ -335,10 +335,10 @@ void UIDelegatesManager::showDialog(QSharedPointer<AuthenticationDialogControlle QString introMessage; if (dialogController->isProxy()) { - introMessage = QObject::tr("Connect to proxy \"%1\" using:"); + introMessage = tr("Connect to proxy \"%1\" using:"); introMessage = introMessage.arg(dialogController->host().toHtmlEscaped()); } else { - introMessage = QObject::tr("Enter username and password for \"%1\" at %2"); + introMessage = tr("Enter username and password for \"%1\" at %2"); introMessage = introMessage.arg(dialogController->realm()).arg(dialogController->url().toString().toHtmlEscaped()); } QQmlProperty textProp(authenticationDialog, QStringLiteral("text")); diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h index fb262aac1..7a87c1eee 100644 --- a/src/webengine/ui_delegates_manager.h +++ b/src/webengine/ui_delegates_manager.h @@ -37,7 +37,12 @@ #ifndef UI_DELEGATES_MANAGER_H #define UI_DELEGATES_MANAGER_H -#include <QObject> +#include "qglobal.h" +#include "web_contents_adapter.h" +#include "web_contents_adapter_client.h" + +#include <QCoreApplication> +#include <QExplicitlySharedDataPointer> #include <QPoint> #include <QSharedPointer> @@ -82,8 +87,9 @@ Q_SIGNALS: void triggered(); }; -class UIDelegatesManager { - +class UIDelegatesManager +{ + Q_DECLARE_TR_FUNCTIONS(UIDelegatesManager) public: enum ComponentType { Invalid = -1, |