diff --git a/CMakeLists.txt b/CMakeLists.txt index e28174c..b0c1e72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,8 @@ find_package(Qt5Network REQUIRED) find_package(Qt5Widgets REQUIRED) +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}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50b8d67..ac550ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,7 @@ +include(libsnore/SnoreAddPlugin.cmake) + add_subdirectory(libsnore) + ecm_optional_add_subdirectory(daemon) add_feature_info(BUILD_daemon BUILD_daemon "Build and installd the snorenotify daemon which recieves and redirects notifications.") diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 81071cb..23ccee3 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -1,7 +1,7 @@ ecm_add_app_icon(SNORENOTIFY_DAEMON_DEPS ICONS ${PROJECT_SOURCE_DIR}/data/128-apps-snore.png) add_executable( snorenotify WIN32 main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DAEMON_DEPS}) -target_link_libraries( snorenotify Snore::Libsnore) +target_link_libraries( snorenotify Snore::Libsnore Snore::LibsnoreSettings) install(TARGETS snorenotify ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) if(UNIX) diff --git a/src/daemon/trayicon.cpp b/src/daemon/trayicon.cpp index c81d0c3..56fea7c 100644 --- a/src/daemon/trayicon.cpp +++ b/src/daemon/trayicon.cpp @@ -17,15 +17,17 @@ */ #include "trayicon.h" -#include "libsnore/settingsdialog.h" +#include "libsnore/settings/settingsdialog.h" #include "libsnore/snore.h" #include "libsnore/snore_p.h" #include #include +#include #include #include #include +#include #include "libsnore/version.h" diff --git a/src/libsnore/CMakeLists.txt b/src/libsnore/CMakeLists.txt index 692de00..3118e07 100644 --- a/src/libsnore/CMakeLists.txt +++ b/src/libsnore/CMakeLists.txt @@ -6,7 +6,6 @@ if(NOT SNORE_REVISION) set(SNORE_REVISION "") endif() -set(LIBSNORE_INCLUDE_DIR ${KDE_INSTALL_INCLUDEDIR}/libsnore) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/version.cpp") @@ -18,8 +17,6 @@ add_subdirectory(notification) add_subdirectory(plugins) -qt5_wrap_ui(UI settingsdialog.ui) - list(APPEND SnoreNotify_SRCS snore.cpp snore_p.cpp @@ -29,9 +26,7 @@ list(APPEND SnoreNotify_SRCS alert_p.cpp hint.cpp lambdahint.cpp - settingsdialog.cpp utils.cpp - ${UI} ${CMAKE_CURRENT_BINARY_DIR}/version.cpp ${SNORENOTIFY_RCS} ) @@ -43,7 +38,6 @@ list(APPEND SnoreNotify_HDR alert.h hint.h lambdahint.h - settingsdialog.h snoreglobals.h utils.h ${CMAKE_CURRENT_BINARY_DIR}/snore_exports.h @@ -54,14 +48,14 @@ list(APPEND SnoreNotify_HDR add_library( libsnore SHARED ${SnoreNotify_SRCS} ${SnoreNotify_QM_LOADER}) set_target_properties( libsnore PROPERTIES OUTPUT_NAME "snore${SNORE_SUFFIX}" - VERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}.${SNORE_VERSION_SUFFIX}" + VERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}" SOVERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}" EXPORT_NAME Libsnore) set_property( TARGET libsnore APPEND PROPERTY COMPILE_DEFINITIONS LIBSNORE_PLUGIN_PATH="${KDE_INSTALL_FULL_PLUGINDIR}/libsnore${SNORE_SUFFIX}" SNORE_SUFFIX="${SNORE_SUFFIX}" ) -target_link_libraries( libsnore PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network) +target_link_libraries( libsnore PUBLIC Qt5::Core Qt5::Gui Qt5::Network) add_library(Snore::Libsnore ALIAS libsnore) @@ -75,7 +69,7 @@ target_include_directories( libsnore PUBLIC $) -ecm_setup_version("${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}" VARIABLE_PREFIX SOLID +ecm_setup_version("${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}" VARIABLE_PREFIX SNORE PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Libsnore${SNORE_CamelCase_SUFFIX}ConfigVersion.cmake" SOVERSION ${SNORE_VERSION_MAJOR}) @@ -100,6 +94,7 @@ install(EXPORT Libsnore${SNORE_CamelCase_SUFFIX}Target DESTINATION ${KDE_INSTALL install(FILES ${SnoreNotify_HDR} DESTINATION ${LIBSNORE_INCLUDE_DIR}) install(FILES + SnoreAddPlugin.cmake ${CMAKE_CURRENT_BINARY_DIR}/Libsnore${SNORE_CamelCase_SUFFIX}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/Libsnore${SNORE_CamelCase_SUFFIX}ConfigVersion.cmake DESTINATION @@ -110,3 +105,4 @@ if(UNIX) endif() +add_subdirectory(settings) diff --git a/src/libsnore/LibsnoreConfig.cmake.in b/src/libsnore/LibsnoreConfig.cmake.in index b3e3cc9..79a38c5 100644 --- a/src/libsnore/LibsnoreConfig.cmake.in +++ b/src/libsnore/LibsnoreConfig.cmake.in @@ -2,7 +2,8 @@ find_dependency(Qt5Core REQUIRED) find_dependency(Qt5Network REQUIRED) -find_dependency(Qt5Widgets REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/Libsnore@SNORE_CamelCase_SUFFIX@Target.cmake") +set(SNORE_PLUGIN_INSTALL_PATH @SNORE_PLUGIN_INSTALL_PATH@) +include("${CMAKE_CURRENT_LIST_DIR}/SnoreAddPlugin.cmake") diff --git a/src/libsnore/SnoreAddPlugin.cmake b/src/libsnore/SnoreAddPlugin.cmake new file mode 100644 index 0000000..6286ac1 --- /dev/null +++ b/src/libsnore/SnoreAddPlugin.cmake @@ -0,0 +1,20 @@ + +include(CMakeParseArguments) + +function(add_snore_plugin name) + set(options) + set(oneValueArgs TYPE) + set(multiValueArgs SETTINGS_SOURCES SETTINGS_LIBS SOURCES LIBS) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_library(libsnore_${ARG_TYPE}_${name} MODULE ${ARG_SOURCES}) + target_link_libraries(libsnore_${ARG_TYPE}_${name} Snore::Libsnore ${ARG_LIBS}) + install(TARGETS libsnore_${ARG_TYPE}_${name} ${SNORE_PLUGIN_INSTALL_PATH}) + + if(ARG_SETTINGS_SOURCES) + add_library(libsnore_settings_${ARG_TYPE}_${name} MODULE ${ARG_SETTINGS_SOURCES} ) + target_link_libraries(libsnore_settings_${ARG_TYPE}_${name} Snore::Libsnore Snore::LibsnoreSettings ${ARG_SETTINGS_LIBS}) + install(TARGETS libsnore_settings_${ARG_TYPE}_${name} ${SNORE_PLUGIN_INSTALL_PATH}) + endif() + +endfunction() diff --git a/src/libsnore/application_p.cpp b/src/libsnore/application_p.cpp index 1f6c6fe..9871e96 100644 --- a/src/libsnore/application_p.cpp +++ b/src/libsnore/application_p.cpp @@ -20,7 +20,7 @@ #include "lambdahint.h" #include "snore_p.h" -#include +#include using namespace Snore; diff --git a/src/libsnore/notification/icon.cpp b/src/libsnore/notification/icon.cpp index 86f3e3d..47877c1 100644 --- a/src/libsnore/notification/icon.cpp +++ b/src/libsnore/notification/icon.cpp @@ -20,7 +20,7 @@ #include "../snore.h" #include "../snore_p.h" -#include +#include #include #include #include diff --git a/src/libsnore/plugins/CMakeLists.txt b/src/libsnore/plugins/CMakeLists.txt index cae7895..32ca807 100644 --- a/src/libsnore/plugins/CMakeLists.txt +++ b/src/libsnore/plugins/CMakeLists.txt @@ -4,7 +4,7 @@ set(SnoreNotify_SRCS ${SnoreNotify_SRCS} plugins/snorefrontend.cpp plugins/snorebackend.cpp plugins/snoresecondarybackend.cpp - plugins/pluginsettingswidget.cpp + plugins/settingsplugin.cpp PARENT_SCOPE) set(SnoreNotify_HDR @@ -12,7 +12,7 @@ set(SnoreNotify_HDR snorefrontend.h snorebackend.h snoresecondarybackend.h - pluginsettingswidget.h) + settingsplugin.h) install(FILES ${SnoreNotify_HDR} DESTINATION ${LIBSNORE_INCLUDE_DIR}/plugins) diff --git a/src/libsnore/plugins/plugincontainer.cpp b/src/libsnore/plugins/plugincontainer.cpp index 17217c8..8ccc645 100644 --- a/src/libsnore/plugins/plugincontainer.cpp +++ b/src/libsnore/plugins/plugincontainer.cpp @@ -25,7 +25,7 @@ #include "../version.h" #include -#include +#include #include using namespace Snore; diff --git a/src/libsnore/plugins/plugins.cpp b/src/libsnore/plugins/plugins.cpp index db363dc..af42e7a 100644 --- a/src/libsnore/plugins/plugins.cpp +++ b/src/libsnore/plugins/plugins.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace Snore; @@ -62,15 +62,6 @@ void SnorePlugin::setDefaultSettingsValue(const QString &key, const QVariant &va SnoreCore::instance().setDefaultSettingsValue(normaliseKey(key), value, type); } -Snore::PluginSettingsWidget *SnorePlugin::settingsWidget() -{ - if (type() != SnorePlugin::BACKEND) { - // don't display a useless default widget for backends - return new PluginSettingsWidget(this); - } - return nullptr; -} - QString SnorePlugin::normaliseKey(const QString &key) const { return name() + QLatin1Char('-') + typeName() + QLatin1Char('/') + key + QLatin1Char('.') + settingsVersion(); diff --git a/src/libsnore/plugins/plugins.h b/src/libsnore/plugins/plugins.h index 8a063cf..d0a5452 100644 --- a/src/libsnore/plugins/plugins.h +++ b/src/libsnore/plugins/plugins.h @@ -21,7 +21,6 @@ #include "libsnore/snore_exports.h" #include "libsnore/snoreglobals.h" #include "libsnore/notification/notification.h" -#include "pluginsettingswidget.h" #include @@ -70,6 +69,11 @@ public: */ PLUGIN = 1 << 3, + /** + * A settings page for a Plugin. + */ + SETTINGS = 1 << 4, + /** * Flag for loading all plugins. */ @@ -114,7 +118,7 @@ public: /** * Returns the plugin type. */ - PluginTypes type() const; + virtual PluginTypes type() const; /** * Returns the name of the plugin type. @@ -132,7 +136,6 @@ public: void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); - virtual PluginSettingsWidget *settingsWidget(); Q_SIGNALS: void enabledChanged(bool enabled); diff --git a/src/libsnore/plugins/settingsplugin.cpp b/src/libsnore/plugins/settingsplugin.cpp new file mode 100644 index 0000000..8f4f915 --- /dev/null +++ b/src/libsnore/plugins/settingsplugin.cpp @@ -0,0 +1,31 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Hannah von Reth + + SnoreNotify is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SnoreNotify is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with SnoreNotify. If not, see . +*/ + +#include "settingsplugin.h" + +using namespace Snore; + +SettingsPlugin::SettingsPlugin() +{ + +} + +SettingsPlugin::~SettingsPlugin() +{ + +} diff --git a/src/libsnore/plugins/settingsplugin.h b/src/libsnore/plugins/settingsplugin.h new file mode 100644 index 0000000..0d56b38 --- /dev/null +++ b/src/libsnore/plugins/settingsplugin.h @@ -0,0 +1,64 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Hannah von Reth + + SnoreNotify is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SnoreNotify is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with SnoreNotify. If not, see . +*/ + +#ifndef SETTINGSPLUGIN_H +#define SETTINGSPLUGIN_H + + +#include "libsnore/snore_exports.h" +#include "libsnore/plugins/plugins.h" + +namespace Snore { + +class PluginSettingsWidget; + +class SNORE_EXPORT SettingsPlugin : public SnorePlugin +{ +Q_OBJECT +Q_INTERFACES(Snore::SnorePlugin) +public: +SettingsPlugin(); +~SettingsPlugin(); + +PluginTypes type() const override{ + return SnorePlugin::SETTINGS; +}; + +virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0; + +}; + +} + + +Q_DECLARE_INTERFACE(Snore::SettingsPlugin, + "org.Snore.SettingsPlugin/1.0") + +#define SNORE_DECLARE_SETTINGS_PLUGIN(NAME)\ +class NAMESettings : public Snore::SettingsPlugin{\ + Q_OBJECT\ + Q_INTERFACES(Snore::SettingsPlugin)\ + Q_PLUGIN_METADATA(IID "org.Snore.SettingsPlugin/1.0" FILE "plugin.json")\ +public:\ + Snore::PluginSettingsWidget *settingsWidget(Snore::SnorePlugin *parent) override{\ + return new NAME(parent);\ +}\ +}; + + +#endif // SETTINGSPLUGIN_H diff --git a/src/libsnore/settings/CMakeLists.txt b/src/libsnore/settings/CMakeLists.txt new file mode 100644 index 0000000..628c1bf --- /dev/null +++ b/src/libsnore/settings/CMakeLists.txt @@ -0,0 +1,67 @@ +QT5_ADD_RESOURCES(SNORENOTIFY_RCS ${SNORE_RCS}) + + +qt5_wrap_ui(UI settingsdialog.ui) + +set(snoresettings_SRCS + settings.cpp + settingsdialog.cpp + pluginsettingswidget.cpp + ${UI} + ) + +set(snoresettings_HDR + settings.h + settingsdialog.h + pluginsettingswidget.h + ${CMAKE_CURRENT_BINARY_DIR}/snore_settings_exports.h + ) + + +add_library( libsnoresettings SHARED ${snoresettings_SRCS}) +set_target_properties( libsnoresettings PROPERTIES + OUTPUT_NAME "snoresettings${SNORE_SUFFIX}" + VERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}" + SOVERSION "${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}" + EXPORT_NAME LibsnoreSettings) + +target_link_libraries( libsnoresettings PUBLIC Qt5::Widgets Snore::Libsnore) + +add_library(Snore::LibsnoreSettings ALIAS libsnoresettings) + +generate_export_header(libsnoresettings + EXPORT_FILE_NAME snore_settings_exports.h + EXPORT_MACRO_NAME SNORE_SETTINGS_EXPORT +) + + +ecm_setup_version("${SNORE_VERSION_MAJOR}.${SNORE_VERSION_MINOR}.${SNORE_VERSION_PATCH}" VARIABLE_PREFIX SNORE + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibsnoreSettings${SNORE_CamelCase_SUFFIX}ConfigVersion.cmake" + SOVERSION ${SNORE_VERSION_MAJOR}) + +ecm_configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/LibsnoreSettingsConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/LibsnoreSettings${SNORE_CamelCase_SUFFIX}Config.cmake" + INSTALL_DESTINATION ${KDE_INSTALL_CMAKEPACKAGEDIR}/libsnoresettings${SNORE_CamelCase_SUFFIX} + ) + + +ecm_generate_pri_file(BASE_NAME LibsnoreSettings${SNORE_CamelCase_SUFFIX} + LIB_NAME snoresettings${SNORE_SUFFIX} + DEPS "core gui widgets network LibsnoreQt5" + INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR} + FILENAME_VAR pri_filename) + +install(FILES ${pri_filename} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) + +install(TARGETS libsnoresettings EXPORT LibsnoreSettings${SNORE_CamelCase_SUFFIX}Target ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +install(EXPORT LibsnoreSettings${SNORE_CamelCase_SUFFIX}Target DESTINATION ${KDE_INSTALL_CMAKEPACKAGEDIR}/libsnoresettings${SNORE_CamelCase_SUFFIX} NAMESPACE Snore::) + +install(FILES ${snoresettings_HDR} DESTINATION ${LIBSNORE_INCLUDE_DIR}/settings) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/LibsnoreSettings${SNORE_CamelCase_SUFFIX}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/LibsnoreSettings${SNORE_CamelCase_SUFFIX}ConfigVersion.cmake + DESTINATION + ${KDE_INSTALL_CMAKEPACKAGEDIR}/libsnoresettings${SNORE_CamelCase_SUFFIX}) + diff --git a/src/libsnore/settings/LibsnoreSettingsConfig.cmake.in b/src/libsnore/settings/LibsnoreSettingsConfig.cmake.in new file mode 100644 index 0000000..8cf2f4e --- /dev/null +++ b/src/libsnore/settings/LibsnoreSettingsConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +find_dependency(Libsnore@SNORE_CamelCase_SUFFIX@ REQUIRED) +find_dependency(Qt5Widgets REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/LibsnoreSettings@SNORE_CamelCase_SUFFIX@Target.cmake") diff --git a/src/libsnore/plugins/pluginsettingswidget.cpp b/src/libsnore/settings/pluginsettingswidget.cpp similarity index 98% rename from src/libsnore/plugins/pluginsettingswidget.cpp rename to src/libsnore/settings/pluginsettingswidget.cpp index 13823a7..0e3df1e 100644 --- a/src/libsnore/plugins/pluginsettingswidget.cpp +++ b/src/libsnore/settings/pluginsettingswidget.cpp @@ -16,7 +16,7 @@ along with SnoreNotify. If not, see . */ #include "pluginsettingswidget.h" -#include "plugins.h" +#include "libsnore/plugins/plugins.h" #include "snore.h" #include diff --git a/src/libsnore/plugins/pluginsettingswidget.h b/src/libsnore/settings/pluginsettingswidget.h similarity index 93% rename from src/libsnore/plugins/pluginsettingswidget.h rename to src/libsnore/settings/pluginsettingswidget.h index 0b5a70e..e3ddc1e 100644 --- a/src/libsnore/plugins/pluginsettingswidget.h +++ b/src/libsnore/settings/pluginsettingswidget.h @@ -18,7 +18,7 @@ #ifndef PLUGINSETTINGSWIDGET_H #define PLUGINSETTINGSWIDGET_H -#include "libsnore/snore_exports.h" +#include "libsnore/settings/snore_settings_exports.h" #include "libsnore/snoreglobals.h" #include @@ -29,7 +29,7 @@ namespace Snore { class SnorePlugin; -class SNORE_EXPORT PluginSettingsWidget : public QWidget +class SNORE_SETTINGS_EXPORT PluginSettingsWidget : public QWidget { Q_OBJECT public: diff --git a/src/libsnore/settings/settings.cpp b/src/libsnore/settings/settings.cpp new file mode 100644 index 0000000..abee706 --- /dev/null +++ b/src/libsnore/settings/settings.cpp @@ -0,0 +1,53 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Hannah von Reth + + SnoreNotify is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SnoreNotify is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with SnoreNotify. If not, see . +*/ +#include "settings.h" +#include "libsnore/snore_p.h" +#include "libsnore/plugins/settingsplugin.h" +#include "libsnore/settings/pluginsettingswidget.h" + +#include + +using namespace Snore; + + +QList Settings::settingWidgets(SnorePlugin::PluginTypes type) +{ + SnoreCorePrivate *core(SnoreCorePrivate::instance()); + QList list; + foreach(const QString & name, core->m_pluginNames[type]) { + //TODO: mem leak? + + SnorePlugin *plugin = core->m_plugins[qMakePair(type, name)]; + SettingsPlugin *settingsPlugin = qobject_cast< Snore::SettingsPlugin* >(core->m_plugins[qMakePair(Snore::SnorePlugin::SETTINGS, name)]); + if(settingsPlugin){ + PluginSettingsWidget *widget = settingsPlugin->settingsWidget(plugin); + if (widget) { + list.append(widget); + } + }else{ + if(!qobject_cast< Snore::SnoreBackend* >(plugin)) + { + list.append(new PluginSettingsWidget(plugin)); + } + } + } + qSort(list.begin(), list.end(), [](PluginSettingsWidget * a, PluginSettingsWidget * b) { + return a->name() < b->name(); + }); + return list; +} diff --git a/src/libsnore/settings/settings.h b/src/libsnore/settings/settings.h new file mode 100644 index 0000000..3bf6546 --- /dev/null +++ b/src/libsnore/settings/settings.h @@ -0,0 +1,39 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Hannah von Reth + + SnoreNotify is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SnoreNotify is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with SnoreNotify. If not, see . +*/ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include "libsnore/settings/snore_settings_exports.h" +#include "libsnore/plugins/plugins.h" +#include "libsnore/settings/pluginsettingswidget.h" + +namespace Snore{ + +class SNORE_SETTINGS_EXPORT Settings +{ +public: + /** + * + * @return A list of widgets a settings dialog. + */ + static QList settingWidgets(SnorePlugin::PluginTypes type); + +}; +} + +#endif // SETTINGS_H diff --git a/src/libsnore/settingsdialog.cpp b/src/libsnore/settings/settingsdialog.cpp similarity index 98% rename from src/libsnore/settingsdialog.cpp rename to src/libsnore/settings/settingsdialog.cpp index 270417d..e9fa87f 100644 --- a/src/libsnore/settingsdialog.cpp +++ b/src/libsnore/settings/settingsdialog.cpp @@ -20,6 +20,7 @@ #include "ui_settingsdialog.h" #include "snore.h" #include "snore_p.h" +#include "settings.h" #include #include @@ -49,7 +50,7 @@ void SettingsDialog::initTabs() bool enabled = false; target->clear(); if (types & type) { - foreach(PluginSettingsWidget * widget, SnoreCore::instance().settingWidgets(type)) { + foreach(PluginSettingsWidget * widget, Settings::settingWidgets(type)) { target->addTab(widget, widget->name()); m_tabs.append(widget); enabled = true; diff --git a/src/libsnore/settingsdialog.h b/src/libsnore/settings/settingsdialog.h similarity index 91% rename from src/libsnore/settingsdialog.h rename to src/libsnore/settings/settingsdialog.h index 5c9d81e..4f63f2c 100644 --- a/src/libsnore/settingsdialog.h +++ b/src/libsnore/settings/settingsdialog.h @@ -18,7 +18,8 @@ #ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H -#include "snore_exports.h" +#include "libsnore/settings/snore_settings_exports.h" +#include "libsnore/settings/pluginsettingswidget.h" #include @@ -42,7 +43,7 @@ namespace Snore * If your application does not offer a ui you might call snore-settings insetad. */ -class SNORE_EXPORT SettingsDialog : public QWidget +class SNORE_SETTINGS_EXPORT SettingsDialog : public QWidget { Q_OBJECT diff --git a/src/libsnore/settingsdialog.ui b/src/libsnore/settings/settingsdialog.ui similarity index 100% rename from src/libsnore/settingsdialog.ui rename to src/libsnore/settings/settingsdialog.ui diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index f005682..a6d9d81 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -28,7 +28,7 @@ #include "version.h" -#include +#include #include #include @@ -90,6 +90,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) case SnorePlugin::SECONDARY_BACKEND: case SnorePlugin::FRONTEND: case SnorePlugin::PLUGIN: + case SnorePlugin::SETTINGS: plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); break; default: @@ -208,23 +209,6 @@ void SnoreCore::setDefaultApplication(Application app) d->m_defaultApp = app; } -QList SnoreCore::settingWidgets(SnorePlugin::PluginTypes type) -{ - Q_D(SnoreCore); - QList list; - foreach(const QString & name, d->m_pluginNames[type]) { - //TODO: mem leak? - SnorePlugin *p = d->m_plugins[qMakePair(type, name)]; - PluginSettingsWidget *widget = p->settingsWidget(); - if (widget) { - list.append(widget); - } - } - qSort(list.begin(), list.end(), [](PluginSettingsWidget * a, PluginSettingsWidget * b) { - return a->name() < b->name(); - }); - return list; -} QVariant SnoreCore::settingsValue(const QString &key, SettingsType type) const { diff --git a/src/libsnore/snore.h b/src/libsnore/snore.h index bd4ca26..4e309fb 100644 --- a/src/libsnore/snore.h +++ b/src/libsnore/snore.h @@ -138,12 +138,6 @@ public: */ void setDefaultApplication(Application app); - /** - * - * @return A list of widgets a settings dialog. - */ - QList settingWidgets(SnorePlugin::PluginTypes type); - QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const; void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING); diff --git a/src/libsnore/snore_p.cpp b/src/libsnore/snore_p.cpp index 4eb6667..d46c77b 100644 --- a/src/libsnore/snore_p.cpp +++ b/src/libsnore/snore_p.cpp @@ -25,7 +25,7 @@ #include "notification/notification_p.h" #include "version.h" -#include +#include #include #include diff --git a/src/libsnore/snore_p.h b/src/libsnore/snore_p.h index 50c689f..af82d48 100644 --- a/src/libsnore/snore_p.h +++ b/src/libsnore/snore_p.h @@ -30,6 +30,8 @@ class QSettings; namespace Snore { +class Settings; + class SNORE_EXPORT SnoreCorePrivate : public QObject { Q_DECLARE_PUBLIC(SnoreCore) @@ -116,6 +118,7 @@ private: QList m_notificationQue; QHash m_activeNotifications; friend class Snore::Notification; + friend class Snore::Settings; }; } diff --git a/src/plugins/backends/growl/CMakeLists.txt b/src/plugins/backends/growl/CMakeLists.txt index 6e17cc6..8dd8d25 100644 --- a/src/plugins/backends/growl/CMakeLists.txt +++ b/src/plugins/backends/growl/CMakeLists.txt @@ -6,11 +6,5 @@ set_package_properties(SnoreGrowl++ PROPERTIES TYPE RECOMMENDED) if(SnoreGrowl++_FOUND) - set( GROWL_SRC growlbackend.cpp growlsettings.cpp) - - add_library(libsnore_backend_growl MODULE ${GROWL_SRC} ) - target_link_libraries(libsnore_backend_growl Snore::Libsnore Snore::SnoreGrowl++ ${CMAKE_THREAD_LIBS_INIT}) - - - install(TARGETS libsnore_backend_growl ${SNORE_PLUGIN_INSTALL_PATH}) + add_snore_plugin(growl SOURCES growlbackend.cpp SETTINGS_SOURCES growlsettings.cpp TYPE backend LIBS Snore::SnoreGrowl++) endif() diff --git a/src/plugins/backends/growl/growlbackend.cpp b/src/plugins/backends/growl/growlbackend.cpp index 0b60f0f..759011b 100644 --- a/src/plugins/backends/growl/growlbackend.cpp +++ b/src/plugins/backends/growl/growlbackend.cpp @@ -17,7 +17,6 @@ */ #include "growlbackend.h" -#include "growlsettings.h" #include "libsnore/snore.h" #include "libsnore/snore_p.h" @@ -115,11 +114,6 @@ void GrowlBackend::slotNotify(Notification notification) slotNotificationDisplayed(notification); } -PluginSettingsWidget *GrowlBackend::settingsWidget() -{ - return new GrowlSettings(this); -} - void GrowlBackend::setDefaultSettings() { SnoreBackend::setDefaultSettings(); diff --git a/src/plugins/backends/growl/growlbackend.h b/src/plugins/backends/growl/growlbackend.h index 96de023..3fe8010 100644 --- a/src/plugins/backends/growl/growlbackend.h +++ b/src/plugins/backends/growl/growlbackend.h @@ -32,7 +32,6 @@ class GrowlBackend: public Snore::SnoreBackend public: GrowlBackend(); ~GrowlBackend(); - Snore::PluginSettingsWidget *settingsWidget() override; bool isReady() override; protected: diff --git a/src/plugins/backends/growl/growlsettings.h b/src/plugins/backends/growl/growlsettings.h index 9163063..576ba87 100644 --- a/src/plugins/backends/growl/growlsettings.h +++ b/src/plugins/backends/growl/growlsettings.h @@ -18,7 +18,8 @@ #ifndef GROWLSETTINGS_H #define GROWLSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" class QLineEdit; @@ -38,4 +39,6 @@ private: QLineEdit *m_password; }; +SNORE_DECLARE_SETTINGS_PLUGIN(GrowlSettings); + #endif // GROWLSETTINGS_H diff --git a/src/plugins/backends/osxnotificationcenter/CMakeLists.txt b/src/plugins/backends/osxnotificationcenter/CMakeLists.txt index 2b15047..d821f59 100644 --- a/src/plugins/backends/osxnotificationcenter/CMakeLists.txt +++ b/src/plugins/backends/osxnotificationcenter/CMakeLists.txt @@ -1,10 +1,3 @@ if(APPLE) - message(STATUS "adding osx notification center backend") - #find_library(FOUNDATION Foundation) - set(OSXNOTIFICATIONCENTER_SRC - osxnotificationcenter.mm - ) - add_library(libsnore_backend_osxnotificationcenter MODULE ${OSXNOTIFICATIONCENTER_SRC}) - target_link_libraries(libsnore_backend_osxnotificationcenter Snore::Libsnore /System/Library/Frameworks/Foundation.framework) - install(TARGETS libsnore_backend_osxnotificationcenter ${SNORE_PLUGIN_INSTALL_PATH}) + add_snore_plugin(osxnotificationcenter SOURCES osxnotificationcenter.mm TYPE backend LIBS /System/Library/Frameworks/Foundation.framework) endif(APPLE) diff --git a/src/plugins/backends/snarl/CMakeLists.txt b/src/plugins/backends/snarl/CMakeLists.txt index 889bbcf..9b97633 100644 --- a/src/plugins/backends/snarl/CMakeLists.txt +++ b/src/plugins/backends/snarl/CMakeLists.txt @@ -1,19 +1,6 @@ - -if(WIN32) - message(STATUS "Adding Snarl notification backend") - - - set( SNARL_SRC - SnarlInterface.cpp - snarl.cpp - snarlsettings.cpp - ) - add_library(libsnore_backend_snarl MODULE ${SNARL_SRC} ) - target_link_libraries(libsnore_backend_snarl Snore::Libsnore ) +if(WIN32) + add_snore_plugin(snarl SOURCES snarl.cpp SnarlInterface.cpp SETTINGS_SOURCES snarlsettings.cpp TYPE backend LIBS Qt5::Widgets) if(MINGW) set_target_properties(libsnore_backend_snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused") endif(MINGW) - - install(TARGETS libsnore_backend_snarl ${SNORE_PLUGIN_INSTALL_PATH}) - endif(WIN32) diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index d356018..cee7e25 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -17,7 +17,6 @@ */ #include "snarl.h" -#include "snarlsettings.h" #include "libsnore/snore.h" #include "libsnore/snore_p.h" @@ -26,6 +25,7 @@ #include "libsnore/plugins/snorebackend.h" #include "libsnore/notification/notification_p.h" +#include #include #include @@ -39,20 +39,18 @@ class SnarlBackend::SnarlWidget: public QWidget { //Q_OBJECT public: - SnarlWidget(SnarlBackend *snarl): - m_snarl(snarl) - { + SnarlWidget(SnarlBackend* snarl): + m_snarl(snarl) { SNARL_GLOBAL_MESSAGE = SnarlInterface::Broadcast(); } - bool nativeEvent(const QByteArray &eventType, void *message, long *) override - { + bool nativeEvent(const QByteArray& eventType, void* message, long*) override { if (eventType == "windows_generic_MSG") { - MSG *msg = static_cast(message); + MSG* msg = static_cast(message); if (msg->message == SNARL_GLOBAL_MESSAGE) { int action = msg->wParam; if (action == SnarlEnums::SnarlLaunched) { - for (const Application &a : SnoreCore::instance().aplications()) { + for (const Application & a : SnoreCore::instance().aplications()) { m_snarl->slotRegisterApplication(a); } } @@ -87,7 +85,7 @@ public: reason = Notification::TIMED_OUT; qCDebug(SNORE) << "Notification timed out"; break; - //away stuff + //away stuff case SnarlEnums::SnarlUserAway: qCDebug(SNORE) << "Snalr user has gone away"; return true; @@ -113,24 +111,19 @@ public: private: uint SNARL_GLOBAL_MESSAGE; - SnarlBackend *m_snarl; + SnarlBackend* m_snarl; }; -SnarlBackend::SnarlBackend(): - m_eventLoop(new SnarlBackend::SnarlWidget(this)) +SnarlBackend::SnarlBackend() { - } SnarlBackend::~SnarlBackend() { - delete m_eventLoop; -} - -PluginSettingsWidget *SnarlBackend::settingsWidget() -{ - return new SnarlSettings(this); + if (m_eventLoop) { + delete m_eventLoop; + } } bool SnarlBackend::canCloseNotification() const @@ -145,6 +138,14 @@ bool SnarlBackend::canUpdateNotification() const bool SnarlBackend::isReady() { + if (!qobject_cast< QApplication* >(qApp)) { + setErrorString(tr("This plugin only works with QApllication")); + return false; + } + + if (!m_eventLoop) { + m_eventLoop = new SnarlBackend::SnarlWidget(this); + } bool running = SnarlInterface::IsSnarlRunning(); if (!running) { setErrorString(tr("%1 is not running.").arg(name())); @@ -159,7 +160,7 @@ void SnarlBackend::setDefaultSettings() SnoreBackend::setDefaultSettings(); } -void SnarlBackend::slotRegisterApplication(const Application &application) +void SnarlBackend::slotRegisterApplication(const Application& application) { if (!m_eventLoop) { return; @@ -167,7 +168,7 @@ void SnarlBackend::slotRegisterApplication(const Application &application) Q_ASSERT_X(!m_applications.contains(application.name()), Q_FUNC_INFO, "Application already registered"); - SnarlInterface *snarlInterface = new SnarlInterface(); + SnarlInterface* snarlInterface = new SnarlInterface(); m_applications.insert(application.name(), snarlInterface); QString appName = application.name().replace(QLatin1Char(' '), QLatin1Char('_')); //app sig must not contain spaces @@ -179,20 +180,20 @@ void SnarlBackend::slotRegisterApplication(const Application &application) (HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID); qCDebug(SNORE) << result; - foreach(const Alert & alert, application.alerts()) { + foreach (const 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 SnarlBackend::slotDeregisterApplication(const Application& application) { if (!m_applications.contains(application.name())) { qCDebug(SNORE) << "Unknown apllication: " << application.name(); return; } - SnarlInterface *snarlInterface = m_applications.take(application.name()); + SnarlInterface* snarlInterface = m_applications.take(application.name()); QString appName = application.name().replace(QLatin1Char(' '), QLatin1Char('_')); //app sig must not contain spaces snarlInterface->Unregister(appName.toUtf8().constData()); delete snarlInterface; @@ -205,7 +206,7 @@ void SnarlBackend::slotNotify(Notification notification) return; } - SnarlInterface *snarlInterface = m_applications.value(notification.application().name()); + SnarlInterface* snarlInterface = m_applications.value(notification.application().name()); Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined; if (notification.priority() > 1) { @@ -228,7 +229,7 @@ void SnarlBackend::slotNotify(Notification notification) Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(), priority); - foreach(const Action & a, notification.actions()) { + foreach (const Action & a, notification.actions()) { snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData()); } m_idMap[id] = notification; diff --git a/src/plugins/backends/snarl/snarl.h b/src/plugins/backends/snarl/snarl.h index 6fc65f7..d7f7c3d 100644 --- a/src/plugins/backends/snarl/snarl.h +++ b/src/plugins/backends/snarl/snarl.h @@ -29,7 +29,6 @@ class SnarlBackend: public Snore::SnoreBackend public: SnarlBackend(); ~SnarlBackend(); - Snore::PluginSettingsWidget *settingsWidget() override; virtual bool canCloseNotification() const override; virtual bool canUpdateNotification() const override; @@ -41,7 +40,7 @@ protected: private: class SnarlWidget; - SnarlBackend::SnarlWidget *m_eventLoop; + SnarlBackend::SnarlWidget *m_eventLoop = nullptr; QHash m_applications; public Q_SLOTS: diff --git a/src/plugins/backends/snarl/snarlsettings.h b/src/plugins/backends/snarl/snarlsettings.h index 9b7271a..8007680 100644 --- a/src/plugins/backends/snarl/snarlsettings.h +++ b/src/plugins/backends/snarl/snarlsettings.h @@ -15,10 +15,11 @@ You should have received a copy of the GNU Lesser General Public License along with SnoreNotify. If not, see . */ -#ifndef GROWLSETTINGS_H -#define GROWLSETTINGS_H +#ifndef SNARLSETTINGS_H +#define SNARLSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" class QLineEdit; @@ -37,4 +38,6 @@ private: QLineEdit *m_password; }; -#endif // GROWLSETTINGS_H +SNORE_DECLARE_SETTINGS_PLUGIN(SnarlSettings); + +#endif // SNARLSETTINGS_H diff --git a/src/plugins/backends/snore/CMakeLists.txt b/src/plugins/backends/snore/CMakeLists.txt index 4fabec1..6ca2764 100644 --- a/src/plugins/backends/snore/CMakeLists.txt +++ b/src/plugins/backends/snore/CMakeLists.txt @@ -7,16 +7,8 @@ set_package_properties(Qt5Quick PROPERTIES if(Qt5Quick_FOUND) QT5_ADD_RESOURCES(SNORENOTIFIER_RCS ${CMAKE_CURRENT_SOURCE_DIR}/snore_notification.qrc) - set( SNORE_SRC - snorenotifier.cpp - snorenotifiersettings.cpp - notifywidget.cpp - ${SNORENOTIFIER_RCS} - ) - - - add_library(libsnore_backend_snore MODULE ${SNORE_SRC} ) - target_link_libraries(libsnore_backend_snore Snore::Libsnore Qt5::Quick) - - install(TARGETS libsnore_backend_snore ${SNORE_PLUGIN_INSTALL_PATH}) -endif() \ No newline at end of file + add_snore_plugin(snore SOURCES snorenotifier.cpp + notifywidget.cpp + ${SNORENOTIFIER_RCS} + TYPE backend SETTINGS_SOURCES snorenotifiersettings.cpp LIBS Qt5::Quick) +endif() diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index 80efbf0..2981ca8 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -4,17 +4,16 @@ import QtQuick.Window 2.2 Window { id: window property int snoreBaseSize: body.font.pixelSize + property int animationStart width: snoreBaseSize * 30 height: snoreBaseSize * 9 color: notifyWidget.color - - onVisibleChanged: { if(visible){ - animation.from = notifyWidget.animationFrom + animation.from = animationStart animation.restart() show() } @@ -23,8 +22,6 @@ Window { NumberAnimation on x{ id: animation duration: 500 - from: notifyWidget.animationFrom - to: notifyWidget.animationTo } Rectangle{ @@ -38,15 +35,42 @@ Window { Drag.active: mouseAreaAccept.drag.active + function updatePosition() + { + var corner = notifyWidget.position + + if (corner === Qt.TopLeftCorner || corner === Qt.BottomLeftCorner) { + animationStart = mouseAreaAccept.drag.minimumX = animation.from = -window.width + mouseAreaAccept.drag.maximumX = animation.to = 0 + } else { + animationStart = animation.from = Screen.desktopAvailableWidth + animation.to = Screen.desktopAvailableWidth - window.width + mouseAreaAccept.drag.minimumX = 0 + mouseAreaAccept.drag.maximumX = window.width + } + var space = (notifyWidget.id + 1) * window.height * 0.025 + + if (corner === Qt.TopRightCorner || corner === Qt.TopLeftCorner) { + window.y = space + (space + window.height) * notifyWidget.id + } else { + window.y = Screen.desktopAvailableHeight - (space + (space + height) * (notifyWidget.id + 1)) + } + } + + Screen.onDesktopAvailableHeightChanged: root.updatePosition() + Screen.onDesktopAvailableWidthChanged: root.updatePosition() + + Connections{ + target: notifyWidget + onPositionChanged: root.updatePosition() + } onXChanged: { // There is a Qt bug which will not stop the mouse tracking if the // item is hid during a drag event. if(Drag.active){ window.x += x - if(Math.abs(window.x - (notifyWidget.isOrientatedLeft? - notifyWidget.animationTo: - notifyWidget.animationFrom) + mouseAreaAccept.mouseX) <= width * 0.05){ + if(Math.abs(window.x - Math.max(animation.from, animation.to) + mouseAreaAccept.mouseX) <= width * 0.05){ Drag.cancel() notifyWidget.dismissed() } @@ -63,8 +87,6 @@ Window { } drag.target: root drag.axis: Drag.XAxis - drag.maximumX: notifyWidget.dragMaxX - drag.minimumX: notifyWidget.dragMinX drag.smoothed: true onPressed: { animation.stop() diff --git a/src/plugins/backends/snore/notifywidget.cpp b/src/plugins/backends/snore/notifywidget.cpp index 7741bcf..12122c8 100644 --- a/src/plugins/backends/snore/notifywidget.cpp +++ b/src/plugins/backends/snore/notifywidget.cpp @@ -20,8 +20,7 @@ #include "snorenotifier.h" #include "libsnore/utils.h" -#include -#include +#include #include using namespace Snore; @@ -179,34 +178,10 @@ int NotifyWidget::id() const void NotifyWidget::syncSettings() { Qt::Corner c = static_cast(m_parent->settingsValue(QStringLiteral("Position")).toInt()); - if (c != m_cornerOld || !m_initialized) { + if (c != m_corner || !m_initialized) { m_initialized = true; - QDesktopWidget desktop; - - m_cornerOld = c; - m_isOrientatedLeft = c == Qt::TopLeftCorner || c == Qt::BottomLeftCorner; - if (m_isOrientatedLeft) { - m_dragMinX = m_animationFrom = -m_window->width(); - m_dragMaxX = m_animationTo = 0; - } else { - m_animationFrom = desktop.availableGeometry().width(); - m_animationTo = desktop.availableGeometry().width() - m_window->width(); - m_dragMinX = 0; - m_dragMaxX = m_window->width(); - - } - double space = (id() + 1) * m_window->height() * 0.025; - - if (c == Qt::TopRightCorner || c == Qt::TopLeftCorner) { - m_window->setY(space + (space + m_window->height()) * id()); - } else { - m_window->setY(desktop.availableGeometry().height() - (space + (space + m_window->height()) * (id() + 1))); - } - emit isOrientatedLeftChanged(); - emit animationFromChanged(); - emit animationtoChanged(); - emit dragMaxXChanged(); - emit dragMinXChanged(); + m_corner = c; + emit positionChanged(); } } diff --git a/src/plugins/backends/snore/notifywidget.h b/src/plugins/backends/snore/notifywidget.h index 2cc60c7..2795ba6 100644 --- a/src/plugins/backends/snore/notifywidget.h +++ b/src/plugins/backends/snore/notifywidget.h @@ -42,11 +42,7 @@ class NotifyWidget : public QObject { Q_OBJECT Q_PROPERTY(int id READ id) - Q_PROPERTY(bool isOrientatedLeft MEMBER m_isOrientatedLeft NOTIFY isOrientatedLeftChanged) - Q_PROPERTY(int animationFrom MEMBER m_animationFrom NOTIFY animationFromChanged) - Q_PROPERTY(int animationTo MEMBER m_animationTo NOTIFY animationtoChanged) - Q_PROPERTY(int dragMinX MEMBER m_dragMinX NOTIFY dragMinXChanged) - Q_PROPERTY(int dragMaxX MEMBER m_dragMaxX NOTIFY dragMaxXChanged) + Q_PROPERTY(Qt::Corner position MEMBER m_corner NOTIFY positionChanged) Q_PROPERTY(QColor color MEMBER m_color NOTIFY colorChanged) Q_PROPERTY(QColor textColor MEMBER m_textColor NOTIFY textColorChanged) Q_PROPERTY(QString title MEMBER m_title NOTIFY titleChanged) @@ -74,11 +70,7 @@ Q_SIGNALS: void invoked(); void dismissed(); - void isOrientatedLeftChanged(); - void animationFromChanged(); - void animationtoChanged(); - void dragMinXChanged(); - void dragMaxXChanged(); + void positionChanged(); void textColorChanged(); void colorChanged(); @@ -102,14 +94,8 @@ private: const SnoreNotifier *m_parent; QSharedMemory m_mem; bool m_ready; - Qt::Corner m_cornerOld = Qt::TopLeftCorner; - bool m_isOrientatedLeft; - int m_animationFrom; - int m_animationTo; - - int m_dragMinX; - int m_dragMaxX; + Qt::Corner m_corner = Qt::TopLeftCorner; int m_imageSize; int m_appIconSize; diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index 4615a35..a49b8c3 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -18,7 +18,6 @@ #include "snorenotifier.h" #include "notifywidget.h" -#include "snorenotifiersettings.h" #include "libsnore/notification/notification_p.h" #include "libsnore/snore_p.h" @@ -132,11 +131,6 @@ bool SnoreNotifier::canUpdateNotification() const return true; } -PluginSettingsWidget *SnoreNotifier::settingsWidget() -{ - return new SnoreNotifierSettings(this); -} - void SnoreNotifier::setDefaultSettings() { setDefaultSettingsValue(QStringLiteral("Position"), Qt::TopRightCorner); diff --git a/src/plugins/backends/snore/snorenotifier.h b/src/plugins/backends/snore/snorenotifier.h index bd33566..817de51 100644 --- a/src/plugins/backends/snore/snorenotifier.h +++ b/src/plugins/backends/snore/snorenotifier.h @@ -35,8 +35,6 @@ public: bool canCloseNotification() const override; bool canUpdateNotification() const override; - Snore::PluginSettingsWidget *settingsWidget() override; - protected: void setDefaultSettings() override; public Q_SLOTS: @@ -53,4 +51,5 @@ private: }; + #endif // SNORENOTIFIER_H diff --git a/src/plugins/backends/snore/snorenotifiersettings.cpp b/src/plugins/backends/snore/snorenotifiersettings.cpp index d7438e5..79ecdd2 100644 --- a/src/plugins/backends/snore/snorenotifiersettings.cpp +++ b/src/plugins/backends/snore/snorenotifiersettings.cpp @@ -46,3 +46,4 @@ void SnoreNotifierSettings::save() { setSettingsValue(QStringLiteral("Position"), m_comboBox->currentIndex()); } + diff --git a/src/plugins/backends/snore/snorenotifiersettings.h b/src/plugins/backends/snore/snorenotifiersettings.h index 62052d4..d7fa6b2 100644 --- a/src/plugins/backends/snore/snorenotifiersettings.h +++ b/src/plugins/backends/snore/snorenotifiersettings.h @@ -18,7 +18,8 @@ #ifndef SNORENOTIFIERSETTINGS_H #define SNORENOTIFIERSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" namespace Snore { @@ -39,4 +40,7 @@ private: QComboBox *m_comboBox; }; + +SNORE_DECLARE_SETTINGS_PLUGIN(SnoreNotifierSettings); + #endif // SNORENOTIFIERSETTINGS_H diff --git a/src/plugins/backends/snoretoast/CMakeLists.txt b/src/plugins/backends/snoretoast/CMakeLists.txt index 01a7693..8321de3 100644 --- a/src/plugins/backends/snoretoast/CMakeLists.txt +++ b/src/plugins/backends/snoretoast/CMakeLists.txt @@ -1,11 +1,4 @@ if(WIN32) - message(STATUS "Adding SnoreToast notification backend") - set( TOASTER_SRC - snoretoast.cpp - ) - add_library(libsnore_backend_snoretoast MODULE ${TOASTER_SRC} ) - target_link_libraries(libsnore_backend_snoretoast Snore::Libsnore) - - install(TARGETS libsnore_backend_snoretoast ${SNORE_PLUGIN_INSTALL_PATH}) - install(FILES SnoreToast.exe DESTINATION bin) + add_snore_plugin(snoretoast SOURCES snoretoast.cpp TYPE backend) + install(FILES SnoreToast.exe ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) endif(WIN32) diff --git a/src/plugins/backends/trayicon/CMakeLists.txt b/src/plugins/backends/trayicon/CMakeLists.txt index d60499f..2287d0b 100644 --- a/src/plugins/backends/trayicon/CMakeLists.txt +++ b/src/plugins/backends/trayicon/CMakeLists.txt @@ -1,7 +1 @@ -set( trayicon_SRC - trayiconnotifer.cpp - ) -add_library(libsnore_backend_trayicon MODULE ${trayicon_SRC} ) -target_link_libraries(libsnore_backend_trayicon Snore::Libsnore) - -install(TARGETS libsnore_backend_trayicon ${SNORE_PLUGIN_INSTALL_PATH}) +add_snore_plugin(trayicon SOURCES trayiconnotifer.cpp TYPE backend LIBS Qt5::Widgets) \ No newline at end of file diff --git a/src/plugins/backends/trayicon/trayiconnotifer.cpp b/src/plugins/backends/trayicon/trayiconnotifer.cpp index 08b4649..1d88d0e 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.cpp +++ b/src/plugins/backends/trayicon/trayiconnotifer.cpp @@ -4,6 +4,8 @@ #include "libsnore/utils.h" #include +#include + using namespace Snore; TrayIconNotifer::TrayIconNotifer() @@ -94,3 +96,12 @@ void TrayIconNotifer::actionInvoked() } +bool TrayIconNotifer::isReady() +{ + if(!qobject_cast< QApplication* >(qApp)){ + setErrorString(tr("This plugin only works with QApllication")); + return false; + } + return true; +} + diff --git a/src/plugins/backends/trayicon/trayiconnotifer.h b/src/plugins/backends/trayicon/trayiconnotifer.h index ecea63d..4e243e2 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.h +++ b/src/plugins/backends/trayicon/trayiconnotifer.h @@ -18,7 +18,8 @@ public: TrayIconNotifer(); ~TrayIconNotifer() = default; - virtual bool canCloseNotification() const override; + bool canCloseNotification() const override; + bool isReady() override; public Q_SLOTS: void slotNotify(Snore::Notification notification) override; diff --git a/src/plugins/frontends/freedesktop_frontend/CMakeLists.txt b/src/plugins/frontends/freedesktop_frontend/CMakeLists.txt index 7ad88b7..29d1c02 100644 --- a/src/plugins/frontends/freedesktop_frontend/CMakeLists.txt +++ b/src/plugins/frontends/freedesktop_frontend/CMakeLists.txt @@ -13,9 +13,8 @@ if(Qt5DBus_FOUND) ) qt5_add_dbus_adaptor( FREEDESKTOP_NOTIFICATION_FRONTEND_SRC org.freedesktop.Notifications.xml freedesktopnotificationfrontend.h FreedesktopFrontend) - - add_library(libsnore_frontend_freedesktop MODULE ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} ) - target_link_libraries(libsnore_frontend_freedesktop Snore::Libsnore Qt5::DBus ) + + add_snore_plugin(freedesktop SOURCES ${FREEDESKTOP_NOTIFICATION_FRONTEND_SRC} TYPE frontend LIBS Qt5::DBus) #install the dbus interface diff --git a/src/plugins/frontends/pushover_frontend/CMakeLists.txt b/src/plugins/frontends/pushover_frontend/CMakeLists.txt index e9de8bd..f1ed6ea 100644 --- a/src/plugins/frontends/pushover_frontend/CMakeLists.txt +++ b/src/plugins/frontends/pushover_frontend/CMakeLists.txt @@ -5,13 +5,5 @@ set_package_properties(Qt5WebSockets PROPERTIES TYPE OPTIONAL) if(Qt5WebSockets_FOUND) - set( PUSHOVER_FRONTEND_SRC - pushover_frontend.cpp - pushoversettings.cpp - ) - - add_library(libsnore_frontend_pushover MODULE ${PUSHOVER_FRONTEND_SRC} ) - target_link_libraries(libsnore_frontend_pushover Snore::Libsnore Qt5::WebSockets ) - install(TARGETS libsnore_frontend_pushover ${SNORE_PLUGIN_INSTALL_PATH}) - + add_snore_plugin(pushover SOURCES pushover_frontend.cpp SETTINGS_SOURCES pushoversettings.cpp TYPE frontend LIBS Qt5::WebSockets) endif() diff --git a/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp b/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp index 39f1309..b432408 100644 --- a/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp +++ b/src/plugins/frontends/pushover_frontend/pushover_frontend.cpp @@ -17,7 +17,6 @@ */ #include "pushover_frontend.h" -#include "pushoversettings.h" #include "libsnore/snore.h" #include "libsnore/version.h" @@ -51,11 +50,6 @@ PushoverFrontend::PushoverFrontend() }); } -PluginSettingsWidget *PushoverFrontend::settingsWidget() -{ - return new PushoverSettings(this); -} - void PushoverFrontend::login(const QString &email, const QString &password, const QString &deviceName) { setSettingsValue(QStringLiteral("DeviceName"), deviceName, Snore::LOCAL_SETTING); diff --git a/src/plugins/frontends/pushover_frontend/pushover_frontend.h b/src/plugins/frontends/pushover_frontend/pushover_frontend.h index f30d671..d881502 100644 --- a/src/plugins/frontends/pushover_frontend/pushover_frontend.h +++ b/src/plugins/frontends/pushover_frontend/pushover_frontend.h @@ -35,8 +35,6 @@ public: PushoverFrontend(); ~PushoverFrontend() = default; - Snore::PluginSettingsWidget *settingsWidget() override; - void login(const QString &email, const QString &password, const QString &deviceName); void logOut(); diff --git a/src/plugins/frontends/pushover_frontend/pushoversettings.cpp b/src/plugins/frontends/pushover_frontend/pushoversettings.cpp index f766fc9..6fe43d6 100644 --- a/src/plugins/frontends/pushover_frontend/pushoversettings.cpp +++ b/src/plugins/frontends/pushover_frontend/pushoversettings.cpp @@ -16,7 +16,7 @@ along with SnoreNotify. If not, see . */ #include "pushoversettings.h" -#include "pushover_frontend.h" +//#include "pushover_frontend.h" #include "plugins/plugins.h" @@ -46,7 +46,8 @@ PushoverSettings::PushoverSettings(Snore::SnorePlugin *plugin, QWidget *parent) m_deviceLineEdit->setEnabled(false); m_registerButton->setEnabled(false); - PushoverFrontend *pushover = dynamic_cast(plugin); + // TODO: find a replacement +/* PushoverFrontend *pushover = dynamic_cast(plugin); m_errorMessageLabel->setText(pushover->errorMessage()); connect(pushover, &PushoverFrontend::loggedInChanged, this, &PushoverSettings::slotUpdateLoginState); @@ -64,6 +65,7 @@ PushoverSettings::PushoverSettings(Snore::SnorePlugin *plugin, QWidget *parent) pushover->logOut(); } }); + */ } PushoverSettings::~PushoverSettings() diff --git a/src/plugins/frontends/pushover_frontend/pushoversettings.h b/src/plugins/frontends/pushover_frontend/pushoversettings.h index 75b9388..edbadde 100644 --- a/src/plugins/frontends/pushover_frontend/pushoversettings.h +++ b/src/plugins/frontends/pushover_frontend/pushoversettings.h @@ -18,7 +18,9 @@ #ifndef PUSHOVERSETTINGS_H #define PUSHOVERSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" + class QLineEdit; class QPushButton; @@ -46,4 +48,6 @@ private Q_SLOTS: }; +SNORE_DECLARE_SETTINGS_PLUGIN(PushoverSettings) + #endif // PUSHOVERSETTINGS_H diff --git a/src/plugins/frontends/snarlnetwork/CMakeLists.txt b/src/plugins/frontends/snarlnetwork/CMakeLists.txt index 182b1fe..aa65751 100644 --- a/src/plugins/frontends/snarlnetwork/CMakeLists.txt +++ b/src/plugins/frontends/snarlnetwork/CMakeLists.txt @@ -1,8 +1 @@ -set( SNARL_NETWORK_SRC - snarlnetwork.cpp - parser.cpp - ) -add_library(libsnore_frontend_snarlnetwork MODULE ${SNARL_NETWORK_SRC} ) -target_link_libraries(libsnore_frontend_snarlnetwork Snore::Libsnore) - -install(TARGETS libsnore_frontend_snarlnetwork ${SNORE_PLUGIN_INSTALL_PATH}) +add_snore_plugin(snarlnetwork SOURCES snarlnetwork.cpp parser.cpp TYPE frontend) \ No newline at end of file diff --git a/src/plugins/secondary_backends/nma/CMakeLists.txt b/src/plugins/secondary_backends/nma/CMakeLists.txt index 856c0b5..126f551 100644 --- a/src/plugins/secondary_backends/nma/CMakeLists.txt +++ b/src/plugins/secondary_backends/nma/CMakeLists.txt @@ -1,10 +1 @@ -set( NMA_SRC - nma.cpp - nmasettings.cpp - ) - -add_library(libsnore_secondary_backend_nma MODULE ${NMA_SRC} ) -target_link_libraries(libsnore_secondary_backend_nma Snore::Libsnore) - -install(TARGETS libsnore_secondary_backend_nma ${SNORE_PLUGIN_INSTALL_PATH}) - +add_snore_plugin(nma SOURCES nma.cpp SETTINGS_SOURCES nmasettings.cpp TYPE secondary_backend) \ No newline at end of file diff --git a/src/plugins/secondary_backends/nma/nma.cpp b/src/plugins/secondary_backends/nma/nma.cpp index 0441427..5fe500a 100644 --- a/src/plugins/secondary_backends/nma/nma.cpp +++ b/src/plugins/secondary_backends/nma/nma.cpp @@ -16,7 +16,6 @@ along with SnoreNotify. If not, see . */ #include "nma.h" -#include "nmasettings.h" #include "libsnore/utils.h" @@ -59,11 +58,6 @@ void NotifyMyAndroid::slotNotify(Notification notification) } -PluginSettingsWidget *NotifyMyAndroid::settingsWidget() -{ - return new NotifyMyAndroidSettings(this); -} - void NotifyMyAndroid::setDefaultSettings() { setDefaultSettingsValue(QStringLiteral("ApiKey"), QString()); diff --git a/src/plugins/secondary_backends/nma/nma.h b/src/plugins/secondary_backends/nma/nma.h index d83b8dd..e3e3ae2 100644 --- a/src/plugins/secondary_backends/nma/nma.h +++ b/src/plugins/secondary_backends/nma/nma.h @@ -31,8 +31,6 @@ public: NotifyMyAndroid() = default; ~NotifyMyAndroid() = default; - Snore::PluginSettingsWidget *settingsWidget() override; - protected: void setDefaultSettings() override; diff --git a/src/plugins/secondary_backends/nma/nmasettings.cpp b/src/plugins/secondary_backends/nma/nmasettings.cpp index 29c5a25..b8fbd07 100644 --- a/src/plugins/secondary_backends/nma/nmasettings.cpp +++ b/src/plugins/secondary_backends/nma/nmasettings.cpp @@ -17,7 +17,7 @@ */ #include "nmasettings.h" -#include "plugins/plugins.h" +#include "libsnore/plugins/plugins.h" #include #include diff --git a/src/plugins/secondary_backends/nma/nmasettings.h b/src/plugins/secondary_backends/nma/nmasettings.h index b250075..5b800a4 100644 --- a/src/plugins/secondary_backends/nma/nmasettings.h +++ b/src/plugins/secondary_backends/nma/nmasettings.h @@ -18,7 +18,8 @@ #ifndef NOTIFYMYANDROID_H #define NOTIFYMYANDROID_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" +#include "libsnore/settings/pluginsettingswidget.h" class QLineEdit; @@ -37,4 +38,6 @@ private: }; +SNORE_DECLARE_SETTINGS_PLUGIN(NotifyMyAndroidSettings); + #endif // NOTIFYMYANDROID_HH diff --git a/src/plugins/secondary_backends/pushover_backend/CMakeLists.txt b/src/plugins/secondary_backends/pushover_backend/CMakeLists.txt index d6995b6..afeee94 100644 --- a/src/plugins/secondary_backends/pushover_backend/CMakeLists.txt +++ b/src/plugins/secondary_backends/pushover_backend/CMakeLists.txt @@ -1,10 +1,2 @@ -set( PUSHOVER_SRC - pushover.cpp - pushoversettings.cpp - ) - -add_library(libsnore_secondary_backend_pushover MODULE ${PUSHOVER_SRC} ) -target_link_libraries(libsnore_secondary_backend_pushover Snore::Libsnore) - -install(TARGETS libsnore_secondary_backend_pushover ${SNORE_PLUGIN_INSTALL_PATH}) +add_snore_plugin(puhover SOURCES pushover.cpp SETTINGS_SOURCES pushoversettings.cpp TYPE secondary_backend) diff --git a/src/plugins/secondary_backends/pushover_backend/pushover.cpp b/src/plugins/secondary_backends/pushover_backend/pushover.cpp index 778917b..9733ee0 100644 --- a/src/plugins/secondary_backends/pushover_backend/pushover.cpp +++ b/src/plugins/secondary_backends/pushover_backend/pushover.cpp @@ -16,7 +16,6 @@ along with SnoreNotify. If not, see . */ #include "pushover.h" -#include "pushoversettings.h" #include "libsnore/utils.h" #include "libsnore/notification/notification_p.h" @@ -120,11 +119,6 @@ void Pushover::slotNotify(Notification notification) } -PluginSettingsWidget *Pushover::settingsWidget() -{ - return new PushoverSettings(this); -} - void Pushover::setDefaultSettings() { setDefaultSettingsValue(QStringLiteral("UserKey"), QString()); diff --git a/src/plugins/secondary_backends/pushover_backend/pushover.h b/src/plugins/secondary_backends/pushover_backend/pushover.h index 201cfc6..c12b7b7 100644 --- a/src/plugins/secondary_backends/pushover_backend/pushover.h +++ b/src/plugins/secondary_backends/pushover_backend/pushover.h @@ -31,8 +31,6 @@ public: Pushover() = default; ~Pushover() = default; - Snore::PluginSettingsWidget *settingsWidget() override; - protected: void setDefaultSettings() override; diff --git a/src/plugins/secondary_backends/pushover_backend/pushoversettings.h b/src/plugins/secondary_backends/pushover_backend/pushoversettings.h index 7cab1f0..45db8ee 100644 --- a/src/plugins/secondary_backends/pushover_backend/pushoversettings.h +++ b/src/plugins/secondary_backends/pushover_backend/pushoversettings.h @@ -18,7 +18,8 @@ #ifndef PUSHOVERSETTINGS_H #define PUSHOVERSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" class QLineEdit; @@ -39,4 +40,6 @@ private: }; +SNORE_DECLARE_SETTINGS_PLUGIN(PushoverSettings); + #endif // PUSHOVERSETTINGS_H diff --git a/src/plugins/secondary_backends/sound/CMakeLists.txt b/src/plugins/secondary_backends/sound/CMakeLists.txt index 7fbb8d0..edc238f 100644 --- a/src/plugins/secondary_backends/sound/CMakeLists.txt +++ b/src/plugins/secondary_backends/sound/CMakeLists.txt @@ -3,14 +3,5 @@ set_package_properties(Qt5Multimedia PROPERTIES PURPOSE "Support for sound Notifications" TYPE OPTIONAL) if(Qt5Multimedia_FOUND) - - set( SOUND_SRC - sound.cpp - soundsettings.cpp - ) - - add_library(libsnore_secondary_backend_sound MODULE ${SOUND_SRC} ) - target_link_libraries(libsnore_secondary_backend_sound Snore::Libsnore Qt5::Multimedia) - - install(TARGETS libsnore_secondary_backend_sound ${SNORE_PLUGIN_INSTALL_PATH}) + add_snore_plugin(sound SOURCES sound.cpp SETTINGS_SOURCES soundsettings.cpp TYPE secondary_backend LIBS Qt5::Multimedia) endif() diff --git a/src/plugins/secondary_backends/sound/sound.cpp b/src/plugins/secondary_backends/sound/sound.cpp index b503742..a9436e0 100644 --- a/src/plugins/secondary_backends/sound/sound.cpp +++ b/src/plugins/secondary_backends/sound/sound.cpp @@ -16,7 +16,6 @@ along with SnoreNotify. If not, see . */ #include "sound.h" -#include "soundsettings.h" #include #include @@ -34,11 +33,6 @@ Sound::Sound(): }); } -PluginSettingsWidget *Sound::settingsWidget() -{ - return new SoundSettings(this); -} - void Sound::setDefaultSettings() { setDefaultSettingsValue(QStringLiteral("Volume"), 50); diff --git a/src/plugins/secondary_backends/sound/sound.h b/src/plugins/secondary_backends/sound/sound.h index 2a6001f..e119cdb 100644 --- a/src/plugins/secondary_backends/sound/sound.h +++ b/src/plugins/secondary_backends/sound/sound.h @@ -31,8 +31,6 @@ public: Sound(); ~Sound() = default; - Snore::PluginSettingsWidget *settingsWidget() override; - protected: void setDefaultSettings() override; diff --git a/src/plugins/secondary_backends/sound/soundsettings.h b/src/plugins/secondary_backends/sound/soundsettings.h index 4f4dec6..e60fd52 100644 --- a/src/plugins/secondary_backends/sound/soundsettings.h +++ b/src/plugins/secondary_backends/sound/soundsettings.h @@ -2,7 +2,8 @@ #ifndef SOUNDSETTINGS_H #define SOUNDSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" class QLineEdit; class QSpinBox; @@ -23,4 +24,6 @@ private: }; +SNORE_DECLARE_SETTINGS_PLUGIN(SoundSettings); + #endif // SOUNDSETTINGS_H diff --git a/src/plugins/secondary_backends/toasty/CMakeLists.txt b/src/plugins/secondary_backends/toasty/CMakeLists.txt index e778503..0ef42b4 100644 --- a/src/plugins/secondary_backends/toasty/CMakeLists.txt +++ b/src/plugins/secondary_backends/toasty/CMakeLists.txt @@ -1,10 +1 @@ -set( TOASTY_SRC - toasty.cpp - toastysettings.cpp - ) - -add_library(libsnore_secondary_backend_toasty MODULE ${TOASTY_SRC} ) -target_link_libraries(libsnore_secondary_backend_toasty Snore::Libsnore) - -install(TARGETS libsnore_secondary_backend_toasty ${SNORE_PLUGIN_INSTALL_PATH}) - +add_snore_plugin(toasty SOURCES toasty.cpp SETTINGS_SOURCES toastysettings.cpp TYPE secondary_backend) \ No newline at end of file diff --git a/src/plugins/secondary_backends/toasty/toasty.cpp b/src/plugins/secondary_backends/toasty/toasty.cpp index 46feb7f..f736016 100644 --- a/src/plugins/secondary_backends/toasty/toasty.cpp +++ b/src/plugins/secondary_backends/toasty/toasty.cpp @@ -16,7 +16,6 @@ along with SnoreNotify. If not, see . */ #include "toasty.h" -#include "toastysettings.h" #include "libsnore/utils.h" @@ -73,11 +72,6 @@ void Toasty::slotNotify(Notification notification) } -PluginSettingsWidget *Toasty::settingsWidget() -{ - return new ToastySettings(this); -} - void Toasty::setDefaultSettings() { setDefaultSettingsValue(QStringLiteral("DeviceID"), QString()); diff --git a/src/plugins/secondary_backends/toasty/toasty.h b/src/plugins/secondary_backends/toasty/toasty.h index 16995ce..d7fd5c9 100644 --- a/src/plugins/secondary_backends/toasty/toasty.h +++ b/src/plugins/secondary_backends/toasty/toasty.h @@ -31,8 +31,6 @@ public: Toasty() = default; ~Toasty() = default; - Snore::PluginSettingsWidget *settingsWidget() override; - protected: void setDefaultSettings() override; @@ -44,4 +42,5 @@ private: }; + #endif // TOASTY_H diff --git a/src/plugins/secondary_backends/toasty/toastysettings.h b/src/plugins/secondary_backends/toasty/toastysettings.h index b0352d5..8fd484e 100644 --- a/src/plugins/secondary_backends/toasty/toastysettings.h +++ b/src/plugins/secondary_backends/toasty/toastysettings.h @@ -18,7 +18,8 @@ #ifndef TOASTYSETTINGS_H #define TOASTYSETTINGS_H -#include "plugins/pluginsettingswidget.h" +#include "libsnore/settings/pluginsettingswidget.h" +#include "libsnore/plugins/settingsplugin.h" class QLineEdit; @@ -37,4 +38,7 @@ private: }; + +SNORE_DECLARE_SETTINGS_PLUGIN(ToastySettings); + #endif // TOASTYSETTINGS_H diff --git a/src/settings/CMakeLists.txt b/src/settings/CMakeLists.txt index cade7d7..91981ed 100644 --- a/src/settings/CMakeLists.txt +++ b/src/settings/CMakeLists.txt @@ -3,7 +3,7 @@ ecm_add_app_icon(SNORENOTIFY_SETTINGS_DEPS ICONS ${PROJECT_SOURCE_DIR}/data/128- qt5_wrap_ui(UI settingswindow.ui) add_executable( snoresettings WIN32 main.cpp settingswindow.cpp ${UI} ${SNORENOTIFY_SETTINGS_DEPS}) -target_link_libraries( snoresettings Snore::Libsnore ) +target_link_libraries( snoresettings Snore::Libsnore Snore::LibsnoreSettings) install(TARGETS snoresettings ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) if(UNIX) diff --git a/src/settings/settingswindow.cpp b/src/settings/settingswindow.cpp index 855fb7d..1eef652 100644 --- a/src/settings/settingswindow.cpp +++ b/src/settings/settingswindow.cpp @@ -25,6 +25,7 @@ #include #include +#include #include diff --git a/src/settings/settingswindow.ui b/src/settings/settingswindow.ui index a446a55..151ab43 100644 --- a/src/settings/settingswindow.ui +++ b/src/settings/settingswindow.ui @@ -53,7 +53,7 @@ Snore::SettingsDialog QWidget -
libsnore/settingsdialog.h
+
libsnore/settings/settingsdialog.h
1
diff --git a/src/snoresend/main.cpp b/src/snoresend/main.cpp index 515ccb9..76055e6 100644 --- a/src/snoresend/main.cpp +++ b/src/snoresend/main.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ void bringToFront(QString pid) int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QGuiApplication app(argc, argv); app.setApplicationName(QStringLiteral("snoresend")); app.setOrganizationName(QStringLiteral("Snorenotify")); app.setApplicationVersion(Snore::Version::version()); @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) } returnCode = noti.closeReason(); }); - app.connect(&core, &SnoreCore::notificationClosed, &app, &QApplication::quit); + app.connect(&core, &SnoreCore::notificationClosed, &app, &QGuiApplication::quit); app.processEvents(); core.broadcastNotification(n);