apply astyle-kdelibs
This commit is contained in:
parent
63db3a5c90
commit
5b4229224e
|
@ -41,24 +41,24 @@ IconData::IconData(const QString &url):
|
|||
}
|
||||
m_isRemoteFile = !m_isLocalFile && !m_isResource;
|
||||
|
||||
if(!m_isLocalFile && !s_localImageCache.contains(m_localUrl)) {
|
||||
if (!m_isLocalFile && !s_localImageCache.contains(m_localUrl)) {
|
||||
if (m_isRemoteFile) {
|
||||
m_isDownloading = true;
|
||||
snoreDebug(SNORE_DEBUG) << "Downloading:" << m_url;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager();
|
||||
QNetworkRequest request(m_url);
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
QObject::connect(reply,&QNetworkReply::downloadProgress,[&](qint64 bytesReceived, qint64 bytesTotal){
|
||||
snoreDebug(SNORE_DEBUG) << "Downloading:" << m_localUrl << bytesReceived/double(bytesTotal) * 100.0 << "%";
|
||||
QObject::connect(reply, &QNetworkReply::downloadProgress, [&](qint64 bytesReceived, qint64 bytesTotal) {
|
||||
snoreDebug(SNORE_DEBUG) << "Downloading:" << m_localUrl << bytesReceived / double(bytesTotal) * 100.0 << "%";
|
||||
});
|
||||
|
||||
QObject::connect(reply,static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),[&,reply,manager](QNetworkReply::NetworkError code){
|
||||
QObject::connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), [ &, reply, manager](QNetworkReply::NetworkError code) {
|
||||
snoreDebug(SNORE_WARNING) << "Error:" << code;
|
||||
reply->deleteLater();
|
||||
manager->deleteLater();
|
||||
m_isDownloading = false;
|
||||
});
|
||||
QObject::connect(reply, &QNetworkReply::finished, [&,reply,manager]() {
|
||||
QObject::connect(reply, &QNetworkReply::finished, [ &, reply, manager]() {
|
||||
m_img = QImage::fromData(reply->readAll(), "PNG");
|
||||
m_img.save(m_localUrl, "PNG");
|
||||
s_localImageCache.insert(m_localUrl);
|
||||
|
@ -68,7 +68,7 @@ IconData::IconData(const QString &url):
|
|||
manager->deleteLater();
|
||||
m_isDownloading = false;
|
||||
});
|
||||
} else if(m_isResource) {
|
||||
} else if (m_isResource) {
|
||||
m_img = QImage(url);
|
||||
m_img.save(m_localUrl, "PNG");
|
||||
s_localImageCache.insert(m_localUrl);
|
||||
|
@ -100,8 +100,7 @@ IconData::~IconData()
|
|||
const QImage &IconData::image()
|
||||
{
|
||||
if (m_img.isNull()) {
|
||||
while(m_isDownloading)
|
||||
{
|
||||
while (m_isDownloading) {
|
||||
qApp->processEvents();
|
||||
}
|
||||
if (!m_isRemoteFile) {
|
||||
|
@ -113,8 +112,7 @@ const QImage &IconData::image()
|
|||
|
||||
QString IconData::localUrl()
|
||||
{
|
||||
while(m_isDownloading)
|
||||
{
|
||||
while (m_isDownloading) {
|
||||
qApp->processEvents();
|
||||
}
|
||||
return m_localUrl;
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
#include <QSharedData>
|
||||
#include <QSet>
|
||||
|
||||
|
||||
class QNetworkAccessManager;
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ SnorePlugin *PluginContainer::load()
|
|||
return nullptr;
|
||||
}
|
||||
SnorePlugin *plugin = qobject_cast<SnorePlugin *> (m_loader.instance());
|
||||
Q_ASSERT_X(m_pluginName == plugin->name(),Q_FUNC_INFO, "The plugin name is different to the one in the meta data.");
|
||||
Q_ASSERT_X(m_pluginName == plugin->name(), Q_FUNC_INFO, "The plugin name is different to the one in the meta data.");
|
||||
plugin->m_type = type();
|
||||
return plugin;
|
||||
}
|
||||
|
@ -142,9 +142,8 @@ const QHash<QString, PluginContainer *> PluginContainer::pluginCache(SnorePlugin
|
|||
}
|
||||
|
||||
QHash<QString, PluginContainer *> out;
|
||||
for(auto t:types()){
|
||||
if(t & type)
|
||||
{
|
||||
for (auto t : types()) {
|
||||
if (t & type) {
|
||||
out.unite(s_pluginCache.value(t));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ SnorePlugin::SnorePlugin(const QString &name) :
|
|||
if (thread() != qApp->thread()) {
|
||||
moveToThread(qApp->thread());
|
||||
}
|
||||
setDefaultValue("Enabled",true,"Whether the plugin is enabled");
|
||||
setDefaultValue("Enabled", true, "Whether the plugin is enabled");
|
||||
}
|
||||
|
||||
SnorePlugin::~SnorePlugin()
|
||||
|
@ -82,7 +82,7 @@ void SnorePlugin::setValue(const QString &key, const QVariant &value)
|
|||
void SnorePlugin::setDefaultValue(const QString &key, const QVariant &value, const QString &help)
|
||||
{
|
||||
QString pk(normaliseKey(key));
|
||||
snore()->d()->addSettingsDescription(pk,help);
|
||||
snore()->d()->addSettingsDescription(pk, help);
|
||||
if (!snore()->settings()->contains(pk)) {
|
||||
snore()->settings()->setValue(normaliseKey(key), value);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
namespace Snore
|
||||
{
|
||||
class Application;
|
||||
class SnoreCore;
|
||||
|
||||
class SNORE_EXPORT SnorePlugin : public QObject
|
||||
|
@ -56,10 +55,9 @@ public:
|
|||
PluginTypes type() const;
|
||||
const QString typeName() const;
|
||||
|
||||
|
||||
QVariant value(const QString &key) const;
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
void setDefaultValue(const QString &key, const QVariant &value,const QString &help);
|
||||
void setDefaultValue(const QString &key, const QVariant &value, const QString &help);
|
||||
|
||||
virtual PluginSettingsWidget *settingsWidget();
|
||||
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *parent ) :
|
||||
PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_snorePlugin(snorePlugin),
|
||||
m_layout(new QFormLayout),
|
||||
|
@ -33,7 +32,7 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
|
|||
{
|
||||
setLayout(m_layout);
|
||||
addRow("Type:", new QLabel(snorePlugin->typeName()));
|
||||
addRow("Enabled:",m_enabled);
|
||||
addRow("Enabled:", m_enabled);
|
||||
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ const QString PluginSettingsWidget::name() const
|
|||
|
||||
void PluginSettingsWidget::addRow(const QString &label, QWidget *widget)
|
||||
{
|
||||
m_layout->addRow(label,widget);
|
||||
m_layout->addRow(label, widget);
|
||||
}
|
||||
|
||||
void PluginSettingsWidget::loadSettings()
|
||||
|
@ -60,8 +59,8 @@ void PluginSettingsWidget::loadSettings()
|
|||
|
||||
void PluginSettingsWidget::saveSettings()
|
||||
{
|
||||
m_snorePlugin->setValue("Enabled",m_enabled->isChecked());
|
||||
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(),m_enabled->isChecked());
|
||||
m_snorePlugin->setValue("Enabled", m_enabled->isChecked());
|
||||
m_snorePlugin->snore()->setPluginEnabled(m_snorePlugin->name(), m_enabled->isChecked());
|
||||
save();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SnorePlugin;
|
||||
|
@ -38,7 +37,7 @@ public:
|
|||
|
||||
const QString name() const;
|
||||
|
||||
void addRow(const QString &label,QWidget *widget);
|
||||
void addRow(const QString &label, QWidget *widget);
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
@ -53,7 +52,6 @@ private:
|
|||
QFormLayout *m_layout;
|
||||
QCheckBox *m_enabled;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "../notification/notification.h"
|
||||
#include "../snore.h"
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "snorefrontend.h"
|
||||
#include "../snore.h"
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@
|
|||
#include "../notification/notification.h"
|
||||
#include "plugins.h"
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class Application;
|
||||
class SnoreCore;
|
||||
class SnorePlugin;
|
||||
|
||||
class SNORE_EXPORT SnoreFrontend: public SnorePlugin
|
||||
|
|
|
@ -49,11 +49,11 @@ SnoreCore::~SnoreCore()
|
|||
void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
for(SnorePlugin::PluginTypes type : PluginContainer::types()) {
|
||||
for (SnorePlugin::PluginTypes type : PluginContainer::types()) {
|
||||
if (type != SnorePlugin::ALL && types & type) {
|
||||
for(PluginContainer * info : PluginContainer::pluginCache(type).values()) {
|
||||
for (PluginContainer *info : PluginContainer::pluginCache(type).values()) {
|
||||
SnorePlugin *plugin = info->load();
|
||||
if(!plugin) {
|
||||
if (!plugin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,8 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
|||
break;
|
||||
case SnorePlugin::SECONDARY_BACKEND:
|
||||
case SnorePlugin::FRONTEND:
|
||||
case SnorePlugin::PLUGIN:
|
||||
{
|
||||
if(plugin->value("Enabled").toBool()) {
|
||||
case SnorePlugin::PLUGIN: {
|
||||
if (plugin->value("Enabled").toBool()) {
|
||||
if (!plugin->initialize()) {
|
||||
plugin->deinitialize();
|
||||
info->unload();
|
||||
|
@ -72,7 +71,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();
|
||||
continue;
|
||||
|
@ -130,9 +129,8 @@ const QStringList SnoreCore::pluginNames(SnorePlugin::PluginTypes type) const
|
|||
{
|
||||
Q_D(const SnoreCore);
|
||||
QStringList out;
|
||||
for(auto t:PluginContainer::types()){
|
||||
if(t & type)
|
||||
{
|
||||
for (auto t : PluginContainer::types()) {
|
||||
if (t & type) {
|
||||
out.append(d->m_pluginNames.value(t));
|
||||
}
|
||||
}
|
||||
|
@ -227,12 +225,11 @@ bool SnoreCore::primaryBackendSupportsRichtext()
|
|||
return d->m_notificationBackend->supportsRichtext();
|
||||
}
|
||||
|
||||
QList<PluginSettingsWidget*> SnoreCore::settingWidgets()
|
||||
QList<PluginSettingsWidget *> SnoreCore::settingWidgets()
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
QList<PluginSettingsWidget*> list;
|
||||
for(auto p:d->m_plugins)
|
||||
{
|
||||
QList<PluginSettingsWidget *> list;
|
||||
for (auto p : d->m_plugins) {
|
||||
//TODO: mem leak?
|
||||
list.append(p->settingsWidget());
|
||||
}
|
||||
|
@ -245,7 +242,8 @@ QSettings *SnoreCore::settings()
|
|||
return d->m_settings;
|
||||
}
|
||||
|
||||
const QSettings *SnoreCore::settings() const{
|
||||
const QSettings *SnoreCore::settings() const
|
||||
{
|
||||
Q_D(const SnoreCore);
|
||||
return d->m_settings;
|
||||
}
|
||||
|
@ -256,16 +254,13 @@ const QHash<QString, QString> &SnoreCore::settingsDescription() const
|
|||
return d->m_help;
|
||||
}
|
||||
|
||||
|
||||
bool SnoreCore::setPluginEnabled(const QString &pluginName, bool enable)
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
SnorePlugin *plugin = d->m_plugins.value(pluginName);
|
||||
if(!plugin->isInitialized() && enable)
|
||||
{
|
||||
if (!plugin->isInitialized() && enable) {
|
||||
plugin->initialize();
|
||||
} else if(plugin->isInitialized() && !enable)
|
||||
{
|
||||
} else if (plugin->isInitialized() && !enable) {
|
||||
plugin->deinitialize();
|
||||
}
|
||||
return plugin->isInitialized();
|
||||
|
|
|
@ -151,12 +151,11 @@ public:
|
|||
*/
|
||||
bool primaryBackendSupportsRichtext();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A list of widgets a settings dialog.
|
||||
*/
|
||||
QList<PluginSettingsWidget*> settingWidgets();
|
||||
QList<PluginSettingsWidget *> settingWidgets();
|
||||
|
||||
/**
|
||||
* @return a pointer to the global settings
|
||||
|
@ -167,7 +166,7 @@ public:
|
|||
/**
|
||||
* @return a hashmap containing the documentation of the settings keys.
|
||||
*/
|
||||
const QHash<QString,QString> &settingsDescription() const;
|
||||
const QHash<QString, QString> &settingsDescription() const;
|
||||
|
||||
/**
|
||||
* Enables or disables a plugin
|
||||
|
@ -175,12 +174,12 @@ public:
|
|||
* @param enable
|
||||
* @return whether the backend is enabled
|
||||
*/
|
||||
bool setPluginEnabled(const QString& pluginName,bool enable);
|
||||
bool setPluginEnabled(const QString &pluginName, bool enable);
|
||||
|
||||
/**
|
||||
* @return whether the backend is enabled
|
||||
*/
|
||||
bool pluginIsEnabled(const QString& pluginName) const;
|
||||
bool pluginIsEnabled(const QString &pluginName) const;
|
||||
|
||||
/**
|
||||
* @return a pointer to the private class, for internal use only.
|
||||
|
|
|
@ -63,7 +63,10 @@ public:
|
|||
|
||||
void addSettingsDescription(const QString &key, const QString &help) const;
|
||||
|
||||
static SnoreCore *snoreInstance(){ return q_ptr; }
|
||||
static SnoreCore *snoreInstance()
|
||||
{
|
||||
return q_ptr;
|
||||
}
|
||||
|
||||
signals:
|
||||
void applicationRegistered(const Snore::Application &);
|
||||
|
@ -81,14 +84,14 @@ private:
|
|||
QHash<QString, Application> m_applications;
|
||||
|
||||
QHash<SnorePlugin::PluginTypes, QStringList> m_pluginNames;
|
||||
QHash<QString, SnorePlugin*> m_plugins;
|
||||
QHash<QString, SnorePlugin *> m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
Application m_defaultApp;
|
||||
|
||||
QSettings *m_settings;
|
||||
mutable QHash<QString,QString> m_help;
|
||||
mutable QHash<QString, QString> m_help;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,8 @@ SettingsDialog::SettingsDialog(SnoreCore *snore, QWidget *parent) :
|
|||
m_snore(snore)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
for(auto widget : snore->settingWidgets())
|
||||
{
|
||||
ui->tabWidget->addTab(widget,widget->name());
|
||||
for (auto widget : snore->settingWidgets()) {
|
||||
ui->tabWidget->addTab(widget, widget->name());
|
||||
widget->loadSettings();
|
||||
m_tabs.append(widget);
|
||||
}
|
||||
|
@ -46,8 +45,7 @@ SettingsDialog::~SettingsDialog()
|
|||
|
||||
void SettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
for( auto w:m_tabs)
|
||||
{
|
||||
for (auto w : m_tabs) {
|
||||
w->saveSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Snore {
|
||||
namespace Snore
|
||||
{
|
||||
class SnoreCore;
|
||||
class PluginSettingsWidget;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class SettingsDialog;
|
||||
}
|
||||
|
||||
|
@ -34,7 +36,7 @@ class SettingsDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(Snore::SnoreCore *snore,QWidget *parent = 0);
|
||||
explicit SettingsDialog(Snore::SnoreCore *snore, QWidget *parent = 0);
|
||||
~SettingsDialog();
|
||||
|
||||
private slots:
|
||||
|
@ -43,7 +45,7 @@ private slots:
|
|||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
Snore::SnoreCore *m_snore;
|
||||
QList<Snore::PluginSettingsWidget*> m_tabs;
|
||||
QList<Snore::PluginSettingsWidget *> m_tabs;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "trayicon.h"
|
||||
#include "core/snore.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ TrayIcon::TrayIcon():
|
|||
m_alert("Default", Icon(":/root/snore.png"))
|
||||
{
|
||||
m_app.addAlert(m_alert);
|
||||
m_app.hints().setValue("tray-icon",m_trayIcon);
|
||||
m_app.hints().setValue("tray-icon", m_trayIcon);
|
||||
}
|
||||
|
||||
void TrayIcon::initConextMenu(SnoreCore *snore)
|
||||
|
@ -58,7 +58,7 @@ void TrayIcon::initConextMenu(SnoreCore *snore)
|
|||
m_trayMenu->addSeparator();
|
||||
m_backendActions = new QActionGroup(m_trayMenu);
|
||||
m_backendActions->setExclusive(true);
|
||||
for(const QString & back : m_snore->pluginNames(SnorePlugin::BACKEND)) {
|
||||
for (const QString &back : m_snore->pluginNames(SnorePlugin::BACKEND)) {
|
||||
QAction *b = m_trayMenu->addAction(back, this, SLOT(setPrimaryBackend()));
|
||||
b->setCheckable(true);
|
||||
if (back == m_snore->primaryNotificationBackend()) {
|
||||
|
|
|
@ -23,8 +23,8 @@ bool FreedesktopBackend::initialize(SnoreCore *snore)
|
|||
reply.waitForFinished();
|
||||
QStringList caps = reply.value();
|
||||
setSupportsRichtext(caps.contains("body-markup"));
|
||||
connect(m_interface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString)));
|
||||
connect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
|
||||
connect(m_interface, SIGNAL(ActionInvoked(uint, QString)), this, SLOT(slotActionInvoked(uint, QString)));
|
||||
connect(m_interface, SIGNAL(NotificationClosed(uint, uint)), this , SLOT(slotNotificationClosed(uint, uint)));
|
||||
|
||||
return SnoreBackend::initialize(snore);
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ bool FreedesktopBackend::initialize(SnoreCore *snore)
|
|||
bool FreedesktopBackend::deinitialize()
|
||||
{
|
||||
if (SnoreBackend::deinitialize()) {
|
||||
disconnect(m_interface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString)));
|
||||
disconnect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
|
||||
disconnect(m_interface, SIGNAL(ActionInvoked(uint, QString)), this, SLOT(slotActionInvoked(uint, QString)));
|
||||
disconnect(m_interface, SIGNAL(NotificationClosed(uint, uint)), this , SLOT(slotNotificationClosed(uint, uint)));
|
||||
m_interface->deleteLater();
|
||||
m_interface = NULL;
|
||||
return true;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "core/snore.h"
|
||||
#include "core/snore_p.h"
|
||||
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
GrowlBackend *GrowlBackend::s_instance = NULL;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "snorenotifier.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) :
|
||||
|
@ -35,11 +34,11 @@ NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) :
|
|||
|
||||
setFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus
|
||||
#ifdef Q_OS_MAC
|
||||
| Qt::SubWindow
|
||||
| Qt::SubWindow
|
||||
#else
|
||||
| Qt::ToolTip
|
||||
| Qt::ToolTip
|
||||
#endif
|
||||
);
|
||||
);
|
||||
|
||||
// setFocusPolicy(Qt::NoFocus);
|
||||
// setAttribute(Qt::WA_ShowWithoutActivating, true);
|
||||
|
@ -94,7 +93,6 @@ void NotifyWidget::display(const Notification ¬ification)
|
|||
Q_ARG(QVariant, notification.isUpdate()));
|
||||
}
|
||||
|
||||
|
||||
bool NotifyWidget::acquire()
|
||||
{
|
||||
bool out = false;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "core/notification/notification_p.h"
|
||||
#include "core/snore_p.h"
|
||||
|
||||
|
||||
#include <QThread>
|
||||
|
||||
using namespace Snore;
|
||||
|
@ -125,7 +124,7 @@ void SnoreNotifier::slotProcessQueue()
|
|||
void SnoreNotifier::setup()
|
||||
{
|
||||
for (int i = 0; i < m_widgets.size(); ++i) {
|
||||
NotifyWidget *w = new NotifyWidget(i,this);
|
||||
NotifyWidget *w = new NotifyWidget(i, this);
|
||||
m_widgets[i] = w;
|
||||
connect(w, SIGNAL(dismissed()), this, SLOT(slotDismissed()));
|
||||
connect(w, SIGNAL(invoked()), this, SLOT(slotInvoked()));
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
using namespace Snore;
|
||||
|
||||
SnoreNotifierSettings::SnoreNotifierSettings(SnorePlugin *snore, QWidget *parent) :
|
||||
PluginSettingsWidget(snore,parent),
|
||||
PluginSettingsWidget(snore, parent),
|
||||
m_comboBox(new QComboBox)
|
||||
{
|
||||
|
||||
m_comboBox->addItem("TopLeftCorner",Qt::TopLeftCorner);
|
||||
m_comboBox->addItem("TopRightCorner",Qt::TopRightCorner);
|
||||
m_comboBox->addItem("BottomLeftCorner",Qt::BottomLeftCorner);
|
||||
m_comboBox->addItem("BottomRightCorner",Qt::BottomRightCorner);
|
||||
m_comboBox->addItem("TopLeftCorner", Qt::TopLeftCorner);
|
||||
m_comboBox->addItem("TopRightCorner", Qt::TopRightCorner);
|
||||
m_comboBox->addItem("BottomLeftCorner", Qt::BottomLeftCorner);
|
||||
m_comboBox->addItem("BottomRightCorner", Qt::BottomRightCorner);
|
||||
addRow("Position:", m_comboBox);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
#include "plugins/pluginsettingswidget.h"
|
||||
|
||||
namespace Snore{
|
||||
namespace Snore
|
||||
{
|
||||
class SnorePlugin;
|
||||
}
|
||||
class QComboBox;
|
||||
|
|
|
@ -36,7 +36,7 @@ void SnoreToast::slotNotify(Notification notification)
|
|||
QProcess *p = new QProcess(this);
|
||||
p->setReadChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
|
||||
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotToastNotificationClosed(int, QProcess::ExitStatus)));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
|
||||
QStringList arguements;
|
||||
|
@ -77,7 +77,7 @@ void SnoreToast::slotRegisterApplication(const Application &application)
|
|||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
|
||||
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int, QProcess::ExitStatus)));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void SnoreToast::slotCloseNotification(Notification notification)
|
|||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
|
||||
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int, QProcess::ExitStatus)));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ TrayIconNotifer::~TrayIconNotifer()
|
|||
|
||||
bool TrayIconNotifer::deinitialize()
|
||||
{
|
||||
if(SnoreBackend::deinitialize()) {
|
||||
if (SnoreBackend::deinitialize()) {
|
||||
m_currentlyDisplaying = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ bool TrayIconNotifer::deinitialize()
|
|||
void TrayIconNotifer::slotNotify(Notification notification)
|
||||
{
|
||||
QSystemTrayIcon *icon = trayIcon(notification.application());
|
||||
if(icon) {
|
||||
if (icon) {
|
||||
m_notificationQue.append(notification);
|
||||
displayNotification(icon);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void TrayIconNotifer::slotNotify(Notification notification)
|
|||
void TrayIconNotifer::slotCloseNotification(Notification n)
|
||||
{
|
||||
QSystemTrayIcon *icon = trayIcon(n.application());
|
||||
if(icon) {
|
||||
if (icon) {
|
||||
snoreDebug(SNORE_DEBUG) << n;
|
||||
m_currentlyDisplaying = false;
|
||||
displayNotification(icon);
|
||||
|
@ -49,7 +49,7 @@ void TrayIconNotifer::slotCloseNotification(Notification n)
|
|||
void TrayIconNotifer::slotRegisterApplication(const Application &application)
|
||||
{
|
||||
QSystemTrayIcon *icon = trayIcon(application);
|
||||
if(icon) {
|
||||
if (icon) {
|
||||
connect(icon, SIGNAL(messageClicked()), this, SLOT(actionInvoked()));
|
||||
}
|
||||
}
|
||||
|
@ -57,15 +57,15 @@ void TrayIconNotifer::slotRegisterApplication(const Application &application)
|
|||
void TrayIconNotifer::slotDeregisterApplication(const Application &application)
|
||||
{
|
||||
QSystemTrayIcon *icon = trayIcon(application);
|
||||
if(icon) {
|
||||
if (icon) {
|
||||
disconnect(icon, SIGNAL(messageClicked()), this, SLOT(actionInvoked()));
|
||||
}
|
||||
}
|
||||
|
||||
QSystemTrayIcon *TrayIconNotifer::trayIcon(const Application &app)
|
||||
{
|
||||
if(app.constHints().contains("tray-icon")) {
|
||||
return app.constHints().value("tray-icon").value<QSystemTrayIcon*>();
|
||||
if (app.constHints().contains("tray-icon")) {
|
||||
return app.constHints().value("tray-icon").value<QSystemTrayIcon *>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace Snore
|
||||
{
|
||||
class SnoreCore;
|
||||
}
|
||||
|
||||
class QSystemTrayIcon;
|
||||
|
@ -31,7 +30,6 @@ private:
|
|||
uint m_displayed;
|
||||
bool m_currentlyDisplaying;
|
||||
|
||||
|
||||
private slots:
|
||||
void displayNotification(QSystemTrayIcon *icon);
|
||||
void actionInvoked();
|
||||
|
|
|
@ -32,10 +32,10 @@ public:
|
|||
FreedesktopFrontend();
|
||||
~FreedesktopFrontend();
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
void actionInvoked(Snore::Notification notification) override;
|
||||
void notificationClosed(Snore::Notification notification) override;
|
||||
void actionInvoked(Snore::Notification notification) override;
|
||||
void notificationClosed(Snore::Notification notification) override;
|
||||
|
||||
uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout);
|
||||
void CloseNotification(uint id);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
using namespace Snore;
|
||||
|
||||
Sound::Sound():
|
||||
SnoreSecondaryBackend("Sound",false),
|
||||
SnoreSecondaryBackend("Sound", false),
|
||||
m_player(new QMediaPlayer(this))
|
||||
{
|
||||
m_player->setVolume(50);
|
||||
|
@ -48,11 +48,11 @@ PluginSettingsWidget *Sound::settingsWidget()
|
|||
void Sound::slotNotify(Snore::Notification notification)
|
||||
{
|
||||
QString sound = notification.hints().value("sound").toString();
|
||||
if(sound.isEmpty()) {
|
||||
if (sound.isEmpty()) {
|
||||
sound = value("Sound").toString();
|
||||
}
|
||||
snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound;
|
||||
if(!sound.isEmpty()) {
|
||||
if (!sound.isEmpty()) {
|
||||
m_player->setMedia(QUrl::fromLocalFile(sound));
|
||||
snoreDebug(SNORE_DEBUG) << "SoundFile:" << m_player->media().canonicalUrl();
|
||||
m_player->play();
|
||||
|
|
|
@ -35,7 +35,7 @@ public slots:
|
|||
void slotNotify(Snore::Notification notification) override;
|
||||
|
||||
private:
|
||||
class QMediaPlayer* m_player;
|
||||
class QMediaPlayer *m_player;
|
||||
};
|
||||
|
||||
#endif // SOUND_H
|
||||
|
|
|
@ -22,16 +22,15 @@
|
|||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
|
||||
PluginSettingsWidget(snorePlugin,parent),
|
||||
PluginSettingsWidget(snorePlugin, parent),
|
||||
m_lineEdit(new QLineEdit)
|
||||
{
|
||||
addRow("Sound File:",m_lineEdit);
|
||||
addRow("Sound File:", m_lineEdit);
|
||||
QPushButton *button = new QPushButton("Select a sound File");
|
||||
connect(button, &QPushButton::clicked, [this](){
|
||||
connect(button, &QPushButton::clicked, [this]() {
|
||||
QFileDialog dialog;
|
||||
dialog.setNameFilter("All Audio files (*.mp3 *.wav *.ogg)");
|
||||
dialog.setFilter(QDir::Files);
|
||||
|
@ -39,7 +38,7 @@ SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
|
|||
dialog.exec();
|
||||
m_lineEdit->setText(dialog.selectedFiles().first());
|
||||
});
|
||||
addRow("",button);
|
||||
addRow("", button);
|
||||
}
|
||||
|
||||
SoundSettings::~SoundSettings()
|
||||
|
@ -53,6 +52,6 @@ void SoundSettings::load()
|
|||
|
||||
void SoundSettings::save()
|
||||
{
|
||||
m_snorePlugin->setValue("Sound",m_lineEdit->text());
|
||||
m_snorePlugin->setValue("Sound", m_lineEdit->text());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "plugins/pluginsettingswidget.h"
|
||||
|
||||
|
||||
class QLineEdit;
|
||||
class SoundSettings : public Snore::PluginSettingsWidget
|
||||
{
|
||||
|
@ -20,7 +19,6 @@ public:
|
|||
private:
|
||||
QLineEdit *m_lineEdit;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SOUNDSETTINGS_H
|
||||
|
|
|
@ -41,7 +41,7 @@ void Toasty::slotNotify(Notification notification)
|
|||
QString key = value("DeviceID").toString();
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
QNetworkRequest request(QString("http://api.supertoasty.com/notify/%1").arg(key));
|
||||
QHttpMultiPart *mp = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
QHttpPart title;
|
||||
|
@ -63,7 +63,7 @@ void Toasty::slotNotify(Notification notification)
|
|||
|
||||
Icon sIcon = notification.icon();
|
||||
QSize iconSize = notification.icon().image().size();
|
||||
if (iconSize.height() > 128 || iconSize.width() > 128 ) {
|
||||
if (iconSize.height() > 128 || iconSize.width() > 128) {
|
||||
sIcon = sIcon.scaled(QSize(128, 128));
|
||||
}
|
||||
icon.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QString("form-data; name=\"image\"; filename=\"%1\"").arg(sIcon.localUrl())));
|
||||
|
@ -77,7 +77,7 @@ void Toasty::slotNotify(Notification notification)
|
|||
mp->setParent(reply);
|
||||
file->setParent(reply);
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply](){
|
||||
connect(reply, &QNetworkReply::finished, [reply]() {
|
||||
snoreDebug(SNORE_DEBUG) << reply->error();
|
||||
snoreDebug(SNORE_DEBUG) << reply->readAll();
|
||||
reply->close();
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include <QLineEdit>
|
||||
|
||||
ToastySettings::ToastySettings(Snore::SnorePlugin *plugin, QWidget *parent) :
|
||||
Snore::PluginSettingsWidget(plugin,parent),
|
||||
Snore::PluginSettingsWidget(plugin, parent),
|
||||
m_lineEdit(new QLineEdit)
|
||||
{
|
||||
addRow("Device ID:",m_lineEdit);
|
||||
addRow("Device ID:", m_lineEdit);
|
||||
}
|
||||
|
||||
ToastySettings::~ToastySettings()
|
||||
|
@ -39,5 +39,5 @@ void ToastySettings::load()
|
|||
|
||||
void ToastySettings::save()
|
||||
{
|
||||
m_snorePlugin->setValue("DeviceID",m_lineEdit->text());
|
||||
m_snorePlugin->setValue("DeviceID", m_lineEdit->text());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue