Remove the dependencie to QWidget from snorenotify by moving the settings to extra plugins

This commit is contained in:
Hannah von Reth 2015-12-02 16:08:15 +01:00
parent ac7ac2ddb3
commit 0ce253fad3
77 changed files with 474 additions and 338 deletions

View File

@ -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}")

View File

@ -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.")

View File

@ -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)

View File

@ -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 <QAction>
#include <QApplication>
#include <QAbstractButton>
#include <QDialogButtonBox>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QLayout>
#include "libsnore/version.h"

View File

@ -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
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>)
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)

View File

@ -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")

View File

@ -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()

View File

@ -20,7 +20,7 @@
#include "lambdahint.h"
#include "snore_p.h"
#include <QApplication>
#include <QGuiApplication>
using namespace Snore;

View File

@ -20,7 +20,7 @@
#include "../snore.h"
#include "../snore_p.h"
#include <QApplication>
#include <QGuiApplication>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>

View File

@ -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)

View File

@ -25,7 +25,7 @@
#include "../version.h"
#include <QDir>
#include <QApplication>
#include <QGuiApplication>
#include <QTime>
using namespace Snore;

View File

@ -25,7 +25,7 @@
#include <QDebug>
#include <QMetaEnum>
#include <QApplication>
#include <QGuiApplication>
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();

View File

@ -21,7 +21,6 @@
#include "libsnore/snore_exports.h"
#include "libsnore/snoreglobals.h"
#include "libsnore/notification/notification.h"
#include "pluginsettingswidget.h"
#include <QHash>
@ -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);

View File

@ -0,0 +1,31 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Hannah von Reth <vonreth@kde.org>
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 <http://www.gnu.org/licenses/>.
*/
#include "settingsplugin.h"
using namespace Snore;
SettingsPlugin::SettingsPlugin()
{
}
SettingsPlugin::~SettingsPlugin()
{
}

View File

@ -0,0 +1,64 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Hannah von Reth <vonreth@kde.org>
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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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})

View File

@ -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")

View File

@ -16,7 +16,7 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pluginsettingswidget.h"
#include "plugins.h"
#include "libsnore/plugins/plugins.h"
#include "snore.h"
#include <QCheckBox>

View File

@ -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 <QWidget>
@ -29,7 +29,7 @@ namespace Snore
{
class SnorePlugin;
class SNORE_EXPORT PluginSettingsWidget : public QWidget
class SNORE_SETTINGS_EXPORT PluginSettingsWidget : public QWidget
{
Q_OBJECT
public:

View File

@ -0,0 +1,53 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Hannah von Reth <vonreth@kde.org>
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 <http://www.gnu.org/licenses/>.
*/
#include "settings.h"
#include "libsnore/snore_p.h"
#include "libsnore/plugins/settingsplugin.h"
#include "libsnore/settings/pluginsettingswidget.h"
#include <QList>
using namespace Snore;
QList<PluginSettingsWidget *> Settings::settingWidgets(SnorePlugin::PluginTypes type)
{
SnoreCorePrivate *core(SnoreCorePrivate::instance());
QList<PluginSettingsWidget *> 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;
}

View File

@ -0,0 +1,39 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Hannah von Reth <vonreth@kde.org>
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 <http://www.gnu.org/licenses/>.
*/
#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<PluginSettingsWidget *> settingWidgets(SnorePlugin::PluginTypes type);
};
}
#endif // SETTINGS_H

View File

@ -20,6 +20,7 @@
#include "ui_settingsdialog.h"
#include "snore.h"
#include "snore_p.h"
#include "settings.h"
#include <QTabWidget>
#include <QCheckBox>
@ -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;

View File

@ -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 <QWidget>
@ -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

View File

@ -28,7 +28,7 @@
#include "version.h"
#include <QApplication>
#include <QGuiApplication>
#include <QSettings>
#include <QThread>
@ -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<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes type)
{
Q_D(SnoreCore);
QList<PluginSettingsWidget *> 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
{

View File

@ -138,12 +138,6 @@ public:
*/
void setDefaultApplication(Application app);
/**
*
* @return A list of widgets a settings dialog.
*/
QList<PluginSettingsWidget *> 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);

View File

@ -25,7 +25,7 @@
#include "notification/notification_p.h"
#include "version.h"
#include <QApplication>
#include <QGuiApplication>
#include <QSettings>
#include <QTemporaryDir>

View File

@ -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<Notification> m_notificationQue;
QHash<uint, Snore::Notification> m_activeNotifications;
friend class Snore::Notification;
friend class Snore::Settings;
};
}

View File

@ -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()

View File

@ -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();

View File

@ -32,7 +32,6 @@ class GrowlBackend: public Snore::SnoreBackend
public:
GrowlBackend();
~GrowlBackend();
Snore::PluginSettingsWidget *settingsWidget() override;
bool isReady() override;
protected:

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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 <QApplication>
#include <QWidget>
#include <iostream>
@ -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<MSG *>(message);
MSG* msg = static_cast<MSG*>(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;

View File

@ -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<QString, Snarl::V42::SnarlInterface *> m_applications;
public Q_SLOTS:

View File

@ -15,10 +15,11 @@
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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()
add_snore_plugin(snore SOURCES snorenotifier.cpp
notifywidget.cpp
${SNORENOTIFIER_RCS}
TYPE backend SETTINGS_SOURCES snorenotifiersettings.cpp LIBS Qt5::Quick)
endif()

View File

@ -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()

View File

@ -20,8 +20,7 @@
#include "snorenotifier.h"
#include "libsnore/utils.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QQmlProperty>
using namespace Snore;
@ -179,34 +178,10 @@ int NotifyWidget::id() const
void NotifyWidget::syncSettings()
{
Qt::Corner c = static_cast<Qt::Corner>(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();
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -46,3 +46,4 @@ void SnoreNotifierSettings::save()
{
setSettingsValue(QStringLiteral("Position"), m_comboBox->currentIndex());
}

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -4,6 +4,8 @@
#include "libsnore/utils.h"
#include <QSystemTrayIcon>
#include <QApplication>
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;
}

View File

@ -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;

View File

@ -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

View File

@ -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()

View File

@ -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);

View File

@ -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();

View File

@ -16,7 +16,7 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#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<PushoverFrontend *>(plugin);
// TODO: find a replacement
/* PushoverFrontend *pushover = dynamic_cast<PushoverFrontend *>(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()

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#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());

View File

@ -31,8 +31,6 @@ public:
NotifyMyAndroid() = default;
~NotifyMyAndroid() = default;
Snore::PluginSettingsWidget *settingsWidget() override;
protected:
void setDefaultSettings() override;

View File

@ -17,7 +17,7 @@
*/
#include "nmasettings.h"
#include "plugins/plugins.h"
#include "libsnore/plugins/plugins.h"
#include <QLabel>
#include <QLineEdit>

View File

@ -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

View File

@ -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)

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#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());

View File

@ -31,8 +31,6 @@ public:
Pushover() = default;
~Pushover() = default;
Snore::PluginSettingsWidget *settingsWidget() override;
protected:
void setDefaultSettings() override;

View File

@ -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

View File

@ -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()

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sound.h"
#include "soundsettings.h"
#include <QtMultimedia/QMediaPlayer>
#include <QTimer>
@ -34,11 +33,6 @@ Sound::Sound():
});
}
PluginSettingsWidget *Sound::settingsWidget()
{
return new SoundSettings(this);
}
void Sound::setDefaultSettings()
{
setDefaultSettingsValue(QStringLiteral("Volume"), 50);

View File

@ -31,8 +31,6 @@ public:
Sound();
~Sound() = default;
Snore::PluginSettingsWidget *settingsWidget() override;
protected:
void setDefaultSettings() override;

View File

@ -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

View File

@ -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)

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#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());

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -25,6 +25,7 @@
#include <QApplication>
#include <QDialogButtonBox>
#include <QAbstractButton>
#include <iostream>

View File

@ -53,7 +53,7 @@
<customwidget>
<class>Snore::SettingsDialog</class>
<extends>QWidget</extends>
<header location="global">libsnore/settingsdialog.h</header>
<header location="global">libsnore/settings/settingsdialog.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@ -21,7 +21,7 @@
#include <libsnore/version.h>
#include <libsnore/utils.h>
#include <QApplication>
#include <QGuiApplication>
#include <QCommandLineParser>
#include <iostream>
@ -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);