default initialisation for the backends
This commit is contained in:
parent
50b78c6cca
commit
b2cad9a712
|
@ -286,24 +286,60 @@ const QStringList &SnoreCore::secondaryNotificationBackends() const
|
|||
return m_secondaryNotificationBackends;
|
||||
}
|
||||
|
||||
void SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
||||
bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
|
||||
{
|
||||
if(!pluginCache().contains(backend)){
|
||||
qDebug()<<"Unknown Backend:"<<backend;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
qDebug()<<"Setting Notification Backend to:"<<backend;
|
||||
SnoreBackend* b = qobject_cast<SnoreBackend*>(pluginCache()[backend]->load());
|
||||
if(!b->isInitialized()){
|
||||
if(!b->init(this)){
|
||||
qDebug()<<"Failed to initialize"<<b->name();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
connect(b,SIGNAL(closeNotification(Snore::Notification)),this,SLOT(slotNotificationClosed(Snore::Notification)));
|
||||
}
|
||||
|
||||
|
||||
m_notificationBackend = b;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SnoreCore::setPrimaryNotificationBackend()
|
||||
{
|
||||
QStringList backends = notificationBackends();
|
||||
#ifdef Q_OS_WIN
|
||||
if(QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8 && backends.contains("SnoreToast"))
|
||||
{
|
||||
if(setPrimaryNotificationBackend("SnoreToast"))
|
||||
return true;
|
||||
}
|
||||
if( backends.contains("Growl"))
|
||||
{
|
||||
if(setPrimaryNotificationBackend("Growl"))
|
||||
return true;
|
||||
}
|
||||
if( backends.contains("Snarl"))
|
||||
{
|
||||
if(setPrimaryNotificationBackend("Snarl"))
|
||||
return true;
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if( backends.contains("FreedesktopNotification_Backend"))
|
||||
{
|
||||
return setPrimaryNotificationBackend("FreedesktopNotification_Backend");
|
||||
}
|
||||
#elif defined(Q_OS_MAC)
|
||||
if( backends.contains("Growl"))
|
||||
{
|
||||
return setPrimaryNotificationBackend("Growl");
|
||||
}
|
||||
#endif
|
||||
if( trayIcon() && backends.contains("SystemTray"))
|
||||
{
|
||||
return setPrimaryNotificationBackend("SystemTray");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString &SnoreCore::primaryNotificationBackend(){
|
||||
|
|
|
@ -60,7 +60,8 @@ public:
|
|||
const QStringList ¬ificationFrontends() const;
|
||||
const QStringList &secondaryNotificationBackends() const;
|
||||
|
||||
void setPrimaryNotificationBackend ( const QString &backend );
|
||||
bool setPrimaryNotificationBackend( const QString &backend );
|
||||
bool setPrimaryNotificationBackend();
|
||||
const QString &primaryNotificationBackend();
|
||||
QSystemTrayIcon *trayIcon();
|
||||
|
||||
|
|
|
@ -54,9 +54,15 @@ SnoreNotify::~SnoreNotify(){
|
|||
}
|
||||
|
||||
void SnoreNotify::load(){
|
||||
m_snore->setPrimaryNotificationBackend(m_settings.value("notificationBackend","SystemTray").toString());
|
||||
if(m_settings.contains("notificationBackend"))
|
||||
{
|
||||
m_snore->setPrimaryNotificationBackend(m_settings.value("notificationBackend","SystemTray").toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_snore->setPrimaryNotificationBackend();
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreNotify::save(){
|
||||
m_settings.setValue("notificationBackend",m_snore->primaryNotificationBackend());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue