mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-25 22:14:15 +00:00
527137e3ee
Now it can't be told if this is was a Windows App before. All Mac design principles are fulfilled and some cosmetics have been applied to suit the native look and feel. The biggest change there is the proper use of the Dock icon which takes the role of the Tray icon on Mac. The QDoubleSpinBox improves entering of Bitcoin amounts, no two separate fields are required anymore. All functionality and validation effects have been retained; pressing the comma key will be internally translated to a period to keep it consistent throughout the application and eases entering in countries which use the comma as decimal separator. Additionally, Notificator now supports Growl, Mac's native notification system. This is provided via Apple Script in order to avoid linking to Growl on compile time. Other changes involve encapsulation of Toolbar and Menubar creation, loading of Qt's own translation and some clean up.
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#ifndef NOTIFICATOR_H
|
|
#define NOTIFICATOR_H
|
|
|
|
#include <QObject>
|
|
#include <QIcon>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QSystemTrayIcon;
|
|
#ifdef USE_DBUS
|
|
class QDBusInterface;
|
|
#endif
|
|
QT_END_NAMESPACE
|
|
|
|
// Cross-platform desktop notification client
|
|
class Notificator: public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
// Create a new notificator
|
|
// Ownership of trayIcon is not transferred to this object
|
|
Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
|
|
~Notificator();
|
|
|
|
// Message class
|
|
enum Class
|
|
{
|
|
Information,
|
|
Warning,
|
|
Critical,
|
|
};
|
|
|
|
public slots:
|
|
|
|
/* Show notification message.
|
|
*
|
|
* cls: general message class
|
|
* title: title shown with message
|
|
* text: message content
|
|
* icon: optional icon to show with message
|
|
* millisTimeout: notification timeout in milliseconds (default 10 seconds)
|
|
*/
|
|
void notify(Class cls, const QString &title, const QString &text,
|
|
const QIcon &icon = QIcon(), int millisTimeout = 10000);
|
|
|
|
private:
|
|
QWidget *parent;
|
|
enum Mode {
|
|
None,
|
|
Freedesktop, // Use DBus org.freedesktop.Notifications
|
|
QSystemTray, // Use QSystemTray::showMessage
|
|
Growl // Use the Growl notification system (Mac only)
|
|
};
|
|
QString programName;
|
|
Mode mode;
|
|
QSystemTrayIcon *trayIcon;
|
|
#ifdef USE_DBUS
|
|
QDBusInterface *interface;
|
|
|
|
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
|
#endif
|
|
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
|
#ifdef Q_WS_MAC
|
|
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
|
#endif
|
|
};
|
|
|
|
#endif // NOTIFICATOR_H
|