Use Snore only if building without KDE
authorPatrick von Reth <vonreth@kde.org>
Tue, 25 Feb 2014 23:26:06 +0000 (00:26 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 25 Feb 2014 23:29:16 +0000 (00:29 +0100)
Also use the system tray backend as default.

CMakeLists.txt
cmake/modules/FindLibsnore.cmake
src/qtui/snorenotificationbackend.cpp

index 3e4ee9c..42bacd8 100644 (file)
@@ -397,6 +397,13 @@ if(BUILD_GUI)
     else(WITH_PHONON)
       message(STATUS "Not enabling Phonon support")
     endif(WITH_PHONON)
     else(WITH_PHONON)
       message(STATUS "Not enabling Phonon support")
     endif(WITH_PHONON)
+
+    find_package(Libsnore)
+    if(LIBSNORE_FOUND)
+        add_definitions(-DHAVE_LIBSNORE)
+        set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${LIBSNORE_LIBRARIES})
+        set(HAVE_SNORENOTIFY true)
+    endif(LIBSNORE_FOUND)
   endif(NOT HAVE_KDE)
 
   # Setup libindicate-qt support
   endif(NOT HAVE_KDE)
 
   # Setup libindicate-qt support
@@ -425,13 +432,6 @@ if(BUILD_GUI)
       /System/Library/Frameworks/Foundation.framework
     )
   endif()
       /System/Library/Frameworks/Foundation.framework
     )
   endif()
-
-find_package(Libsnore)
-if(LIBSNORE_FOUND)
-    add_definitions(-DHAVE_LIBSNORE -DLIBSNORE_PLUGIN_PATH="${LIBSNORE_PLUGIN_PATH}")
-    set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${LIBSNORE_LIBRARIES})
-    set(HAVE_SNORENOTIFY true)
-endif(LIBSNORE_FOUND)
 endif(BUILD_GUI)
 
 # Core-only deps
 endif(BUILD_GUI)
 
 # Core-only deps
index 4dc0b9e..1af3944 100644 (file)
@@ -4,8 +4,7 @@
 #  LIBSNORE_FOUND - system has the LIBSNORE library
 #  LIBSNORE_LIBRARIES - The libraries needed to use LIBSNORE
 #  LIBSNORE_INCLUDE_DIRS - The includes needed to use LIBSNORE
 #  LIBSNORE_FOUND - system has the LIBSNORE library
 #  LIBSNORE_LIBRARIES - The libraries needed to use LIBSNORE
 #  LIBSNORE_INCLUDE_DIRS - The includes needed to use LIBSNORE
-#  LIBSNORE_PLUGIN_PATH - Path of the plugins
-#  Copyright 2013 Patrick von Reth <vonreth@kde.org>
+#  Copyright 2013-2014 Patrick von Reth <vonreth@kde.org>
 
 find_path(LIBSNORE_INCLUDE_DIR
   NAMES snore/core/snore.h
 
 find_path(LIBSNORE_INCLUDE_DIR
   NAMES snore/core/snore.h
@@ -19,12 +18,6 @@ find_library(LIBSNORE_LIBRARY
   PATHS ${KDE4_LIB_DIR}
 )
 
   PATHS ${KDE4_LIB_DIR}
 )
 
-find_path(LIBSNORE_PLUGIN_PATH snoreplugins)
-
-if(LIBSNORE_LIBRARY AND LIBSNORE_PLUGIN_PATH)
-    set(LIBSNORE_PLUGIN_PATH ${LIBSNORE_PLUGIN_PATH}/snoreplugins)
-endif()
-
 set(LIBSNORE_LIBRARIES ${LIBSNORE_LIBRARY})
 set(LIBSNORE_INCLUDE_DIRS ${LIBSNORE_INCLUDE_DIR})
 
 set(LIBSNORE_LIBRARIES ${LIBSNORE_LIBRARY})
 set(LIBSNORE_INCLUDE_DIRS ${LIBSNORE_INCLUDE_DIR})
 
index f07aedd..3612bb0 100644 (file)
@@ -37,7 +37,7 @@
 
 
 SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent)
 
 
 SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent)
-    :AbstractNotificationBackend(parent),
+    : AbstractNotificationBackend(parent),
       m_systrayBackend(NULL)
 {
     NotificationSettings notificationSettings;
       m_systrayBackend(NULL)
 {
     NotificationSettings notificationSettings;
@@ -50,12 +50,12 @@ SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent)
     //TODO: try to get an instance of the tray icon to be able to show popups
     m_snore = new Snore::SnoreCore();
     m_snore->loadPlugins(Snore::SnorePlugin::BACKEND);
     //TODO: try to get an instance of the tray icon to be able to show popups
     m_snore = new Snore::SnoreCore();
     m_snore->loadPlugins(Snore::SnorePlugin::BACKEND);
-    m_application = Snore::Application("Quassel", Snore::Icon(DesktopIcon("quassel").toImage()));
+    m_icon = Snore::Icon(DesktopIcon("quassel").toImage());
+    m_application = Snore::Application("Quassel", m_icon);
     m_application.hints().setValue("WINDOWS_APP_ID","QuasselProject.QuasselIRC");
 
     connect(m_snore, SIGNAL(actionInvoked(Snore::Notification)), this, SLOT(actionInvoked(Snore::Notification)));
 
     m_application.hints().setValue("WINDOWS_APP_ID","QuasselProject.QuasselIRC");
 
     connect(m_snore, SIGNAL(actionInvoked(Snore::Notification)), this, SLOT(actionInvoked(Snore::Notification)));
 
-    m_icon = Snore::Icon(DesktopIcon("dialog-information").toImage());
 
     m_alert = Snore::Alert(tr("Private Message"), m_icon);
     m_application.addAlert(m_alert);
 
     m_alert = Snore::Alert(tr("Private Message"), m_icon);
     m_application.addAlert(m_alert);
@@ -76,12 +76,7 @@ SnoreNotificationBackend::~SnoreNotificationBackend()
 void SnoreNotificationBackend::backendChanged(const QVariant &v)
 {
     QString backend = v.toString();
 void SnoreNotificationBackend::backendChanged(const QVariant &v)
 {
     QString backend = v.toString();
-    if (backend == "Default") {
-        if (m_snore->setPrimaryNotificationBackend()) {//try to find the default backend for the platform
-            return;
-        }
-    }
-    else if (backend != "SystemTray") {
+    if (backend != "Default") {
         if (setSnoreBackend(backend)) {
             return;
         }
         if (setSnoreBackend(backend)) {
             return;
         }
@@ -154,8 +149,10 @@ SnoreNotificationBackend::ConfigWidget::ConfigWidget(Snore::SnoreCore *snore, QW
       m_snore(snore)
 {
     ui.setupUi(this);
       m_snore(snore)
 {
     ui.setupUi(this);
-    ui.backends->insertItem(0, "Default");
-    ui.backends->insertItems(1, m_snore->notificationBackends());
+    QStringList backends = m_snore->notificationBackends();
+    backends.append("Default");
+    qSort(backends);
+    ui.backends->insertItems(0, backends);
 
     connect(ui.backends, SIGNAL(currentIndexChanged(QString)), SLOT(backendChanged(QString)));
     connect(ui.timeout, SIGNAL(valueChanged(int)), this, SLOT(timeoutChanged(int)));
 
     connect(ui.backends, SIGNAL(currentIndexChanged(QString)), SLOT(backendChanged(QString)));
     connect(ui.timeout, SIGNAL(valueChanged(int)), this, SLOT(timeoutChanged(int)));
@@ -188,10 +185,7 @@ void SnoreNotificationBackend::ConfigWidget::defaults()
 void SnoreNotificationBackend::ConfigWidget::load()
 {
     NotificationSettings s;
 void SnoreNotificationBackend::ConfigWidget::load()
 {
     NotificationSettings s;
-    QString backend = m_snore->primaryNotificationBackend();
-    if (backend.isEmpty()) {
-        backend = "SystemTray";
-    }
+    QString backend = s.value("Snore/Backend", "Default").toString();
     int timeout = s.value("Snore/Timeout", 10).toInt();
     ui.backends->setCurrentIndex(ui.backends->findText(backend));
     ui.timeout->setValue(timeout);
     int timeout = s.value("Snore/Timeout", 10).toInt();
     ui.backends->setCurrentIndex(ui.backends->findText(backend));
     ui.timeout->setValue(timeout);