2014-02-26 07:41:40 +01:00
|
|
|
// This file is part of RSS Guard.
|
|
|
|
//
|
2015-01-04 14:12:14 +01:00
|
|
|
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
2014-02-26 07:41:40 +01:00
|
|
|
//
|
|
|
|
// RSS Guard is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// RSS Guard is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-06-13 09:47:42 +02:00
|
|
|
#ifndef SYSTEMTRAYICON_H
|
|
|
|
#define SYSTEMTRAYICON_H
|
|
|
|
|
|
|
|
#include <QSystemTrayIcon>
|
2014-10-06 18:35:34 +02:00
|
|
|
|
|
|
|
#include "definitions/definitions.h"
|
|
|
|
|
2014-01-11 11:51:39 +01:00
|
|
|
#include <QPixmap>
|
2013-06-26 19:04:38 +02:00
|
|
|
#include <QMenu>
|
2013-06-13 09:47:42 +02:00
|
|
|
|
2013-06-13 20:11:16 +02:00
|
|
|
|
2013-06-19 15:48:33 +02:00
|
|
|
class FormMain;
|
2013-06-26 19:04:38 +02:00
|
|
|
class QEvent;
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
class TrayIconMenu : public QMenu {
|
2014-04-20 09:00:10 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-06-26 19:04:38 +02:00
|
|
|
public:
|
2013-08-30 17:40:17 +02:00
|
|
|
// Constructors and destructors.
|
2013-06-26 19:04:38 +02:00
|
|
|
explicit TrayIconMenu(const QString &title, QWidget *parent);
|
|
|
|
virtual ~TrayIconMenu();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool event(QEvent *event);
|
|
|
|
};
|
|
|
|
#endif
|
2013-06-19 15:48:33 +02:00
|
|
|
|
2013-06-13 20:11:16 +02:00
|
|
|
class SystemTrayIcon : public QSystemTrayIcon {
|
2014-01-11 11:51:39 +01:00
|
|
|
Q_OBJECT
|
2013-06-19 21:28:26 +02:00
|
|
|
|
2013-06-13 09:47:42 +02:00
|
|
|
public:
|
2013-08-30 17:40:17 +02:00
|
|
|
// Constructors and destructors.
|
2013-06-18 19:03:55 +02:00
|
|
|
explicit SystemTrayIcon(const QString &normal_icon,
|
|
|
|
const QString &plain_icon,
|
2013-06-19 15:48:33 +02:00
|
|
|
FormMain *parent = 0);
|
2013-06-25 17:25:36 +02:00
|
|
|
virtual ~SystemTrayIcon();
|
2013-06-17 20:17:13 +02:00
|
|
|
|
2014-10-06 18:35:34 +02:00
|
|
|
// Sets the number to be visible in the tray icon, number <= 0 removes it.
|
2015-06-29 10:27:28 +02:00
|
|
|
void setNumber(int number = -1, bool any_new_message = false);
|
2014-10-06 18:35:34 +02:00
|
|
|
|
|
|
|
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information,
|
|
|
|
int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, QObject *click_target = NULL,
|
|
|
|
const char *click_slot = NULL);
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Returns true if tray icon CAN be constructed on this machine.
|
|
|
|
static bool isSystemTrayAvailable();
|
|
|
|
|
|
|
|
// Returns true if tray icon CAN be costructed and IS enabled in
|
|
|
|
// application settings.
|
|
|
|
static bool isSystemTrayActivated();
|
|
|
|
|
2013-06-13 09:47:42 +02:00
|
|
|
public slots:
|
2013-06-18 19:30:38 +02:00
|
|
|
void show();
|
|
|
|
|
|
|
|
private slots:
|
2013-06-25 09:46:52 +02:00
|
|
|
void showPrivate();
|
2013-08-30 17:40:17 +02:00
|
|
|
void onActivated(const QSystemTrayIcon::ActivationReason &reason);
|
2013-06-17 20:17:13 +02:00
|
|
|
|
2015-06-04 08:07:48 +02:00
|
|
|
signals:
|
|
|
|
void shown();
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
private:
|
2014-01-11 11:51:39 +01:00
|
|
|
QIcon m_normalIcon;
|
|
|
|
QPixmap m_plainPixmap;
|
|
|
|
QFont m_font;
|
2014-10-06 18:35:34 +02:00
|
|
|
|
|
|
|
QObject *m_bubbleClickTarget;
|
|
|
|
char *m_bubbleClickSlot;
|
2013-06-13 09:47:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SYSTEMTRAYICON_H
|