diff --git a/src/core/snore.cpp b/src/core/snore.cpp index c02e4e9..d7679c6 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -1,6 +1,6 @@ /* SnoreNotify is a Notification Framework based on Qt - Copyright (C) 2013-2014 Patrick von Reth + Copyright (C) 2013-2015 Patrick 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 @@ -232,7 +232,7 @@ QList SnoreCore::settingWidgets() QList list; for(auto p:PluginContainer::pluginCache(SnorePlugin::ALL)) { -//TODO: set parent +//TODO: mem leak? PluginSettingsWidget *w = p->load()->settingsWidget(); if(w) { list.append(w); diff --git a/src/core/snore.h b/src/core/snore.h index 3a47023..baf1c7f 100644 --- a/src/core/snore.h +++ b/src/core/snore.h @@ -163,6 +163,10 @@ public: bool primaryBackendSupportsRichtext(); + /** + * + * @return A list of widgets a settings dialog. + */ QList settingWidgets(); /** diff --git a/src/plugins/backends/snore/snorenotifier.h b/src/plugins/backends/snore/snorenotifier.h index 7e88590..4495451 100644 --- a/src/plugins/backends/snore/snorenotifier.h +++ b/src/plugins/backends/snore/snorenotifier.h @@ -1,6 +1,6 @@ /* SnoreNotify is a Notification Framework based on Qt - Copyright (C) 2014 Patrick von Reth + Copyright (C) 2015 Patrick 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 diff --git a/src/plugins/backends/snore/snorenotifiersettings.cpp b/src/plugins/backends/snore/snorenotifiersettings.cpp index e48ca27..eba114f 100644 --- a/src/plugins/backends/snore/snorenotifiersettings.cpp +++ b/src/plugins/backends/snore/snorenotifiersettings.cpp @@ -1,3 +1,20 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2013-2015 Patrick 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 "snorenotifiersettings.h" #include "ui_snorenotifiersettings.h" #include "snore.h" diff --git a/src/plugins/secondary_backends/toasty/CMakeLists.txt b/src/plugins/secondary_backends/toasty/CMakeLists.txt index 909a6b6..d3054df 100644 --- a/src/plugins/secondary_backends/toasty/CMakeLists.txt +++ b/src/plugins/secondary_backends/toasty/CMakeLists.txt @@ -1,6 +1,11 @@ +qt5_wrap_ui(UI toastysettings.ui) + set( TOASTY_SRC toasty.cpp + toastysettings.cpp + ${UI} ) + add_library(libsnore_secondary_backend_toasty MODULE ${TOASTY_SRC} ) target_link_libraries(libsnore_secondary_backend_toasty Snore::Libsnore) diff --git a/src/plugins/secondary_backends/toasty/toasty.cpp b/src/plugins/secondary_backends/toasty/toasty.cpp index 64ff1d4..4609f42 100644 --- a/src/plugins/secondary_backends/toasty/toasty.cpp +++ b/src/plugins/secondary_backends/toasty/toasty.cpp @@ -1,4 +1,22 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2014-2015 Patrick 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 "toasty.h" +#include "toastysettings.h" #include #include @@ -78,3 +96,8 @@ bool Toasty::deinitialize() { return SnoreSecondaryBackend::deinitialize(); } + +PluginSettingsWidget *Toasty::settingsWidget() +{ + return new ToastySettings(this); +} diff --git a/src/plugins/secondary_backends/toasty/toasty.h b/src/plugins/secondary_backends/toasty/toasty.h index acabe15..e2c107c 100644 --- a/src/plugins/secondary_backends/toasty/toasty.h +++ b/src/plugins/secondary_backends/toasty/toasty.h @@ -1,3 +1,20 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2014-2015 Patrick 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 TOASTY_H #define TOASTY_H @@ -13,11 +30,13 @@ class Toasty : public Snore::SnoreSecondaryBackend public: Toasty(); ~Toasty(); - virtual bool initialize(Snore::SnoreCore *snore) override; - virtual bool deinitialize() override; + bool initialize(Snore::SnoreCore *snore) override; + bool deinitialize() override; + + Snore::PluginSettingsWidget *settingsWidget() override; public slots: - virtual void slotNotify(Snore::Notification notification) override; + void slotNotify(Snore::Notification notification) override; private: QNetworkAccessManager m_manager; diff --git a/src/plugins/secondary_backends/toasty/toastysettings.cpp b/src/plugins/secondary_backends/toasty/toastysettings.cpp new file mode 100644 index 0000000..a5369dd --- /dev/null +++ b/src/plugins/secondary_backends/toasty/toastysettings.cpp @@ -0,0 +1,43 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Patrick 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 "toastysettings.h" +#include "ui_toastysettings.h" + +#include "plugins/plugins.h" + +ToastySettings::ToastySettings(Snore::SnorePlugin *plugin, QWidget *parent) : + Snore::PluginSettingsWidget(plugin,parent), + ui(new Ui::ToastySettings) +{ + ui->setupUi(this); +} + +ToastySettings::~ToastySettings() +{ + delete ui; +} + +void ToastySettings::load() +{ + ui->lineEdit->setText(m_snorePlugin->value("DeviceID").toString()); +} + +void ToastySettings::save() +{ + m_snorePlugin->setValue("DeviceID",ui->lineEdit->text()); +} diff --git a/src/plugins/secondary_backends/toasty/toastysettings.h b/src/plugins/secondary_backends/toasty/toastysettings.h new file mode 100644 index 0000000..68c6727 --- /dev/null +++ b/src/plugins/secondary_backends/toasty/toastysettings.h @@ -0,0 +1,43 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2015 Patrick 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 TOASTYSETTINGS_H +#define TOASTYSETTINGS_H + +#include "plugins/pluginsettingswidget.h" + +namespace Ui { +class ToastySettings; +} + +class ToastySettings : public Snore::PluginSettingsWidget +{ + Q_OBJECT + +public: + explicit ToastySettings(Snore::SnorePlugin *plugin, QWidget *parent = 0); + ~ToastySettings(); + + void load() override; + void save() override; + +private: + Ui::ToastySettings *ui; + +}; + +#endif // TOASTYSETTINGS_H diff --git a/src/plugins/secondary_backends/toasty/toastysettings.ui b/src/plugins/secondary_backends/toasty/toastysettings.ui new file mode 100644 index 0000000..e4ea6d5 --- /dev/null +++ b/src/plugins/secondary_backends/toasty/toastysettings.ui @@ -0,0 +1,35 @@ + + + ToastySettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + Device ID: + + + + + + + + + + + + +