[WIP] Support to build with static Qt and static plugins

This commit is contained in:
Hannah von Reth 2016-11-21 08:57:00 +01:00
parent b8d39da311
commit 96fd4a7914
55 changed files with 501 additions and 287 deletions

View File

@ -40,28 +40,82 @@ find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets QUIET)
find_package(Qt5Quick QUIET)
set_package_properties(Qt5Quick PROPERTIES
PURPOSE "Support builtin notifiaction backend."
TYPE OPTIONAL)
set_package_properties(Qt5Widgets PROPERTIES
PURPOSE "Supprot for the daemon and the settings dialog as well as some backends."
TYPE OPTIONAL)
option(SNORE_STATIC "Build a static snore" OFF)
option(SNORE_STATIC_QT "Build a static snore" OFF)
set(LIBSNORE_INCLUDE_DIR ${KDE_INSTALL_INCLUDEDIR}/libsnore)
set(LIBSNORE_PLUGIN_PATH ${KDE_INSTALL_PLUGINDIR}/libsnore${SNORE_SUFFIX})
set(SNORE_PLUGIN_INSTALL_PATH LIBRARY DESTINATION ${LIBSNORE_PLUGIN_PATH})
message(STATUS "Installing plugins to ${LIBSNORE_PLUGIN_PATH}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
if (SNORE_STATIC_QT)
if (WIN32)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(d "d")
else()
set(d "")
endif()
if(MSVC)
set(SUFFIX "lib")
foreach(_bt DEBUG RELEASE RELWITHDEBINFO)
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_${_bt} ${CMAKE_CXX_FLAGS_${_bt}})
endforeach(_bt DEBUG RELEASE RELWITHDEBINFO)
else()
set(SUFFIX "a")
endif()
link_libraries(
"${_qt5Core_install_prefix}/lib/qtharfbuzzng${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/lib/qtpcre${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/lib/qtpng${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/lib/qtfreetype${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/lib/Qt5PlatformSupport${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/plugins/platforms/qwindows${d}.${SUFFIX}"
"Ws2_32"
"Imm32"
"Winmm"
"Iphlpapi"
"opengl32"
)
if (Qt5Quick_FOUND)
link_libraries(
"${_qt5Core_install_prefix}/qml/QtQuick.2/qtquick2plugin${d}.${SUFFIX}"
"${_qt5Core_install_prefix}/qml/QtQuick/Window.2/windowplugin${d}.${SUFFIX}"
)
endif()
endif()
endif()
add_subdirectory(data)
add_subdirectory(src)
add_subdirectory(autotest)
if (NOT SNORE_STATIC)
add_subdirectory(autotest)
endif()
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
ecm_install_po_files_as_qm(po)
endif()
generate_snore_plugin_header()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES)

View File

@ -2,7 +2,7 @@ include(libsnore/SnoreAddPlugin.cmake)
add_subdirectory(libsnore)
if(Qt5Widgets_FOUND)
if(Qt5Widgets_FOUND AND NOT SNORE_STATIC)
ecm_optional_add_subdirectory(daemon)
add_feature_info(BUILD_daemon BUILD_daemon "Build and install the snorenotify daemon which receives and redirects notifications.")
endif()

View File

@ -6,9 +6,9 @@ if(NOT SNORE_REVISION)
set(SNORE_REVISION "")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
ecm_create_qm_loader(SnoreNotify_QM_LOADER snorenotify${SNORE_SUFFIX}_qt)
QT5_ADD_RESOURCES(SNORENOTIFY_RCS ${SNORE_RCS})
@ -41,10 +41,14 @@ list(APPEND SnoreNotify_HDR
utils.h
${CMAKE_CURRENT_BINARY_DIR}/snore_exports.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
${CMAKE_CURRENT_BINARY_DIR}/snore_static_plugins.h
)
add_library( libsnore SHARED ${SnoreNotify_SRCS} ${SnoreNotify_QM_LOADER})
if (NOT SNORE_STATIC)
add_library( libsnore SHARED ${SnoreNotify_SRCS} ${SnoreNotify_QM_LOADER})
else()
add_library( libsnore STATIC ${SnoreNotify_SRCS} ${SnoreNotify_QM_LOADER})
endif()
set_target_properties( libsnore PROPERTIES
OUTPUT_NAME "snore${SNORE_SUFFIX}"
VERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}"
@ -105,4 +109,4 @@ endif()
if(Qt5Widgets_FOUND)
add_subdirectory(settings)
endif()
endif()

View File

@ -1,4 +1,3 @@
include(CMakeParseArguments)
function(_test_type TYPE)
@ -16,29 +15,77 @@ function(_test_name UPPER LOWER)
endif()
endfunction()
function(generate_snore_plugin_header)
set(SNORE_PLUGIN_LOADING "")
foreach(PLUGIN ${SNORE_PLUGIN_LIST})
set(SNORE_PLUGIN_LOADING "${SNORE_PLUGIN_LOADING}Q_IMPORT_PLUGIN(${PLUGIN})\n")
endforeach()
set(SNORE_RESOURCE_LOADING "Q_INIT_RESOURCE(snore);")
foreach(RESOURCE ${SNORE_PLUGIN_RESOURCES})
set(SNORE_RESOURCE_LOADING "${SNORE_RESOURCE_LOADING}\n Q_INIT_RESOURCE(${RESOURCE});")
endforeach()
configure_file("${PROJECT_SOURCE_DIR}/src/libsnore/snore_static_plugins.h.in" "${PROJECT_BINARY_DIR}/src/libsnore/snore_static_plugins.h")
endfunction()
function(add_snore_plugin SNORE_NAME)
set(options)
set(oneValueArgs TYPE)
set(multiValueArgs SETTINGS_SOURCES SETTINGS_LIBS SOURCES LIBS)
set(multiValueArgs SETTINGS_SOURCES SETTINGS_LIBS SOURCES LIBS RESOURCES)
cmake_parse_arguments(SNORE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
string( TOLOWER "${SNORE_NAME}" SNORE_NAME_LOWERCASE)
string(REGEX REPLACE "[ \t\r\n]" "" SNORE_NAME_NO_SPACE ${SNORE_NAME})
string( TOLOWER "${SNORE_NAME_NO_SPACE}" SNORE_NAME_LOWERCASE)
_test_name(${SNORE_NAME} ${SNORE_NAME_LOWERCASE})
string(REGEX REPLACE "[ \t\r\n]" "" SNORE_NAME_LOWERCASE ${SNORE_NAME_LOWERCASE})
_test_type(${SNORE_TYPE})
string( TOLOWER "${SNORE_TYPE}" SNORE_TYPE_LOWERCASE)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/snore_plugin.json "{ \"name\" : \"${SNORE_NAME}\" }")
add_library(libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} MODULE ${SNORE_SOURCES})
if(NOT SNORE_STATIC)
add_library(libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} MODULE ${SNORE_SOURCES})
install(TARGETS libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} ${SNORE_PLUGIN_INSTALL_PATH})
else()
list(APPEND SNORE_PLUGIN_LIST "${SNORE_NAME_NO_SPACE}")
add_library(libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} STATIC ${SNORE_SOURCES})
#todo install and export the plugins
#install(TARGETS libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
set_property( TARGET libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE}
APPEND
PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
endif()
target_link_libraries(libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} Snore::Libsnore ${SNORE_LIBS})
install(TARGETS libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} ${SNORE_PLUGIN_INSTALL_PATH})
if(SNORE_SETTINGS_SOURCES AND Qt5Widgets_FOUND)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/snore_settings_plugin.json "{ \"name\" : \"${SNORE_NAME}${SNORE_TYPE}\" }")
add_library(libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} MODULE ${SNORE_SETTINGS_SOURCES} )
if(NOT SNORE_STATIC)
add_library(libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} MODULE ${SNORE_SETTINGS_SOURCES} )
install(TARGETS libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} ${SNORE_PLUGIN_INSTALL_PATH})
else()
add_library(libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} STATIC ${SNORE_SETTINGS_SOURCES} )
set_property( TARGET libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE}
APPEND
PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
list(APPEND SNORE_PLUGINS libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} )
list(APPEND SNORE_PLUGIN_LIST "${SNORE_NAME_NO_SPACE}SettingsPlugin")
endif()
target_link_libraries(libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} Snore::Libsnore Snore::LibsnoreSettings ${SNORE_SETTINGS_LIBS})
install(TARGETS libsnore_settings_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE} ${SNORE_PLUGIN_INSTALL_PATH})
endif()
if(SNORE_STATIC)
list(REMOVE_DUPLICATES SNORE_PLUGIN_LIST)
set(SNORE_PLUGIN_LIST ${SNORE_PLUGIN_LIST} CACHE INTERNAL "A list of all plugins names." FORCE)
list(APPEND SNORE_PLUGIN_RESOURCES "${SNORE_RESOURCES}")
list(APPEND SNORE_PLUGINS libsnore_${SNORE_TYPE_LOWERCASE}_${SNORE_NAME_LOWERCASE})
list(REMOVE_DUPLICATES SNORE_PLUGINS)
set(SNORE_PLUGINS ${SNORE_PLUGINS} CACHE INTERNAL "A list of all plugins." FORCE)
list(REMOVE_DUPLICATES SNORE_PLUGIN_RESOURCES)
set(SNORE_PLUGIN_RESOURCES ${SNORE_PLUGIN_RESOURCES} CACHE INTERNAL "A list of all plugins resources." FORCE)
endif()
endfunction()

View File

@ -25,6 +25,7 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QUrl>
#include <QTime>
using namespace Snore;

View File

@ -24,21 +24,32 @@
#include "snorefrontend.h"
#include "libsnore/version.h"
#define SNORE_CONFIG_ONLY
#include "libsnore/snore_static_plugins.h"
#include <QDir>
#include <QGuiApplication>
#include <QTime>
using namespace Snore;
namespace Snore {
QHash<SnorePlugin::PluginTypes, QHash<QString, PluginContainer *> > PluginContainer::s_pluginCache;
PluginContainer::PluginContainer(const QString &pluginName, SnorePlugin::PluginTypes type, SnorePlugin *plugin):
m_pluginName(pluginName),
m_pluginType(type),
m_plugin(plugin)
{
m_plugin->m_name = pluginName;
}
PluginContainer::PluginContainer(const QString &fileName, const QString &pluginName, SnorePlugin::PluginTypes type):
m_pluginFile(fileName),
m_pluginName(pluginName),
m_pluginType(type),
m_loader(pluginDir().absoluteFilePath(file()))
{
}
PluginContainer::~PluginContainer()
@ -48,24 +59,18 @@ PluginContainer::~PluginContainer()
SnorePlugin *PluginContainer::load()
{
if (!m_loader.isLoaded() && !m_loader.load()) {
if (!m_plugin && !m_loader.isLoaded() && !m_loader.load()) {
qCWarning(SNORE) << "Failed loading plugin: " << m_loader.errorString();
return nullptr;
}
if (!m_plugin) {
m_plugin = qobject_cast<SnorePlugin *> (m_loader.instance());
m_plugin->m_container = this;
m_plugin->m_name = name();
m_plugin->setDefaultSettings();
}
return m_plugin;
}
void PluginContainer::unload()
{
m_loader.unload();
m_plugin = nullptr;
}
const QString &PluginContainer::file()
{
return m_pluginFile;
@ -94,9 +99,9 @@ void PluginContainer::updatePluginCache()
list.clear();
}
#if !SNORE_STATIC
foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) {
foreach(const QFileInfo & file, pluginDir().entryInfoList(
QStringList(pluginFileFilters(type)), QDir::Files)) {
foreach(const QFileInfo & file, pluginDir().entryInfoList(pluginFileFilters(type), QDir::Files)) {
qCDebug(SNORE) << "adding" << file.absoluteFilePath();
QPluginLoader loader(file.absoluteFilePath());
QJsonObject data = loader.metaData()[QStringLiteral("MetaData")].toObject();
@ -108,6 +113,18 @@ void PluginContainer::updatePluginCache()
}
}
}
#else
foreach (const QStaticPlugin plugin, QPluginLoader::staticPlugins()) {
QJsonObject data = plugin.metaData()[QStringLiteral("MetaData")].toObject();
QString name = data.value(QStringLiteral("name")).toString();
if (!name.isEmpty()) {
SnorePlugin *sp = qobject_cast<SnorePlugin*>(plugin.instance());
PluginContainer *info = new PluginContainer(name, sp->type(), sp);
s_pluginCache[sp->type()].insert(name, info);
qCDebug(SNORE) << "added" << sp->type() << ":" << name << "to cache";
}
}
#endif
}
const QHash<QString, PluginContainer *> PluginContainer::pluginCache(SnorePlugin::PluginTypes type)
@ -170,3 +187,4 @@ const QDir &PluginContainer::pluginDir()
return path;
}
}

View File

@ -35,10 +35,10 @@ class PluginContainer
public:
static const QHash<QString, PluginContainer *> pluginCache(SnorePlugin::PluginTypes type);
PluginContainer(const QString &pluginName, SnorePlugin::PluginTypes type, SnorePlugin *plugin);
PluginContainer(const QString &fileName, const QString &pluginName, SnorePlugin::PluginTypes type);
~PluginContainer();
SnorePlugin *load();
void unload();
const QString &file();
const QString &name();
SnorePlugin::PluginTypes type();

View File

@ -79,8 +79,7 @@ QString SnorePlugin::normaliseKey(const QString &key) const
const QString &SnorePlugin::name() const
{
Q_ASSERT_X(m_container, Q_FUNC_INFO, "Plugin container not set.");
return m_container->name();
return m_name;
}
const QString SnorePlugin::typeName() const

View File

@ -162,7 +162,7 @@ private:
void setDefaultSettingsPlugin();
bool m_enabled = false;
PluginContainer *m_container = nullptr;
QString m_name;
QString m_error;
Hint m_hints;

View File

@ -38,7 +38,7 @@ public:
PluginTypes type() const override
{
return SnorePlugin::Settings;
};
}
virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0;
@ -49,15 +49,17 @@ public:
Q_DECLARE_INTERFACE(Snore::SettingsPlugin,
"org.Snore.SettingsPlugin/1.0")
#define SNORE_DECLARE_SETTINGS_PLUGIN(NAME)\
class NAMESettings : public Snore::SettingsPlugin{\
#define SNORE_DECLARE_SETTINGS_PLUGIN( NAME )\
namespace SnorePlugin {\
class NAME ##SettingsPlugin : public Snore::SettingsPlugin {\
Q_OBJECT\
Q_INTERFACES(Snore::SettingsPlugin)\
Q_PLUGIN_METADATA(IID "org.Snore.SettingsPlugin/1.0" FILE "snore_settings_plugin.json")\
public:\
Snore::PluginSettingsWidget *settingsWidget(Snore::SnorePlugin *parent) override{\
return new NAME(parent);\
return new NAME ##Settings(parent);\
}\
};
};\
}
#endif // SETTINGSPLUGIN_H

View File

@ -17,8 +17,11 @@ set(snoresettings_HDR
${CMAKE_CURRENT_BINARY_DIR}/snore_settings_exports.h
)
add_library( libsnoresettings SHARED ${snoresettings_SRCS})
if (NOT SNORE_STATIC)
add_library( libsnoresettings SHARED ${snoresettings_SRCS})
else()
add_library( libsnoresettings STATIC ${snoresettings_SRCS})
endif()
set_target_properties( libsnoresettings PROPERTIES
OUTPUT_NAME "snoresettings${SNORE_SUFFIX}"
VERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}"

View File

@ -0,0 +1,48 @@
#ifndef SNORE_STATIC_PLUGINS_H
#define SNORE_STATIC_PLUGINS_H
#include <QCoreApplication>
#include <QtPlugin>
#cmakedefine01 SNORE_STATIC
#cmakedefine01 SNORE_STATIC_QT
#cmakedefine01 Qt5Quick_FOUND
#ifndef SNORE_CONFIG_ONLY
#if SNORE_STATIC_QT
#if Qt5Quick_FOUND
Q_IMPORT_PLUGIN(QtQuick2Plugin)
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
#endif
#ifdef Q_OS_WIN
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
#else
#error Unsupported platform
#endif
#endif
#if SNORE_STATIC
namespace SnorePlugin {}
using namespace SnorePlugin;
${SNORE_PLUGIN_LOADING}
namespace {
static void loadSnoreResources()
{
// prevent multiple symbols
static const auto load = []() {
${SNORE_RESOURCE_LOADING}
};
load();
}
}
Q_COREAPP_STARTUP_FUNCTION(loadSnoreResources)
#endif
#endif
#endif

View File

@ -4,7 +4,9 @@ add_feature_info(BUILD_backends BUILD_backends "Build and install the backends,
ecm_optional_add_subdirectory(secondary_backends)
add_feature_info(BUILD_secondary_backends BUILD_secondary_backends "Build and install the secondary_backends, which are used to display non interactive notifications.")
ecm_optional_add_subdirectory(frontends)
add_feature_info(BUILD_frontends BUILD_frontends "Build and install the frontends, which are used to receive notifications.")
if (NOT SNORE_STATIC)
ecm_optional_add_subdirectory(frontends)
add_feature_info(BUILD_frontends BUILD_frontends "Build and install the frontends, which are used to receive notifications.")
endif()
ecm_optional_add_subdirectory(plugins)

View File

@ -8,9 +8,7 @@
#include "fredesktopnotification.h"
using namespace Snore;
FreedesktopBackend::FreedesktopBackend()
SnorePlugin::Freedesktop::Freedesktop()
{
m_interface = new org::freedesktop::Notifications(QStringLiteral("org.freedesktop.Notifications"),
QStringLiteral("/org/freedesktop/Notifications"),
@ -21,29 +19,29 @@ FreedesktopBackend::FreedesktopBackend()
m_supportsRichtext = reply.value().contains(QStringLiteral("body-markup"));
watcher->deleteLater();
});
connect(this, &FreedesktopBackend::enabledChanged, [this](bool enabled) {
connect(this, &Freedesktop::enabledChanged, [this](bool enabled) {
if (enabled) {
connect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &FreedesktopBackend::slotActionInvoked);
connect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &FreedesktopBackend::slotNotificationClosed);
connect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &Freedesktop::slotActionInvoked);
connect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &Freedesktop::slotNotificationClosed);
} else {
disconnect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &FreedesktopBackend::slotActionInvoked);
disconnect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &FreedesktopBackend::slotNotificationClosed);
disconnect(m_interface, &org::freedesktop::Notifications::ActionInvoked, this, &Freedesktop::slotActionInvoked);
disconnect(m_interface, &org::freedesktop::Notifications::NotificationClosed, this , &Freedesktop::slotNotificationClosed);
}
});
}
bool FreedesktopBackend::canCloseNotification() const
bool SnorePlugin::Freedesktop::canCloseNotification() const
{
return true;
}
bool FreedesktopBackend::canUpdateNotification() const
bool SnorePlugin::Freedesktop::canUpdateNotification() const
{
return true;
}
void FreedesktopBackend::slotNotify(Notification noti)
void SnorePlugin::Freedesktop::slotNotify(Snore::Notification noti)
{
if (noti.data()->sourceAndTargetAreSimilar(this)) {
return;
@ -78,8 +76,8 @@ void FreedesktopBackend::slotNotify(Notification noti)
m_dbusIdMap.take(updateId);
}
QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup);
QString body(noti.text(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup));
QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup);
QString body(noti.text(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup));
//TODO: add app icon hint?
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, QString(), title,
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);
@ -92,24 +90,24 @@ void FreedesktopBackend::slotNotify(Notification noti)
qCDebug(SNORE) << noti.id() << "|" << id.value();
}
void FreedesktopBackend::slotActionInvoked(const uint id, const QString &actionID)
void SnorePlugin::Freedesktop::slotActionInvoked(const uint id, const QString &actionID)
{
qCDebug(SNORE) << id << m_dbusIdMap[id];
Notification noti = m_dbusIdMap[id];
Snore::Notification noti = m_dbusIdMap[id];
if (!noti.isValid()) {
return;
}
slotNotificationActionInvoked(noti, noti.actions().value(actionID.toInt()));;
}
void FreedesktopBackend::slotCloseNotification(Notification notification)
void SnorePlugin::Freedesktop::slotCloseNotification(Snore::Notification notification)
{
uint id = notification.hints().privateValue(this, "id").toUInt();
qCDebug(SNORE) << notification.id() << id;
m_interface->CloseNotification(id);
}
void FreedesktopBackend::slotNotificationClosed(const uint id, const uint reason)
void SnorePlugin::Freedesktop::slotNotificationClosed(const uint id, const uint reason)
{
/*
*
@ -123,26 +121,26 @@ void FreedesktopBackend::slotNotificationClosed(const uint id, const uint reason
*
* 4 - Undefined/reserved reasons.
*/
Notification::CloseReasons closeReason;
Snore::Notification::CloseReasons closeReason;
switch (reason) {
case (1):
closeReason = Notification::TimedOut;
closeReason = Snore::Notification::TimedOut;
break;
case (2):
closeReason = Notification::Dismissed;
closeReason = Snore::Notification::Dismissed;
break;
case (3):
closeReason = Notification::Closed;
closeReason = Snore::Notification::Closed;
break;
default:
closeReason = Notification::None;
closeReason = Snore::Notification::None;
}
qCDebug(SNORE) << id << "|" << closeReason << reason;
if (id == 0) {
return;
}
Notification noti = m_dbusIdMap.take(id);
Snore::Notification noti = m_dbusIdMap.take(id);
if (noti.isValid()) {
closeNotification(noti, closeReason);
}

View File

@ -3,14 +3,16 @@
#include "libsnore/plugins/snorebackend.h"
#include "notificationinterface.h"
class FreedesktopBackend: public Snore::SnoreBackend
namespace SnorePlugin {
class Freedesktop: public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
FreedesktopBackend();
~FreedesktopBackend() = default;
Freedesktop();
~Freedesktop() = default;
bool canCloseNotification() const override;
bool canUpdateNotification() const override;
@ -29,4 +31,6 @@ private:
};
}
#endif // FREEDESKTOPNOTIFICATION_H

View File

@ -24,64 +24,63 @@
#include <functional>
using namespace Snore;
GrowlBackend *GrowlBackend::s_instance = nullptr;
SnorePlugin::Growl *SnorePlugin::Growl::s_instance = nullptr;
GrowlBackend::GrowlBackend()
SnorePlugin::Growl::Growl()
{
s_instance = this;
auto func = [](growl_callback_data * data)->void {
qCDebug(SNORE) << data->id << QString::fromUtf8(data->reason) << QString::fromUtf8(data->data);
Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id);
Snore::Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id);
if (!n.isValid())
{
return;
}
Notification::CloseReasons r = Notification::None;
Snore::Notification::CloseReasons r = Snore::Notification::None;
std::string reason(data->reason);
if (reason == "TIMEDOUT")
{
r = Notification::TimedOut;
r = Snore::Notification::TimedOut;
} else if (reason == "CLOSED")
{
r = Notification::Dismissed;
r = Snore::Notification::Dismissed;
} else if (reason == "CLICK")
{
r = Notification::Activated;
r = Snore::Notification::Activated;
s_instance->slotNotificationActionInvoked(n);
}
s_instance->closeNotification(n, r);
};
Growl::init((GROWL_CALLBACK)static_cast<void(*)(growl_callback_data *)>(func));
::Growl::init((GROWL_CALLBACK)static_cast<void(*)(growl_callback_data *)>(func));
}
GrowlBackend::~GrowlBackend()
SnorePlugin::Growl::~Growl()
{
Growl::shutdown();
::Growl::shutdown();
}
bool GrowlBackend::isReady()
bool SnorePlugin::Growl::isReady()
{
bool running = Growl::isRunning(GROWL_TCP, settingsValue(QStringLiteral("Host")).toString().toUtf8().constData());
bool running = ::Growl::isRunning(GROWL_TCP, settingsValue(QStringLiteral("Host")).toString().toUtf8().constData());
if (!running) {
setErrorString(tr("%1 is not running.").arg(name()));
}
return running;
}
void GrowlBackend::slotRegisterApplication(const Application &application)
void SnorePlugin::Growl::slotRegisterApplication(const Snore::Application &application)
{
qCDebug(SNORE) << application.name();
std::vector<std::string> alerts;
alerts.reserve(application.alerts().size());
foreach(const Alert & a, application.alerts()) {
foreach(const Snore::Alert & a, application.alerts()) {
qCDebug(SNORE) << a.name();
alerts.push_back(a.name().toUtf8().constData());
}
Growl *growl = new Growl(GROWL_TCP, settingsValue(QStringLiteral("Host")).toString().toUtf8().constData(),
::Growl *growl = new ::Growl(GROWL_TCP, settingsValue(QStringLiteral("Host")).toString().toUtf8().constData(),
settingsValue(QStringLiteral("Password")).toString().toUtf8().constData(),
application.name().toUtf8().constData());
m_applications.insert(application.name(), growl);
@ -89,18 +88,18 @@ void GrowlBackend::slotRegisterApplication(const Application &application)
}
void GrowlBackend::slotDeregisterApplication(const Application &application)
void SnorePlugin::Growl::slotDeregisterApplication(const Snore::Application &application)
{
Growl *growl = m_applications.take(application.name());
::Growl *growl = m_applications.take(application.name());
if (growl == nullptr) {
return;
}
delete growl;
}
void GrowlBackend::slotNotify(Notification notification)
void SnorePlugin::Growl::slotNotify(Snore::Notification notification)
{
Growl *growl = m_applications.value(notification.application().name());
::Growl *growl = m_applications.value(notification.application().name());
QString alert = notification.alert().name();
qCDebug(SNORE) << "Notify Growl:" << notification.application() << alert << notification.title();
@ -115,7 +114,7 @@ void GrowlBackend::slotNotify(Notification notification)
slotNotificationDisplayed(notification);
}
void GrowlBackend::setDefaultSettings()
void SnorePlugin::Growl::setDefaultSettings()
{
SnoreBackend::setDefaultSettings();
setDefaultSettingsValue(QStringLiteral("Host"), QLatin1String("localhost"));

View File

@ -23,15 +23,17 @@
#include "growl.hpp"
#include <string>
class GrowlBackend: public Snore::SnoreBackend
namespace SnorePlugin {
class Growl: public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
GrowlBackend();
~GrowlBackend();
Growl();
~Growl();
bool isReady() override;
protected:
@ -39,8 +41,8 @@ protected:
private:
//a static instance for the static callback methode
static GrowlBackend *s_instance;
QHash<QString, Growl *> m_applications;
static Growl *s_instance;
QHash<QString, ::Growl *> m_applications;
public Q_SLOTS:
void slotRegisterApplication(const Snore::Application &application) override;
@ -49,4 +51,5 @@ public Q_SLOTS:
};
}
#endif // GROWL_BACKEND_H

View File

@ -19,9 +19,7 @@
#include <QLineEdit>
using namespace Snore;
GrowlSettings::GrowlSettings(SnorePlugin *plugin, QWidget *parent):
GrowlSettings::GrowlSettings(Snore::SnorePlugin *plugin, QWidget *parent):
PluginSettingsWidget(plugin, parent),
m_host(new QLineEdit),
m_password(new QLineEdit)

View File

@ -39,6 +39,6 @@ private:
QLineEdit *m_password;
};
SNORE_DECLARE_SETTINGS_PLUGIN(GrowlSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Growl)
#endif // GROWLSETTINGS_H

View File

@ -32,14 +32,13 @@
#define SNORENOTIFIER_MESSAGE_ID WM_USER + 238
using namespace Snore;
using namespace Snarl::V42;
class SnarlBackend::SnarlWidget: public QWidget
class SnarlWidget: public QWidget
{
//Q_OBJECT
public:
SnarlWidget(SnarlBackend *snarl):
SnarlWidget(SnorePlugin::Snarl *snarl):
m_snarl(snarl)
{
SNARL_GLOBAL_MESSAGE = SnarlInterface::Broadcast();
@ -52,7 +51,7 @@ public:
if (msg->message == SNARL_GLOBAL_MESSAGE) {
int action = msg->wParam;
if (action == SnarlEnums::SnarlLaunched) {
for (const Application &a : SnoreCore::instance().aplications()) {
for (const Snore::Application &a : Snore::SnoreCore::instance().aplications()) {
m_snarl->slotRegisterApplication(a);
}
}
@ -61,30 +60,30 @@ public:
int action = msg->wParam & 0xffff;
int data = (msg->wParam & 0xffffffff) >> 16;
Notification notification;
Snore::Notification notification;
if (msg->lParam != 0) {
notification = m_snarl->m_idMap.value(msg->lParam);
}
Notification::CloseReasons reason = Notification::None;
Snore::Notification::CloseReasons reason = Snore::Notification::None;
switch (action) {
case SnarlEnums::CallbackInvoked:
reason = Notification::Activated;
reason = Snore::Notification::Activated;
qCDebug(SNORE) << "Notification clicked";
break;
case SnarlEnums::NotifyAction:
reason = Notification::Activated;
reason = Snore::Notification::Activated;
qCDebug(SNORE) << "Notification action invoked";
if (notification.isValid()) {
m_snarl->slotNotificationActionInvoked(notification, notification.actions().value(data));
}
break;
case SnarlEnums::CallbackClosed:
reason = Notification::Dismissed;
reason = Snore::Notification::Dismissed;
qCDebug(SNORE) << "Notification dismissed";
break;
case SnarlEnums::CallbackTimedOut:
reason = Notification::TimedOut;
reason = Snore::Notification::TimedOut;
qCDebug(SNORE) << "Notification timed out";
break;
//away stuff
@ -113,32 +112,32 @@ public:
private:
uint SNARL_GLOBAL_MESSAGE;
SnarlBackend *m_snarl;
SnorePlugin::Snarl *m_snarl;
};
SnarlBackend::SnarlBackend()
SnorePlugin::Snarl::Snarl()
{
}
SnarlBackend::~SnarlBackend()
SnorePlugin::Snarl::~Snarl()
{
if (m_eventLoop) {
delete m_eventLoop;
}
}
bool SnarlBackend::canCloseNotification() const
bool SnorePlugin::Snarl::canCloseNotification() const
{
return true;
}
bool SnarlBackend::canUpdateNotification() const
bool SnorePlugin::Snarl::canUpdateNotification() const
{
return true;
}
bool SnarlBackend::isReady()
bool SnorePlugin::Snarl::isReady()
{
if (!qobject_cast< QApplication * >(qApp)) {
setErrorString(tr("This plugin only works with QApplication"));
@ -146,7 +145,7 @@ bool SnarlBackend::isReady()
}
if (!m_eventLoop) {
m_eventLoop = new SnarlBackend::SnarlWidget(this);
m_eventLoop = new SnarlWidget(this);
}
bool running = SnarlInterface::IsSnarlRunning();
if (!running) {
@ -155,18 +154,16 @@ bool SnarlBackend::isReady()
return running;
}
void SnarlBackend::setDefaultSettings()
void SnorePlugin::Snarl::setDefaultSettings()
{
setDefaultSettingsValue(QLatin1String("Password"), QString());
SnoreBackend::setDefaultSettings();
}
void SnarlBackend::slotRegisterApplication(const Application &application)
void SnorePlugin::Snarl::slotRegisterApplication(const Snore::Application &application)
{
if (!m_eventLoop) {
return;
}
Q_ASSERT(m_eventLoop);
Q_ASSERT_X(!m_applications.contains(application.name()), Q_FUNC_INFO, "Application already registered");
@ -182,14 +179,14 @@ void SnarlBackend::slotRegisterApplication(const Application &application)
(HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID);
qCDebug(SNORE) << result;
foreach(const Alert & alert, application.alerts()) {
foreach(const Snore::Alert & alert, application.alerts()) {
snarlInterface->AddClass(alert.name().toUtf8().constData(),
alert.name().toUtf8().constData(),
0, 0, alert.icon().localUrl(QSize(128, 128)).toUtf8().constData());
}
}
void SnarlBackend::slotDeregisterApplication(const Application &application)
void SnorePlugin::Snarl::slotDeregisterApplication(const Snore::Application &application)
{
if (!m_applications.contains(application.name())) {
qCDebug(SNORE) << "Unknown apllication: " << application.name();
@ -201,7 +198,7 @@ void SnarlBackend::slotDeregisterApplication(const Application &application)
delete snarlInterface;
}
void SnarlBackend::slotNotify(Notification notification)
void SnorePlugin::Snarl::slotNotify(Snore::Notification notification)
{
if (!m_applications.contains(notification.application().name())) {
qCDebug(SNORE) << "Unknown apllication: " << notification.application().name();
@ -210,13 +207,13 @@ void SnarlBackend::slotNotify(Notification notification)
SnarlInterface *snarlInterface = m_applications.value(notification.application().name());
Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined;
::Snarl::V42::SnarlEnums::MessagePriority priority = ::Snarl::V42::SnarlEnums::PriorityUndefined;
if (notification.priority() > 1) {
priority = Snarl::V42::SnarlEnums::PriorityHigh;
priority = ::Snarl::V42::SnarlEnums::PriorityHigh;
} else if (notification.priority() < -1) {
priority = Snarl::V42::SnarlEnums::PriorityLow;
priority = ::Snarl::V42::SnarlEnums::PriorityLow;
} else {
priority = static_cast<Snarl::V42::SnarlEnums::MessagePriority>(notification.priority());
priority = static_cast<::Snarl::V42::SnarlEnums::MessagePriority>(notification.priority());
}
ULONG32 id = 0;
@ -228,10 +225,10 @@ void SnarlBackend::slotNotify(Notification notification)
notification.text().toUtf8().constData(),
notification.timeout(),
nullptr,
Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(),
Snore::Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(),
priority);
foreach(const Action & a, notification.actions()) {
foreach(const Snore::Action & a, notification.actions()) {
snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData());
}
m_idMap[id] = notification;
@ -245,7 +242,7 @@ void SnarlBackend::slotNotify(Notification notification)
notification.text().toUtf8().constData(),
notification.timeout(),
nullptr,
Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(),
Snore::Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(),
priority);
}
@ -254,7 +251,7 @@ void SnarlBackend::slotNotify(Notification notification)
}
void SnarlBackend::slotCloseNotification(Notification notification)
void SnorePlugin::Snarl::slotCloseNotification(Snore::Notification notification)
{
if (!m_applications.contains(notification.application().name())) {
qCDebug(SNORE) << "Unknown apllication: " << notification.application().name();

View File

@ -21,14 +21,18 @@
#include "libsnore/plugins/snorebackend.h"
#include "SnarlInterface.h"
class SnarlBackend: public Snore::SnoreBackend
class SnarlWidget;
namespace SnorePlugin {
class Snarl : public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
SnarlBackend();
~SnarlBackend();
Snarl();
~Snarl();
virtual bool canCloseNotification() const override;
virtual bool canUpdateNotification() const override;
@ -39,9 +43,9 @@ protected:
void setDefaultSettings() override;
private:
class SnarlWidget;
SnarlBackend::SnarlWidget *m_eventLoop = nullptr;
QHash<QString, Snarl::V42::SnarlInterface *> m_applications;
friend class SnarlWidget;
SnarlWidget *m_eventLoop = nullptr;
QHash<QString, ::Snarl::V42::SnarlInterface *> m_applications;
public Q_SLOTS:
void slotRegisterApplication(const Snore::Application &application) override;
@ -53,5 +57,6 @@ private:
QHash<LONG32, Snore::Notification> m_idMap;
};
}
#endif // SNARL_BACKEND_H

View File

@ -19,9 +19,7 @@
#include <QLineEdit>
using namespace Snore;
SnarlSettings::SnarlSettings(SnorePlugin *plugin, QWidget *parent):
SnarlSettings::SnarlSettings(Snore::SnorePlugin *plugin, QWidget *parent):
PluginSettingsWidget(plugin, parent),
m_password(new QLineEdit)
{

View File

@ -38,6 +38,6 @@ private:
QLineEdit *m_password;
};
SNORE_DECLARE_SETTINGS_PLUGIN(SnarlSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Snarl)
#endif // SNARLSETTINGS_H

View File

@ -1,13 +1,9 @@
find_package(Qt5Quick QUIET)
set_package_properties(Qt5Quick PROPERTIES
PURPOSE "Adding builtin notifiaction backend."
TYPE OPTIONAL)
if(Qt5Quick_FOUND)
QT5_ADD_RESOURCES(SNORENOTIFIER_RCS ${CMAKE_CURRENT_SOURCE_DIR}/snore_notification.qrc)
add_snore_plugin(Snore SOURCES snorenotifier.cpp
notifywidget.cpp
${SNORENOTIFIER_RCS}
TYPE Backend SETTINGS_SOURCES snorenotifiersettings.cpp LIBS Qt5::Quick)
TYPE Backend SETTINGS_SOURCES snorenotifiersettings.cpp LIBS Qt5::Quick
RESOURCES snore_notification )
endif()

View File

@ -24,16 +24,18 @@
#include <QQmlProperty>
using namespace Snore;
using namespace SnorePlugin;
NotifyWidget::NotifyWidget(int id, const SnoreNotifier *parent) :
NotifyWidget::NotifyWidget(int id, const ::SnorePlugin::Snore *parent) :
m_id(id),
m_parent(parent),
m_mem(QLatin1String("SnoreNotifyWidget_rev") + QString::number(SHARED_MEM_TYPE_REV()) + QLatin1String("_id") + QString::number(m_id)),
m_mem(QStringLiteral("SnoreNotifyWidget_rev%1_id%2").arg(SHARED_MEM_TYPE_REV(), m_id)),
m_ready(true),
m_fontFamily(qApp->font().family())
{
#ifdef Q_OS_WIN
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)// Qt 5.7+ is broken and can only display it in black and white.
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
m_fontFamily = QStringLiteral("Segoe UI Symbol");
emit fontFamilyChanged();
@ -44,6 +46,7 @@ NotifyWidget::NotifyWidget(int id, const SnoreNotifier *parent) :
emit fontFamilyChanged();
}
#endif
#endif
#endif
QQmlApplicationEngine *engine = new QQmlApplicationEngine(this);
engine->rootContext()->setContextProperty(QStringLiteral("notifyWidget"), this);
@ -187,6 +190,9 @@ void NotifyWidget::syncSettings()
QColor NotifyWidget::computeBackgrondColor(const QImage &img)
{
if (img.isNull())
return Qt::black;
int stepSize = img.depth() / 8;
qulonglong r = 0;
qulonglong g = 0;

View File

@ -24,7 +24,9 @@
#include <QtQuick/QtQuick>
class SnoreNotifier;
namespace SnorePlugin {
class Snore;
}
typedef struct {
bool free;
@ -54,7 +56,7 @@ class NotifyWidget : public QObject
Q_PROPERTY(QString fontFamily MEMBER m_fontFamily NOTIFY fontFamilyChanged)
public:
explicit NotifyWidget(int id, const SnoreNotifier *parent);
explicit NotifyWidget(int id, const SnorePlugin::Snore *parent);
~NotifyWidget();
void display(const Snore::Notification &notification);
@ -91,7 +93,7 @@ private:
Snore::Notification m_notification;
int m_id;
const SnoreNotifier *m_parent;
const SnorePlugin::Snore *m_parent;
QSharedMemory m_mem;
bool m_ready;

View File

@ -23,42 +23,22 @@
#include <QThread>
using namespace Snore;
SnoreNotifier::SnoreNotifier():
m_widgets(3),
SnorePlugin::Snore::Snore():
m_timer(new QTimer(this))
{
for (int i = 0; i < m_widgets.size(); ++i) {
NotifyWidget *w = new NotifyWidget(i, this);
m_widgets[i] = w;
connect(w, &NotifyWidget::dismissed, [this, w]() {
Notification notification = w->notification();
closeNotification(notification, Notification::Dismissed);
slotCloseNotification(notification);
});
connect(w, &NotifyWidget::invoked, [this, w]() {
Notification notification = w->notification();
slotNotificationActionInvoked(notification);
closeNotification(notification, Notification::Activated);
slotCloseNotification(notification);
});
}
m_timer->setInterval(1000);
connect(m_timer, &QTimer::timeout, this, &SnoreNotifier::slotQueueTimeout);
connect(m_timer, &QTimer::timeout, this, &Snore::slotQueueTimeout);
}
SnoreNotifier::~SnoreNotifier()
SnorePlugin::Snore::~Snore()
{
qDeleteAll(m_widgets);
}
void SnoreNotifier::slotNotify(Snore::Notification notification)
void SnorePlugin::Snore::slotNotify(::Snore::Notification notification)
{
auto display = [this](NotifyWidget * w, Snore::Notification notification) {
auto display = [this](NotifyWidget * w, ::Snore::Notification notification) {
w->display(notification);
notification.hints().setPrivateValue(this, "id", w->id());
slotNotificationDisplayed(notification);
@ -73,7 +53,7 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
}
} else {
for (int i = 0; i < m_queue.length(); ++i) {
Notification n = m_queue.at(i);
::Snore::Notification n = m_queue.at(i);
if (n.id() == notification.old().id()) {
qCDebug(SNORE) << "replacing qued notification" << n.id() << notification.id();
m_queue.replace(i, notification);
@ -97,14 +77,39 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
}
}
void SnoreNotifier::slotCloseNotification(Snore::Notification notification)
void SnorePlugin::Snore::slotCloseNotification(::Snore::Notification notification)
{
NotifyWidget *w = m_widgets[notification.hints().privateValue(this, "id").toInt()];
w->release();
slotQueueTimeout();
}
void SnoreNotifier::slotQueueTimeout()
void SnorePlugin::Snore::slotRegisterApplication(const ::Snore::Application &)
{
if (!m_widgets.isEmpty())
return;
m_widgets.resize(3);
for (int i = 0; i < m_widgets.size(); ++i) {
auto *w = new NotifyWidget(i, this);
m_widgets[i] = w;
connect(w, &NotifyWidget::dismissed, [this, w]() {
::Snore::Notification notification = w->notification();
closeNotification(notification, ::Snore::Notification::Dismissed);
slotCloseNotification(notification);
});
connect(w, &NotifyWidget::invoked, [this, w]() {
::Snore::Notification notification = w->notification();
slotNotificationActionInvoked(notification);
closeNotification(notification, ::Snore::Notification::Activated);
slotCloseNotification(notification);
});
}
}
void SnorePlugin::Snore::slotQueueTimeout()
{
if (m_queue.isEmpty()) {
qCDebug(SNORE) << "queue is empty";
@ -112,7 +117,7 @@ void SnoreNotifier::slotQueueTimeout()
} else {
foreach(NotifyWidget * w, m_widgets) {
if (!m_queue.isEmpty() && w->acquire(m_queue.first().timeout())) {
Notification notification = m_queue.takeFirst();
::Snore::Notification notification = m_queue.takeFirst();
notification.hints().setPrivateValue(this, "id", w->id());
w->display(notification);
slotNotificationDisplayed(notification);
@ -121,17 +126,17 @@ void SnoreNotifier::slotQueueTimeout()
}
}
bool SnoreNotifier::canCloseNotification() const
bool SnorePlugin::Snore::canCloseNotification() const
{
return true;
}
bool SnoreNotifier::canUpdateNotification() const
bool SnorePlugin::Snore::canUpdateNotification() const
{
return true;
}
void SnoreNotifier::setDefaultSettings()
void SnorePlugin::Snore::setDefaultSettings()
{
setDefaultSettingsValue(QStringLiteral("Position"), Qt::TopRightCorner);
SnoreBackend::setDefaultSettings();

View File

@ -23,14 +23,16 @@
#include "notifywidget.h"
class SnoreNotifier : public Snore::SnoreBackend
namespace SnorePlugin {
class Snore : public ::Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
SnoreNotifier();
~SnoreNotifier();
Snore();
~Snore();
bool canCloseNotification() const override;
bool canUpdateNotification() const override;
@ -38,17 +40,18 @@ public:
protected:
void setDefaultSettings() override;
public Q_SLOTS:
virtual void slotNotify(Snore::Notification notification) override;
virtual void slotCloseNotification(Snore::Notification notification) override;
virtual void slotNotify(::Snore::Notification notification) override;
virtual void slotCloseNotification(::Snore::Notification notification) override;
void slotRegisterApplication(const ::Snore::Application &application);
private Q_SLOTS:
void slotQueueTimeout();
private:
QList<Snore::Notification> m_queue;
QList<::Snore::Notification> m_queue;
QVector<NotifyWidget *> m_widgets;
QTimer *m_timer;
};
}
#endif // SNORENOTIFIER_H

View File

@ -20,9 +20,7 @@
#include <QComboBox>
using namespace Snore;
SnoreNotifierSettings::SnoreNotifierSettings(SnorePlugin *snore, QWidget *parent) :
SnoreSettings::SnoreSettings(Snore::SnorePlugin *snore, QWidget *parent) :
PluginSettingsWidget(snore, parent),
m_comboBox(new QComboBox)
{
@ -33,17 +31,16 @@ SnoreNotifierSettings::SnoreNotifierSettings(SnorePlugin *snore, QWidget *parent
addRow(tr("Position:"), m_comboBox);
}
SnoreNotifierSettings::~SnoreNotifierSettings()
SnoreSettings::~SnoreSettings()
{
}
void SnoreNotifierSettings::load()
void SnoreSettings::load()
{
m_comboBox->setCurrentIndex(settingsValue(QStringLiteral("Position")).toInt());
}
void SnoreNotifierSettings::save()
void SnoreSettings::save()
{
setSettingsValue(QStringLiteral("Position"), m_comboBox->currentIndex());
}

View File

@ -27,12 +27,12 @@ class SnorePlugin;
}
class QComboBox;
class SnoreNotifierSettings : public Snore::PluginSettingsWidget
class SnoreSettings : public Snore::PluginSettingsWidget
{
Q_OBJECT
public:
explicit SnoreNotifierSettings(Snore::SnorePlugin *snore, QWidget *parent = nullptr);
~SnoreNotifierSettings();
explicit SnoreSettings(Snore::SnorePlugin *snore, QWidget *parent = nullptr);
~SnoreSettings();
void load();
void save();
@ -40,6 +40,6 @@ private:
QComboBox *m_comboBox;
};
SNORE_DECLARE_SETTINGS_PLUGIN(SnoreNotifierSettings)
SNORE_DECLARE_SETTINGS_PLUGIN( Snore )
#endif // SNORENOTIFIERSETTINGS_H

View File

@ -12,9 +12,7 @@
#include <windows.h>
using namespace Snore;
bool SnoreToast::isReady()
bool SnorePlugin::WindowsToast::isReady()
{
if (errorString().isEmpty() && QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8) {
setErrorString(tr("%1 needs at least Windows 8 to run.").arg(name()));
@ -23,12 +21,12 @@ bool SnoreToast::isReady()
return true;
}
bool SnoreToast::canCloseNotification() const
bool SnorePlugin::WindowsToast::canCloseNotification() const
{
return true;
}
void SnoreToast::slotNotify(Notification notification)
void SnorePlugin::WindowsToast::slotNotify(Snore::Notification notification)
{
QProcess *p = createProcess(notification);
@ -51,21 +49,21 @@ void SnoreToast::slotNotify(Notification notification)
qCDebug(SNORE) << "SnoreToast" << arguements;
connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this, notification](int code) {
Notification::CloseReasons reason = Notification::None;
Snore::Notification::CloseReasons reason = Snore::Notification::None;
switch (code) {
case 0:
reason = Notification::Activated;
reason = Snore::Notification::Activated;
slotNotificationActionInvoked(notification);
break;
case 1:
//hidden;
break;
case 2:
reason = Notification::Dismissed;
reason = Snore::Notification::Dismissed;
break;
case 3:
reason = Notification::TimedOut;
reason = Snore::Notification::TimedOut;
break;
case -1:
//failed
@ -78,11 +76,11 @@ void SnoreToast::slotNotify(Notification notification)
p->start(QLatin1String("SnoreToast"), arguements);
}
void SnoreToast::slotRegisterApplication(const Application &application)
void SnorePlugin::WindowsToast::slotRegisterApplication(const Snore::Application &application)
{
if (!application.constHints().contains("windows-app-id")) {
qCInfo(SNORE) << "No windows-app-id found in hints. Installing default shortcut with appID.";
QProcess *p = createProcess(Notification());
QProcess *p = createProcess(Snore::Notification());
QStringList arguements;
arguements << QLatin1String("-install")
<< QLatin1String("SnoreNotify\\") + qApp->applicationName()
@ -93,7 +91,7 @@ void SnoreToast::slotRegisterApplication(const Application &application)
}
}
void SnoreToast::slotCloseNotification(Notification notification)
void SnorePlugin::WindowsToast::slotCloseNotification(Snore::Notification notification)
{
QProcess *p = createProcess(notification);
@ -104,7 +102,7 @@ void SnoreToast::slotCloseNotification(Notification notification)
p->start(QLatin1String("SnoreToast"), arguements);
}
QString SnoreToast::appId(const Application &application)
QString SnorePlugin::WindowsToast::appId(const Snore::Application &application)
{
QString appID = application.constHints().value("windows-app-id").toString();
if (appID.isEmpty()) {
@ -113,7 +111,7 @@ QString SnoreToast::appId(const Application &application)
return appID;
}
QProcess *SnoreToast::createProcess(Notification noti)
QProcess *SnorePlugin::WindowsToast::createProcess(Snore::Notification noti)
{
QProcess *p = new QProcess(this);
p->setReadChannelMode(QProcess::MergedChannels);
@ -127,7 +125,7 @@ QProcess *SnoreToast::createProcess(Notification noti)
setErrorString(name() + p->errorString());
qCDebug(SNORE) << p->readAll();
if (noti.isValid()) {
closeNotification(noti, Notification::None);
closeNotification(noti, Snore::Notification::None);
}
p->deleteLater();
});

View File

@ -4,14 +4,16 @@
#include "libsnore/plugins/snorebackend.h"
#include <QProcess>
class SnoreToast : public Snore::SnoreBackend
namespace SnorePlugin {
class WindowsToast : public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
SnoreToast() = default;
~SnoreToast() = default;
WindowsToast() = default;
~WindowsToast() = default;
virtual bool canCloseNotification() const override;
@ -27,5 +29,6 @@ private:
QProcess *createProcess(Snore::Notification noti);
};
}
#endif // TOASTER_H

View File

@ -6,33 +6,31 @@
#include <QSystemTrayIcon>
#include <QApplication>
using namespace Snore;
TrayIconNotifer::TrayIconNotifer()
SnorePlugin::Trayicon::Trayicon()
{
connect(this, &TrayIconNotifer::enabledChanged, [this](bool) {
connect(this, &Trayicon::enabledChanged, [this](bool) {
m_currentlyDisplaying = false;
});
}
bool TrayIconNotifer::canCloseNotification() const
bool SnorePlugin::Trayicon::canCloseNotification() const
{
return true;
}
void TrayIconNotifer::slotNotify(Notification notification)
void SnorePlugin::Trayicon::slotNotify(Snore::Notification notification)
{
QSystemTrayIcon *icon = trayIcon(notification.application());
if (icon) {
m_notificationQue.append(notification);
displayNotification(icon);
} else {
closeNotification(notification, Notification::Closed);
closeNotification(notification, Snore::Notification::Closed);
setErrorString(QLatin1String("No tray-icon hint provided for ") + notification.application().name());
}
}
void TrayIconNotifer::slotCloseNotification(Notification n)
void SnorePlugin::Trayicon::slotCloseNotification(Snore::Notification n)
{
QSystemTrayIcon *icon = trayIcon(n.application());
if (icon) {
@ -42,23 +40,23 @@ void TrayIconNotifer::slotCloseNotification(Notification n)
}
}
void TrayIconNotifer::slotRegisterApplication(const Application &application)
void SnorePlugin::Trayicon::slotRegisterApplication(const Snore::Application &application)
{
QSystemTrayIcon *icon = trayIcon(application);
if (icon) {
connect(icon, &QSystemTrayIcon::messageClicked, this, &TrayIconNotifer::actionInvoked);
connect(icon, &QSystemTrayIcon::messageClicked, this, &Trayicon::actionInvoked);
}
}
void TrayIconNotifer::slotDeregisterApplication(const Application &application)
void SnorePlugin::Trayicon::slotDeregisterApplication(const Snore::Application &application)
{
QSystemTrayIcon *icon = trayIcon(application);
if (icon) {
disconnect(icon, &QSystemTrayIcon::messageClicked, this, &TrayIconNotifer::actionInvoked);
disconnect(icon, &QSystemTrayIcon::messageClicked, this, &Trayicon::actionInvoked);
}
}
QSystemTrayIcon *TrayIconNotifer::trayIcon(const Application &app)
QSystemTrayIcon *SnorePlugin::Trayicon::trayIcon(const Snore::Application &app)
{
if (app.constHints().contains("tray-icon")) {
return app.constHints().value("tray-icon").value<QPointer<QSystemTrayIcon>>();
@ -66,7 +64,7 @@ QSystemTrayIcon *TrayIconNotifer::trayIcon(const Application &app)
return nullptr;
}
void TrayIconNotifer::displayNotification(QSystemTrayIcon *icon)
void SnorePlugin::Trayicon::displayNotification(QSystemTrayIcon *icon)
{
Q_ASSERT(icon);
if (m_currentlyDisplaying) {
@ -77,26 +75,26 @@ void TrayIconNotifer::displayNotification(QSystemTrayIcon *icon)
return;
}
m_currentlyDisplaying = true;
Notification notification = m_notificationQue.takeFirst();
Snore::Notification notification = m_notificationQue.takeFirst();
m_displayed = notification;
icon->showMessage(notification.title(), notification.text(), QSystemTrayIcon::NoIcon, notification.timeout() * 1000);
slotNotificationDisplayed(notification);
}
void TrayIconNotifer::actionInvoked()
void SnorePlugin::Trayicon::actionInvoked()
{
Notification n = m_displayed;
Snore::Notification n = m_displayed;
QSystemTrayIcon *icon = trayIcon(n.application());
if (icon && n.isValid()) {
slotNotificationActionInvoked(n);
closeNotification(n, Notification::Activated);
closeNotification(n, Snore::Notification::Activated);
m_currentlyDisplaying = false;
displayNotification(icon);
}
}
bool TrayIconNotifer::isReady()
bool SnorePlugin::Trayicon::isReady()
{
if (!qobject_cast< QApplication * >(qApp)) {
setErrorString(tr("This plugin only works with QApplication"));

View File

@ -3,20 +3,18 @@
#include "libsnore/plugins/snorebackend.h"
namespace Snore
{
}
class QSystemTrayIcon;
class TrayIconNotifer: public Snore::SnoreBackend
namespace SnorePlugin {
class Trayicon: public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "snore_plugin.json")
public:
TrayIconNotifer();
~TrayIconNotifer() = default;
Trayicon();
~Trayicon() = default;
bool canCloseNotification() const override;
bool isReady() override;
@ -38,5 +36,6 @@ private Q_SLOTS:
void actionInvoked();
};
}
#endif // TRAYICONNOTIFER_H

View File

@ -50,6 +50,6 @@ private Q_SLOTS:
};
SNORE_DECLARE_SETTINGS_PLUGIN(PushoverSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Pushover)
#endif // PUSHOVERSETTINGS_H

View File

@ -22,9 +22,9 @@
#include <QNetworkReply>
#include <QNetworkRequest>
using namespace Snore;
namespace SnorePlugin {
void NotifyMyAndroid::slotNotify(Notification notification)
void NMA::slotNotify(Snore::Notification notification)
{
QString key = settingsValue(QStringLiteral("ApiKey")).toString();
if (key.isEmpty()) {
@ -41,8 +41,8 @@ void NotifyMyAndroid::slotNotify(Notification notification)
+ QLatin1String("&description=");
if (notification.constHints().value("supports-markup").toBool()) {
data += notification.text(Utils::Href | Utils::Bold | Utils::Break |
Utils::Underline | Utils::Font | Utils::Italic)
data += notification.text(Snore::Utils::Href | Snore::Utils::Bold | Snore::Utils::Break |
Snore::Utils::Underline | Snore::Utils::Font | Snore::Utils::Italic)
+ QLatin1String("&content-type=text/html");
} else {
data += notification.text();
@ -58,8 +58,10 @@ void NotifyMyAndroid::slotNotify(Notification notification)
}
void NotifyMyAndroid::setDefaultSettings()
void NMA::setDefaultSettings()
{
setDefaultSettingsValue(QStringLiteral("ApiKey"), QString());
SnoreSecondaryBackend::setDefaultSettings();
}
}

View File

@ -22,14 +22,17 @@
#include <QNetworkAccessManager>
class NotifyMyAndroid : public Snore::SnoreSecondaryBackend
namespace SnorePlugin {
class NMA : public Snore::SnoreSecondaryBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreSecondaryBackend)
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0" FILE "snore_plugin.json")
public:
NotifyMyAndroid() = default;
~NotifyMyAndroid() = default;
NMA() = default;
~NMA() = default;
protected:
void setDefaultSettings() override;
@ -42,4 +45,5 @@ private:
};
}
#endif // NMA_H

View File

@ -22,7 +22,7 @@
#include <QLabel>
#include <QLineEdit>
NotifyMyAndroidSettings::NotifyMyAndroidSettings(Snore::SnorePlugin *plugin, QWidget *parent) :
NMASettings::NMASettings(Snore::SnorePlugin *plugin, QWidget *parent) :
Snore::PluginSettingsWidget(plugin, parent),
m_lineEdit(new QLineEdit)
{
@ -30,16 +30,16 @@ NotifyMyAndroidSettings::NotifyMyAndroidSettings(Snore::SnorePlugin *plugin, QWi
addRow(QString(), new QLabel(tr("If you don't have an account yet please register at <a href=\"http://notifymyandroid.com/\">Notifymyandroid.com</a>."), this));
}
NotifyMyAndroidSettings::~NotifyMyAndroidSettings()
NMASettings::~NMASettings()
{
}
void NotifyMyAndroidSettings::load()
void NMASettings::load()
{
m_lineEdit->setText(settingsValue(QStringLiteral("ApiKey")).toString());
}
void NotifyMyAndroidSettings::save()
void NMASettings::save()
{
setSettingsValue(QStringLiteral("ApiKey"), m_lineEdit->text());
}

View File

@ -23,12 +23,12 @@
class QLineEdit;
class NotifyMyAndroidSettings : public Snore::PluginSettingsWidget
class NMASettings : public Snore::PluginSettingsWidget
{
Q_OBJECT
public:
explicit NotifyMyAndroidSettings(Snore::SnorePlugin *plugin, QWidget *parent = 0);
~NotifyMyAndroidSettings();
explicit NMASettings(Snore::SnorePlugin *plugin, QWidget *parent = 0);
~NMASettings();
void load() override;
void save() override;
@ -38,6 +38,6 @@ private:
};
SNORE_DECLARE_SETTINGS_PLUGIN(NotifyMyAndroidSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(NMA)
#endif // NOTIFYMYANDROID_HH

View File

@ -1,2 +1,2 @@
add_snore_plugin(Puhover SOURCES pushover.cpp SETTINGS_SOURCES pushoversettings.cpp TYPE SecondaryBackend)
add_snore_plugin(Pushover SOURCES pushover.cpp SETTINGS_SOURCES pushoversettings.cpp TYPE SecondaryBackend)

View File

@ -24,9 +24,9 @@
#include <QNetworkRequest>
#include <QHttpMultiPart>
using namespace Snore;
namespace SnorePlugin {
void Pushover::slotNotify(Notification notification)
void Pushover::slotNotify(Snore::Notification notification)
{
if (notification.data()->sourceAndTargetAreSimilar(this)) {
return;
@ -47,7 +47,7 @@ void Pushover::slotNotify(Notification notification)
QString textString;
if (notification.constHints().value("use-markup").toBool()) {
textString = notification.text(Utils::Href | Utils::Bold | Utils::Underline | Utils::Font | Utils::Italic);
textString = notification.text(Snore::Utils::Href | Snore::Utils::Bold | Snore::Utils::Underline | Snore::Utils::Font | Snore::Utils::Italic);
QHttpPart html;
html.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"html\"")));
@ -68,7 +68,7 @@ void Pushover::slotNotify(Notification notification)
priority.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"priority\"")));
priority.setBody(QString::number(notification.priority()).toUtf8().constData());
mp->append(priority);
if (notification.priority() == Notification::Emergency) {
if (notification.priority() == Snore::Notification::Emergency) {
QHttpPart retry;
retry.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"retry\"")));
@ -86,14 +86,14 @@ void Pushover::slotNotify(Notification notification)
if (notification.hints().value("silent").toBool()) {
sound.setBody("none");
} else {
sound.setBody(settingsValue(QStringLiteral("Sound"), LocalSetting).toString().toUtf8().constData());
sound.setBody(settingsValue(QStringLiteral("Sound"), Snore::LocalSetting).toString().toUtf8().constData());
}
mp->append(sound);
if (!settingsValue(QStringLiteral("Devices"), LocalSetting).toString().isEmpty()) {
if (!settingsValue(QStringLiteral("Devices"), Snore::LocalSetting).toString().isEmpty()) {
QHttpPart devices;
devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"device\"")));
devices.setBody(settingsValue(QStringLiteral("Devices"), LocalSetting).toString().toUtf8().constData());
devices.setBody(settingsValue(QStringLiteral("Devices"), Snore::LocalSetting).toString().toUtf8().constData());
mp->append(devices);
}
@ -122,7 +122,9 @@ void Pushover::slotNotify(Notification notification)
void Pushover::setDefaultSettings()
{
setDefaultSettingsValue(QStringLiteral("UserKey"), QString());
setDefaultSettingsValue(QStringLiteral("Sound"), QLatin1String("pushover"), LocalSetting);
setDefaultSettingsValue(QStringLiteral("Devices"), QString(), LocalSetting);
setDefaultSettingsValue(QStringLiteral("Sound"), QLatin1String("pushover"), Snore::LocalSetting);
setDefaultSettingsValue(QStringLiteral("Devices"), QString(), Snore::LocalSetting);
SnoreSecondaryBackend::setDefaultSettings();
}
}

View File

@ -22,6 +22,8 @@
#include <QNetworkAccessManager>
namespace SnorePlugin {
class Pushover : public Snore::SnoreSecondaryBackend
{
Q_OBJECT
@ -42,4 +44,5 @@ private:
};
}
#endif // PUSHOVER_H

View File

@ -40,6 +40,6 @@ private:
};
SNORE_DECLARE_SETTINGS_PLUGIN(PushoverSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Pushover)
#endif // PUSHOVERSETTINGS_H

View File

@ -20,7 +20,7 @@
#include <QtMultimedia/QMediaPlayer>
#include <QTimer>
using namespace Snore;
namespace SnorePlugin {
Sound::Sound():
m_player(new QMediaPlayer(this))
@ -64,3 +64,5 @@ void Sound::slotNotificationDisplayed(Snore::Notification notification)
});
}
}
}

View File

@ -22,6 +22,8 @@
class QMediaPlayer;
namespace SnorePlugin {
class Sound : public Snore::SnoreSecondaryBackend
{
Q_OBJECT
@ -41,4 +43,5 @@ private:
QMediaPlayer *m_player;
};
}
#endif // SOUND_H

View File

@ -23,9 +23,7 @@
#include <QSpinBox>
#include <QPushButton>
using namespace Snore;
SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
SoundSettings::SoundSettings(Snore::SnorePlugin *snorePlugin, QWidget *parent) :
PluginSettingsWidget(snorePlugin, parent),
m_lineEditFileName(new QLineEdit),
m_spinBoxVolume(new QSpinBox)

View File

@ -24,6 +24,6 @@ private:
};
SNORE_DECLARE_SETTINGS_PLUGIN(SoundSettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Sound)
#endif // SOUNDSETTINGS_H

View File

@ -24,9 +24,9 @@
#include <QHttpMultiPart>
#include <QFile>
using namespace Snore;
namespace SnorePlugin {
void Toasty::slotNotify(Notification notification)
void Toasty::slotNotify(Snore::Notification notification)
{
QString key = settingsValue(QStringLiteral("DeviceID")).toString();
if (key.isEmpty()) {
@ -77,3 +77,5 @@ void Toasty::setDefaultSettings()
setDefaultSettingsValue(QStringLiteral("DeviceID"), QString());
SnoreSecondaryBackend::setDefaultSettings();
}
}

View File

@ -22,6 +22,8 @@
#include <QNetworkAccessManager>
namespace SnorePlugin {
class Toasty : public Snore::SnoreSecondaryBackend
{
Q_OBJECT
@ -42,4 +44,6 @@ private:
};
}
#endif // TOASTY_H

View File

@ -38,6 +38,6 @@ private:
};
SNORE_DECLARE_SETTINGS_PLUGIN(ToastySettings)
SNORE_DECLARE_SETTINGS_PLUGIN(Toasty)
#endif // TOASTYSETTINGS_H

View File

@ -2,13 +2,14 @@ ecm_add_app_icon(SNORENOTIFY_SETTINGS_DEPS ICONS ${PROJECT_SOURCE_DIR}/data/128-
add_executable( snoresettings-cli main-cli.cpp settingsutils.cpp ${SNORENOTIFY_SETTINGS_DEPS})
ecm_mark_nongui_executable(snoresettings-cli)
target_link_libraries( snoresettings-cli Snore::Libsnore)
target_link_libraries( snoresettings-cli Snore::Libsnore ${SNORE_PLUGINS})
install(TARGETS snoresettings-cli ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
if(Qt5Widgets_FOUND)
qt5_wrap_ui(UI settingswindow.ui)
add_executable( snoresettings main.cpp settingswindow.cpp settingsutils.cpp ${UI} ${SNORENOTIFY_SETTINGS_DEPS})
target_link_libraries( snoresettings Snore::Libsnore Snore::LibsnoreSettings)
install(TARGETS snoresettings snoresettings-cli ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
target_link_libraries( snoresettings Snore::Libsnore Snore::LibsnoreSettings ${SNORE_PLUGINS})
install(TARGETS snoresettings ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
if(UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/snoresettings.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/snoresettings.desktop" @ONLY)

View File

@ -19,6 +19,8 @@
#include "libsnore/snoreglobals.h"
#include "libsnore/utils.h"
#include "libsnore/snore_static_plugins.h"
#include "settingsutils.h"
#include <QGuiApplication>
@ -121,4 +123,4 @@ int main(int argc, char *argv[])
}
app.processEvents();
return 0;
}
}

View File

@ -20,6 +20,8 @@
#include "libsnore/version.h"
#include "settingswindow.h"
#include "libsnore/snore_static_plugins.h"
#include <QApplication>
#include <QCommandLineParser>

View File

@ -1,7 +1,7 @@
ecm_add_app_icon(SNORENOTIFY_SNORESEND_DEPS ICONS ${PROJECT_SOURCE_DIR}/data/128-apps-snore.png)
add_executable(snoresend main.cpp ${SNORENOTIFY_SNORESEND_DEPS})
target_link_libraries(snoresend Snore::Libsnore)
target_link_libraries(snoresend Snore::Libsnore ${SNORE_PLUGINS})
ecm_mark_nongui_executable(snoresend)
install(TARGETS snoresend ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

View File

@ -20,6 +20,8 @@
#include <libsnore/notification/notification.h>
#include <libsnore/version.h>
#include <libsnore/utils.h>
#include <libsnore/snore_static_plugins.h>
#include <QGuiApplication>
#include <QCommandLineParser>
@ -116,7 +118,7 @@ int main(int argc, char *argv[])
if (parser.isSet(title) && parser.isSet(message)) {
SnoreCore &core = SnoreCore::instance();
core.loadPlugins(SnorePlugin::Backend | SnorePlugin::SecondaryBackend);
core.loadPlugins(Snore::SnorePlugin::Backend | Snore::SnorePlugin::SecondaryBackend);
Icon icon = Icon::defaultIcon();
if (parser.isSet(iconPath)) {