install a .desktop

This commit is contained in:
Patrick von Reth 2011-08-02 17:50:07 +02:00
parent e348dd7f7c
commit 020ea2c4d2
12 changed files with 57 additions and 53 deletions

View File

@ -6,6 +6,12 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(KDE4) find_package(KDE4)
if(MINGW)
SET (CMAKE_RC_COMPILER_INIT windres)
ENABLE_LANGUAGE (RC)
SET (CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -i <SOURCE> -o <OBJECT>")
endif(MINGW)
if(KDE4_FOUND) if(KDE4_FOUND)
add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS} -D_UNICODE) add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS} -D_UNICODE)
include_directories(${KDE4_INCLUDES}) include_directories(${KDE4_INCLUDES})

View File

@ -1,19 +1,16 @@
set(SNORE_RCS ${SNORE_RCS} ../data/snore.qrc PARENT_SCOPE) set(SNORE_RCS ${SNORE_RCS} ../data/snore.qrc PARENT_SCOPE)
if(WIN32) if(WIN32)
set(ICON_NAME zzz) set(ICON_NAME zzz)
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${ICON_NAME}.ico ICON) FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${ICON_NAME}.ico ICON)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.rc "IDI_ICON1 ICON DISCARDABLE \"${ICON}\"\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.rc "IDI_ICON1 ICON DISCARDABLE \"${ICON}\"\n")
if(MINGW) set(SNORENOTIFY_DEPS ${SNORENOTIFY_DEPS} ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.rc PARENT_SCOPE)
find_program(WINDRES_EXECUTABLE NAMES windres) endif(WIN32)
if(WINDRES_EXECUTABLE)
exec_program(windres if(KDE4_FOUND)
ARGS "-i ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.rc" install(FILES snore.png DESTINATION ${ICON_INSTALL_DIR}/hicolor/48x48/apps)
"-o ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.o" if(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
"--include-dir=${CMAKE_CURRENT_SOURCE_DIR}") install(FILES snore.png DESTINATION /usr/share/pixmaps)
set(SNORENOTIFY_DEPS ${SNORENOTIFY_DEPS} ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.o PARENT_SCOPE) endif(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
endif(WINDRES_EXECUTABLE) endif(KDE4_FOUND)
else(MINGW)
set(SNORENOTIFY_DEPS ${SNORENOTIFY_DEPS} ${CMAKE_CURRENT_BINARY_DIR}/${ICON_NAME}.rc PARENT_SCOPE)
endif(MINGW)
endif(WIN32)

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,6 +1,6 @@
<RCC> <RCC>
<qresource prefix="/root"> <qresource prefix="/root">
<file>zzz.png</file> <file>snore.png</file>
</qresource> </qresource>
<qresource prefix="/root/images"> <qresource prefix="/root/images">
<file>freedesktop-dbus.png</file> <file>freedesktop-dbus.png</file>

View File

@ -6,4 +6,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Notifications.service
DESTINATION share/dbus-1/services/) DESTINATION share/dbus-1/services/)
install(FILES FindLibsnore.cmake DESTINATION share/apps/cmake/modules) install(FILES FindLibsnore.cmake DESTINATION share/apps/cmake/modules)
if(KDE4_FOUND)
install(FILES snorenotify.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
endif(KDE4_FOUND)

10
share/snorenotify.desktop Normal file
View File

@ -0,0 +1,10 @@
[Desktop Entry]
Type=Application
Version=0.15
Name=SnoreNotify
Comment=An application which redirects dbus notifications to a unifided notification backend
Icon=snore
Exec=snorenotify
Categories=Qt;System;
X-KDE-StartupNotify=true
X-DBUS-StartupType=Unique

View File

@ -28,7 +28,7 @@ class SNORE_EXPORT Application:public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Application ( const QString &name, const SnoreIcon &icon = SnoreIcon(":/root/zzz.png")); Application ( const QString &name, const SnoreIcon &icon = SnoreIcon(":/root/snore.png"));
Application(); Application();
~Application(); ~Application();
void addAlert ( Alert *alert ); void addAlert ( Alert *alert );
@ -51,7 +51,7 @@ class SNORE_EXPORT Alert:public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Alert ( const QString &name,const QString &title="",const SnoreIcon &icon = SnoreIcon(":/root/zzz.png"),bool active=true ); Alert ( const QString &name,const QString &title="",const SnoreIcon &icon = SnoreIcon(":/root/snore.png"),bool active=true );
Alert(); Alert();
const QString &name() const; const QString &name() const;

View File

@ -35,25 +35,12 @@ QString const SnoreServer::snoreTMP(){
return tmp; return tmp;
} }
void SnoreServer::cleanupTMP(){ void SnoreServer::initTMP(){
QDir home ( snoreTMP() ); QDir home ( snoreTMP() );
if ( home.exists() ) if ( !home.exists() ){
{
QStringList filetypes;
filetypes<<"*.png"<<"*.jpg";
QStringList toDell;
toDell=home.entryList ( filetypes );
foreach ( QString s,toDell )
{
home.remove ( s );
}
}
else{
home.cdUp(); home.cdUp();
home.mkdir("SnoreNotify"); home.mkdir("SnoreNotify");
} }
} }
SnoreServer::SnoreServer ( QSystemTrayIcon *trayIcon ) : SnoreServer::SnoreServer ( QSystemTrayIcon *trayIcon ) :

View File

@ -29,7 +29,7 @@ class SNORE_EXPORT SnoreServer:public QObject
public: public:
static const QString version(); static const QString version();
static const QString snoreTMP(); static const QString snoreTMP();
static void cleanupTMP(); static void initTMP();
public: public:

View File

@ -7,7 +7,7 @@
#include <QDebug> #include <QDebug>
TrayIconNotifer::TrayIconNotifer ( SnoreServer *snore, QSystemTrayIcon *icon ) : TrayIconNotifer::TrayIconNotifer ( SnoreServer *snore, QSystemTrayIcon *icon ) :
Notification_Backend ( "TrayiconNotifer",snore ), Notification_Backend ( "SystemTray",snore ),
_trayIcon ( icon ), _trayIcon ( icon ),
_id ( 0 ), _id ( 0 ),
_displayed(-1) _displayed(-1)

View File

@ -31,19 +31,19 @@
#include <iostream> #include <iostream>
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#define PROFILEPATH qgetenv("APPDATA") + "\\snorenotify\\" #define PROFILEPATH qgetenv("APPDATA") + "\\snorenotify\\"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#define PROFILEPATH qgetenv("HOME") + "/.snorenotify/" #define PROFILEPATH qgetenv("HOME") + "/.snorenotify/"
#endif #endif
SnoreNotify::SnoreNotify() SnoreNotify::SnoreNotify()
{ {
_trayIcon = new TrayIcon(); _trayIcon = new TrayIcon();
_snore = new SnoreServer(_trayIcon->trayIcon()); _snore = new SnoreServer(_trayIcon->trayIcon());
_snore->cleanupTMP(); _snore->initTMP();
QDir pluginsDir ( qApp->applicationDirPath() +"/snoreplugins" ); QDir pluginsDir ( qApp->applicationDirPath() +"/snoreplugins" );
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) ) foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )
@ -52,20 +52,20 @@ SnoreNotify::SnoreNotify()
} }
load(); load();
_trayIcon->initConextMenu(_snore); _trayIcon->initConextMenu(_snore);
connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(exit())); connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(exit()));
} }
SnoreNotify::~SnoreNotify(){ SnoreNotify::~SnoreNotify(){
delete _snore; delete _snore;
delete _trayIcon; delete _trayIcon;
} }
void SnoreNotify::load(){ void SnoreNotify::load(){
QDomDocument doc( "Settings" ); QDomDocument doc( "Settings" );
QFile file( PROFILEPATH + "settings.xml" ); QFile file( PROFILEPATH + "settings.xml" );
if(!file.open( QFile::ReadOnly )){ if(!file.open( QFile::ReadOnly )){
std::cout<<"Failed openeing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml"<<std::endl; std::cout<<"Failed openeing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml"<<std::endl;
@ -79,7 +79,7 @@ void SnoreNotify::load(){
if(!doc.setContent(&file,&errorMessage,&errorLine, &errorCulumn )){ if(!doc.setContent(&file,&errorMessage,&errorLine, &errorCulumn )){
std::cout<<"Failed parsing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml\n" std::cout<<"Failed parsing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml\n"
<<"Error: "<<errorMessage.toLatin1().data()<<" line: " <<"Error: "<<errorMessage.toLatin1().data()<<" line: "
<<QString::number(errorLine).toLatin1().data()<<" collumn: "<<QString::number(errorCulumn).toLatin1().data()<<std::endl; <<QString::number(errorLine).toLatin1().data()<<" collumn: "<<QString::number(errorCulumn).toLatin1().data()<<std::endl;
file.close(); file.close();
return; return;
} }
@ -87,12 +87,12 @@ void SnoreNotify::load(){
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
QDomElement backend = root.elementsByTagName("notificationBackend").item(0).toElement(); QDomElement backend = root.elementsByTagName("notificationBackend").item(0).toElement();
if(!backend.isNull()) if(!backend.isNull())
_snore->setPrimaryNotificationBackend(backend.text()); _snore->setPrimaryNotificationBackend(backend.text());
} }
void SnoreNotify::save(){ void SnoreNotify::save(){
QDomDocument doc("Settings"); QDomDocument doc("Settings");
QDomElement root = doc.createElement( "SnoreNotifyProfile" ); QDomElement root = doc.createElement( "SnoreNotifyProfile" );
doc.appendChild(root); doc.appendChild(root);
QDomElement backend = doc.createElement( "notificationBackend"); QDomElement backend = doc.createElement( "notificationBackend");
@ -112,9 +112,9 @@ void SnoreNotify::save(){
} }
void SnoreNotify::exit(){ void SnoreNotify::exit(){
qDebug()<<"Saving snore settings"; qDebug()<<"Saving snore settings";
save(); save();
_trayIcon->hide(); _trayIcon->hide();
} }

View File

@ -23,7 +23,7 @@
TrayIcon::TrayIcon() TrayIcon::TrayIcon()
{ {
_trayIcon = new QSystemTrayIcon(QIcon(":/root/zzz.png")); _trayIcon = new QSystemTrayIcon(QIcon(":/root/snore.png"));
} }
void TrayIcon::initConextMenu(SnoreServer *snore){ void TrayIcon::initConextMenu(SnoreServer *snore){