summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2019-03-20 18:04:50 +0100
committerKirill Burtsev <kirill.burtsev@qt.io>2019-04-05 08:20:49 +0000
commitd2fa5fd0f5b1972bd372510cc14509e85b972b23 (patch)
tree0f36120b208394729aff28de483369591f38ad4b /src/core
parent320c7316b75be22112cb4802187c3873c9934eab (diff)
Notification API cleanup
Task-number: QTBUG-74543 Change-Id: Ice5a0dbfc3485c8b7e6fa900ef427a9aed871d42 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebenginenotification.cpp54
-rw-r--r--src/core/api/qwebenginenotification.h16
-rw-r--r--src/core/user_notification_controller.cpp11
-rw-r--r--src/core/user_notification_controller.h2
4 files changed, 22 insertions, 61 deletions
diff --git a/src/core/api/qwebenginenotification.cpp b/src/core/api/qwebenginenotification.cpp
index ba9739b35..0b1d48ce9 100644
--- a/src/core/api/qwebenginenotification.cpp
+++ b/src/core/api/qwebenginenotification.cpp
@@ -58,8 +58,8 @@ using QtWebEngineCore::UserNotificationController;
Web engine notifications are passed to the user in the
\l QWebEngineProfile::setNotificationPresenter() and
- \l QQuickWebEngineProfile::userNotification() calls and the
- \l WebEngineProfile::userNotification() signal.
+ \l QQuickWebEngineProfile::presentNotification() calls and the
+ \l WebEngineProfile::presentNotification() signal.
*/
class QWebEngineNotificationPrivate : public UserNotificationController::Client {
@@ -86,14 +86,6 @@ public:
QWebEngineNotification *q;
};
-
-/*!
- Creates a null QWebEngineNotification.
-
- \sa isNull()
-*/
-QWebEngineNotification::QWebEngineNotification() { }
-
/*! \internal
*/
QWebEngineNotification::QWebEngineNotification(const QSharedPointer<UserNotificationController> &controller)
@@ -102,25 +94,10 @@ QWebEngineNotification::QWebEngineNotification(const QSharedPointer<UserNotifica
/*! \internal
*/
-QWebEngineNotification::QWebEngineNotification(const QWebEngineNotification &other)
- : QObject()
- , d_ptr(new QWebEngineNotificationPrivate(this, other.d_ptr->controller))
-{ }
-
-/*! \internal
-*/
QWebEngineNotification::~QWebEngineNotification()
{
}
-/*! \internal
-*/
-const QWebEngineNotification &QWebEngineNotification::operator=(const QWebEngineNotification &other)
-{
- d_ptr.reset(new QWebEngineNotificationPrivate(this, other.d_ptr->controller));
- return *this;
-}
-
/*!
Returns \c true if the two notifications belong to the same message chain.
That is, if their tag() and origin() are the same. This means one is
@@ -128,13 +105,15 @@ const QWebEngineNotification &QWebEngineNotification::operator=(const QWebEngine
\sa tag(), origin()
*/
-bool QWebEngineNotification::matches(const QWebEngineNotification &other) const
+bool QWebEngineNotification::matches(const QWebEngineNotification *other) const
{
+ if (!other)
+ return false;
if (!d_ptr)
- return !other.d_ptr;
- if (!other.d_ptr)
+ return !other->d_ptr;
+ if (!other->d_ptr)
return false;
- return tag() == other.tag() && origin() == other.origin();
+ return tag() == other->tag() && origin() == other->origin();
}
/*!
@@ -187,15 +166,14 @@ QUrl QWebEngineNotification::origin() const
}
/*!
- \property QWebEngineNotification::icon
- \brief The icon to be shown with the notification.
+ Returns the icon to be shown with the notification.
- If no icon is set by the sender, an null QIcon is returned.
+ If no icon is set by the sender, a null QImage is returned.
*/
-QIcon QWebEngineNotification::icon() const
+QImage QWebEngineNotification::icon() const
{
Q_D(const QWebEngineNotification);
- return d ? d->controller->icon() : QIcon();
+ return d ? d->controller->icon() : QImage();
}
/*!
@@ -224,14 +202,6 @@ Qt::LayoutDirection QWebEngineNotification::direction() const
}
/*!
- Returns \c true if the notification is not a default constructed null notification.
-*/
-bool QWebEngineNotification::isValid() const
-{
- return !d_ptr.isNull();
-}
-
-/*!
Creates and dispatches a JavaScript \e {show event} on notification.
Should be called by the notification platform when the notification has been shown to user.
diff --git a/src/core/api/qwebenginenotification.h b/src/core/api/qwebenginenotification.h
index 6c9a8f891..08fd629be 100644
--- a/src/core/api/qwebenginenotification.h
+++ b/src/core/api/qwebenginenotification.h
@@ -46,7 +46,6 @@
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer>
#include <QtCore/QUrl>
-#include <QtGui/QIcon>
namespace QtWebEngineCore {
class UserNotificationController;
@@ -59,7 +58,6 @@ class QWebEngineNotificationPrivate;
class Q_WEBENGINECORE_EXPORT QWebEngineNotification : public QObject {
Q_OBJECT
Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
- Q_PROPERTY(QIcon icon READ icon CONSTANT FINAL)
Q_PROPERTY(QString title READ title CONSTANT FINAL)
Q_PROPERTY(QString message READ message CONSTANT FINAL)
Q_PROPERTY(QString tag READ tag CONSTANT FINAL)
@@ -67,23 +65,18 @@ class Q_WEBENGINECORE_EXPORT QWebEngineNotification : public QObject {
Q_PROPERTY(Qt::LayoutDirection direction READ direction CONSTANT FINAL)
public:
- QWebEngineNotification();
- QWebEngineNotification(const QWebEngineNotification &other);
- virtual ~QWebEngineNotification();
- const QWebEngineNotification &operator=(const QWebEngineNotification &other);
+ virtual ~QWebEngineNotification() override;
- bool matches(const QWebEngineNotification &other) const;
+ bool matches(const QWebEngineNotification *other) const;
QUrl origin() const;
- QIcon icon() const;
+ QImage icon() const;
QString title() const;
QString message() const;
QString tag() const;
QString language() const;
Qt::LayoutDirection direction() const;
- bool isValid() const;
-
public Q_SLOTS:
void show() const;
void click() const;
@@ -93,8 +86,9 @@ Q_SIGNALS:
void closed();
private:
- QWebEngineNotification(const QSharedPointer<QtWebEngineCore::UserNotificationController> &controller);
+ Q_DISABLE_COPY(QWebEngineNotification)
Q_DECLARE_PRIVATE(QWebEngineNotification)
+ QWebEngineNotification(const QSharedPointer<QtWebEngineCore::UserNotificationController> &controller);
QScopedPointer<QWebEngineNotificationPrivate> d_ptr;
friend class QQuickWebEngineProfilePrivate;
friend class QWebEngineProfilePrivate;
diff --git a/src/core/user_notification_controller.cpp b/src/core/user_notification_controller.cpp
index 82cb57e51..d169bf854 100644
--- a/src/core/user_notification_controller.cpp
+++ b/src/core/user_notification_controller.cpp
@@ -86,7 +86,7 @@ public:
std::unique_ptr<UserNotificationController::Delegate> m_delegate;
blink::NotificationResources m_resources;
UserNotificationController::Client *m_client;
- QIcon m_icon;
+ QImage m_icon;
QImage m_image;
QImage m_badge;
bool m_iconGenerated;
@@ -155,15 +155,12 @@ QUrl UserNotificationController::origin() const
return toQt(d->m_origin);
}
-QIcon UserNotificationController::icon() const
+QImage UserNotificationController::icon() const
{
if (!d->m_iconGenerated) {
d->m_iconGenerated = true;
- if (!d->m_resources.notification_icon.isNull()) {
- QImage image = toQImage(d->m_resources.notification_icon);
- if (!image.isNull())
- d->m_icon = QIcon(QPixmap::fromImage(std::move(image), Qt::NoFormatConversion));
- }
+ if (!d->m_resources.notification_icon.isNull())
+ d->m_icon = toQImage(d->m_resources.notification_icon);
}
return d->m_icon;
}
diff --git a/src/core/user_notification_controller.h b/src/core/user_notification_controller.h
index 213629334..bab85c7ec 100644
--- a/src/core/user_notification_controller.h
+++ b/src/core/user_notification_controller.h
@@ -86,7 +86,7 @@ public:
void closeNotification();
QUrl origin() const;
- QIcon icon() const;
+ QImage icon() const;
QImage image() const;
QImage badge() const;
QString title() const;