3
I am creating a simple browser using Qtwebkit and added in it the "support" for Notification Web API using the QWebPage::setFeaturePermission
.
An example:
function notifyMe() {
if (Notification.permission === "granted") {
var notification = new Notification("Hi there!");
} else if (Notification.permission !== "denied") {
Notification.requestPermission(function(permission) {
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
}
}
<button onclick="notifyMe();">Notify me</button>
Code:
QObject::connect(page,
SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this,
SLOT(featurePermissionRequested(QWebFrame*,QWebPage::Feature))
);
...
void Form::featurePermissionRequested(QWebFrame* frame, QWebPage::Feature feature) {
switch (feature) {
case QWebPage::Notifications:
qDebug() << "Notification";
page->setFeaturePermission(frame, feature, QWebPage::PermissionGrantedByUser);
break;
case QWebPage::Geolocation:
qDebug() << "GEO";
break;
default:
qDebug() << "Unknown feature";
}
}
Whenever I click on the "Notify me" button the following message appears on the Desktop:
That is to say it works perfectly, but I wonder if it is possible to "customize" the "Notifications" in Qt?
In other words, I would like them to be similar to Googlechrome or Firefox, something like this:
but you can not customize using the same JS? See there on the page of Mozilla has how to customize, icons, body, etc
– Adir Kuhn
@Adirkuhn I don’t think you understand "customizing". Qwebpage uses the
QSystemTrayIcon
to generate notifications, what I want is to replace theQSystemTrayIcon
by a custom Qwidget. Because even if I change the icon inNotification
yet QT uses theQSystemTrayIcon
as in the image: http://i.stack.Imgur.com/oxiZT.png I nay want to useQSystemTrayIcon
, I want it to be a window pretty, this looks like: http://i.stack.Imgur.com/S62wy.png– Guilherme Nascimento
Got it? I was curious, kkkkkk
– Adir Kuhn