mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-09 16:15:45 +00:00
use KDE Frameworks compile settings
This commit is contained in:
parent
a8f7d93523
commit
ba72d65420
@ -12,8 +12,8 @@ set_package_properties(ECM PROPERTIES
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules )
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECompilerSettings)
|
||||
include(KDECMakeSettings)
|
||||
include(KDEFrameworkCompilerSettings)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
|
||||
|
@ -20,14 +20,14 @@ public:
|
||||
}
|
||||
|
||||
|
||||
QString htmlTestString = QString("<i>Italic A</i><br>"
|
||||
QString htmlTestString = QLatin1String("<i>Italic A</i><br>"
|
||||
"<i>Italic B</i><br>"
|
||||
"<b>Bold</b><br>"
|
||||
"<u>Underline</u><br>"
|
||||
"<font color=\"blue\">Font</font><br>"
|
||||
"<&><br>"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a><br>");
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void benchmarkUtilsToHtml();
|
||||
void benchmarkUtilsToHtmlAllMarkup();
|
||||
void benchmarkUtilsToPlain();
|
||||
@ -38,14 +38,14 @@ void benchmarkUtilsToPlain();
|
||||
void SnoreBenchmark::benchmarkUtilsToHtml(){
|
||||
|
||||
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QString("Italic A\n"
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"Website\n"));
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QString("Italic A\n"
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
|
@ -8,8 +8,8 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("SnoreNotify");
|
||||
app.setOrganizationName("SnoreNotify");
|
||||
app.setApplicationName(QLatin1String("SnoreNotify"));
|
||||
app.setOrganizationName(QLatin1String("SnoreNotify"));
|
||||
app.setApplicationVersion(Snore::Version::version());
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
using namespace Snore;
|
||||
|
||||
TrayIcon::TrayIcon():
|
||||
m_trayIcon(new QSystemTrayIcon(QIcon(":/root/snore.png")))
|
||||
m_trayIcon(new QSystemTrayIcon(QIcon(QLatin1String(":/root/snore.png"))))
|
||||
{
|
||||
SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", true);
|
||||
SnoreCorePrivate::instance()->defaultApplication().hints().setValue("tray-icon", QVariant::fromValue(QPointer<QSystemTrayIcon>(m_trayIcon)));
|
||||
@ -68,18 +68,18 @@ void TrayIcon::initConextMenu()
|
||||
|
||||
m_trayIcon->setVisible(true);
|
||||
|
||||
m_trayMenu = new QMenu("SnoreNotify");
|
||||
QString version = QString("SnoreNotify %1").arg(Version::version());
|
||||
m_trayMenu = new QMenu(QLatin1String("SnoreNotify"));
|
||||
QString version = QLatin1String("SnoreNotify ") + Version::version();
|
||||
if (!Version::revision().isEmpty()) {
|
||||
version += QString("-%1").arg(Version::revision());
|
||||
version += QLatin1String("-") + Version::revision();
|
||||
}
|
||||
m_trayMenu->addAction(version);
|
||||
m_trayMenu->addSeparator();
|
||||
m_trayMenu->addAction("Test Notification", this, SLOT(slotTestNotification()));
|
||||
m_trayMenu->addAction(tr("Display Test Notification"), this, SLOT(slotTestNotification()));
|
||||
m_trayMenu->addSeparator();
|
||||
m_trayMenu->addAction("Settings", this, SLOT(slotSettings()));
|
||||
m_trayMenu->addAction(tr("Settings"), this, SLOT(slotSettings()));
|
||||
m_trayMenu->addSeparator();
|
||||
m_trayMenu->addAction("Exit", qApp, SLOT(quit()));
|
||||
m_trayMenu->addAction(tr("Exit"), qApp, SLOT(quit()));
|
||||
|
||||
m_trayIcon->setContextMenu(m_trayMenu);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
QActionGroup *m_backendActions;
|
||||
Snore::SettingsDialog *m_settings;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotTestNotification();
|
||||
void slotSettings();
|
||||
};
|
||||
|
@ -19,10 +19,12 @@
|
||||
#include "alert.h"
|
||||
#include "alert_p.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
Alert::Alert() :
|
||||
d(NULL)
|
||||
d(nullptr)
|
||||
{}
|
||||
|
||||
Alert::Alert(const QString &name, const Icon &icon, bool active):
|
||||
|
@ -29,7 +29,7 @@ Application::Application(const QString &name, const Icon &icon) :
|
||||
d(new ApplicationData(name, icon))
|
||||
|
||||
{
|
||||
addAlert(Alert("Default", icon));
|
||||
addAlert(Alert(QObject::tr("Default"), icon));
|
||||
}
|
||||
|
||||
Application::Application(const Application &other):
|
||||
@ -50,7 +50,7 @@ Application::~Application()
|
||||
|
||||
void Application::addAlert(const Alert &alert)
|
||||
{
|
||||
d->m_alerts.insert(alert.name(), alert);
|
||||
d->m_alerts.insert(alert.name().toUtf8(), alert);
|
||||
}
|
||||
|
||||
QString Application::name() const
|
||||
@ -63,14 +63,14 @@ const Icon &Application::icon()const
|
||||
return d->m_icon;
|
||||
}
|
||||
|
||||
const QHash<QString, Alert> &Application::alerts() const
|
||||
const QHash<QByteArray, Alert> &Application::alerts() const
|
||||
{
|
||||
return d->m_alerts;
|
||||
}
|
||||
|
||||
const Alert Application::defaultAlert() const
|
||||
{
|
||||
return d->m_alerts["Default"];
|
||||
return d->m_alerts.value("Default");
|
||||
}
|
||||
|
||||
bool Application::isValid() const
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
*
|
||||
* @return a QHash with the Alers registered with this Application.
|
||||
*/
|
||||
const QHash<QString, Alert> &alerts() const;
|
||||
const QHash<QByteArray, Alert> &alerts() const;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "application_p.h"
|
||||
#include "snore_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
@ -25,9 +26,9 @@ ApplicationData::ApplicationData(const QString &name, const Icon &icon):
|
||||
m_icon(icon)
|
||||
{
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "invalid name detected");
|
||||
m_hint.setValue("pushover-token", "aFB1TPCyZkkr7mubCGEKy5vJEWak9t");
|
||||
m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t"));
|
||||
m_hint.setValue("use-markup", false);
|
||||
m_hints.setValue("silent", SnoreCore::instance().value("Silent", LOCAL_SETTING));
|
||||
m_hint.setValue("silent", SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING));
|
||||
}
|
||||
|
||||
ApplicationData::~ApplicationData()
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
QString m_name;
|
||||
Icon m_icon;
|
||||
QHash<QString, Alert> m_alerts;
|
||||
QHash<QByteArray, Alert> m_alerts;
|
||||
Hint m_hint;
|
||||
};
|
||||
|
||||
|
@ -24,63 +24,55 @@ Hint::Hint()
|
||||
{
|
||||
}
|
||||
|
||||
void Hint::setValue(const QString &key, const QVariant &value)
|
||||
void Hint::setValue(const QByteArray & key, const QVariant &value)
|
||||
{
|
||||
m_data.insert(key.toLower(), value);
|
||||
m_data.insert(key, value);
|
||||
}
|
||||
|
||||
QVariant Hint::value(const QString &k) const
|
||||
QVariant Hint::value(const QByteArray &key) const
|
||||
{
|
||||
return m_data.value(k.toLower());
|
||||
return m_data.value(key);
|
||||
}
|
||||
|
||||
QVariant Hint::take(const QString &key)
|
||||
QVariant Hint::take(const QByteArray & key)
|
||||
{
|
||||
return m_data.take(key.toLower());
|
||||
return m_data.take(key);
|
||||
}
|
||||
|
||||
bool Hint::contains(const QString &key) const
|
||||
bool Hint::contains(const QByteArray & key) const
|
||||
{
|
||||
return m_data.contains(key.toLower());
|
||||
return m_data.contains(key);
|
||||
}
|
||||
|
||||
void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value) const
|
||||
void Hint::setPrivateValue(const void *owner, const QByteArray & key, const QVariant &value)
|
||||
{
|
||||
QPair<quintptr, QString> pk((quintptr)owner, key.toLower());
|
||||
m_privateData.insert(pk, value);
|
||||
m_privateData.insert(qMakePair<const quintptr,const QByteArray>((quintptr)owner,key), value);
|
||||
}
|
||||
|
||||
QVariant Hint::privateValue(const void *owner, const QString &k) const
|
||||
QVariant Hint::privateValue(const void *owner, const QByteArray &key) const
|
||||
{
|
||||
QPair<quintptr, QString> key((quintptr)owner, k.toLower());
|
||||
return m_privateData.value(key);
|
||||
return m_privateData.value(qMakePair<const quintptr,const QByteArray>((quintptr)owner,key));
|
||||
}
|
||||
|
||||
bool Hint::containsPrivateValue(const void *owner, const QString &key) const
|
||||
bool Hint::containsPrivateValue(const void *owner, const QByteArray & key) const
|
||||
{
|
||||
QPair<quintptr, QString> pk((quintptr)owner, key.toLower());
|
||||
return m_privateData.contains(pk);
|
||||
return m_privateData.contains(qMakePair<const quintptr,const QByteArray>((quintptr)owner,key));
|
||||
}
|
||||
|
||||
QVariant Hint::takePrivateValue(const void *owner, const QString &key)
|
||||
QVariant Hint::takePrivateValue(const void *owner, const QByteArray & key)
|
||||
{
|
||||
QPair<quintptr, QString> pk((quintptr)owner, key.toLower());
|
||||
return m_privateData.take(pk);
|
||||
return m_privateData.take(qMakePair<const quintptr,const QByteArray>((quintptr)owner,key));
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const Snore::Hint &hint)
|
||||
{
|
||||
debug << "Snore::Hint(";
|
||||
for (QVariantHash::const_iterator it = hint.m_data.constBegin(); it != hint.m_data.constEnd(); ++it) {
|
||||
if (it != hint.m_data.constBegin()) {
|
||||
debug << ", ";
|
||||
}
|
||||
for (auto it = hint.m_data.cbegin(); it != hint.m_data.cend(); ++it) {
|
||||
debug << ", ";
|
||||
debug << "(" << it.key() << ", " << it.value();
|
||||
}
|
||||
for (QHash< QPair<quintptr, QString>, QVariant>::const_iterator it = hint.m_privateData.constBegin(); it != hint.m_privateData.constEnd(); ++it) {
|
||||
if (it != hint.m_privateData.constBegin()) {
|
||||
debug << ", ";
|
||||
}
|
||||
for (auto it = hint.m_privateData.cbegin(); it != hint.m_privateData.cend(); ++it) {
|
||||
debug << ", ";
|
||||
debug << "(" << it.key() << ", " << it.value();
|
||||
}
|
||||
debug << ")" ;
|
||||
|
@ -35,7 +35,7 @@ namespace Snore
|
||||
{
|
||||
/**
|
||||
* Hint contains extra information accesible by key.
|
||||
* The keys are case insensitive.
|
||||
* The keys are case sensitive.
|
||||
*/
|
||||
|
||||
class SNORE_EXPORT Hint
|
||||
@ -48,28 +48,28 @@ public:
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
void setValue(const QByteArray & key, const QVariant &value);
|
||||
|
||||
|
||||
/**
|
||||
* The associated value of the key.
|
||||
* @param key the key
|
||||
*/
|
||||
QVariant value(const QString &key) const;
|
||||
QVariant value(const QByteArray & key) const;
|
||||
|
||||
|
||||
/**
|
||||
* The associated value of the key.
|
||||
* @param key the key
|
||||
*/
|
||||
QVariant take(const QString &key);
|
||||
QVariant take(const QByteArray & key);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key the key
|
||||
* @return whether the key is set
|
||||
*/
|
||||
bool contains(const QString &key) const;
|
||||
bool contains(const QByteArray & key) const;
|
||||
|
||||
/**
|
||||
* Sets the value for the key depending on the owner
|
||||
@ -77,14 +77,14 @@ public:
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void setPrivateValue(const void *owner, const QString &key, const QVariant &value) const;
|
||||
void setPrivateValue(const void *owner, const QByteArray & key, const QVariant &value);
|
||||
|
||||
/**
|
||||
* The associated value of the key if present.
|
||||
* @param owner the owner
|
||||
* @param key the key
|
||||
*/
|
||||
QVariant privateValue(const void *owner, const QString &key) const;
|
||||
QVariant privateValue(const void *owner, const QByteArray & key) const;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -92,9 +92,7 @@ public:
|
||||
* @param key the key
|
||||
* @return whether the key is set
|
||||
*/
|
||||
bool containsPrivateValue(const void *owner, const QString &key) const;
|
||||
|
||||
|
||||
bool containsPrivateValue(const void *owner, const QByteArray & key) const;
|
||||
|
||||
/**
|
||||
* The associated value of the key if present.
|
||||
@ -102,11 +100,11 @@ public:
|
||||
* @param key the key
|
||||
* @return whether the key is set
|
||||
*/
|
||||
QVariant takePrivateValue(const void *owner, const QString &key);
|
||||
QVariant takePrivateValue(const void *owner, const QByteArray &key);
|
||||
|
||||
private:
|
||||
QVariantHash m_data;
|
||||
mutable QHash<QPair<quintptr, QString>, QVariant> m_privateData;
|
||||
QHash<QByteArray, QVariant> m_data;
|
||||
QHash<QPair<quintptr, QByteArray>, QVariant> m_privateData;
|
||||
|
||||
friend SNORE_EXPORT QDebug(::operator<<)(QDebug, const Snore::Hint &);
|
||||
|
||||
|
@ -36,11 +36,13 @@ static void init()
|
||||
debugLevel = qgetenv("LIBSNORE_DEBUG_LVL").toInt();
|
||||
if (qgetenv("LIBSNORE_LOG_TO_FILE").toInt() == 1) {
|
||||
|
||||
QString name = QString("%1/libsnore/%2-log.txt").arg(QDir::tempPath(), qApp->applicationName().isEmpty() ? QString::number(qApp->applicationPid()) : qApp->applicationName());
|
||||
QString name = QDir::tempPath() + QLatin1String("/libsnore/") +
|
||||
(qApp->applicationName().isEmpty() ? QString::number(qApp->applicationPid()) : qApp->applicationName()) +
|
||||
QLatin1String("-log.txt");
|
||||
if (!qgetenv("LIBSNORE_LOGFILE").isNull()) {
|
||||
name = QString(qgetenv("LIBSNORE_LOGFILE"));
|
||||
name = QString::fromUtf8(qgetenv("LIBSNORE_LOGFILE"));
|
||||
} else {
|
||||
QDir::temp().mkpath("libsnore");
|
||||
QDir::temp().mkpath(QLatin1String("libsnore"));
|
||||
}
|
||||
std::cout << "Started logging to " << name.toLocal8Bit().constData() << std::endl;
|
||||
|
||||
|
@ -35,6 +35,12 @@ QByteArray Icon::dataFromImage(const QImage &image)
|
||||
return data;
|
||||
}
|
||||
|
||||
Icon Icon::defaultIcon()
|
||||
{
|
||||
static Icon icon(QLatin1String(":/root/snore.png"));
|
||||
return icon;
|
||||
}
|
||||
|
||||
Icon::Icon() :
|
||||
d(NULL)
|
||||
{
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
|
||||
static QByteArray dataFromImage(const QImage &image);
|
||||
|
||||
static Icon defaultIcon();
|
||||
|
||||
Icon();
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ IconData::IconData(const QString &url):
|
||||
m_hash(Utils::computeMD5Hash(m_url.toLatin1())),
|
||||
m_localUrl(createLocalFileName(m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(m_url.startsWith(":/") || m_url.startsWith("qrc:/"))
|
||||
m_isResource(m_url.startsWith(QLatin1String(":/")) || m_url.startsWith(QLatin1String("qrc:/")))
|
||||
{
|
||||
if (!m_isResource && QFile::exists(url)) {
|
||||
m_isLocalFile = true;
|
||||
@ -47,7 +47,7 @@ IconData::IconData(const QString &url):
|
||||
m_isDownloading = true;
|
||||
snoreDebug(SNORE_DEBUG) << "Downloading:" << m_url;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager();
|
||||
QNetworkRequest request(m_url);
|
||||
QNetworkRequest request(QUrl::fromUserInput(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 << "%";
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
|
||||
inline QString createLocalFileName(const QString &hash)
|
||||
{
|
||||
return QString("%1/%2.png").arg(SnoreCorePrivate::tempPath(), hash);
|
||||
return SnoreCorePrivate::tempPath() + QLatin1Char('/') + hash + QLatin1String(".png");
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ const Action &Notification::actionInvoked() const
|
||||
return d->m_actionInvoked;
|
||||
}
|
||||
|
||||
const Application &Notification::application() const
|
||||
Application &Notification::application() const
|
||||
{
|
||||
return d->m_application;
|
||||
}
|
||||
@ -184,7 +184,7 @@ NotificationData *Notification::data()
|
||||
|
||||
int Notification::defaultTimeout()
|
||||
{
|
||||
return SnoreCore::instance().value("Timeout", LOCAL_SETTING).toInt();
|
||||
return SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt();
|
||||
}
|
||||
|
||||
QDataStream &operator<< (QDataStream &stream, const Notification ¬i)
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
*
|
||||
* @return the associated application
|
||||
*/
|
||||
const Application &application() const;
|
||||
Application &application() const;
|
||||
|
||||
/**
|
||||
* Returns the title of the notification.
|
||||
|
@ -98,8 +98,8 @@ void PluginContainer::updatePluginCache()
|
||||
QStringList(pluginFileFilters(type)), QDir::Files)) {
|
||||
snoreDebug(SNORE_DEBUG) << "adding" << file.absoluteFilePath();
|
||||
QPluginLoader loader(file.absoluteFilePath());
|
||||
QJsonObject data = loader.metaData()["MetaData"].toObject();
|
||||
QString name = data.value("name").toString();
|
||||
QJsonObject data = loader.metaData()[QLatin1String("MetaData")].toObject();
|
||||
QString name = data.value(QLatin1String("name")).toString();
|
||||
if (!name.isEmpty()) {
|
||||
PluginContainer *info = new PluginContainer(file.fileName(), name, type);
|
||||
s_pluginCache[type].insert(name, info);
|
||||
@ -146,12 +146,13 @@ const QDir &PluginContainer::pluginDir()
|
||||
appDir = dir.absolutePath();
|
||||
}
|
||||
#endif
|
||||
QString suffix = QLatin1String("/libsnore") + QLatin1String(SNORE_SUFFIX);
|
||||
list << appDir
|
||||
<< QLatin1String(LIBSNORE_PLUGIN_PATH)
|
||||
<< QString("%1/libsnore" SNORE_SUFFIX).arg(appDir)
|
||||
<< QString("%1/../lib/plugins/libsnore" SNORE_SUFFIX).arg(appDir)
|
||||
<< QString("%1/../lib64/plugins/libsnore" SNORE_SUFFIX).arg(appDir);
|
||||
foreach(const QString & p, list) {
|
||||
<< appDir + suffix
|
||||
<< appDir + QLatin1String("/../lib/plugins") + suffix
|
||||
<< appDir + QLatin1String("/../lib64/plugins") + suffix;
|
||||
for(const QString & p : list) {
|
||||
path = QDir(p);
|
||||
|
||||
if (!path.entryInfoList(pluginFileFilters()).isEmpty()) {
|
||||
|
@ -68,8 +68,8 @@ private:
|
||||
static inline const QStringList pluginFileFilters()
|
||||
{
|
||||
QStringList out;
|
||||
foreach(const QString extention, pluginExtentions()) {
|
||||
out << QString("libsnore_*.%1").arg(extention);
|
||||
for(const QString &extention : pluginExtentions()) {
|
||||
out << QString(QLatin1String("libsnore_*.%1")).arg(extention);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -77,8 +77,8 @@ private:
|
||||
static inline const QStringList pluginFileFilters(Snore::SnorePlugin::PluginTypes type)
|
||||
{
|
||||
QStringList out;
|
||||
foreach(const QString extention, pluginExtentions()) {
|
||||
out << QString("libsnore_%1_*.%2").arg(SnorePlugin::typeToString(type).toLower(), extention);
|
||||
for(const QString &extention : pluginExtentions()) {
|
||||
out << QString(QLatin1String("libsnore_%1_*.%2")).arg(SnorePlugin::typeToString(type).toLower(), extention);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ SnorePlugin::~SnorePlugin()
|
||||
|
||||
bool SnorePlugin::initialize()
|
||||
{
|
||||
setDefaultValue("Enabled", false, LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("Enabled"), false, LOCAL_SETTING);
|
||||
if (m_initialized) {
|
||||
qFatal("Something went wrong, plugin %s is already initialized", this->name().toLatin1().constData());
|
||||
return false;
|
||||
@ -85,7 +85,7 @@ Snore::PluginSettingsWidget *SnorePlugin::settingsWidget()
|
||||
|
||||
QString SnorePlugin::normaliseKey(const QString &key) const
|
||||
{
|
||||
return QString("%1/%2.%3").arg(name(), key, settingsVersion());
|
||||
return name() + QLatin1Char('/') + key + QLatin1Char('.') + settingsVersion();
|
||||
}
|
||||
|
||||
const QString &SnorePlugin::name() const
|
||||
@ -107,7 +107,7 @@ const QString SnorePlugin::typeName() const
|
||||
|
||||
QString SnorePlugin::settingsVersion() const
|
||||
{
|
||||
return "v1";
|
||||
return QLatin1String("v1");
|
||||
}
|
||||
|
||||
bool SnorePlugin::deinitialize()
|
||||
@ -122,12 +122,12 @@ bool SnorePlugin::deinitialize()
|
||||
|
||||
SnorePlugin::PluginTypes SnorePlugin::typeFromString(const QString &t)
|
||||
{
|
||||
return (SnorePlugin::PluginTypes)SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).keyToValue(t.toUpper().toLatin1());
|
||||
return (SnorePlugin::PluginTypes)SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).keyToValue(t.toUpper().toLatin1().constData());
|
||||
}
|
||||
|
||||
QString SnorePlugin::typeToString(const SnorePlugin::PluginTypes t)
|
||||
{
|
||||
return SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).valueToKey(t);
|
||||
return QString::fromLatin1(SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType")).valueToKey(t));
|
||||
}
|
||||
|
||||
QList<SnorePlugin::PluginTypes> SnorePlugin::types()
|
||||
|
@ -56,7 +56,7 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget)
|
||||
void PluginSettingsWidget::loadSettings()
|
||||
{
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
m_enabled->setChecked(m_snorePlugin->value("Enabled", LOCAL_SETTING).toBool());
|
||||
m_enabled->setChecked(m_snorePlugin->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool());
|
||||
}
|
||||
load();
|
||||
}
|
||||
@ -64,7 +64,7 @@ void PluginSettingsWidget::loadSettings()
|
||||
void PluginSettingsWidget::saveSettings()
|
||||
{
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
m_snorePlugin->setValue("Enabled", m_enabled->isChecked(), LOCAL_SETTING);
|
||||
m_snorePlugin->setValue(QLatin1String("Enabled"), m_enabled->isChecked(), LOCAL_SETTING);
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ public:
|
||||
virtual bool canCloseNotification() const;
|
||||
virtual bool canUpdateNotification() const;
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void notificationClosed(Snore::Notification);
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void slotRegisterApplication(const Snore::Application &application);
|
||||
virtual void slotDeregisterApplication(const Snore::Application &application);
|
||||
virtual void slotNotify(Snore::Notification notification) = 0;
|
||||
virtual void slotCloseNotification(Snore::Notification notification);
|
||||
|
||||
protected slots:
|
||||
protected Q_SLOTS:
|
||||
void slotNotificationDisplayed(Notification notification);
|
||||
void slotNotificationActionInvoked(Notification notification, const Action &action = Action());
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
public slots:
|
||||
public Q_SLOT:
|
||||
virtual void slotNotify(Snore::Notification notification);
|
||||
virtual void slotNotificationDisplayed(Snore::Notification notification);
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void slotActionInvoked(Snore::Notification notification);
|
||||
virtual void slotNotificationClosed(Snore::Notification notification);
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ SettingsDialog::~SettingsDialog()
|
||||
|
||||
void SettingsDialog::initTabs()
|
||||
{
|
||||
SnorePlugin::PluginTypes types = SnoreCore::instance().value("PluginTypes", LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
|
||||
SnorePlugin::PluginTypes types = SnoreCore::instance().value(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
|
||||
if (types == SnorePlugin::NONE) {
|
||||
types = SnorePlugin::ALL;
|
||||
}
|
||||
@ -80,19 +80,19 @@ void Snore::SettingsDialog::on_pushButton_clicked()
|
||||
void SettingsDialog::load()
|
||||
{
|
||||
snoreDebug(SNORE_DEBUG) << "loading";
|
||||
if (SnoreCore::instance().value("PluginTypes", LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) {
|
||||
if (SnoreCore::instance().value(QLatin1String("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) {
|
||||
ui->primaryBackendComboBox->clear();
|
||||
QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::BACKEND);
|
||||
ui->primaryBackendComboBox->addItems(list);
|
||||
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(SnoreCore::instance().value("PrimaryBackend", LOCAL_SETTING).toString()));
|
||||
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(SnoreCore::instance().value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString()));
|
||||
ui->primaryBackendComboBox->setVisible(true);
|
||||
ui->primaryBackendLabel->setVisible(true);
|
||||
} else {
|
||||
ui->primaryBackendComboBox->setVisible(false);
|
||||
ui->primaryBackendLabel->setVisible(false);
|
||||
}
|
||||
ui->timeoutSpinBox->setValue(SnoreCore::instance().value("Timeout", LOCAL_SETTING).toInt());
|
||||
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().value("Silent", LOCAL_SETTING).toBool());
|
||||
ui->timeoutSpinBox->setValue(SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt());
|
||||
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING).toBool());
|
||||
for (auto widget : m_tabs) {
|
||||
widget->loadSettings();
|
||||
}
|
||||
@ -106,13 +106,13 @@ void SettingsDialog::save()
|
||||
w->saveSettings();
|
||||
dirty |= w->isDirty();
|
||||
}
|
||||
dirty |= SnoreCore::instance().value("PrimaryBackend", LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText();
|
||||
dirty |= SnoreCore::instance().value("Timeout", LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value();
|
||||
dirty |= SnoreCore::instance().value("Silent", LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
|
||||
dirty |= SnoreCore::instance().value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText();
|
||||
dirty |= SnoreCore::instance().value(QLatin1String("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value();
|
||||
dirty |= SnoreCore::instance().value(QLatin1String("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
|
||||
|
||||
SnoreCore::instance().setValue("PrimaryBackend", ui->primaryBackendComboBox->currentText(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setValue("Timeout", ui->timeoutSpinBox->value(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setValue("Silent", ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setValue(QLatin1String("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setValue(QLatin1String("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setValue(QLatin1String("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING);
|
||||
|
||||
if (dirty) {
|
||||
SnoreCorePrivate::instance()->syncSettings();
|
||||
|
@ -51,12 +51,12 @@ public:
|
||||
//TODO: move to private header
|
||||
void initTabs();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void setVisible(bool b) override;
|
||||
void accept();
|
||||
void reset();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void on_pushButton_clicked();
|
||||
void load();
|
||||
void save();
|
||||
|
@ -41,12 +41,15 @@ SnoreCore::SnoreCore(QObject *parent):
|
||||
d_ptr = new SnoreCorePrivate();
|
||||
Q_D(SnoreCore);
|
||||
d->q_ptr = this;
|
||||
d->init();
|
||||
}
|
||||
|
||||
SnoreCore &SnoreCore::instance()
|
||||
{
|
||||
static SnoreCore *instance(new SnoreCore(qApp));
|
||||
static SnoreCore *instance = nullptr;
|
||||
if(!instance){
|
||||
instance = new SnoreCore(qApp);
|
||||
SnoreCorePrivate::instance()->init();
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
@ -64,7 +67,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||
return;
|
||||
}
|
||||
Q_D(SnoreCore);
|
||||
setValue("PluginTypes", QVariant::fromValue(types), LOCAL_SETTING);
|
||||
setValue(QLatin1String("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING);
|
||||
snoreDebug(SNORE_DEBUG) << "Loading plugin types:" << types;
|
||||
for (SnorePlugin::PluginTypes type : SnorePlugin::types()) {
|
||||
if (type != SnorePlugin::ALL && types & type) {
|
||||
@ -79,7 +82,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||
case SnorePlugin::SECONDARY_BACKEND:
|
||||
case SnorePlugin::FRONTEND:
|
||||
case SnorePlugin::PLUGIN: {
|
||||
if (plugin->value("Enabled", LOCAL_SETTING).toBool()) {
|
||||
if (plugin->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool()) {
|
||||
if (!plugin->initialize()) {
|
||||
snoreDebug(SNORE_WARNING) << "Failed to initialize" << plugin->name();
|
||||
plugin->deinitialize();
|
||||
@ -88,7 +91,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();
|
||||
continue;
|
||||
@ -187,7 +190,7 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
|
||||
Q_D(SnoreCore);
|
||||
QList<PluginSettingsWidget *> list;
|
||||
for (auto name : d->m_pluginNames[type]) {
|
||||
//TODO: mem leak?
|
||||
//TODO: mem leak?
|
||||
SnorePlugin *p = d->m_plugins[name];
|
||||
PluginSettingsWidget *widget = p->settingsWidget();
|
||||
if (widget) {
|
||||
@ -205,7 +208,7 @@ QVariant SnoreCore::value(const QString &key, SettingsType type) const
|
||||
Q_D(const SnoreCore);
|
||||
QString nk = d->normalizeKey(key, type);
|
||||
if(type == LOCAL_SETTING && !d->m_settings->contains(nk)){
|
||||
nk = d->normalizeKey(QString("%1-SnoreDefault").arg(key),type);
|
||||
nk = d->normalizeKey(key + QStringLiteral("-SnoreDefault"),type);
|
||||
}
|
||||
return d->m_settings->value(nk);
|
||||
}
|
||||
@ -235,8 +238,8 @@ Notification SnoreCore::getActiveNotificationByID(uint id) const
|
||||
void SnoreCore::displayExapleNotification()
|
||||
{
|
||||
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||
QString text = QString("<i>%1</i><br>"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">%2</a><br>").arg(tr("This is Snore"), tr("Project Website"));
|
||||
QString text = QLatin1String("<i>") + tr("This is Snore") + QLatin1String("</i><br>") +
|
||||
QLatin1String("<a href=\"https://github.com/Snorenotify/Snorenotify\">") + tr("Project Website") + QLatin1String("</a><br>");
|
||||
if(!app.constHints().value("use-markup").toBool()) {
|
||||
text = Utils::normalizeMarkup(text, Utils::NO_MARKUP);
|
||||
}
|
||||
|
@ -150,7 +150,8 @@ public:
|
||||
void setDefaultValue(const QString &key, const QVariant &value, SettingsType type = GLOBAL_SETTING);
|
||||
|
||||
Notification getActiveNotificationByID(uint id) const;
|
||||
signals:
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when an action on the Notification was performed.
|
||||
* Some notification systems don't support actions but will report one if the notification was clicked,
|
||||
|
@ -32,8 +32,8 @@
|
||||
using namespace Snore;
|
||||
|
||||
SnoreCorePrivate::SnoreCorePrivate():
|
||||
m_localSettingsPrefix(qApp->applicationName().isEmpty() ? "SnoreNotify" : qApp->applicationName()),
|
||||
m_settings(new QSettings("Snorenotify", "libsnore", this))
|
||||
m_localSettingsPrefix(qApp->applicationName().isEmpty() ? QLatin1String("SnoreNotify") : qApp->applicationName()),
|
||||
m_settings(new QSettings(QLatin1String("Snorenotify"), QLatin1String("libsnore"), this))
|
||||
{
|
||||
snoreDebug(SNORE_INFO) << "Version:" << Version::version();
|
||||
if (!Version::revision().isEmpty()) {
|
||||
@ -42,12 +42,9 @@ SnoreCorePrivate::SnoreCorePrivate():
|
||||
|
||||
snoreDebug(SNORE_DEBUG) << "Temp dir is" << tempPath();
|
||||
snoreDebug(SNORE_DEBUG) << "Snore settings are located in" << m_settings->fileName();
|
||||
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeKey("Test", LOCAL_SETTING);
|
||||
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeKey(QLatin1String("Test"), LOCAL_SETTING);
|
||||
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
|
||||
|
||||
|
||||
m_defaultApp = Application("SnoreNotify", Icon(":/root/snore.png"));
|
||||
}
|
||||
|
||||
SnoreCorePrivate::~SnoreCorePrivate()
|
||||
@ -99,7 +96,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
||||
}
|
||||
|
||||
m_notificationBackend = b;
|
||||
q->setValue("PrimaryBackend", backend, LOCAL_SETTING);
|
||||
q->setValue(QLatin1String("PrimaryBackend"), backend, LOCAL_SETTING);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -108,33 +105,33 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
||||
bool SnoreCorePrivate::initPrimaryNotificationBackend()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
snoreDebug(SNORE_DEBUG) << q->value("PrimaryBackend", LOCAL_SETTING).toString();
|
||||
if (setBackendIfAvailible(q->value("PrimaryBackend", LOCAL_SETTING).toString())) {
|
||||
snoreDebug(SNORE_DEBUG) << q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
|
||||
if (setBackendIfAvailible(q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString())) {
|
||||
return true;
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8 && setBackendIfAvailible("Windows 8")) {
|
||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8 && setBackendIfAvailible(QLatin1String("Windows 8"))) {
|
||||
return true;
|
||||
}
|
||||
if (setBackendIfAvailible("Growl")) {
|
||||
if (setBackendIfAvailible(QLatin1String("Growl"))) {
|
||||
return true;
|
||||
}
|
||||
if (setBackendIfAvailible("Snarl")) {
|
||||
if (setBackendIfAvailible(QLatin1String("Snarl"))) {
|
||||
return true;
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if (setBackendIfAvailible("FreedesktopNotification")) {
|
||||
if (setBackendIfAvailible(QLatin1String("FreedesktopNotification")) {
|
||||
return true;
|
||||
}
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (setBackendIfAvailible("OSX Notification Center")) {
|
||||
if (setBackendIfAvailible(QLatin1String("OSX Notification Center"))) {
|
||||
return true;
|
||||
}
|
||||
if (setBackendIfAvailible("Growl")) {
|
||||
if (setBackendIfAvailible(QLatin1String("Growl")) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
if (setBackendIfAvailible("Snore")) {
|
||||
if (setBackendIfAvailible(QLatin1String("Snore"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -143,14 +140,15 @@ bool SnoreCorePrivate::initPrimaryNotificationBackend()
|
||||
void SnoreCorePrivate::init()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
setDefaultValueIntern("Timeout", 10);
|
||||
setDefaultValueIntern("Silent", false);
|
||||
setDefaultValueIntern(QLatin1String("Timeout"), 10);
|
||||
setDefaultValueIntern(QLatin1String("Silent"), false);
|
||||
m_defaultApp = Application(QLatin1String("SnoreNotify"), Icon::defaultIcon());
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant &value)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
QString nk = normalizeKey(QString("%1-SnoreDefault").arg(key), LOCAL_SETTING);
|
||||
QString nk = normalizeKey( key + QLatin1String("-SnoreDefault"), LOCAL_SETTING);
|
||||
if (!m_settings->contains(nk)) {
|
||||
m_settings->setValue(nk, value);
|
||||
}
|
||||
@ -159,7 +157,7 @@ void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant
|
||||
void SnoreCorePrivate::syncSettings()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
QString newBackend = q->value("PrimaryBackend", LOCAL_SETTING).toString();
|
||||
QString newBackend = q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString();
|
||||
if (!newBackend.isEmpty()) {
|
||||
QString oldBackend;
|
||||
if (m_notificationBackend) {
|
||||
@ -168,7 +166,7 @@ void SnoreCorePrivate::syncSettings()
|
||||
m_notificationBackend = nullptr;
|
||||
}
|
||||
if (!setBackendIfAvailible(newBackend)) {
|
||||
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value("PrimaryBackend", LOCAL_SETTING).toString() << "restoring" << oldBackend;
|
||||
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value(QLatin1String("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend;
|
||||
setBackendIfAvailible(oldBackend);
|
||||
}
|
||||
}
|
||||
@ -178,7 +176,7 @@ void SnoreCorePrivate::syncSettings()
|
||||
for(auto type : types) {
|
||||
for (auto &pluginName : m_pluginNames[type]) {
|
||||
SnorePlugin *plugin = m_plugins.value(pluginName);
|
||||
bool enable = m_plugins[pluginName]->value("Enabled", LOCAL_SETTING).toBool();
|
||||
bool enable = m_plugins[pluginName]->value(QLatin1String("Enabled"), LOCAL_SETTING).toBool();
|
||||
if (!plugin->isInitialized() && enable) {
|
||||
plugin->initialize();
|
||||
} else if (plugin->isInitialized() && !enable) {
|
||||
@ -232,14 +230,14 @@ static void loadTranslator()
|
||||
{
|
||||
auto installTranslator = [](const QString & locale) {
|
||||
snoreDebug(SNORE_DEBUG) << locale;
|
||||
if (locale != "C") {
|
||||
if (locale != QLatin1String("C")) {
|
||||
QTranslator *translator = new QTranslator(qApp->instance());
|
||||
if (translator->load(locale, ":/lang/libsnore/")) {
|
||||
if (translator->load(locale, QLatin1String(":/lang/libsnore/"))) {
|
||||
snoreDebug(SNORE_DEBUG) << "Using system locale:" << locale;
|
||||
snoreDebug(SNORE_DEBUG) << qApp->installTranslator(translator);
|
||||
} else {
|
||||
translator->deleteLater();
|
||||
QString fileName = QString(":/lang/libsnore/%1.qm").arg(locale);
|
||||
QString fileName = QLatin1String(":/lang/libsnore/") + locale + QLatin1String(".qm");
|
||||
snoreDebug(SNORE_DEBUG) << "Failed to load translations for:" << locale << fileName << QFile::exists(fileName) ;
|
||||
return false;
|
||||
}
|
||||
@ -247,9 +245,9 @@ static void loadTranslator()
|
||||
return true;
|
||||
};
|
||||
|
||||
installTranslator("en");
|
||||
installTranslator(QLatin1String("en"));
|
||||
QLocale locale = QLocale::system();
|
||||
if (locale.name() != "en") {
|
||||
if (locale.name() != QLatin1String("en")) {
|
||||
if (!installTranslator(locale.name())) {
|
||||
installTranslator(locale.bcp47Name());
|
||||
}
|
||||
|
@ -72,22 +72,20 @@ public:
|
||||
*/
|
||||
void setDefaultValueIntern(const QString &key, const QVariant &value);
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
//TODO: find a better solutinon for the slots in this section
|
||||
friend class Snore::SnoreBackend;
|
||||
void slotNotificationActionInvoked(Notification notification);
|
||||
void slotNotificationDisplayed(Notification notification);
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
void slotAboutToQuit();
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void applicationRegistered(const Snore::Application &);
|
||||
void applicationDeregistered(const Snore::Application &);
|
||||
void notify(Snore::Notification noti);
|
||||
void notificationDisplayed(Snore::Notification notification);
|
||||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
void slotAboutToQuit();
|
||||
|
||||
private:
|
||||
SnoreCorePrivate();
|
||||
SnoreCore *q_ptr;
|
||||
|
@ -74,7 +74,7 @@ void Utils::raiseWindowToFront(qlonglong wid)
|
||||
|
||||
#define HTML_REPLACE(STRING, PATTERN){\
|
||||
static QRegExp regexp(QLatin1String(PATTERN));\
|
||||
STRING = STRING.replace(regexp, QStringLiteral("\\1"));\
|
||||
STRING = STRING.replace(regexp, QLatin1String("\\1"));\
|
||||
}\
|
||||
|
||||
|
||||
@ -89,8 +89,8 @@ QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags)
|
||||
|
||||
QMutexLocker lock(&mutex);
|
||||
if (~tags & Utils::BREAK) {
|
||||
static QRegExp br("<br>");
|
||||
string = string.replace(br, "\n");
|
||||
static QRegExp br(QLatin1String("<br>"));
|
||||
string = string.replace(br, QLatin1String("\n"));
|
||||
}
|
||||
if (~tags & Utils::HREF) {
|
||||
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
|
||||
|
@ -72,27 +72,27 @@ public:
|
||||
*/
|
||||
static inline QString computeMD5Hash(const QByteArray &data)
|
||||
{
|
||||
return QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex();
|
||||
return QString::fromUtf8(QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex());
|
||||
}
|
||||
|
||||
static inline QString settingsVersionSchema()
|
||||
{
|
||||
return "v1";
|
||||
return QLatin1String("v1");
|
||||
}
|
||||
|
||||
static inline QString normalizeSettingsKey(const QString &key, SettingsType type, const QString &application)
|
||||
{
|
||||
if (type == LOCAL_SETTING) {
|
||||
return QString("%1/LocalSettings/%2/%3").arg(settingsVersionSchema(), application, key);
|
||||
return settingsVersionSchema() + QLatin1String("/LocalSettings/") + application + QLatin1Char('/') + key;
|
||||
} else {
|
||||
return QString("%1/GlobalSettings/%2").arg(settingsVersionSchema(), key);
|
||||
return settingsVersionSchema() + QLatin1String("/GlobalSettings/") + key;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Func>
|
||||
static QStringList allSettingsKeysWithPrefix(const QString &prefix, QSettings &settings, Func fun)
|
||||
{
|
||||
QStringList groups = prefix.split("/");
|
||||
QStringList groups = prefix.split(QLatin1Char('/'));
|
||||
QStringList out;
|
||||
|
||||
for (const QString group : groups) {
|
||||
|
@ -1,22 +1,20 @@
|
||||
if(NOT WITH_FREEDESKTOP_FRONTEND AND UNIX AND NOT APPLE)
|
||||
find_package(Qt5DBus QUIET)
|
||||
set_package_properties(Qt5DBus PROPERTIES
|
||||
PURPOSE "Support for the Freedesktop Notification Backend."
|
||||
TYPE OPTIONAL)
|
||||
if(Qt5DBus_FOUND)
|
||||
find_package(Qt5DBus QUIET)
|
||||
set_package_properties(Qt5DBus PROPERTIES
|
||||
PURPOSE "Support for the Freedesktop Notification Backend."
|
||||
TYPE OPTIONAL)
|
||||
if(Qt5DBus_FOUND)
|
||||
|
||||
set ( FREEDESKTOP_NOTIFICATION_SRC
|
||||
freedesktopnotification_backend.cpp
|
||||
fredesktopnotification.cpp
|
||||
)
|
||||
set ( FREEDESKTOP_NOTIFICATION_SRC
|
||||
freedesktopnotification_backend.cpp
|
||||
fredesktopnotification.cpp
|
||||
)
|
||||
|
||||
qt5_add_dbus_interface( FREEDESKTOP_NOTIFICATION_SRC ../../frontends/freedesktop/org.freedesktop.Notifications.xml notificationinterface )
|
||||
qt5_add_dbus_interface( FREEDESKTOP_NOTIFICATION_SRC ../../frontends/freedesktop/org.freedesktop.Notifications.xml notificationinterface )
|
||||
|
||||
|
||||
add_library(libsnore_backend_freedesktop MODULE ${FREEDESKTOP_NOTIFICATION_SRC} )
|
||||
target_link_libraries(libsnore_backend_freedesktop Snore::Libsnore Qt5::DBus )
|
||||
add_library(libsnore_backend_freedesktop MODULE ${FREEDESKTOP_NOTIFICATION_SRC} )
|
||||
target_link_libraries(libsnore_backend_freedesktop Snore::Libsnore Qt5::DBus )
|
||||
|
||||
install(TARGETS libsnore_backend_freedesktop ${SNORE_PLUGIN_INSTALL_PATH})
|
||||
endif()
|
||||
install(TARGETS libsnore_backend_freedesktop ${SNORE_PLUGIN_INSTALL_PATH})
|
||||
endif()
|
||||
|
||||
|
@ -13,13 +13,14 @@ using namespace Snore;
|
||||
bool FreedesktopBackend::initialize()
|
||||
{
|
||||
|
||||
m_interface = new org::freedesktop::Notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications",
|
||||
m_interface = new org::freedesktop::Notifications(QLatin1String("org.freedesktop.Notifications"),
|
||||
QLatin1String("/org/freedesktop/Notifications"),
|
||||
QDBusConnection::sessionBus(), this);
|
||||
|
||||
QDBusPendingReply<QStringList> reply = m_interface->GetCapabilities();
|
||||
reply.waitForFinished();
|
||||
QStringList caps = reply.value();
|
||||
m_supportsRichtext = caps.contains("body-markup");
|
||||
m_supportsRichtext = caps.contains(QLatin1String("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)));
|
||||
|
||||
@ -58,7 +59,7 @@ void FreedesktopBackend::slotNotify(Notification noti)
|
||||
QVariantMap hints;
|
||||
if (noti.icon().isValid()) {
|
||||
FreedesktopImageHint image(noti.icon().image());
|
||||
hints["image_data"] = QVariant::fromValue(image);
|
||||
hints.insert(QLatin1String("image_data"), QVariant::fromValue(image));
|
||||
}
|
||||
|
||||
char urgency = '1';
|
||||
@ -67,10 +68,10 @@ void FreedesktopBackend::slotNotify(Notification noti)
|
||||
} else if(noti.priority() > 2) {
|
||||
urgency = '2';
|
||||
}
|
||||
hints["urgency"] = urgency;
|
||||
hints.insert(QLatin1String("urgency"), urgency);
|
||||
|
||||
if (noti.application().constHints().contains("desktop-entry")) {
|
||||
hints["desktop-entry"] = noti.application().constHints().value("desktop-entry");
|
||||
hints.insert(QLatin1String("desktop-entry"), noti.application().constHints().value("desktop-entry"));
|
||||
}
|
||||
|
||||
uint updateId = 0;
|
||||
@ -79,9 +80,10 @@ void FreedesktopBackend::slotNotify(Notification noti)
|
||||
m_dbusIdMap.take(updateId);
|
||||
}
|
||||
|
||||
QString title = QString("%1 - %2").arg(noti.application().name(), noti.title(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP));
|
||||
QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP);
|
||||
QString body(noti.text(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP));
|
||||
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, "", title,
|
||||
//TODO: add app icon hint?
|
||||
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, QString(), title,
|
||||
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);
|
||||
|
||||
id.waitForFinished();
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
bool canCloseNotification() const override;
|
||||
bool canUpdateNotification() const override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
void slotCloseNotification(Snore::Notification notification) override;
|
||||
|
||||
|
@ -32,8 +32,8 @@ GrowlBackend *GrowlBackend::s_instance = nullptr;
|
||||
|
||||
bool GrowlBackend::initialize()
|
||||
{
|
||||
setDefaultValue("Host", "localhost");
|
||||
setDefaultValue("Password", "");
|
||||
setDefaultValue(QLatin1String("Host"), QLatin1String("localhost"));
|
||||
setDefaultValue(QLatin1String("Password"), QString());
|
||||
|
||||
if(!SnoreBackend::initialize()) {
|
||||
return false;
|
||||
@ -41,7 +41,7 @@ bool GrowlBackend::initialize()
|
||||
|
||||
s_instance = this;
|
||||
auto func = [](growl_callback_data * data)->void {
|
||||
snoreDebug(SNORE_DEBUG) << data->id << QString(data->reason) << QString(data->data);
|
||||
snoreDebug(SNORE_DEBUG) << data->id << QString::fromUtf8(data->reason) << QString::fromUtf8(data->data);
|
||||
Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id);
|
||||
if (!n.isValid())
|
||||
{
|
||||
@ -63,7 +63,7 @@ bool GrowlBackend::initialize()
|
||||
s_instance->closeNotification(n, r);
|
||||
};
|
||||
if (Growl::init((GROWL_CALLBACK)static_cast<void(*)(growl_callback_data *)>(func))
|
||||
&& Growl::isRunning(GROWL_TCP, value("Host").toString().toUtf8().constData())) {
|
||||
&& Growl::isRunning(GROWL_TCP, value(QLatin1String("Host")).toString().toUtf8().constData())) {
|
||||
return true;
|
||||
}
|
||||
snoreDebug(SNORE_DEBUG) << "Growl is not running";
|
||||
@ -87,8 +87,8 @@ void GrowlBackend::slotRegisterApplication(const Application &application)
|
||||
alerts.push_back(a.name().toUtf8().constData());
|
||||
}
|
||||
|
||||
Growl *growl = new Growl(GROWL_TCP, value("Host").toString().toUtf8().constData(),
|
||||
value("Password").toString().toUtf8().constData(),
|
||||
Growl *growl = new Growl(GROWL_TCP, value(QLatin1String("Host")).toString().toUtf8().constData(),
|
||||
value(QLatin1String("Password")).toString().toUtf8().constData(),
|
||||
application.name().toUtf8().constData());
|
||||
growl->Register(alerts, application.icon().localUrl().toUtf8().constData());
|
||||
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
static GrowlBackend *s_instance;
|
||||
QHash<QString, Growl *> m_applications;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotRegisterApplication(const Snore::Application &application) override;
|
||||
void slotDeregisterApplication(const Snore::Application &application) override;
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
|
@ -38,13 +38,13 @@ GrowlSettings::~GrowlSettings()
|
||||
|
||||
void GrowlSettings::load()
|
||||
{
|
||||
m_host->setText(value("Host").toString());
|
||||
m_password->setText(value("Password").toString());
|
||||
m_host->setText(value(QLatin1String("Host")).toString());
|
||||
m_password->setText(value(QLatin1String("Password")).toString());
|
||||
}
|
||||
|
||||
void GrowlSettings::save()
|
||||
{
|
||||
setValue("Host", m_host->text());
|
||||
setValue("Password", m_password->text());
|
||||
setValue(QLatin1String("Host"), m_host->text());
|
||||
setValue(QLatin1String("Password"), m_password->text());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
OSXNotificationCenter();
|
||||
~OSXNotificationCenter();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
namespace {
|
||||
|
||||
NSString * NSStringFromQString(QString qstr) {
|
||||
return [NSString stringWithUTF8String: qstr.toUtf8().data()];
|
||||
return [NSString stringWithUTF8String: qstr.toUtf8().constData()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ private:
|
||||
|
||||
bool SnarlBackend::initialize()
|
||||
{
|
||||
setDefaultValue("Password", QString());
|
||||
setDefaultValue(QLatin1String("Password"), QString());
|
||||
|
||||
if(!SnoreBackend::initialize()) {
|
||||
return false;
|
||||
@ -167,8 +167,8 @@ void SnarlBackend::slotRegisterApplication(const Application &application)
|
||||
SnarlInterface *snarlInterface = new SnarlInterface();
|
||||
m_applications.insert(application.name(), snarlInterface);
|
||||
|
||||
QString appName = application.name().replace(" ", "_"); //app sig must not contain spaces
|
||||
QString password = value("Password").toString();
|
||||
QString appName = application.name().replace(QLatin1Char(' '), QLatin1Char('_')); //app sig must not contain spaces
|
||||
QString password = value(QLatin1String("Password")).toString();
|
||||
LONG32 result = snarlInterface->Register(appName.toUtf8().constData(),
|
||||
application.name().toUtf8().constData(),
|
||||
application.icon().localUrl().toUtf8().constData(),
|
||||
@ -190,7 +190,7 @@ void SnarlBackend::slotDeregisterApplication(const Application &application)
|
||||
return;
|
||||
}
|
||||
SnarlInterface *snarlInterface = m_applications.take(application.name());
|
||||
QString appName = application.name().replace(" ", "_"); //app sig must not contain spaces
|
||||
QString appName = application.name().replace(QLatin1Char(' '), QLatin1Char('_')); //app sig must not contain spaces
|
||||
snarlInterface->Unregister(appName.toUtf8().constData());
|
||||
delete snarlInterface;
|
||||
}
|
||||
@ -226,7 +226,7 @@ void SnarlBackend::slotNotify(Notification notification)
|
||||
priority);
|
||||
|
||||
foreach(const Action & a, notification.actions()) {
|
||||
snarlInterface->AddAction(id, a.name().toUtf8().constData(), QString("@").append(QString::number(a.id())).toUtf8().constData());
|
||||
snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData());
|
||||
}
|
||||
m_idMap[id] = notification;
|
||||
notification.hints().setPrivateValue(this, "id", id);
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
SnarlBackend::SnarlWidget *m_eventLoop;
|
||||
QHash<QString, Snarl::V42::SnarlInterface *> m_applications;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotRegisterApplication(const Snore::Application &application);
|
||||
void slotDeregisterApplication(const Snore::Application &application);
|
||||
void slotNotify(Snore::Notification notification);
|
||||
|
@ -36,11 +36,11 @@ SnarlSettings::~SnarlSettings()
|
||||
|
||||
void SnarlSettings::load()
|
||||
{
|
||||
m_password->setText(value("Password").toString());
|
||||
m_password->setText(value(QLatin1String("Password")).toString());
|
||||
}
|
||||
|
||||
void SnarlSettings::save()
|
||||
{
|
||||
setValue("Password", m_password->text());
|
||||
setValue(QLatin1String("Password"), m_password->text());
|
||||
}
|
||||
|
||||
|
@ -24,14 +24,14 @@
|
||||
using namespace Snore;
|
||||
|
||||
NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) :
|
||||
QQuickView(QUrl("qrc:/notification.qml")),
|
||||
QQuickView(QUrl::fromEncoded("qrc:/notification.qml")),
|
||||
m_id(pos),
|
||||
m_parent(parent),
|
||||
m_mem(QString("SnoreNotifyWidget_rev%1_id%2").arg(QString::number(SHARED_MEM_TYPE_REV()), QString::number(m_id))),
|
||||
m_mem(QLatin1String("SnoreNotifyWidget_rev") + QString::number(SHARED_MEM_TYPE_REV()) + QLatin1String("_id") + QString::number(m_id)),
|
||||
m_ready(true)
|
||||
{
|
||||
rootContext()->setContextProperty("window", this);
|
||||
rootContext()->setContextProperty("utils", new Utils(this));
|
||||
rootContext()->setContextProperty(QLatin1String("window"), this);
|
||||
rootContext()->setContextProperty(QLatin1String("utils"), new Utils(this));
|
||||
m_qmlNotification = rootObject();
|
||||
|
||||
setFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus
|
||||
@ -82,7 +82,7 @@ void NotifyWidget::display(const Notification ¬ification)
|
||||
color = vcolor.value<QColor>();
|
||||
} else {
|
||||
color = computeBackgrondColor(notification.application().icon().image().scaled(20, 20));
|
||||
notification.application().constHints().setPrivateValue(parent(), "backgroundColor", color);
|
||||
notification.application().hints().setPrivateValue(parent(), "backgroundColor", color);
|
||||
}
|
||||
QRgb gray = qGray(qGray(color.rgb()) - qGray(QColor(Qt::white).rgb()));
|
||||
QColor textColor = QColor(gray, gray, gray);
|
||||
@ -148,7 +148,7 @@ int NotifyWidget::id()
|
||||
|
||||
Qt::Corner NotifyWidget::corner()
|
||||
{
|
||||
return static_cast<Qt::Corner>(m_parent->value("Position").toInt());
|
||||
return static_cast<Qt::Corner>(m_parent->value(QLatin1String("Position")).toInt());
|
||||
}
|
||||
|
||||
qlonglong NotifyWidget::wid()
|
||||
|
@ -59,11 +59,11 @@ public:
|
||||
Qt::Corner corner();
|
||||
qlonglong wid();
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void invoked();
|
||||
void dismissed();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void slotDismissed();
|
||||
|
||||
void slotInvoked();
|
||||
|
@ -107,7 +107,7 @@ void SnoreNotifier::slotCloseNotification(Snore::Notification notification)
|
||||
|
||||
bool SnoreNotifier::initialize()
|
||||
{
|
||||
setDefaultValue("Position", Qt::TopRightCorner);
|
||||
setDefaultValue(QLatin1String("Position"), Qt::TopRightCorner);
|
||||
|
||||
if (SnoreBackend::initialize()) {
|
||||
for (int i = 0; i < m_widgets.size(); ++i) {
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void slotNotify(Snore::Notification notification) override;
|
||||
virtual void slotCloseNotification(Snore::Notification notification) override;
|
||||
|
||||
|
@ -40,10 +40,10 @@ SnoreNotifierSettings::~SnoreNotifierSettings()
|
||||
|
||||
void SnoreNotifierSettings::load()
|
||||
{
|
||||
m_comboBox->setCurrentIndex(value("Position").toInt());
|
||||
m_comboBox->setCurrentIndex(value(QLatin1String("Position")).toInt());
|
||||
}
|
||||
|
||||
void SnoreNotifierSettings::save()
|
||||
{
|
||||
setValue("Position", m_comboBox->currentIndex());
|
||||
setValue(QLatin1String("Position"), m_comboBox->currentIndex());
|
||||
}
|
||||
|
@ -40,25 +40,25 @@ void SnoreToast::slotNotify(Notification notification)
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-t"
|
||||
arguements << QLatin1String("-t")
|
||||
<< notification.title()
|
||||
<< "-m"
|
||||
<< QLatin1String("-m")
|
||||
<< notification.text();
|
||||
if (notification.icon().isValid()) {
|
||||
arguements << "-p"
|
||||
arguements << QLatin1String("-p")
|
||||
<< QDir::toNativeSeparators(notification.icon().localUrl());
|
||||
}
|
||||
arguements << "-w"
|
||||
<< "-appID"
|
||||
arguements << QLatin1String("-w")
|
||||
<< QLatin1String("-appID")
|
||||
<< appId(notification.application())
|
||||
<< "-id"
|
||||
<< QLatin1String("-id")
|
||||
<< QString::number(notification.id());
|
||||
//TODO: could clash with sound backend
|
||||
if (notification.hints().value("silent").toBool() || notification.hints().value("sound").isValid()) {
|
||||
arguements << "-silent";
|
||||
arguements << QLatin1String("-silent");
|
||||
}
|
||||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
p->start(QLatin1String("SnoreToast"), arguements);
|
||||
|
||||
p->setProperty("SNORE_NOTIFICATION", QVariant::fromValue(notification));
|
||||
}
|
||||
@ -70,12 +70,12 @@ void SnoreToast::slotRegisterApplication(const Application &application)
|
||||
p->setReadChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-install"
|
||||
<< QString("SnoreNotify\\%1").arg(qApp->applicationName())
|
||||
arguements << QLatin1String("-install")
|
||||
<< QLatin1String("SnoreNotify\\") + qApp->applicationName()
|
||||
<< QDir::toNativeSeparators(qApp->applicationFilePath())
|
||||
<< appId(application);
|
||||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
p->start(QLatin1String("SnoreToast"), arguements);
|
||||
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
@ -88,10 +88,10 @@ void SnoreToast::slotCloseNotification(Notification notification)
|
||||
p->setReadChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-close"
|
||||
arguements << QLatin1String("-close")
|
||||
<< QString::number(notification.id());
|
||||
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
p->start(QLatin1String("SnoreToast"), arguements);
|
||||
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
|
||||
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
|
||||
@ -145,7 +145,7 @@ QString SnoreToast::appId(const Application &application)
|
||||
appID = application.constHints().value("windows_app_id").toString();
|
||||
}
|
||||
if (appID.isEmpty()) {
|
||||
appID = QString("%1.%2.SnoreToast").arg(qApp->organizationName(), qApp->applicationName()).remove(" ");
|
||||
appID = QString(QLatin1String("%1.%2.SnoreToast")).arg(qApp->organizationName(), qApp->applicationName()).remove(QLatin1Char(' '));
|
||||
}
|
||||
return appID;
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ public:
|
||||
|
||||
virtual bool canCloseNotification() const override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
void slotRegisterApplication(const Snore::Application &application) override;
|
||||
void slotCloseNotification(Snore::Notification notification) override;
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
||||
void slotPrintExitStatus(int code, QProcess::ExitStatus);
|
||||
private:
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
virtual bool canCloseNotification() const override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification);
|
||||
void slotCloseNotification(Snore::Notification notification);
|
||||
void slotRegisterApplication(const Snore::Application &application);
|
||||
@ -33,7 +33,7 @@ private:
|
||||
Snore::Notification m_displayed;
|
||||
bool m_currentlyDisplaying = false;
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void displayNotification(QSystemTrayIcon *icon);
|
||||
void actionInvoked();
|
||||
|
||||
|
@ -37,8 +37,8 @@ bool FreedesktopFrontend::initialize()
|
||||
}
|
||||
m_adaptor = new NotificationsAdaptor(this);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
if (dbus.registerService("org.freedesktop.Notifications")) {
|
||||
if (dbus.registerObject("/org/freedesktop/Notifications", this)) {
|
||||
if (dbus.registerService(QLatin1String("org.freedesktop.Notifications"))) {
|
||||
if (dbus.registerObject(QLatin1String("/org/freedesktop/Notifications"), this)) {
|
||||
return true;
|
||||
} else {
|
||||
snoreDebug(SNORE_WARNING) << "Failed to initialize" << name() << "failed to register object";
|
||||
@ -53,8 +53,8 @@ bool FreedesktopFrontend::deinitialize()
|
||||
{
|
||||
if (SnoreFrontend::deinitialize()) {
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
dbus.unregisterService("org.freedesktop.Notifications");
|
||||
dbus.unregisterObject("/org/freedesktop/Notifications");
|
||||
dbus.unregisterService(QLatin1String("org.freedesktop.Notifications"));
|
||||
dbus.unregisterObject(QLatin1String("/org/freedesktop/Notifications"));
|
||||
m_adaptor->deleteLater();
|
||||
m_adaptor = nullptr;
|
||||
return true;
|
||||
@ -87,17 +87,17 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
Application app;
|
||||
Notification::Prioritys priotity = Notification::NORMAL;
|
||||
|
||||
if (hints.contains("image_data")) {
|
||||
if (hints.contains(QLatin1String("image_data"))) {
|
||||
FreedesktopImageHint image;
|
||||
hints["image_data"].value<QDBusArgument>() >> image;
|
||||
hints.value(QLatin1String("image_data")).value<QDBusArgument>() >> image;
|
||||
icon = Icon(image.toQImage());
|
||||
} else {
|
||||
icon = Icon(":/root/snore.png");
|
||||
icon = Icon::defaultIcon();
|
||||
}
|
||||
|
||||
if (!SnoreCore::instance().aplications().contains(app_name)) {
|
||||
qDebug() << QIcon::themeSearchPaths();
|
||||
QIcon qicon = QIcon::fromTheme(app_icon, QIcon(":/root/snore.png"));
|
||||
QIcon qicon = QIcon::fromTheme(app_icon, QIcon(QLatin1String(":/root/snore.png")));
|
||||
QSize max;
|
||||
foreach(const QSize & s, qicon.availableSizes()) {
|
||||
if (s.width()*s.height() > max.width()*max.height()) {
|
||||
@ -105,17 +105,15 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
}
|
||||
}
|
||||
Icon appIcon(qicon.pixmap(max).toImage());
|
||||
Alert alert(tr("DBus Alert"), appIcon);
|
||||
app = Application(app_name, appIcon);
|
||||
app.hints().setValue("use-markup", QVariant::fromValue(true));
|
||||
app.addAlert(alert);
|
||||
app.hints().setValue("use-markup", true);
|
||||
SnoreCore::instance().registerApplication(app);
|
||||
} else {
|
||||
app = SnoreCore::instance().aplications()[app_name];
|
||||
}
|
||||
|
||||
if (hints.contains("urgency")) {
|
||||
priotity = Notification::Prioritys(hints["urgency"].toInt() - 1);
|
||||
if (hints.contains(QLatin1String("urgency"))) {
|
||||
priotity = Notification::Prioritys(hints.value(QLatin1String("urgency")).toInt() - 1);
|
||||
}
|
||||
|
||||
Notification noti;
|
||||
@ -123,7 +121,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
if (replaces_id != 0 && toReplace.isValid()) {
|
||||
noti = Notification(toReplace, summary, body, icon, timeout == -1 ? Notification::defaultTimeout() : timeout / 1000, priotity);
|
||||
} else {
|
||||
noti = Notification(app, *app.alerts().begin(), summary, body, icon, timeout == -1 ? Notification::defaultTimeout() : timeout / 1000, priotity);
|
||||
noti = Notification(app, app.defaultAlert(), summary, body, icon, timeout == -1 ? Notification::defaultTimeout() : timeout / 1000, priotity);
|
||||
}
|
||||
for (int i = 0; i < actions.length(); i += 2) {
|
||||
noti.addAction(Action(actions.at(i).toInt(), actions.at(i + 1)));
|
||||
@ -145,18 +143,18 @@ void FreedesktopFrontend::CloseNotification(uint id)
|
||||
QStringList FreedesktopFrontend::GetCapabilities()
|
||||
{
|
||||
return QStringList()
|
||||
<< "body"
|
||||
<< "urgency"
|
||||
<< "body-hyperlinks"
|
||||
<< "body-markup"
|
||||
<< "icon-static"
|
||||
<< "actions";
|
||||
<< QLatin1String("body")
|
||||
<< QLatin1String("urgency")
|
||||
<< QLatin1String("body-hyperlinks")
|
||||
<< QLatin1String("body-markup")
|
||||
<< QLatin1String("icon-static")
|
||||
<< QLatin1String("actions");
|
||||
}
|
||||
|
||||
QString FreedesktopFrontend::GetServerInformation(QString &vendor, QString &version, QString &specVersion)
|
||||
{
|
||||
vendor = "SnoreNotify";
|
||||
vendor = QLatin1String("SnoreNotify");
|
||||
version = Version::version();
|
||||
specVersion = "0.9";
|
||||
return "SnoreNotify";
|
||||
specVersion = QLatin1String("0.9");
|
||||
return vendor;
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
QStringList GetCapabilities();
|
||||
QString GetServerInformation(QString &vendor, QString &version, QString &specVersion);
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void NotificationClosed(uint id, uint reason);
|
||||
void ActionInvoked(uint id, const QString &actionKey);
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotActionInvoked(Snore::Notification notification) override;
|
||||
void slotNotificationClosed(Snore::Notification notification) override;
|
||||
|
||||
|
@ -40,15 +40,15 @@ using namespace Snore;
|
||||
|
||||
bool PushoverFrontend::initialize()
|
||||
{
|
||||
setDefaultValue("Secret", "", LOCAL_SETTING);
|
||||
setDefaultValue("DeviceID", "", LOCAL_SETTING);
|
||||
setDefaultValue("Registered", false, LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("Secret"), QString(), LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("DeviceID"), QString(), LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("Registered"), false, LOCAL_SETTING);
|
||||
|
||||
if(!SnoreFrontend::initialize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(value("Registered", LOCAL_SETTING).toBool())
|
||||
if(value(QLatin1String("Registered"), LOCAL_SETTING).toBool())
|
||||
{
|
||||
connectToService();
|
||||
}
|
||||
@ -76,10 +76,10 @@ PluginSettingsWidget *PushoverFrontend::settingsWidget()
|
||||
void PushoverFrontend::registerDevice(const QString &email, const QString &password, const QString &deviceName)
|
||||
{
|
||||
|
||||
QNetworkRequest request(QUrl(QStringLiteral("https://api.pushover.net/1/users/login.json")));
|
||||
QNetworkRequest request(QUrl(QLatin1String("https://api.pushover.net/1/users/login.json")));
|
||||
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||
QNetworkReply *reply = m_manager.post(request, QString("email=%1&password=%2").arg(email, password).toUtf8().constData());
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
||||
QNetworkReply *reply = m_manager.post(request, QString(QLatin1String("email=%1&password=%2")).arg(email, password).toUtf8().constData());
|
||||
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply, deviceName, this]() {
|
||||
@ -91,13 +91,13 @@ void PushoverFrontend::registerDevice(const QString &email, const QString &passw
|
||||
|
||||
QJsonObject message = QJsonDocument::fromJson(input).object();
|
||||
|
||||
if(message.value("status").toInt() == 1)
|
||||
if(message.value(QLatin1String("status")).toInt() == 1)
|
||||
{
|
||||
QString secret = message.value("secret").toString();
|
||||
QNetworkRequest request(QUrl(QStringLiteral("https://api.pushover.net/1/devices.json")));
|
||||
QString secret = message.value(QLatin1String("secret")).toString();
|
||||
QNetworkRequest request(QUrl(QLatin1String("https://api.pushover.net/1/devices.json")));
|
||||
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||
QNetworkReply *reply = m_manager.post(request, QString("secret=%1&name=%2&os=O").arg(secret, deviceName).toUtf8().constData());
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
||||
QNetworkReply *reply = m_manager.post(request, QString(QLatin1String("secret=%1&name=%2&os=O")).arg(secret, deviceName).toUtf8().constData());
|
||||
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply, secret, this]() {
|
||||
@ -110,10 +110,10 @@ void PushoverFrontend::registerDevice(const QString &email, const QString &passw
|
||||
QJsonObject message = QJsonDocument::fromJson(input).object();
|
||||
|
||||
|
||||
if(message.value("status").toInt() == 1) {
|
||||
setValue("Secret", secret, LOCAL_SETTING);
|
||||
setValue("DeviceID", message.value("id").toString(), LOCAL_SETTING);
|
||||
setValue("Registered", true, LOCAL_SETTING);
|
||||
if(message.value(QLatin1String("status")).toInt() == 1) {
|
||||
setValue(QLatin1String("Secret"), secret, LOCAL_SETTING);
|
||||
setValue(QLatin1String("DeviceID"), message.value(QLatin1String("id")).toString(), LOCAL_SETTING);
|
||||
setValue(QLatin1String("Registered"), true, LOCAL_SETTING);
|
||||
connectToService();
|
||||
} else {
|
||||
snoreDebug(SNORE_WARNING) << "An error occure" << input;
|
||||
@ -136,23 +136,22 @@ void PushoverFrontend::slotActionInvoked(Notification notification)
|
||||
|
||||
QString PushoverFrontend::secret()
|
||||
{
|
||||
return value("Secret", LOCAL_SETTING).toString();
|
||||
return value(QLatin1String("Secret"), LOCAL_SETTING).toString();
|
||||
}
|
||||
|
||||
QString PushoverFrontend::device()
|
||||
{
|
||||
return value("DeviceID", LOCAL_SETTING).toString();
|
||||
return value(QLatin1String("DeviceID"), LOCAL_SETTING).toString();
|
||||
}
|
||||
|
||||
void PushoverFrontend::connectToService()
|
||||
{
|
||||
|
||||
if(!value("Registered", LOCAL_SETTING).toBool())
|
||||
if(!value(QLatin1String("Registered"), LOCAL_SETTING).toBool())
|
||||
{
|
||||
snoreDebug(SNORE_WARNING) << "not logged in";
|
||||
return;
|
||||
}
|
||||
m_socket = new QWebSocket("", QWebSocketProtocol::VersionLatest, this);
|
||||
m_socket = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
|
||||
|
||||
connect(m_socket, &QWebSocket::binaryMessageReceived, [&](const QByteArray &msg){
|
||||
char c = msg.at(0);
|
||||
@ -171,7 +170,7 @@ void PushoverFrontend::connectToService()
|
||||
break;
|
||||
case 'E':
|
||||
snoreDebug(SNORE_DEBUG) << "Connection Error";
|
||||
setValue("Registered", false, LOCAL_SETTING);
|
||||
setValue(QLatin1String("Registered"), false, LOCAL_SETTING);
|
||||
m_socket->close();
|
||||
m_socket->deleteLater();
|
||||
break;
|
||||
@ -187,16 +186,16 @@ void PushoverFrontend::connectToService()
|
||||
});
|
||||
connect(m_socket, &QWebSocket::connected, [&](){
|
||||
snoreDebug(SNORE_DEBUG) << "connecting";
|
||||
m_socket->sendBinaryMessage(QString("login:%1:%2\n").arg(device(), secret()).toUtf8().constData());
|
||||
m_socket->sendBinaryMessage((QLatin1String("login:=") + device() + QLatin1Char(':') + secret() + QLatin1Char('\n')).toUtf8().constData());
|
||||
getMessages();
|
||||
});
|
||||
m_socket->open(QUrl("wss://client.pushover.net/push"));
|
||||
m_socket->open(QUrl::fromEncoded("wss://client.pushover.net/push"));
|
||||
}
|
||||
|
||||
void PushoverFrontend::getMessages()
|
||||
{
|
||||
QNetworkRequest request(QUrl(QString("https://api.pushover.net/1/messages.json?"
|
||||
"secret=%1&device_id=%2").arg(secret(), device())));
|
||||
QNetworkRequest request(QUrl::fromEncoded((QLatin1String("https://api.pushover.net/1/messages.json?"
|
||||
"secret=") + secret() + QLatin1String("&device_id=") + device()).toUtf8().constData()));
|
||||
QNetworkReply *reply = m_manager.get(request);
|
||||
|
||||
|
||||
@ -211,31 +210,34 @@ void PushoverFrontend::getMessages()
|
||||
QJsonObject message = QJsonDocument::fromJson(input).object();
|
||||
|
||||
int latestID = -1;
|
||||
if(message.value("status").toInt() == 1){
|
||||
QJsonArray notifications = message.value("messages").toArray();
|
||||
if(message.value(QLatin1String("status")).toInt() == 1){
|
||||
QJsonArray notifications = message.value(QLatin1String("messages")).toArray();
|
||||
for( const QJsonValue &v : notifications) {
|
||||
QJsonObject notification = v.toObject();
|
||||
|
||||
latestID = notification.value("id").toInt();
|
||||
latestID = qMax(latestID, notification.value(QLatin1String("id")).toInt());
|
||||
|
||||
QString appName = notification.value("app").toString();
|
||||
QString appName = notification.value(QLatin1String("app")).toString();
|
||||
Application app = SnoreCore::instance().aplications().value(appName);
|
||||
|
||||
if (!app.isValid()){
|
||||
Icon icon(QString("https://api.pushover.net/icons/%1.png").arg(notification.value("icon").toString()));
|
||||
Icon icon(QLatin1String("https://api.pushover.net/icons/") +
|
||||
notification.value(QLatin1String("icon")).toString() +
|
||||
QLatin1String(".png"));
|
||||
app = Application(appName, icon);
|
||||
app.addAlert(Alert(tr("Default"), icon));
|
||||
SnoreCore::instance().registerApplication(app);
|
||||
}
|
||||
|
||||
|
||||
Notification n(app, *app.alerts().begin(), notification.value("title").toString(), notification.value("message").toString(),
|
||||
app.icon(), Notification::defaultTimeout(), static_cast<Notification::Prioritys>(notification.value("priority").toInt()));
|
||||
Notification n(app, app.defaultAlert(), notification.value(QLatin1String("title")).toString(),
|
||||
notification.value(QLatin1String("message")).toString(),
|
||||
app.icon(), Notification::defaultTimeout(),
|
||||
static_cast<Notification::Prioritys>(notification.value(QLatin1String("priority")).toInt()));
|
||||
if(n.priority() == Notification::EMERGENCY){
|
||||
n.hints().setValue("receipt", notification.value("receipt").toString());
|
||||
n.hints().setValue("acked", notification.value("acked").toInt());
|
||||
n.hints().setValue("receipt", notification.value(QLatin1String("receipt")).toString());
|
||||
n.hints().setValue("acked", notification.value(QLatin1String("acked")).toInt());
|
||||
}
|
||||
if(notification.value("html").toInt() == 1) {
|
||||
if(notification.value(QLatin1String("html")).toInt() == 1) {
|
||||
n.hints().setValue("use-markup", true) ;
|
||||
}
|
||||
SnoreCore::instance().broadcastNotification(n);
|
||||
@ -254,10 +256,11 @@ void PushoverFrontend::getMessages()
|
||||
void PushoverFrontend::deleteMessages(int latestMessageId)
|
||||
{
|
||||
|
||||
QNetworkRequest request(QUrl(QString("https://api.pushover.net/1/devices/%1/update_highest_message.json").arg(device())));
|
||||
QNetworkRequest request(QUrl::fromEncoded((QLatin1String("https://api.pushover.net/1/devices/") +
|
||||
device() + QLatin1String("/update_highest_message.json")).toUtf8().constData()));
|
||||
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||
QNetworkReply *reply = m_manager.post(request, QString("secret=%1&message=%2").arg(secret(), QString::number(latestMessageId)).toUtf8().constData());
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
||||
QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret() + QLatin1String("&message=") + QString::number(latestMessageId)).toUtf8().constData());
|
||||
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply]() {
|
||||
@ -276,11 +279,11 @@ void PushoverFrontend::acknowledgeNotification(Notification notification)
|
||||
snoreDebug(SNORE_DEBUG) << notification.constHints().value("acked").toInt();
|
||||
QString receipt = notification.constHints().value("receipt").toString();
|
||||
|
||||
QNetworkRequest request(QUrl(QString("https://api.pushover.net/1/receipts/%1/acknowledge.json").arg(receipt)));
|
||||
|
||||
QNetworkRequest request(QUrl::fromEncoded((QLatin1String("https://api.pushover.net/1/receipts/") +
|
||||
receipt + QLatin1String("/acknowledge.json")).toUtf8().constData()));
|
||||
snoreDebug(SNORE_WARNING) << request.url();
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||
QNetworkReply *reply = m_manager.post(request, QString("secret=%1").arg(secret()).toUtf8().constData());
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
||||
QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret()).toUtf8().constData());
|
||||
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [reply]() {
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
void registerDevice(const QString &email, const QString &password, const QString& deviceName);
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotActionInvoked(Snore::Notification notification);
|
||||
|
||||
|
||||
|
@ -36,18 +36,18 @@ PushoverSettings::PushoverSettings(Snore::SnorePlugin *plugin, QWidget *parent)
|
||||
addRow(tr("Password:"), m_passwordLineEdit);
|
||||
addRow(tr("Device Name:"), m_deviceLineEdit);
|
||||
updateLoginState();
|
||||
addRow("", m_registerButton);
|
||||
addRow(QString(), m_registerButton);
|
||||
|
||||
PushoverFrontend *pushover = dynamic_cast<PushoverFrontend*>(plugin);
|
||||
connect(m_registerButton, &QPushButton::clicked, [pushover, this] () {
|
||||
if(!value("Registered", Snore::LOCAL_SETTING).toBool()) {
|
||||
if(!value(QLatin1String("Registered"), Snore::LOCAL_SETTING).toBool()) {
|
||||
pushover->registerDevice(m_emailLineEdit->text(), m_passwordLineEdit->text(), m_deviceLineEdit->text());
|
||||
setValue("DeviceName", m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
setValue(QLatin1String("DeviceName"), m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
QTimer *updateTimer = new QTimer(this);
|
||||
updateTimer->setInterval(500);
|
||||
connect(updateTimer, &QTimer::timeout, [updateTimer, this](){
|
||||
qDebug() << value("Registered").toBool();
|
||||
if (value("Registered", Snore::LOCAL_SETTING).toBool()) {
|
||||
qDebug() << value(QLatin1String("Registered")).toBool();
|
||||
if (value(QLatin1String("Registered"), Snore::LOCAL_SETTING).toBool()) {
|
||||
updateLoginState();
|
||||
updateTimer->deleteLater();
|
||||
}
|
||||
@ -55,7 +55,7 @@ PushoverSettings::PushoverSettings(Snore::SnorePlugin *plugin, QWidget *parent)
|
||||
|
||||
updateTimer->start();
|
||||
}else{
|
||||
setValue("Registered", false, Snore::LOCAL_SETTING);
|
||||
setValue(QLatin1String("Registered"), false, Snore::LOCAL_SETTING);
|
||||
updateLoginState();
|
||||
}
|
||||
});
|
||||
@ -67,7 +67,7 @@ PushoverSettings::~PushoverSettings()
|
||||
|
||||
void PushoverSettings::load()
|
||||
{
|
||||
m_deviceLineEdit->setText(value("DeviceName", Snore::LOCAL_SETTING).toString());
|
||||
m_deviceLineEdit->setText(value(QLatin1String("DeviceName"), Snore::LOCAL_SETTING).toString());
|
||||
}
|
||||
|
||||
void PushoverSettings::save()
|
||||
@ -76,7 +76,7 @@ void PushoverSettings::save()
|
||||
|
||||
void PushoverSettings::updateLoginState()
|
||||
{
|
||||
if (value("Registered", Snore::LOCAL_SETTING).toBool()) {
|
||||
if (value(QLatin1String("Registered"), Snore::LOCAL_SETTING).toBool()) {
|
||||
m_emailLineEdit->setEnabled(false);
|
||||
m_passwordLineEdit->setEnabled(false);
|
||||
m_deviceLineEdit->setEnabled(false);
|
||||
|
@ -51,28 +51,28 @@ Parser::Parser(SnarlNetworkFrontend *snarl):
|
||||
void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *client)
|
||||
{
|
||||
snoreDebug(SNORE_DEBUG) << msg;
|
||||
QStringList splitted(msg.split("#?"));
|
||||
QStringList splitted(msg.split(QLatin1String("#?")));
|
||||
snpTypes action(ERROR);
|
||||
|
||||
QString appName;
|
||||
QString alertName;
|
||||
QString title;
|
||||
QString text;
|
||||
Icon icon(":/root/snore.png");
|
||||
Icon icon = Icon::defaultIcon();
|
||||
int timeout = Notification::defaultTimeout();
|
||||
|
||||
QString key;
|
||||
QByteArray key;
|
||||
QString value;
|
||||
|
||||
foreach(QString s, splitted) {
|
||||
key = s.mid(0, s.indexOf("=")).toLower();
|
||||
value = s.mid(s.indexOf("=") + 1);
|
||||
key = s.mid(0, s.indexOf(QLatin1String("="))).toLower().toLatin1();
|
||||
value = s.mid(s.indexOf(QLatin1String("=")) + 1);
|
||||
switch (getSnpType.value(key)) {
|
||||
case APP:
|
||||
appName = value;
|
||||
break;
|
||||
case ACTION:
|
||||
action = getSnpType.value(value);
|
||||
action = getSnpType.value(value.toLatin1());
|
||||
break;
|
||||
case TITLE:
|
||||
title = value;
|
||||
@ -98,12 +98,12 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *
|
||||
Alert alert;
|
||||
|
||||
if (snarl->m_applications.contains(client)) {
|
||||
app = snarl->m_applications[client];
|
||||
app = snarl->m_applications.value(client);
|
||||
}
|
||||
|
||||
if (!alertName.isEmpty() && app.isValid()) {
|
||||
if (app.alerts().contains(alertName)) {
|
||||
alert = app.alerts()[alertName];
|
||||
if (app.alerts().contains(alertName.toLatin1())) {
|
||||
alert = app.alerts().value(alertName.toLatin1());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
QHash<QString, Parser::snpTypes> getSnpType;
|
||||
QHash<QByteArray, Parser::snpTypes> getSnpType;
|
||||
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ void SnarlNetworkFrontend::slotActionInvoked(Snore::Notification notification)
|
||||
|
||||
if (notification.isActiveIn(this)) {
|
||||
snoreDebug(SNORE_DEBUG) << notification.closeReason();
|
||||
callback(notification, "SNP/1.1/304/Notification acknowledged/");
|
||||
callback(notification, QLatin1String("SNP/1.1/304/Notification acknowledged/"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,13 +72,13 @@ void SnarlNetworkFrontend::slotNotificationClosed(Snore::Notification notificati
|
||||
if (notification.removeActiveIn(this)) {
|
||||
switch (notification.closeReason()) {
|
||||
case Notification::TIMED_OUT:
|
||||
callback(notification, "SNP/1.1/303/Notification timed out/");
|
||||
callback(notification, QLatin1String("SNP/1.1/303/Notification timed out/"));
|
||||
break;
|
||||
case Notification::ACTIVATED:
|
||||
callback(notification, "SNP/1.1/307/Notification closed/");
|
||||
callback(notification, QLatin1String("SNP/1.1/307/Notification closed/"));
|
||||
break;
|
||||
case Notification::DISMISSED:
|
||||
callback(notification, "SNP/1.1/302/Notification cancelled/");
|
||||
callback(notification, QLatin1String("SNP/1.1/302/Notification cancelled/"));
|
||||
break;
|
||||
default:
|
||||
snoreDebug(SNORE_WARNING) << "Unhandled close reason" << notification.closeReason();
|
||||
@ -95,10 +95,10 @@ void SnarlNetworkFrontend::handleConnection()
|
||||
|
||||
void SnarlNetworkFrontend::handleMessages()
|
||||
{
|
||||
const QString out("SNP/1.1/0/OK");
|
||||
const QString out(QLatin1String("SNP/1.1/0/OK"));
|
||||
QTcpSocket *client = qobject_cast<QTcpSocket *>(sender());
|
||||
|
||||
QStringList messages(QString::fromLatin1(client->readAll()).trimmed().split("\r\n"));
|
||||
QStringList messages(QString::fromLatin1(client->readAll()).trimmed().split(QLatin1String("\r\n")));
|
||||
foreach(const QString & s, messages) {
|
||||
if (s.isEmpty()) {
|
||||
continue;
|
||||
@ -108,9 +108,9 @@ void SnarlNetworkFrontend::handleMessages()
|
||||
if (noti.isValid()) {
|
||||
noti.addActiveIn(this);
|
||||
SnoreCore::instance().broadcastNotification(noti);
|
||||
write(client, QString("%1/%2\r\n").arg(out, QString::number(noti.id())));
|
||||
write(client, QString(QLatin1String("%1/%2\r\n")).arg(out, QString::number(noti.id())));
|
||||
} else {
|
||||
write(client, QString("%1\r\n").arg(out));
|
||||
write(client, QString(QLatin1String("%1\r\n")).arg(out));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,9 +120,7 @@ void SnarlNetworkFrontend::callback(Notification &sn, const QString msg)
|
||||
if (sn.hints().containsPrivateValue(this, "clientSocket")) {
|
||||
QTcpSocket *client = sn.hints().privateValue(this, "clientSocket").value<QPointer<QTcpSocket>>();
|
||||
if(client){
|
||||
write(client, QString("%1%2\r\n").arg(msg, QString::number(sn.id())));
|
||||
}else{
|
||||
sn.hints().takePrivateValue(this, "clientSocket");
|
||||
write(client, QString(QLatin1String("%1%2\r\n")).arg(msg, QString::number(sn.id())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
virtual bool initialize() override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotActionInvoked(Snore::Notification notification) override;
|
||||
void slotNotificationClosed(Snore::Notification notification) override;
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void handleConnection();
|
||||
void handleMessages();
|
||||
|
||||
|
@ -28,22 +28,28 @@ using namespace Snore;
|
||||
|
||||
void NotifyMyAndroid::slotNotify(Notification notification)
|
||||
{
|
||||
QString key = value("ApiKey").toString();
|
||||
QString key = value(QLatin1String("ApiKey")).toString();
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkRequest request(QUrl("https://www.notifymyandroid.com/publicapi/notify"));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||
QNetworkRequest request(QUrl::fromEncoded("https://www.notifymyandroid.com/publicapi/notify"));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
||||
|
||||
// TODO: use toHTML?
|
||||
QString data(QString("apikey=%1&application=%2&event=%3&description=%4&priority=%5&content-type=text/html")
|
||||
.arg(key,
|
||||
notification.application().name(),
|
||||
notification.title(),
|
||||
notification.text(Utils::HREF | Utils::BOLD | Utils::BREAK |
|
||||
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC),
|
||||
QString::number(notification.priority())));
|
||||
|
||||
QString data = QLatin1String("apikey=") + key
|
||||
+ QLatin1String("&application=") + notification.application().name()
|
||||
+ QLatin1String("&event=") + notification.title()
|
||||
+ QLatin1String("&priority=") + QString::number(notification.priority())
|
||||
+ QLatin1String("&description=");
|
||||
|
||||
if(notification.constHints().value("supports-markup").toBool()){
|
||||
data += notification.text(Utils::HREF | Utils::BOLD | Utils::BREAK |
|
||||
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC)
|
||||
+ QLatin1String("&content-type=text/html");
|
||||
}else{
|
||||
data += notification.text();
|
||||
}
|
||||
|
||||
|
||||
QNetworkReply *reply = m_manager.post(request, data.toUtf8().constData());
|
||||
@ -58,7 +64,7 @@ void NotifyMyAndroid::slotNotify(Notification notification)
|
||||
|
||||
bool NotifyMyAndroid::initialize()
|
||||
{
|
||||
setDefaultValue("ApiKey", "");
|
||||
setDefaultValue(QLatin1String("ApiKey"), QString());
|
||||
return SnoreSecondaryBackend::initialize();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
|
||||
private:
|
||||
|
@ -34,10 +34,10 @@ NotifyMyAndroidSettings::~NotifyMyAndroidSettings()
|
||||
|
||||
void NotifyMyAndroidSettings::load()
|
||||
{
|
||||
m_lineEdit->setText(value("ApiKey").toString());
|
||||
m_lineEdit->setText(value(QLatin1String("ApiKey")).toString());
|
||||
}
|
||||
|
||||
void NotifyMyAndroidSettings::save()
|
||||
{
|
||||
setValue("ApiKey", m_lineEdit->text());
|
||||
setValue(QLatin1String("ApiKey"), m_lineEdit->text());
|
||||
}
|
||||
|
@ -29,25 +29,25 @@ using namespace Snore;
|
||||
|
||||
void Pushover::slotNotify(Notification notification)
|
||||
{
|
||||
QString key = value("UserKey").toString();
|
||||
QString key = value(QLatin1String("UserKey")).toString();
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkRequest request(QUrl("https://api.pushover.net/1/messages.json"));
|
||||
QNetworkRequest request(QUrl::fromEncoded("https://api.pushover.net/1/messages.json"));
|
||||
QHttpMultiPart *mp = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
|
||||
QHttpPart title;
|
||||
title.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"title\""));
|
||||
title.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"title\"")));
|
||||
title.setBody(notification.title().toUtf8().constData());
|
||||
mp->append(title);
|
||||
|
||||
QString textString;
|
||||
if(notification.application().constHints().value("use-markup").toBool()){
|
||||
if(notification.constHints().value("use-markup").toBool()){
|
||||
textString = notification.text(Utils::HREF | Utils::BOLD | Utils::UNDERLINE | Utils::FONT | Utils::ITALIC);
|
||||
|
||||
QHttpPart html;
|
||||
html.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"html\""));
|
||||
html.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"html\"")));
|
||||
html.setBody("1");
|
||||
mp->append(html);
|
||||
} else {
|
||||
@ -55,52 +55,52 @@ void Pushover::slotNotify(Notification notification)
|
||||
}
|
||||
|
||||
QHttpPart text;
|
||||
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"message\""));
|
||||
snoreDebug(SNORE_DEBUG) << "Use Markup" << notification.application().constHints().value("use-markup").toBool();
|
||||
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"message\"")));
|
||||
snoreDebug(SNORE_DEBUG) << "Use Markup" << notification.constHints().value("use-markup").toBool();
|
||||
snoreDebug(SNORE_DEBUG) << "Message" << textString;
|
||||
text.setBody(textString.toUtf8().constData());
|
||||
mp->append(text);
|
||||
|
||||
QHttpPart priority;
|
||||
priority.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"priority\""));
|
||||
priority.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"priority\"")));
|
||||
priority.setBody(QString::number(notification.priority()).toUtf8().constData());
|
||||
mp->append(priority);
|
||||
if(notification.priority() == Notification::EMERGENCY){
|
||||
|
||||
QHttpPart retry;
|
||||
retry.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"retry\""));
|
||||
retry.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"retry\"")));
|
||||
retry.setBody("30");// rety every 30 s
|
||||
mp->append(retry);
|
||||
|
||||
QHttpPart expire;
|
||||
expire.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"expire\""));
|
||||
expire.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"expire\"")));
|
||||
expire.setBody("300");//5 min
|
||||
mp->append(expire);
|
||||
}
|
||||
|
||||
QHttpPart sound;
|
||||
sound.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"sound\""));
|
||||
sound.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"sound\"")));
|
||||
if (notification.hints().value("silent").toBool()) {
|
||||
sound.setBody("none");
|
||||
} else {
|
||||
sound.setBody(value("Sound", LOCAL_SETTING).toString().toUtf8().constData());
|
||||
sound.setBody(value(QLatin1String("Sound"), LOCAL_SETTING).toString().toUtf8().constData());
|
||||
}
|
||||
mp->append(sound);
|
||||
|
||||
if (!value("Devices", LOCAL_SETTING).toString().isEmpty()) {
|
||||
if (!value(QLatin1String("Devices"), LOCAL_SETTING).toString().isEmpty()) {
|
||||
QHttpPart devices;
|
||||
devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"device\""));
|
||||
devices.setBody(value("Devices", LOCAL_SETTING).toString().toUtf8().constData());
|
||||
devices.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"device\"")));
|
||||
devices.setBody(value(QLatin1String("Devices"), LOCAL_SETTING).toString().toUtf8().constData());
|
||||
mp->append(devices);
|
||||
}
|
||||
|
||||
QHttpPart token;
|
||||
token.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"token\""));
|
||||
token.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"token\"")));
|
||||
token.setBody(notification.application().constHints().value("pushover-token").toString().toUtf8().constData());
|
||||
mp->append(token);
|
||||
|
||||
QHttpPart user;
|
||||
user.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"user\""));
|
||||
user.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"user\"")));
|
||||
user.setBody(key.toUtf8().constData());
|
||||
mp->append(user);
|
||||
|
||||
@ -118,9 +118,9 @@ void Pushover::slotNotify(Notification notification)
|
||||
|
||||
bool Pushover::initialize()
|
||||
{
|
||||
setDefaultValue("UserKey", "");
|
||||
setDefaultValue("Sound", "pushover", LOCAL_SETTING);
|
||||
setDefaultValue("Devices", "", LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("UserKey"), QString());
|
||||
setDefaultValue(QLatin1String("Sound"), QLatin1String("pushover"), LOCAL_SETTING);
|
||||
setDefaultValue(QLatin1String("Devices"), QString(), LOCAL_SETTING);
|
||||
return SnoreSecondaryBackend::initialize();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
|
||||
private:
|
||||
|
@ -38,14 +38,14 @@ PushoverSettings::~PushoverSettings()
|
||||
|
||||
void PushoverSettings::load()
|
||||
{
|
||||
m_keyLineEdit->setText(value("UserKey").toString());
|
||||
m_soundLineEdit->setText(value("Sound", Snore::LOCAL_SETTING).toString());
|
||||
m_deviceLineEdit->setText(value("Devices", Snore::LOCAL_SETTING).toString());
|
||||
m_keyLineEdit->setText(value(QLatin1String("UserKey")).toString());
|
||||
m_soundLineEdit->setText(value(QLatin1String("Sound"), Snore::LOCAL_SETTING).toString());
|
||||
m_deviceLineEdit->setText(value(QLatin1String("Devices"), Snore::LOCAL_SETTING).toString());
|
||||
}
|
||||
|
||||
void PushoverSettings::save()
|
||||
{
|
||||
setValue("UserKey", m_keyLineEdit->text());
|
||||
setValue("Sound", m_soundLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
setValue("Devices", m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
setValue(QLatin1String("UserKey"), m_keyLineEdit->text());
|
||||
setValue(QLatin1String("Sound"), m_soundLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
setValue(QLatin1String("Devices"), m_deviceLineEdit->text(), Snore::LOCAL_SETTING);
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ Sound::Sound():
|
||||
|
||||
bool Sound::initialize()
|
||||
{
|
||||
setDefaultValue("Volume", 50);
|
||||
m_player->setVolume(value("Volume").toInt());
|
||||
setDefaultValue(QLatin1String("Volume"), 50);
|
||||
m_player->setVolume(value(QLatin1String("Volume")).toInt());
|
||||
|
||||
return SnoreSecondaryBackend::initialize();
|
||||
}
|
||||
@ -55,7 +55,7 @@ void Sound::slotNotificationDisplayed(Snore::Notification notification)
|
||||
|
||||
QString sound = notification.hints().value("sound").toString();
|
||||
if (sound.isEmpty()) {
|
||||
sound = value("Sound").toString();
|
||||
sound = value(QLatin1String("Sound")).toString();
|
||||
}
|
||||
snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound;
|
||||
if (!sound.isEmpty()) {
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotificationDisplayed(Snore::Notification notification) override;
|
||||
private:
|
||||
QMediaPlayer *m_player;
|
||||
|
@ -37,14 +37,14 @@ SoundSettings::SoundSettings(SnorePlugin *snorePlugin, QWidget *parent) :
|
||||
QPushButton *button = new QPushButton(tr("Select a audio file"));
|
||||
connect(button, &QPushButton::clicked, [this]() {
|
||||
QFileDialog dialog;
|
||||
dialog.setNameFilter(tr("All Audio files").append("(*.mp3 *.wav *.ogg)"));
|
||||
dialog.setNameFilter(tr("All Audio files").append(QLatin1String("(*.mp3 *.wav *.ogg)")));
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
dialog.setDirectory(m_lineEditFileName->text());
|
||||
if (dialog.exec()) {
|
||||
m_lineEditFileName->setText(dialog.selectedFiles().first());
|
||||
}
|
||||
});
|
||||
addRow("", button);
|
||||
addRow(QString(), button);
|
||||
}
|
||||
|
||||
SoundSettings::~SoundSettings()
|
||||
@ -53,13 +53,13 @@ SoundSettings::~SoundSettings()
|
||||
|
||||
void SoundSettings::load()
|
||||
{
|
||||
m_lineEditFileName->setText(value("Sound").toString());
|
||||
m_spinBoxVolume->setValue(value("Volume").toInt());
|
||||
m_lineEditFileName->setText(value(QLatin1String("Sound")).toString());
|
||||
m_spinBoxVolume->setValue(value(QLatin1String("Volume")).toInt());
|
||||
}
|
||||
|
||||
void SoundSettings::save()
|
||||
{
|
||||
setValue("Sound", m_lineEditFileName->text());
|
||||
setValue("Volume", m_spinBoxVolume->value());
|
||||
setValue(QLatin1String("Sound"), m_lineEditFileName->text());
|
||||
setValue(QLatin1String("Volume"), m_spinBoxVolume->value());
|
||||
}
|
||||
|
||||
|
@ -29,25 +29,25 @@ using namespace Snore;
|
||||
|
||||
void Toasty::slotNotify(Notification notification)
|
||||
{
|
||||
QString key = value("DeviceID").toString();
|
||||
QString key = value(QLatin1String("DeviceID")).toString();
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QNetworkRequest request(QString("http://api.supertoasty.com/notify/%1").arg(key));
|
||||
QNetworkRequest request(QUrl::fromUserInput(QLatin1String("http://api.supertoasty.com/notify/") + key));
|
||||
QHttpMultiPart *mp = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
|
||||
QHttpPart title;
|
||||
title.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"title\""));
|
||||
title.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"title\"")));
|
||||
title.setBody(notification.title().toUtf8().constData());
|
||||
mp->append(title);
|
||||
|
||||
QHttpPart text;
|
||||
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
|
||||
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"text\"")));
|
||||
text.setBody(notification.text().toUtf8().constData());
|
||||
mp->append(text);
|
||||
|
||||
QHttpPart app;
|
||||
app.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"sender\""));
|
||||
app.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"sender\"")));
|
||||
app.setBody(notification.application().name().toUtf8().constData());
|
||||
mp->append(app);
|
||||
|
||||
@ -58,8 +58,8 @@ void Toasty::slotNotify(Notification notification)
|
||||
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())));
|
||||
icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
|
||||
icon.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"image\"; filename=\"") + sIcon.localUrl() + QLatin1Char('"')));
|
||||
icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("image/png")));
|
||||
QFile *file = new QFile(sIcon.localUrl());
|
||||
file->open(QIODevice::ReadOnly);
|
||||
icon.setBodyDevice(file);
|
||||
@ -80,7 +80,7 @@ void Toasty::slotNotify(Notification notification)
|
||||
|
||||
bool Toasty::initialize()
|
||||
{
|
||||
setDefaultValue("DeviceID", "");
|
||||
setDefaultValue(QLatin1String("DeviceID"), QString());
|
||||
return SnoreSecondaryBackend::initialize();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void slotNotify(Snore::Notification notification) override;
|
||||
|
||||
private:
|
||||
|
@ -34,10 +34,10 @@ ToastySettings::~ToastySettings()
|
||||
|
||||
void ToastySettings::load()
|
||||
{
|
||||
m_lineEdit->setText(value("DeviceID").toString());
|
||||
m_lineEdit->setText(value(QLatin1String("DeviceID")).toString());
|
||||
}
|
||||
|
||||
void ToastySettings::save()
|
||||
{
|
||||
setValue("DeviceID", m_lineEdit->text());
|
||||
setValue(QLatin1String("DeviceID"), m_lineEdit->text());
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ bool setSetting(const QString &appName, SettingsType type, const QString &_key,
|
||||
return false;
|
||||
}
|
||||
settings.setValue(key, value);
|
||||
cout << "Set: " << qPrintable(key) << " to " << qPrintable(settings.value(key).toString()) << endl;
|
||||
cout <<"Set: " << qPrintable(key) << " to " << qPrintable(settings.value(key).toString()) << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ void listSettings(SettingsType type, const QString &application)
|
||||
|
||||
cout << qPrintable(application) << endl;
|
||||
for (const QString &key : Utils::allSettingsKeysWithPrefix(
|
||||
Utils::normalizeSettingsKey("", type, application), settings, getAllKeys)) {
|
||||
cout << " " << qPrintable(key) << ": " << qPrintable(settings.value(Utils::normalizeSettingsKey(key, type, application)).toString()) << endl;
|
||||
Utils::normalizeSettingsKey(QLatin1String(""), type, application), settings, getAllKeys)) {
|
||||
cout <<" " << qPrintable(key) << ": " << qPrintable(settings.value(Utils::normalizeSettingsKey(key, type, application)).toString()) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,40 +56,40 @@ int main(int argc, char *argv[])
|
||||
SettingsWindow *window;
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("SnoreSettings");
|
||||
app.setOrganizationName("SnoreNotify");
|
||||
app.setApplicationName(QLatin1String("SnoreSettings"));
|
||||
app.setOrganizationName(QLatin1String("SnoreNotify"));
|
||||
app.setApplicationVersion(Snore::Version::version());
|
||||
|
||||
Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::ALL);
|
||||
Snore::SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", QVariant::fromValue(true));
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("A settings interface for Snorenotify.");
|
||||
parser.setApplicationDescription(QLatin1String("A settings interface for Snorenotify."));
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
//TODO: merge with appNameCommand ?
|
||||
QCommandLineOption listAppsCommand("apps", "List possible application.");
|
||||
QCommandLineOption listAppsCommand(QLatin1String("apps"), QLatin1String("List possible application."));
|
||||
parser.addOption(listAppsCommand);
|
||||
|
||||
QCommandLineOption listSettingsCommand({"l", "list"} , "List settings for the given --appName or the global settings.");
|
||||
QCommandLineOption listSettingsCommand({QLatin1String("l"), QLatin1String("list")} , QLatin1String("List settings for the given --appName or the global settings."));
|
||||
parser.addOption(listSettingsCommand);
|
||||
|
||||
QCommandLineOption appNameCommand({"a", "appName"} , "Set the Name of the app <app>.", "app", "GlobalSettings");
|
||||
QCommandLineOption appNameCommand({QLatin1String("a"), QLatin1String("appName")} , QLatin1String("Set the Name of the app <app>."), QLatin1String("app"), QLatin1String("GlobalSettings"));
|
||||
parser.addOption(appNameCommand);
|
||||
|
||||
QCommandLineOption typeCommand({"t", "type"} , "Type of the setting [global|local].", "type");
|
||||
QCommandLineOption typeCommand({QLatin1String("t"),QLatin1String("type")} ,QLatin1String("Type of the setting [global|local]."),QLatin1String("type"));
|
||||
parser.addOption(typeCommand);
|
||||
|
||||
parser.addPositionalArgument("key", "The settings Key.");
|
||||
parser.addPositionalArgument("value", "The new settings Value");
|
||||
parser.addPositionalArgument(QLatin1String("key"), QLatin1String("The settings Key."));
|
||||
parser.addPositionalArgument(QLatin1String("value"), QLatin1String("The new settings Value"));
|
||||
|
||||
parser.process(app);
|
||||
|
||||
SettingsType type = GLOBAL_SETTING;
|
||||
if (parser.isSet(typeCommand)) {
|
||||
QString typeName = parser.value(typeCommand);
|
||||
if (typeName != "global" && typeName == "local") {
|
||||
if (typeName != QLatin1String("global") && typeName == QLatin1String("local")) {
|
||||
type = LOCAL_SETTING;
|
||||
} else {
|
||||
parser.showHelp(1);
|
||||
|
@ -31,7 +31,7 @@ SettingsWindow::~SettingsWindow()
|
||||
|
||||
QStringList SettingsWindow::knownApps()
|
||||
{
|
||||
return Utils::allSettingsKeysWithPrefix(QString("%1/%2").arg(Utils::settingsVersionSchema(), "LocalSettings"), settings(),
|
||||
return Utils::allSettingsKeysWithPrefix(Utils::settingsVersionSchema() + QLatin1String("/LocalSettings"), settings(),
|
||||
[](QSettings & settings) {
|
||||
return settings.childGroups();
|
||||
});
|
||||
@ -39,7 +39,7 @@ QStringList SettingsWindow::knownApps()
|
||||
|
||||
QSettings &SettingsWindow::settings()
|
||||
{
|
||||
static QSettings settings("Snorenotify", "libsnore");
|
||||
static QSettings settings(QLatin1String("Snorenotify"), QLatin1String("libsnore"));
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
static QSettings &settings();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void on_comboBox_currentIndexChanged(const QString &arg1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user