toasty settings

This commit is contained in:
Patrick von Reth 2015-02-02 16:07:32 +01:00
parent d48da78cc1
commit fbb92d5c00
10 changed files with 195 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
Copyright (C) 2013-2015 Patrick 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
@ -232,7 +232,7 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets()
QList<PluginSettingsWidget*> list;
for(auto p:PluginContainer::pluginCache(SnorePlugin::ALL))
{
//TODO: set parent
//TODO: mem leak?
PluginSettingsWidget *w = p->load()->settingsWidget();
if(w) {
list.append(w);

View File

@ -163,6 +163,10 @@ public:
bool primaryBackendSupportsRichtext();
/**
*
* @return A list of widgets a settings dialog.
*/
QList<PluginSettingsWidget*> settingWidgets();
/**

View File

@ -1,6 +1,6 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
Copyright (C) 2015 Patrick 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

View File

@ -1,3 +1,20 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2013-2015 Patrick 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 "snorenotifiersettings.h"
#include "ui_snorenotifiersettings.h"
#include "snore.h"

View File

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

View File

@ -1,4 +1,22 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014-2015 Patrick 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 "toasty.h"
#include "toastysettings.h"
#include <QtNetwork>
#include <QImage>
@ -78,3 +96,8 @@ bool Toasty::deinitialize()
{
return SnoreSecondaryBackend::deinitialize();
}
PluginSettingsWidget *Toasty::settingsWidget()
{
return new ToastySettings(this);
}

View File

@ -1,3 +1,20 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014-2015 Patrick 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 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;

View File

@ -0,0 +1,43 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Patrick 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 "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());
}

View File

@ -0,0 +1,43 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2015 Patrick 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 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

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ToastySettings</class>
<widget class="QWidget" name="ToastySettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Device ID:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>