reduce possebilitys for typos

This commit is contained in:
Patrick von Reth 2014-01-21 10:04:49 +01:00
parent 5f22236693
commit d20293416e
3 changed files with 23 additions and 20 deletions

View File

@ -191,37 +191,28 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
bool SnoreCore::setPrimaryNotificationBackend() bool SnoreCore::setPrimaryNotificationBackend()
{ {
QStringList backends = notificationBackends(); Q_D(SnoreCore);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8 && backends.contains("Windows 8")) if(QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8 && d->setBackendIfAvailible("Windows 8"))
{ {
if(setPrimaryNotificationBackend("Windows 8"))
return true; return true;
} }
if( backends.contains("Growl")) if(d->setBackendIfAvailible("Growl"))
{ {
if(setPrimaryNotificationBackend("Growl"))
return true; return true;
} }
if( backends.contains("Snarl")) if(d->setBackendIfAvailible("Snarl"))
{ {
if(setPrimaryNotificationBackend("Snarl"))
return true; return true;
} }
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
if( backends.contains("FreedesktopNotification")) return d->setBackendIfAvailible("FreedesktopNotification");
{
return setPrimaryNotificationBackend("FreedesktopNotification");
}
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
if( backends.contains("Growl")) return d->setBackendIfAvailible("Growl");
{
return setPrimaryNotificationBackend("Growl");
}
#endif #endif
if( trayIcon() && backends.contains("SystemTray")) if( trayIcon() && d->setBackendIfAvailible("SystemTray"))
{ {
return setPrimaryNotificationBackend("SystemTray"); return true;
} }
return false; return false;
} }

View File

@ -77,6 +77,16 @@ void SnoreCorePrivate::notificationActionInvoked(Notification notification) cons
} }
} }
bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
{
Q_Q(SnoreCore);
if( q->primaryNotificationBackend().contains(backend))
{
return q->setPrimaryNotificationBackend(backend);
}
return false;
}
void SnoreCorePrivate::slotNotificationClosed(Notification n) void SnoreCorePrivate::slotNotificationClosed(Notification n)
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);

View File

@ -50,6 +50,8 @@ public:
void notificationActionInvoked(Notification notification) const; void notificationActionInvoked(Notification notification) const;
bool setBackendIfAvailible(const QString & backend);
signals: signals:
void applicationRegistered(const Snore::Application&); void applicationRegistered(const Snore::Application&);
void applicationDeregistered(const Snore::Application&); void applicationDeregistered(const Snore::Application&);