added saving of backend, why doesnt it work ...
This commit is contained in:
parent
7de255da37
commit
9e5d649551
|
@ -14,9 +14,9 @@ else(WIN32)
|
|||
set(WIN32_SPECIFIC)
|
||||
endif(WIN32)
|
||||
|
||||
automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp trayicon.cpp ${SNORENOTIFY_DEPS})
|
||||
automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DEPS})
|
||||
|
||||
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} )
|
||||
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
|
||||
|
|
|
@ -202,7 +202,11 @@ void SnoreServer::setPrimaryNotificationBackend ( Notification_Backend *backend
|
|||
if(!backend->isPrimaryNotificationBackend())
|
||||
return;
|
||||
qDebug()<<"Setting Notification Backend to:"<<backend->name();
|
||||
_notificationBackend=backend;
|
||||
_notificationBackend = backend;
|
||||
}
|
||||
|
||||
Notification_Backend * SnoreServer::primaryNotificationBackend(){
|
||||
return _notificationBackend;
|
||||
}
|
||||
|
||||
SnoreNotificationInstance * SnoreServer::defaultNotificationInterface()
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
const QHash<QString,Notification_Backend*> &primaryNotificationBackends() const;
|
||||
void setPrimaryNotificationBackend ( Notification_Backend *backend );
|
||||
Notification_Backend* primaryNotificationBackend();
|
||||
|
||||
class SnoreNotificationInstance *defaultNotificationInterface();
|
||||
|
||||
|
|
25
src/main.cpp
25
src/main.cpp
|
@ -1,33 +1,12 @@
|
|||
|
||||
#include "core/snoreserver.h"
|
||||
#include "trayicon.h"
|
||||
#include "snorenotify.h"
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include <QPluginLoader>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
QApplication a ( argc, argv );
|
||||
QSystemTrayIcon *trayIcon=new QSystemTrayIcon(QIcon(":/root/zzz.png"));
|
||||
trayIcon->setVisible(true);
|
||||
|
||||
SnoreServer *s = new SnoreServer( trayIcon );
|
||||
s->cleanupTMP();
|
||||
|
||||
QDir pluginsDir ( a.applicationDirPath() +"/snoreplugins" );
|
||||
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )
|
||||
{
|
||||
s->publicatePlugin ( pluginsDir.absoluteFilePath ( fileName ) );
|
||||
}
|
||||
|
||||
TrayIcon *i = new TrayIcon(trayIcon,s);
|
||||
i->initConextMenu();
|
||||
|
||||
SnoreNotify();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,14 @@
|
|||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
TrayIcon::TrayIcon(QSystemTrayIcon *trayIcon, SnoreServer *snore ):
|
||||
_trayIcon(trayIcon),
|
||||
_snore(snore)
|
||||
{
|
||||
TrayIcon::TrayIcon()
|
||||
{
|
||||
_trayIcon = new QSystemTrayIcon(QIcon(":/root/zzz.png"));
|
||||
}
|
||||
|
||||
void TrayIcon::initConextMenu(){
|
||||
void TrayIcon::initConextMenu(SnoreServer *snore){
|
||||
_snore = snore;
|
||||
_trayIcon->setVisible(true);
|
||||
|
||||
_trayMenu = new QMenu("SnoreNotify");
|
||||
_trayMenu->addAction(QString("SnoreNotify ").append(_snore->version()));
|
||||
|
@ -44,6 +45,14 @@ void TrayIcon::initConextMenu(){
|
|||
_trayIcon->setContextMenu(_trayMenu);
|
||||
}
|
||||
|
||||
void TrayIcon::hide(){
|
||||
_trayIcon->setVisible(false);
|
||||
}
|
||||
|
||||
QSystemTrayIcon* TrayIcon::trayIcon(){
|
||||
return _trayIcon;
|
||||
}
|
||||
|
||||
void TrayIcon::setPrimaryBackend(){
|
||||
QAction *a= dynamic_cast<QAction*>(sender());
|
||||
_snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text()));
|
||||
|
|
|
@ -23,8 +23,10 @@ class TrayIcon:public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TrayIcon(class QSystemTrayIcon *trayIcon,class SnoreServer *snore);
|
||||
void initConextMenu();
|
||||
TrayIcon();
|
||||
void initConextMenu(class SnoreServer *snore);
|
||||
void hide();
|
||||
class QSystemTrayIcon* trayIcon();
|
||||
|
||||
private:
|
||||
class QSystemTrayIcon *_trayIcon;
|
||||
|
|
Loading…
Reference in New Issue