Home | History | Annotate | Download | only in platformplugin
      1 /*
      2  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  *
     19  */
     20 
     21 #include "WebNotificationPresenter.h"
     22 
     23 WebNotificationWidget::WebNotificationWidget()
     24     : QWidget()
     25 {
     26 }
     27 
     28 WebNotificationWidget::~WebNotificationWidget()
     29 {
     30 }
     31 
     32 void WebNotificationWidget::showNotification(const QWebNotificationData* data)
     33 {
     34     QPixmap mask;
     35     QPainter painter(&mask);
     36     painter.fillRect(0, 0, 300, 100, Qt::lightGray);
     37     QBitmap bitmap(mask);
     38     setMask(bitmap);
     39     QGridLayout* layout = new QGridLayout(this);
     40     layout->addWidget(new QLabel(data->title()), 0, 0, 1, 5);
     41     int messagePosition = 0;
     42     QPixmap pixmap;
     43     if (data->iconData().length() && pixmap.loadFromData(data->iconData())) {
     44         QLabel* label = new QLabel;
     45         label->setPixmap(pixmap);
     46         layout->addWidget(label, 1, 0, 1, 1);
     47         messagePosition++;
     48     }
     49     QLabel* messageLabel = new QLabel(data->message());
     50     messageLabel->setMask(bitmap);
     51     messageLabel->setWordWrap(true);
     52     layout->addWidget(messageLabel, 1, messagePosition, 1, 5 - messagePosition);
     53     setLayout(layout);
     54     setFixedSize(300, 100);
     55     show();
     56 }
     57 
     58 bool WebNotificationWidget::event(QEvent* ev)
     59 {
     60     if (ev->type() == QEvent::MouseButtonRelease) {
     61         emit notificationClicked();
     62         return true;
     63     }
     64     if (ev->type() == QEvent::Close) {
     65         emit notificationClosed();
     66         return true;
     67     }
     68     return QWidget::event(ev);
     69 }
     70 
     71