| 1 | // -*- c-basic-offset: 2 -*- |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of Licq, an instant messaging client for UNIX. |
|---|
| 4 | * Copyright (C) 2007 Licq developers |
|---|
| 5 | * |
|---|
| 6 | * Licq 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. |
|---|
| 10 | * |
|---|
| 11 | * Licq 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. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with Licq; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifndef SYSTEMTRAYICON_H |
|---|
| 22 | #define SYSTEMTRAYICON_H |
|---|
| 23 | |
|---|
| 24 | #include <QSystemTrayIcon> |
|---|
| 25 | |
|---|
| 26 | #include "dockicon.h" |
|---|
| 27 | |
|---|
| 28 | namespace LicqQtGui |
|---|
| 29 | { |
|---|
| 30 | /** |
|---|
| 31 | * Dock icon that uses system tray present in many window managers |
|---|
| 32 | */ |
|---|
| 33 | class SystemTrayIcon : public DockIcon |
|---|
| 34 | { |
|---|
| 35 | Q_OBJECT |
|---|
| 36 | |
|---|
| 37 | public: |
|---|
| 38 | /** |
|---|
| 39 | * Constructor |
|---|
| 40 | * |
|---|
| 41 | * @param menu System menu to popup from tray icon |
|---|
| 42 | */ |
|---|
| 43 | SystemTrayIcon(QMenu* menu); |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * Update number of unread events |
|---|
| 47 | * |
|---|
| 48 | * @param newMsg Number of unread user events |
|---|
| 49 | * @param sysMsg Number of unread system events |
|---|
| 50 | */ |
|---|
| 51 | virtual void updateIconMessages(int newMsg, int sysMsg); |
|---|
| 52 | |
|---|
| 53 | /** |
|---|
| 54 | * Popup message from system tray |
|---|
| 55 | * |
|---|
| 56 | * @param title Popup title text |
|---|
| 57 | * @param message Message text |
|---|
| 58 | * @param icon Icon to display in the popup |
|---|
| 59 | * @param timeout Time before hiding popup |
|---|
| 60 | */ |
|---|
| 61 | virtual void popupMessage(QString title, QString message, const QPixmap& icon, int timeout); |
|---|
| 62 | |
|---|
| 63 | protected slots: |
|---|
| 64 | /** |
|---|
| 65 | * Updated the icon for current status |
|---|
| 66 | */ |
|---|
| 67 | virtual void updateStatusIcon(); |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * Updated the icon for current event |
|---|
| 71 | */ |
|---|
| 72 | virtual void updateEventIcon(); |
|---|
| 73 | |
|---|
| 74 | /** |
|---|
| 75 | * Update configuration for dock icon |
|---|
| 76 | */ |
|---|
| 77 | virtual void updateConfig(); |
|---|
| 78 | |
|---|
| 79 | private slots: |
|---|
| 80 | /** |
|---|
| 81 | * Tray has been activated by user |
|---|
| 82 | * |
|---|
| 83 | * @param reason Type of action that occured |
|---|
| 84 | */ |
|---|
| 85 | virtual void trayActivated(QSystemTrayIcon::ActivationReason reason); |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | * Called when new tooltip is available |
|---|
| 89 | * |
|---|
| 90 | * @param toolTip The tooltip text |
|---|
| 91 | */ |
|---|
| 92 | void updateToolTip(QString toolTip); |
|---|
| 93 | |
|---|
| 94 | private: |
|---|
| 95 | /** |
|---|
| 96 | * Timer has expired, used to blink unread events |
|---|
| 97 | * |
|---|
| 98 | * @param event Event object |
|---|
| 99 | */ |
|---|
| 100 | virtual void timerEvent(QTimerEvent* event); |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * Update tray icon |
|---|
| 104 | */ |
|---|
| 105 | void updateIcon(); |
|---|
| 106 | |
|---|
| 107 | QSystemTrayIcon* myTrayIcon; |
|---|
| 108 | bool myTimerToggle; |
|---|
| 109 | bool myBlink; |
|---|
| 110 | }; |
|---|
| 111 | |
|---|
| 112 | } // namespace LicqQtGui |
|---|
| 113 | |
|---|
| 114 | #endif |
|---|