french -> French
[kdepim.git] / calendarsupport / messagewidget.cpp
blob457d6754e62febb1f127efeefb087c0c824467be
1 /*
2 This file is part of KOrganizer.
4 Copyright (c) 2013 Sérgio Martins <iamsergio@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
25 #include "messagewidget.h"
27 #include <QApplication>
28 #include <QMouseEvent>
30 using namespace CalendarSupport;
32 MessageWidget::MessageWidget(QWidget *parent) : KMessageWidget(parent)
34 hide();
35 setCloseButtonVisible(false);
36 setWordWrap(true);
39 MessageWidget::~MessageWidget()
43 void MessageWidget::showEvent(QShowEvent *event)
45 qApp->installEventFilter(this);
46 KMessageWidget::showEvent(event);
49 void MessageWidget::hideEvent(QHideEvent *event)
51 // No need to spend cycles on an event-filter when this is going to
52 // me hidden most of the time
53 qApp->removeEventFilter(this);
54 KMessageWidget::hideEvent(event);
57 bool MessageWidget::eventFilter(QObject *, QEvent *event)
59 if (event->type() == QEvent::MouseButtonPress)
60 hide();
62 if (event->type() == QEvent::KeyPress) {
63 QKeyEvent *ev = dynamic_cast<QKeyEvent*>(event);
64 hide();
65 if (ev->key() == Qt::Key_Escape) {
66 return true; // We eat this one, it's for us
70 return false; // we don't want it