1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 //! \file NotifyManager.cpp
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 #include "NotifyManager.h"
26 #include <QMessageBox>
28 #include <QMaemo5InformationBox>
33 NotifyManager::NotifyManager(QObject *parent) :
39 void NotifyManager::notificationClosed() {
40 QObject* dialog = QObject::sender();
42 QHash<QString, QDialog*>::Iterator it;
44 for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
45 if(it.value() == dialog) {
46 activeNotifies.remove(it.key());
47 it.value()->deleteLater();
53 void NotifyManager::screenChanged() {
54 QHash<QString, QDialog*>::Iterator it;
56 for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
62 void NotifyManager::showNotification(Notify::NotifyType type, QString text) {
64 if(activeNotifies.contains(text)) {
69 QMaemo5InformationBox* mbox =
70 new QMaemo5InformationBox(0);
72 QLabel* infoLabel = new QLabel(text);
73 infoLabel->setAlignment(Qt::AlignCenter);
74 infoLabel->setWordWrap(true);
76 mbox->setWidget(infoLabel);
79 new QMessageBox(qobject_cast<QWidget*>(this->parent()));
88 mbox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
91 mbox->setWindowTitle(tr("Information"));
92 mbox->setIcon(QMessageBox::Information);
100 mbox->setWindowTitle(tr("Warning"));
101 mbox->setIcon(QMessageBox::Warning);
107 mbox->setTimeout(QMaemo5InformationBox::NoTimeout);
110 mbox->setWindowTitle(tr("Error"));
111 mbox->setIcon(QMessageBox::Critical);
116 activeNotifies.insert(text, mbox);
117 connect(mbox, SIGNAL(finished(int)), this, SLOT(notificationClosed()));