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