mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-11 16:06:24 +00:00
added support for application, alert icon
This commit is contained in:
parent
34a5c4beb3
commit
ce59e355a2
@ -17,6 +17,7 @@ include_directories(
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR} )
|
||||
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
|
||||
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (KDE4_ENABLE_EXCEPTIONS -fexceptions)
|
||||
# Select flags.
|
||||
@ -39,6 +40,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
|
||||
option(WITH_FREEDESKTOP_FRONTEND "Build the freedesktop frontend" OFF)
|
||||
option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
|
||||
|
||||
|
@ -17,8 +17,9 @@
|
||||
#include "application.h"
|
||||
|
||||
|
||||
Application::Application ( const QString &name ) :
|
||||
Application::Application (const QString &name, const QString &icon) :
|
||||
_name ( name ),
|
||||
_icon(icon),
|
||||
_initialized ( false )
|
||||
{
|
||||
_alerts.insert ( "",new Alert ( "Default Alert","Default Alert" ) );
|
||||
@ -46,6 +47,11 @@ const QString &Application::name() const
|
||||
return _name;
|
||||
}
|
||||
|
||||
const QString &Application::icon()const
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
const AlertList &Application::alerts() const
|
||||
{
|
||||
return _alerts;
|
||||
@ -61,15 +67,10 @@ void Application::setInitialized ( bool b )
|
||||
_initialized = b;
|
||||
}
|
||||
|
||||
Alert::Alert ( const QString &name,const QString &title ) :
|
||||
_name ( name ),
|
||||
_title ( title ),
|
||||
_active ( true )
|
||||
{}
|
||||
|
||||
Alert::Alert ( const QString &name,const QString &title,bool active ) :
|
||||
Alert::Alert (const QString &name, const QString &title, const QString &icon, bool active) :
|
||||
_name ( name ),
|
||||
_title ( title ),
|
||||
_icon(icon),
|
||||
_active ( active )
|
||||
{}
|
||||
|
||||
@ -88,6 +89,11 @@ const QString &Alert::title() const
|
||||
return _title;
|
||||
}
|
||||
|
||||
const QString &Alert::icon() const
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
bool Alert::isActive() const
|
||||
{
|
||||
return _active;
|
||||
|
@ -27,11 +27,12 @@ class SNORE_EXPORT Application:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Application ( const QString &name );
|
||||
Application ( const QString &name, const QString &icon = "" );
|
||||
Application();
|
||||
~Application();
|
||||
void addAlert ( Alert *alert );
|
||||
const QString &name() const;
|
||||
const QString &icon() const;
|
||||
const AlertList &alerts() const;
|
||||
bool isInitialized();
|
||||
void setInitialized ( bool b );
|
||||
@ -39,6 +40,7 @@ public:
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QString _icon;
|
||||
AlertList _alerts;
|
||||
bool _initialized;
|
||||
|
||||
@ -48,16 +50,17 @@ class SNORE_EXPORT Alert:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Alert ( const QString &name,const QString &title );
|
||||
Alert ( const QString &name,const QString &title,bool active );
|
||||
Alert ( const QString &name,const QString &title="",const QString &icon="",bool active=true );
|
||||
Alert();
|
||||
|
||||
const QString &name() const;
|
||||
const QString &title() const;
|
||||
const QString &icon() const;
|
||||
bool isActive() const;
|
||||
private:
|
||||
QString _name;
|
||||
QString _title;
|
||||
QString _icon;
|
||||
bool _active;
|
||||
};
|
||||
|
||||
|
@ -87,8 +87,8 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
|
||||
icon=getImagefromHint(image);
|
||||
}
|
||||
if(!snore()->aplications().contains(app_name)){
|
||||
Application *a = new Application(app_name);
|
||||
a->addAlert(new Alert("DBus Alert","DBus Alert"));
|
||||
Application *a = new Application(app_name,app_icon);
|
||||
a->addAlert(new Alert("DBus Alert","DBus Alert",app_icon));
|
||||
snore()->addApplication(a);
|
||||
snore()->applicationIsInitialized(a);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// About:
|
||||
// About:
|
||||
// Snarl C++ interface implementation
|
||||
// To understand what the different functions do and what they return, please
|
||||
// have a look at the API on http://www.fullphat.net/dev/api.htm.
|
||||
|
@ -53,7 +53,8 @@ void Snarl_Backend::registerApplication(Application *application){
|
||||
_applications.insert(application->name(),snarlInterface);
|
||||
|
||||
wchar_t *appName = toWchar(application->name());
|
||||
snarlInterface->RegisterApp(appName,L"",L"");
|
||||
wchar_t *icon = toWchar(application->icon());
|
||||
snarlInterface->RegisterApp(appName,icon,icon);
|
||||
|
||||
foreach(Alert *alert,application->alerts()){
|
||||
wchar_t *alertName = toWchar(alert->name());
|
||||
@ -61,6 +62,7 @@ void Snarl_Backend::registerApplication(Application *application){
|
||||
delete [] alertName;
|
||||
}
|
||||
delete [] appName;
|
||||
delete [] icon;
|
||||
}
|
||||
|
||||
void Snarl_Backend::unregisterApplication(Application *application){
|
||||
|
@ -30,9 +30,10 @@
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
|
||||
Parser::Parser(SnarlNetworkFrontend *snarl):snarl(snarl)
|
||||
Parser::Parser(SnarlNetworkFrontend *snarl):
|
||||
QObject(snarl),
|
||||
snarl(snarl)
|
||||
{
|
||||
setParent(snarl);
|
||||
getSnpType.insert("type",TYPE);
|
||||
getSnpType.insert("app",APP);
|
||||
getSnpType.insert("version",VERSION);
|
||||
|
Loading…
x
Reference in New Issue
Block a user