1/*
2 Copyright (C) 2010 by Sjors Gielen <dazjorz@dazjorz.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 */
19
20#include "notifybypopupgrowl.h"
21#include <QFile>
22#include <QSystemTrayIcon>
23
24#define GROWL_LOCATION_MACOSX "/Library/PreferencePanes/Growl.prefPane/" \
25 "Contents/MacOS/Growl"
26#define GROWL_LOCATION_WIN32 "C:/Program Files/Growl for Windows/Growl.exe"
27
28/**
29 * @brief Check if Growl can display plugins.
30 * Currently, this checks only if Growl is installed, not if it's running.
31 * As soon as the Growl Notification Protocol is finished, it will be
32 * implemented and used for this check.
33 */
34bool NotifyByPopupGrowl::canPopup()
35{
36 return QFile::exists( GROWL_LOCATION_MACOSX )
37 || QFile::exists( GROWL_LOCATION_WIN32 );
38}
39
40/**
41 * @brief Get the capabilities supported by Growl.
42 */
43QStringList NotifyByPopupGrowl::capabilities()
44{
45 return QStringList();
46}
47
48/**
49 * @brief Send a popup through Growl.
50 * @param icon The icon inside the notification. Currently ignored.
51 * @param timeout The time in ms to show the notification.
52 * @param title The title displayed inside the notification.
53 * @param message The message displayed inside the notification.
54 */
55void NotifyByPopupGrowl::popup( const QPixmap *icon, int timeout,
56 const QString &title, const QString &message )
57{
58 Q_UNUSED( icon );
59
60 QSystemTrayIcon i;
61 i.show();
62 i.showMessage( title, message,
63 QSystemTrayIcon::Information, timeout );
64 i.hide();
65}
66