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) :
40 void NotifyManager::notificationClosed() {
41 QObject* dialog = QObject::sender();
43 QHash<QString, QDialog*>::Iterator it;
45 for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
46 if(it.value() == dialog) {
47 activeNotifies.remove(it.key());
48 it.value()->deleteLater();
54 void NotifyManager::screenChanged() {
55 QHash<QString, QDialog*>::Iterator it;
57 for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
63 void NotifyManager::showNotification(Notify::NotifyType type, QString text) {
64 if(activeNotifies.contains(text)) {
70 if(menu && menu->isVisible())
73 parent = qobject_cast<QWidget*>(this->parent());
76 QMaemo5InformationBox* mbox =
77 new QMaemo5InformationBox(parent);
79 QLabel* infoLabel = new QLabel(text);
80 infoLabel->setAlignment(Qt::AlignCenter);
81 infoLabel->setWordWrap(true);
84 mbox->setWidget(infoLabel);
88 new QMessageBox(parent);
98 mbox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
101 mbox->setWindowTitle(tr("Information"));
102 mbox->setIcon(QMessageBox::Information);
109 case Notify::Warning:
112 mbox->setWindowTitle(tr("Warning"));
113 mbox->setIcon(QMessageBox::Warning);
119 mbox->setTimeout(QMaemo5InformationBox::NoTimeout);
120 ((QLabel*)mbox->widget())->setContentsMargins(5,15,5,15);
123 mbox->setWindowTitle(tr("Error"));
124 mbox->setIcon(QMessageBox::Critical);
128 activeNotifies.insert(text, mbox);
129 connect(mbox, SIGNAL(finished(int)), this, SLOT(notificationClosed()));
133 void NotifyManager::setMenu(QWidget *w) {