From d20293416e5185dda23b19a9049b4a9eeb4b3dfe Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Tue, 21 Jan 2014 10:04:49 +0100 Subject: [PATCH] reduce possebilitys for typos --- src/core/snore.cpp | 31 +++++++++++-------------------- src/core/snore_p.cpp | 10 ++++++++++ src/core/snore_p.h | 2 ++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/core/snore.cpp b/src/core/snore.cpp index e5ec47a..d95a7df 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -191,37 +191,28 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend ) bool SnoreCore::setPrimaryNotificationBackend() { - QStringList backends = notificationBackends(); + Q_D(SnoreCore); #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) - if( backends.contains("FreedesktopNotification")) - { - return setPrimaryNotificationBackend("FreedesktopNotification"); - } + return d->setBackendIfAvailible("FreedesktopNotification"); #elif defined(Q_OS_MAC) - if( backends.contains("Growl")) - { - return setPrimaryNotificationBackend("Growl"); - } + return d->setBackendIfAvailible("Growl"); #endif - if( trayIcon() && backends.contains("SystemTray")) + if( trayIcon() && d->setBackendIfAvailible("SystemTray")) { - return setPrimaryNotificationBackend("SystemTray"); + return true; } return false; } diff --git a/src/core/snore_p.cpp b/src/core/snore_p.cpp index feef375..3b6cbfe 100644 --- a/src/core/snore_p.cpp +++ b/src/core/snore_p.cpp @@ -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) { Q_Q(SnoreCore); diff --git a/src/core/snore_p.h b/src/core/snore_p.h index e55b13d..5d2d759 100644 --- a/src/core/snore_p.h +++ b/src/core/snore_p.h @@ -50,6 +50,8 @@ public: void notificationActionInvoked(Notification notification) const; + bool setBackendIfAvailible(const QString & backend); + signals: void applicationRegistered(const Snore::Application&); void applicationDeregistered(const Snore::Application&);