mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-20 03:58:10 +00:00
introduced default app
This commit is contained in:
parent
760ed23bec
commit
6d5b7a7b76
@ -33,7 +33,7 @@ class SNORE_EXPORT Application
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Application();
|
Application();
|
||||||
explicit Application ( const QString &name, const Icon &icon = Icon(":/root/snore.png"));
|
explicit Application ( const QString &name, const Icon &icon);
|
||||||
Application(const Application &other);
|
Application(const Application &other);
|
||||||
Application &operator=(const Application &other);
|
Application &operator=(const Application &other);
|
||||||
~Application();
|
~Application();
|
||||||
|
@ -46,13 +46,16 @@ const QDir &SnoreCorePrivate::pluginDir(){
|
|||||||
|
|
||||||
|
|
||||||
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
||||||
m_trayIcon(trayIcon)
|
m_trayIcon(trayIcon),
|
||||||
|
m_defaultApp("SnoreNotify",Icon(":/root/snore.png"))
|
||||||
{
|
{
|
||||||
QDir home ( snoreTMP() );
|
QDir home ( snoreTMP() );
|
||||||
if ( !home.exists() ){
|
if ( !home.exists() ){
|
||||||
home.cdUp();
|
home.cdUp();
|
||||||
home.mkdir("SnoreNotify");
|
home.mkdir("SnoreNotify");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_defaultApp.addAlert(Alert("Default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SnoreCorePrivate::~SnoreCorePrivate()
|
SnoreCorePrivate::~SnoreCorePrivate()
|
||||||
@ -60,6 +63,11 @@ SnoreCorePrivate::~SnoreCorePrivate()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Application SnoreCorePrivate::defaultApplication() const
|
||||||
|
{
|
||||||
|
return m_defaultApp;
|
||||||
|
}
|
||||||
|
|
||||||
void SnoreCorePrivate::notificationActionInvoked(Notification notification) const
|
void SnoreCorePrivate::notificationActionInvoked(Notification notification) const
|
||||||
{
|
{
|
||||||
Q_Q(const SnoreCore);
|
Q_Q(const SnoreCore);
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
SnoreCorePrivate(QSystemTrayIcon *trayIcon);
|
SnoreCorePrivate(QSystemTrayIcon *trayIcon);
|
||||||
~SnoreCorePrivate();
|
~SnoreCorePrivate();
|
||||||
|
const Application defaultApplication() const;
|
||||||
|
|
||||||
|
|
||||||
void notificationActionInvoked(Notification notification) const;
|
void notificationActionInvoked(Notification notification) const;
|
||||||
@ -67,6 +68,8 @@ private:
|
|||||||
QPointer<SnoreBackend> m_notificationBackend;
|
QPointer<SnoreBackend> m_notificationBackend;
|
||||||
|
|
||||||
QSystemTrayIcon *m_trayIcon;
|
QSystemTrayIcon *m_trayIcon;
|
||||||
|
|
||||||
|
Application m_defaultApp;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ Growl::~Growl()
|
|||||||
|
|
||||||
bool Growl::init(SnoreCore *snore)
|
bool Growl::init(SnoreCore *snore)
|
||||||
{
|
{
|
||||||
Icon icon(":/root/snore.png");
|
const Application &app = snore->d()->defaultApplication();
|
||||||
m_defaultGNTP = new gntp("SnoreNotify", icon.localUrl().toUtf8().constData());
|
m_defaultGNTP = new gntp(app.name().toUtf8().constData(), app.icon().localUrl().toUtf8().constData());
|
||||||
|
|
||||||
std::vector<std::string> alerts;
|
std::vector<std::string> alerts;
|
||||||
alerts.push_back("Default");
|
alerts.push_back(app.alerts().begin()->name().toUtf8().constData());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_defaultGNTP->regist(alerts);
|
m_defaultGNTP->regist(alerts);
|
||||||
|
@ -154,7 +154,7 @@ bool SnarlBackend::init(SnoreCore *snore){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_eventLoop = new SnarlBackend::SnarlWidget(this);
|
m_eventLoop = new SnarlBackend::SnarlWidget(this);
|
||||||
m_applications.insert("SnoreNotify",snarlInterface);
|
m_applications.insert(snore->d()->defaultApplication().name(),snarlInterface);
|
||||||
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersion();
|
qDebug()<<"Initiating Snarl Backend, Snarl version: "<<snarlInterface->GetVersion();
|
||||||
m_defautSnarlinetrface = new SnarlInterface();
|
m_defautSnarlinetrface = new SnarlInterface();
|
||||||
|
|
||||||
@ -199,7 +199,8 @@ void SnarlBackend::slotDeregisterApplication(const Application &application){
|
|||||||
|
|
||||||
void SnarlBackend::slotNotify(Notification notification){
|
void SnarlBackend::slotNotify(Notification notification){
|
||||||
SnarlInterface *snarlInterface = m_applications.value(notification.application().name());
|
SnarlInterface *snarlInterface = m_applications.value(notification.application().name());
|
||||||
if(snarlInterface == NULL){
|
if(snarlInterface == NULL)
|
||||||
|
{
|
||||||
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
|
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
|
||||||
qDebug()<<m_applications.keys();
|
qDebug()<<m_applications.keys();
|
||||||
snarlInterface = m_defautSnarlinetrface;
|
snarlInterface = m_defautSnarlinetrface;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "trayicon.h"
|
#include "trayicon.h"
|
||||||
#include "core/snore.h"
|
#include "core/snore.h"
|
||||||
|
#include "core/snore_p.h"
|
||||||
|
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -84,13 +85,11 @@ void TrayIcon::setPrimaryBackend(){
|
|||||||
|
|
||||||
void TrayIcon::slotTestNotification()
|
void TrayIcon::slotTestNotification()
|
||||||
{
|
{
|
||||||
Application appl("SnoreNotify");
|
const Application &app = m_snore->d()->defaultApplication();
|
||||||
Alert alert("Default");
|
m_snore->registerApplication(app);
|
||||||
appl.addAlert(alert);
|
Notification n(app, *app.alerts().begin(), "Hello World", "This is Snore", Icon(":/root/snore.png"));
|
||||||
m_snore->registerApplication(appl);
|
|
||||||
Notification n(appl, alert, "Hello World", "This is Snore", Icon(":/root/snore.png"));
|
|
||||||
n.addAction(Notification::Action(1,"Test Action"));
|
n.addAction(Notification::Action(1,"Test Action"));
|
||||||
m_snore->broadcastNotification(n);
|
m_snore->broadcastNotification(n);
|
||||||
m_snore->deregisterApplication(appl);
|
m_snore->deregisterApplication(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user