Use CamelCase for enums
This commit is contained in:
parent
e7dec50230
commit
28c1edb783
|
@ -16,8 +16,8 @@ public:
|
|||
app(QStringLiteral("Test"), Icon::defaultIcon())
|
||||
{
|
||||
SnoreCore &instance = SnoreCore::instance();
|
||||
instance.loadPlugins(SnorePlugin::BACKEND);
|
||||
instance.setSettingsValue(QStringLiteral("Timeout"), 5, LOCAL_SETTING);
|
||||
instance.loadPlugins(SnorePlugin::Backend);
|
||||
instance.setSettingsValue(QStringLiteral("Timeout"), 5, LocalSettings);
|
||||
SnoreCore::instance().registerApplication(app);
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ private Q_SLOTS:
|
|||
private:
|
||||
void testString(QString message)
|
||||
{
|
||||
qDebug() << Utils::normalizeMarkup(message, Utils::NO_MARKUP);
|
||||
qDebug() << Utils::normalizeMarkup(message, Utils::NoMarkup);
|
||||
SnoreCore &snore = SnoreCore::instance();
|
||||
QStringList backends = snore.pluginNames(SnorePlugin::BACKEND);
|
||||
QStringList backends = snore.pluginNames(SnorePlugin::Backend);
|
||||
auto notify = [&backends, &snore, &message, this](Notification n) {
|
||||
qDebug() << n << "closed";
|
||||
qDebug() << backends.size();
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
QString old = snore.primaryNotificationBackend();
|
||||
while (snore.primaryNotificationBackend() == old) {
|
||||
QString p = backends.takeLast();
|
||||
snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LOCAL_SETTING);
|
||||
snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LocalSettings);
|
||||
SnoreCorePrivate::instance()->syncSettings();
|
||||
if (snore.primaryNotificationBackend() == p) {
|
||||
qDebug() << p;
|
||||
|
|
|
@ -15,8 +15,8 @@ public:
|
|||
SnoreBenchmark()
|
||||
{
|
||||
SnoreCore &instance = SnoreCore::instance();
|
||||
instance.loadPlugins(SnorePlugin::BACKEND);
|
||||
instance.setSettingsValue(QStringLiteral("Timeout"), 1, LOCAL_SETTING);
|
||||
instance.loadPlugins(SnorePlugin::Backend);
|
||||
instance.setSettingsValue(QStringLiteral("Timeout"), 1, LocalSettings);
|
||||
}
|
||||
|
||||
// clazy is complaining about this string but QStringLiteral won't work for the multiline string, so use QStringBuilder to silence it.
|
||||
|
@ -39,40 +39,40 @@ private Q_SLOTS:
|
|||
void SnoreBenchmark::benchmarkUtilsToHtml()
|
||||
{
|
||||
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP), QLatin1String("Italic A\n"
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::NoMarkup), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"Website\n"));
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF), QLatin1String("Italic A\n"
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::Href), QLatin1String("Italic A\n"
|
||||
"Italic B\n"
|
||||
"Bold\n"
|
||||
"Underline\n"
|
||||
"Font\n"
|
||||
"<&>\n"
|
||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Website</a>\n"));
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::HREF | Utils::BOLD | Utils::BREAK |
|
||||
Utils::UNDERLINE | Utils::FONT | Utils::ITALIC), htmlTestString);
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::Href | Utils::Bold | Utils::Break |
|
||||
Utils::Underline | Utils::Font | Utils::Italic), htmlTestString);
|
||||
QBENCHMARK {
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::HREF);
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::Href);
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreBenchmark::benchmarkUtilsToHtmlAllMarkup()
|
||||
{
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP), htmlTestString);
|
||||
QCOMPARE(Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup), htmlTestString);
|
||||
|
||||
QBENCHMARK {
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::ALL_MARKUP);
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::AllMarkup);
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreBenchmark::benchmarkUtilsToPlain()
|
||||
{
|
||||
QBENCHMARK {
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::NO_MARKUP);
|
||||
Utils::normalizeMarkup(htmlTestString, Utils::NoMarkup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ using namespace Snore;
|
|||
SnoreNotify::SnoreNotify()
|
||||
{
|
||||
m_trayIcon = new TrayIcon();
|
||||
SnoreCore::instance().loadPlugins(SnorePlugin::ALL);
|
||||
SnoreCore::instance().loadPlugins(SnorePlugin::All);
|
||||
m_trayIcon->initConextMenu();
|
||||
|
||||
qCDebug(SNORE) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend();
|
||||
|
|
|
@ -36,7 +36,7 @@ ApplicationData::ApplicationData(const QString &key, const QString &name, const
|
|||
m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t"));
|
||||
m_hint.setValue("use-markup", false);
|
||||
m_hint.setValue("silent", QVariant::fromValue(LambdaHint([]() {
|
||||
return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING);
|
||||
return SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings);
|
||||
})));
|
||||
|
||||
}
|
||||
|
|
|
@ -92,12 +92,12 @@ Application &Notification::application() const
|
|||
return d->m_application;
|
||||
}
|
||||
|
||||
QString Notification::title(Utils::MARKUP_FLAGS flags) const
|
||||
QString Notification::title(Utils::MarkupFlags flags) const
|
||||
{
|
||||
return d->resolveMarkup(d->m_title, flags);
|
||||
}
|
||||
|
||||
QString Notification::text(Utils::MARKUP_FLAGS flags) const
|
||||
QString Notification::text(Utils::MarkupFlags flags) const
|
||||
{
|
||||
return d->resolveMarkup(d->m_text, flags);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ NotificationData *Notification::data()
|
|||
|
||||
int Notification::defaultTimeout()
|
||||
{
|
||||
return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt();
|
||||
return SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt();
|
||||
}
|
||||
|
||||
QDataStream &operator<< (QDataStream &stream, const Notification ¬i)
|
||||
|
@ -197,11 +197,11 @@ QDebug operator <<(QDebug debug, const Snore::Notification::CloseReasons &flags)
|
|||
{
|
||||
debug.nospace() << "CloseReasons(";
|
||||
switch (flags) {
|
||||
debugPrintEnum(Notification::NONE);
|
||||
debugPrintEnum(Notification::TIMED_OUT);
|
||||
debugPrintEnum(Notification::DISMISSED);
|
||||
debugPrintEnum(Notification::ACTIVATED);
|
||||
debugPrintEnum(Notification::REPLACED);
|
||||
debugPrintEnum(Notification::None);
|
||||
debugPrintEnum(Notification::TimedOut);
|
||||
debugPrintEnum(Notification::Dismissed);
|
||||
debugPrintEnum(Notification::Activated);
|
||||
debugPrintEnum(Notification::Replaced);
|
||||
}
|
||||
return debug.space();
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ QDebug operator<< (QDebug debug, const Snore::Notification::Prioritys &flags)
|
|||
{
|
||||
debug.nospace() << "Prioritys(";
|
||||
switch (flags) {
|
||||
debugPrintEnum(Notification::LOW);
|
||||
debugPrintEnum(Notification::NORMAL);
|
||||
debugPrintEnum(Notification::HIGH);
|
||||
debugPrintEnum(Notification::Low);
|
||||
debugPrintEnum(Notification::Normal);
|
||||
debugPrintEnum(Notification::High);
|
||||
default:
|
||||
debug << QByteArray::number(flags, 16) << ")";
|
||||
}
|
||||
|
|
|
@ -49,35 +49,35 @@ public:
|
|||
/**
|
||||
* The default value, the notification was not closed.
|
||||
*/
|
||||
NONE = 0,
|
||||
None = 0,
|
||||
|
||||
/**
|
||||
* The Notification was closed becaouse it timed out.
|
||||
*/
|
||||
TIMED_OUT = 1,
|
||||
TimedOut = 1,
|
||||
|
||||
/**
|
||||
* The Notification was dismissed by the user, close button.
|
||||
*/
|
||||
DISMISSED = 2,
|
||||
Dismissed = 2,
|
||||
|
||||
/**
|
||||
* The Notification was activated, an action was invoked.
|
||||
* @see actionInvoked()
|
||||
*/
|
||||
ACTIVATED = 3,
|
||||
Activated = 3,
|
||||
|
||||
/**
|
||||
* @deprecated same as ACTIVATED
|
||||
*/
|
||||
CLOSED = 3,
|
||||
Closed = 3,
|
||||
|
||||
/**
|
||||
* The notification was replaced by an update.
|
||||
* This value will be used if a notification backend does not support updating.
|
||||
*
|
||||
*/
|
||||
REPLACED = 4
|
||||
Replaced = 4
|
||||
};
|
||||
Q_ENUMS(CloseReasons)
|
||||
|
||||
|
@ -89,27 +89,27 @@ public:
|
|||
/**
|
||||
* Indicates the lowes priority. The backend might ignore the notification.
|
||||
*/
|
||||
LOWEST = -2,
|
||||
Lowest = -2,
|
||||
|
||||
/**
|
||||
* Indicates a low priority.
|
||||
*/
|
||||
LOW = -1,
|
||||
Low = -1,
|
||||
|
||||
/**
|
||||
* The default priority.
|
||||
*/
|
||||
NORMAL = 0,
|
||||
Normal = 0,
|
||||
|
||||
/**
|
||||
* Indicates a priority above the normal level.
|
||||
*/
|
||||
HIGH = +1,
|
||||
High = +1,
|
||||
|
||||
/**
|
||||
* Indicates a emegency priority, the notifications is sticky and should be acknowlegded.
|
||||
*/
|
||||
EMERGENCY = +2
|
||||
Emergency = +2
|
||||
};
|
||||
|
||||
Notification();
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
* @param timeout the timeout
|
||||
* @param priority the priority
|
||||
*/
|
||||
explicit Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Notification::Prioritys priority = NORMAL);
|
||||
explicit Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Notification::Prioritys priority = Normal);
|
||||
|
||||
/**
|
||||
* Creates and update Notification replacing an existing Notification
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
* @param timeout the timeout
|
||||
* @param priority the piority
|
||||
*/
|
||||
explicit Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Snore::Notification::Prioritys priority = NORMAL);
|
||||
explicit Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Snore::Notification::Prioritys priority = Normal);
|
||||
|
||||
/**
|
||||
* The copy constructor
|
||||
|
@ -178,13 +178,13 @@ public:
|
|||
* Returns the title of the notification.
|
||||
* @param flags the supported markup flags.
|
||||
*/
|
||||
QString title(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const;
|
||||
QString title(Utils::MarkupFlags flags = Utils::NoMarkup) const;
|
||||
|
||||
/**
|
||||
* Returns the notification text.
|
||||
* @param flags the supported markup flags.
|
||||
*/
|
||||
QString text(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const;
|
||||
QString text(Utils::MarkupFlags flags = Utils::NoMarkup) const;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -33,7 +33,7 @@ uint NotificationData::m_idCount = 1;
|
|||
NotificationData::NotificationData(const Snore::Application &application, const Snore::Alert &alert, const QString &title, const QString &text, const Icon &icon,
|
||||
int timeout, Notification::Prioritys priority):
|
||||
m_id(m_idCount++),
|
||||
m_timeout(priority == Notification::EMERGENCY ? 0 : timeout),
|
||||
m_timeout(priority == Notification::Emergency ? 0 : timeout),
|
||||
m_application(application),
|
||||
m_alert(alert),
|
||||
m_title(title),
|
||||
|
@ -49,7 +49,7 @@ NotificationData::NotificationData(const Snore::Application &application, const
|
|||
|
||||
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
|
||||
m_id(m_idCount++),
|
||||
m_timeout(priority == Notification::EMERGENCY ? 0 : timeout),
|
||||
m_timeout(priority == Notification::Emergency ? 0 : timeout),
|
||||
m_application(old.application()),
|
||||
m_alert(old.alert()),
|
||||
m_title(title),
|
||||
|
@ -82,10 +82,10 @@ void NotificationData::setCloseReason(Snore::Notification::CloseReasons r)
|
|||
stopTimeoutTimer();
|
||||
}
|
||||
|
||||
QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags)
|
||||
QString NotificationData::resolveMarkup(const QString &string, Utils::MarkupFlags flags)
|
||||
{
|
||||
if (!m_hints.value("use-markup").toBool()) {
|
||||
if (flags == Utils::NO_MARKUP) {
|
||||
if (flags == Utils::NoMarkup) {
|
||||
return string;
|
||||
} else {
|
||||
return Utils::normalizeMarkup(string.toHtmlEscaped(), flags);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
void setCloseReason(Notification::CloseReasons r);
|
||||
|
||||
QString resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags);
|
||||
QString resolveMarkup(const QString &string, Utils::MarkupFlags flags);
|
||||
|
||||
void setBroadcasted();
|
||||
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
QString m_text;
|
||||
Icon m_icon;
|
||||
Notification::Prioritys m_priority;
|
||||
Notification::CloseReasons m_closeReason = Notification::NONE;
|
||||
Notification::CloseReasons m_closeReason = Notification::None;
|
||||
Action m_actionInvoked;
|
||||
QHash<int, Action> m_actions;
|
||||
Hint m_hints;
|
||||
|
|
|
@ -101,7 +101,7 @@ QString SnorePlugin::settingsVersion() const
|
|||
|
||||
void SnorePlugin::setDefaultSettings()
|
||||
{
|
||||
setDefaultSettingsValue(QStringLiteral("Enabled"), false, LOCAL_SETTING);
|
||||
setDefaultSettingsValue(QStringLiteral("Enabled"), false, LocalSettings);
|
||||
}
|
||||
|
||||
void SnorePlugin::setErrorString(const QString &_error)
|
||||
|
|
|
@ -46,38 +46,38 @@ public:
|
|||
/**
|
||||
* Flag for loading no plugins.
|
||||
*/
|
||||
NONE = 0,
|
||||
None = 0,
|
||||
|
||||
/**
|
||||
* Backends are those plugins that are capable of reporting user interaction.
|
||||
*/
|
||||
BACKEND = 1 << 0,
|
||||
Backend = 1 << 0,
|
||||
|
||||
/**
|
||||
* Secondary backaends are non interactive.
|
||||
* Redirection or playback of a sound file.
|
||||
*/
|
||||
SECONDARY_BACKEND = 1 << 1,
|
||||
SecondaryBackend = 1 << 1,
|
||||
|
||||
/**
|
||||
* Frontends are capable of recieving notifications.
|
||||
*/
|
||||
FRONTEND = 1 << 2,
|
||||
Frontend = 1 << 2,
|
||||
|
||||
/**
|
||||
* Generell plugins, currently there are not plugins implemented.
|
||||
*/
|
||||
PLUGIN = 1 << 3,
|
||||
Plugin = 1 << 3,
|
||||
|
||||
/**
|
||||
* A settings page for a Plugin.
|
||||
*/
|
||||
SETTINGS = 1 << 4,
|
||||
Settings = 1 << 4,
|
||||
|
||||
/**
|
||||
* Flag for loading all plugins.
|
||||
*/
|
||||
ALL = ~0
|
||||
All = ~0
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(PluginTypes, PluginType)
|
||||
|
@ -132,9 +132,9 @@ public:
|
|||
*/
|
||||
QString errorString() const;
|
||||
|
||||
QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING);
|
||||
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING);
|
||||
QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
|
||||
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
|
||||
|
||||
Q_SIGNALS:
|
||||
void enabledChanged(bool enabled);
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
PluginTypes type() const override
|
||||
{
|
||||
return SnorePlugin::SETTINGS;
|
||||
return SnorePlugin::Settings;
|
||||
};
|
||||
|
||||
virtual PluginSettingsWidget *settingsWidget(SnorePlugin *parent) = 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ PluginSettingsWidget::PluginSettingsWidget(SnorePlugin *snorePlugin, QWidget *pa
|
|||
m_enabled(new QCheckBox)
|
||||
{
|
||||
setLayout(m_layout);
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
if (m_snorePlugin->type() != SnorePlugin::Backend) {
|
||||
// backends are handled through a combo box.
|
||||
addRow(tr("Enabled:"), m_enabled);
|
||||
}
|
||||
|
@ -60,16 +60,16 @@ void PluginSettingsWidget::addRow(const QString &label, QWidget *widget, const Q
|
|||
|
||||
void PluginSettingsWidget::loadSettings()
|
||||
{
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool());
|
||||
if (m_snorePlugin->type() != SnorePlugin::Backend) {
|
||||
m_enabled->setChecked(m_snorePlugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool());
|
||||
}
|
||||
load();
|
||||
}
|
||||
|
||||
void PluginSettingsWidget::saveSettings()
|
||||
{
|
||||
if (m_snorePlugin->type() != SnorePlugin::BACKEND) {
|
||||
m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LOCAL_SETTING);
|
||||
if (m_snorePlugin->type() != SnorePlugin::Backend) {
|
||||
m_snorePlugin->setSettingsValue(QStringLiteral("Enabled"), m_enabled->isChecked(), LocalSettings);
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
bool isDirty();
|
||||
|
||||
protected:
|
||||
QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GLOBAL_SETTING) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GLOBAL_SETTING);
|
||||
QVariant settingsValue(const QString &key, Snore::SettingsType type = Snore::GlobalSettings) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, Snore::SettingsType type = Snore::GlobalSettings);
|
||||
|
||||
virtual void load();
|
||||
virtual void save();
|
||||
|
|
|
@ -32,7 +32,7 @@ QList<PluginSettingsWidget *> Settings::settingWidgets(SnorePlugin::PluginTypes
|
|||
//TODO: mem leak?
|
||||
|
||||
SnorePlugin *plugin = core->m_plugins[qMakePair(type, name)];
|
||||
SettingsPlugin *settingsPlugin = qobject_cast< Snore::SettingsPlugin * >(core->m_plugins[qMakePair(Snore::SnorePlugin::SETTINGS, name)]);
|
||||
SettingsPlugin *settingsPlugin = qobject_cast< Snore::SettingsPlugin * >(core->m_plugins[qMakePair(Snore::SnorePlugin::Settings, name)]);
|
||||
if (settingsPlugin) {
|
||||
PluginSettingsWidget *widget = settingsPlugin->settingsWidget(plugin);
|
||||
if (widget) {
|
||||
|
|
|
@ -42,9 +42,9 @@ SettingsDialog::~SettingsDialog()
|
|||
|
||||
void SettingsDialog::initTabs()
|
||||
{
|
||||
SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>();
|
||||
if (types == SnorePlugin::NONE) {
|
||||
types = SnorePlugin::ALL;
|
||||
SnorePlugin::PluginTypes types = SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>();
|
||||
if (types == SnorePlugin::None) {
|
||||
types = SnorePlugin::All;
|
||||
}
|
||||
auto addWidgets = [&](QTabWidget * target, QWidget * container, SnorePlugin::PluginTypes type) {
|
||||
bool enabled = false;
|
||||
|
@ -66,10 +66,10 @@ void SettingsDialog::initTabs()
|
|||
ui->tabWidget->removeTab(index);
|
||||
}
|
||||
};
|
||||
addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::BACKEND);
|
||||
addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SECONDARY_BACKEND);
|
||||
addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::FRONTEND);
|
||||
addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::PLUGIN);
|
||||
addWidgets(ui->tabWidget_backends, ui->tab_backends, SnorePlugin::Backend);
|
||||
addWidgets(ui->tabWidget_secondary_backends, ui->tab_secondaryBackends, SnorePlugin::SecondaryBackend);
|
||||
addWidgets(ui->tabWidget_frontends, ui->tab_frontends, SnorePlugin::Frontend);
|
||||
addWidgets(ui->tabWidget_plugins, ui->tab_plugins, SnorePlugin::Plugin);
|
||||
|
||||
ui->errorLabel->setVisible(false);
|
||||
ui->errorLineEdit->setVisible(false);
|
||||
|
@ -90,9 +90,9 @@ void SettingsDialog::on_pushButton_clicked()
|
|||
void SettingsDialog::load()
|
||||
{
|
||||
qCDebug(SNORE) << "loading";
|
||||
loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString());
|
||||
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt());
|
||||
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool());
|
||||
loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString());
|
||||
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt());
|
||||
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool());
|
||||
foreach(auto widget, m_tabs) {
|
||||
widget->loadSettings();
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ void SettingsDialog::load()
|
|||
|
||||
void SettingsDialog::loadPrimaryBackendBox(const QString &backend)
|
||||
{
|
||||
if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LOCAL_SETTING).value<SnorePlugin::PluginTypes>() & SnorePlugin::BACKEND) {
|
||||
if (SnoreCore::instance().settingsValue(QStringLiteral("PluginTypes"), LocalSettings).value<SnorePlugin::PluginTypes>() & SnorePlugin::Backend) {
|
||||
ui->primaryBackendComboBox->clear();
|
||||
QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::BACKEND);
|
||||
QStringList list = SnoreCore::instance().pluginNames(SnorePlugin::Backend);
|
||||
ui->primaryBackendComboBox->addItems(list);
|
||||
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(backend));
|
||||
ui->primaryBackendComboBox->setVisible(true);
|
||||
|
@ -121,13 +121,13 @@ void SettingsDialog::save()
|
|||
w->saveSettings();
|
||||
dirty |= w->isDirty();
|
||||
}
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() != ui->primaryBackendComboBox->currentText();
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt() != ui->timeoutSpinBox->value();
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() != ui->primaryBackendComboBox->currentText();
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LocalSettings).toInt() != ui->timeoutSpinBox->value();
|
||||
dirty |= SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LocalSettings).toBool() != ui->disableNotificationSoundCheckBox->isChecked();
|
||||
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LOCAL_SETTING);
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("PrimaryBackend"), ui->primaryBackendComboBox->currentText(), LocalSettings);
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("Timeout"), ui->timeoutSpinBox->value(), LocalSettings);
|
||||
SnoreCore::instance().setSettingsValue(QStringLiteral("Silent"), ui->disableNotificationSoundCheckBox->isChecked(), LocalSettings);
|
||||
|
||||
if (dirty) {
|
||||
SnoreCorePrivate::instance()->syncSettings();
|
||||
|
|
|
@ -74,10 +74,10 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
|||
return;
|
||||
}
|
||||
Q_D(SnoreCore);
|
||||
setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING);
|
||||
setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LocalSettings);
|
||||
qCDebug(SNORE) << "Loading plugin types:" << types;
|
||||
foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) {
|
||||
if (type != SnorePlugin::ALL && types & type) {
|
||||
if (type != SnorePlugin::All && types & type) {
|
||||
foreach(PluginContainer * info, PluginContainer::pluginCache(type).values()) {
|
||||
SnorePlugin *plugin = info->load();
|
||||
if (!plugin) {
|
||||
|
@ -85,13 +85,13 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
|||
}
|
||||
|
||||
switch (info->type()) {
|
||||
case SnorePlugin::BACKEND:
|
||||
case SnorePlugin::Backend:
|
||||
break;
|
||||
case SnorePlugin::SECONDARY_BACKEND:
|
||||
case SnorePlugin::FRONTEND:
|
||||
case SnorePlugin::PLUGIN:
|
||||
case SnorePlugin::SETTINGS:
|
||||
plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool());
|
||||
case SnorePlugin::SecondaryBackend:
|
||||
case SnorePlugin::Frontend:
|
||||
case SnorePlugin::Plugin:
|
||||
case SnorePlugin::Settings:
|
||||
plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool());
|
||||
break;
|
||||
default:
|
||||
qCWarning(SNORE) << "Plugin Cache corrupted\n" << info->file() << info->type();
|
||||
|
@ -125,7 +125,7 @@ void SnoreCore::broadcastNotification(Notification notification)
|
|||
qCDebug(SNORE) << "Broadcasting" << notification << "timeout:" << notification.timeout();
|
||||
if (d->m_notificationBackend != nullptr) {
|
||||
if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) {
|
||||
requestCloseNotification(notification.old(), Notification::REPLACED);
|
||||
requestCloseNotification(notification.old(), Notification::Replaced);
|
||||
}
|
||||
}
|
||||
notification.data()->setBroadcasted();
|
||||
|
@ -213,7 +213,7 @@ QVariant SnoreCore::settingsValue(const QString &key, SettingsType type) const
|
|||
{
|
||||
Q_D(const SnoreCore);
|
||||
QString nk = d->normalizeSettingsKey(key, type);
|
||||
if (type == LOCAL_SETTING && !d->m_settings->contains(nk)) {
|
||||
if (type == LocalSettings && !d->m_settings->contains(nk)) {
|
||||
nk = d->normalizeSettingsKey(key + QStringLiteral("-SnoreDefault"), type);
|
||||
}
|
||||
return d->m_settings->value(nk);
|
||||
|
@ -247,7 +247,7 @@ void SnoreCore::displayExampleNotification()
|
|||
QString text = QLatin1String("<i>") + tr("This is %1").arg(app.name()) + QLatin1String("</i><br>"
|
||||
"<b>") + tr("Everything is awesome!") + QLatin1String("</b><br>");
|
||||
if (!app.constHints().value("use-markup").toBool()) {
|
||||
text = Utils::normalizeMarkup(text, Utils::NO_MARKUP);
|
||||
text = Utils::normalizeMarkup(text, Utils::NoMarkup);
|
||||
}
|
||||
Notification noti(app, app.defaultAlert(), tr("Hello There!"), text, app.icon());
|
||||
noti.addAction(Action(1, tr("Awesome Action!")));
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
*
|
||||
* @return a list of plugins
|
||||
*/
|
||||
const QStringList pluginNames(SnorePlugin::PluginTypes type = SnorePlugin::ALL) const;
|
||||
const QStringList pluginNames(SnorePlugin::PluginTypes type = SnorePlugin::All) const;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -138,9 +138,9 @@ public:
|
|||
*/
|
||||
void setDefaultApplication(Application app);
|
||||
|
||||
QVariant settingsValue(const QString &key, SettingsType type = GLOBAL_SETTING) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING);
|
||||
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GLOBAL_SETTING);
|
||||
QVariant settingsValue(const QString &key, SettingsType type = GlobalSettings) const;
|
||||
void setSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
|
||||
void setDefaultSettingsValue(const QString &key, const QVariant &settingsValue, SettingsType type = GlobalSettings);
|
||||
|
||||
Notification getActiveNotificationByID(uint id) const;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ SnoreCorePrivate::SnoreCorePrivate():
|
|||
|
||||
qCDebug(SNORE) << "Temp dir is" << tempPath();
|
||||
qCDebug(SNORE) << "Snore settings are located in" << m_settings->fileName();
|
||||
qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LOCAL_SETTING);
|
||||
qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LocalSettings);
|
||||
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
|
||||
}
|
||||
|
@ -85,11 +85,11 @@ void SnoreCorePrivate::slotNotificationDisplayed(Notification notification)
|
|||
bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
if (m_pluginNames[SnorePlugin::BACKEND].contains(backend)) {
|
||||
if (m_pluginNames[SnorePlugin::Backend].contains(backend)) {
|
||||
if (backend == q->primaryNotificationBackend()) {
|
||||
return true;
|
||||
}
|
||||
const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::BACKEND);
|
||||
const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::Backend);
|
||||
if (!backends.contains(backend)) {
|
||||
qCDebug(SNORE) << "Unknown Backend:" << backend;
|
||||
return false;
|
||||
|
@ -107,7 +107,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
|||
}
|
||||
m_notificationBackend = b;
|
||||
m_notificationBackend->enable();
|
||||
q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LOCAL_SETTING);
|
||||
q->setSettingsValue(QStringLiteral("PrimaryBackend"), backend, LocalSettings);
|
||||
|
||||
connect(b, &SnoreBackend::error, [this, b](const QString &) {
|
||||
slotInitPrimaryNotificationBackend();
|
||||
|
@ -121,8 +121,8 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
|
|||
bool SnoreCorePrivate::slotInitPrimaryNotificationBackend()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString();
|
||||
if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString())) {
|
||||
qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString();
|
||||
if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString())) {
|
||||
return true;
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -162,7 +162,7 @@ void SnoreCorePrivate::init()
|
|||
|
||||
void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const QVariant &value)
|
||||
{
|
||||
QString nk = normalizeSettingsKey(key + QLatin1String("-SnoreDefault"), LOCAL_SETTING);
|
||||
QString nk = normalizeSettingsKey(key + QLatin1String("-SnoreDefault"), LocalSettings);
|
||||
if (!m_settings->contains(nk)) {
|
||||
m_settings->setValue(nk, value);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void SnoreCorePrivate::setDefaultSettingsValueIntern(const QString &key, const Q
|
|||
void SnoreCorePrivate::syncSettings()
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString();
|
||||
QString newBackend = q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString();
|
||||
if (!newBackend.isEmpty()) {
|
||||
QString oldBackend;
|
||||
if (m_notificationBackend) {
|
||||
|
@ -180,18 +180,18 @@ void SnoreCorePrivate::syncSettings()
|
|||
m_notificationBackend = nullptr;
|
||||
}
|
||||
if (!setBackendIfAvailible(newBackend)) {
|
||||
qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend;
|
||||
qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LocalSettings).toString() << "restoring" << oldBackend;
|
||||
setBackendIfAvailible(oldBackend);
|
||||
}
|
||||
}
|
||||
|
||||
auto types = SnorePlugin::types();
|
||||
types.removeOne(SnorePlugin::BACKEND);
|
||||
types.removeOne(SnorePlugin::Backend);
|
||||
foreach(auto type, types) {
|
||||
foreach(auto & pluginName, m_pluginNames[type]) {
|
||||
auto key = qMakePair(type, pluginName);
|
||||
SnorePlugin *plugin = m_plugins.value(key);
|
||||
bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool();
|
||||
bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LocalSettings).toBool();
|
||||
plugin->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n)
|
|||
|
||||
void SnoreCorePrivate::slotAboutToQuit()
|
||||
{
|
||||
for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::ALL)) {
|
||||
for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::All)) {
|
||||
if (p->isLoaded()) {
|
||||
qCDebug(SNORE) << "deinitialize" << p->name();
|
||||
p->load()->disable();
|
||||
|
@ -271,7 +271,7 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
|
|||
timer->setInterval(notification.timeout() * 1000);
|
||||
connect(timer, &QTimer::timeout, [q, notification]() {
|
||||
qCDebug(SNORE) << notification;
|
||||
q->requestCloseNotification(notification, Notification::TIMED_OUT);
|
||||
q->requestCloseNotification(notification, Notification::TimedOut);
|
||||
});
|
||||
timer->start();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace Snore
|
|||
{
|
||||
|
||||
enum SettingsType {
|
||||
GLOBAL_SETTING,
|
||||
LOCAL_SETTING
|
||||
GlobalSettings,
|
||||
LocalSettings
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -76,33 +76,33 @@ void Utils::raiseWindowToFront(qlonglong wid)
|
|||
STRING = STRING.replace(regexp, QStringLiteral("\\1"));\
|
||||
}\
|
||||
|
||||
QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags)
|
||||
QString Utils::normalizeMarkup(QString string, MarkupFlags tags)
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (tags == ALL_MARKUP) {
|
||||
if (tags == AllMarkup) {
|
||||
return string;
|
||||
} else if (tags == NO_MARKUP) {
|
||||
} else if (tags == NoMarkup) {
|
||||
return QTextDocumentFragment::fromHtml(string).toPlainText();
|
||||
}
|
||||
|
||||
QMutexLocker lock(&mutex);
|
||||
if (~tags & Utils::BREAK) {
|
||||
if (~tags & Utils::Break) {
|
||||
static QRegExp br(QLatin1String("<br>"));
|
||||
string = string.replace(br, QStringLiteral("\n"));
|
||||
}
|
||||
if (~tags & Utils::HREF) {
|
||||
if (~tags & Utils::Href) {
|
||||
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
|
||||
}
|
||||
if (~tags & Utils::ITALIC) {
|
||||
if (~tags & Utils::Italic) {
|
||||
HTML_REPLACE(string, "<i>([^<]*)</i>");
|
||||
}
|
||||
if (~tags & Utils::BOLD) {
|
||||
if (~tags & Utils::Bold) {
|
||||
HTML_REPLACE(string, "<b>([^<]*)</b>");
|
||||
}
|
||||
if (~tags & Utils::UNDERLINE) {
|
||||
if (~tags & Utils::Underline) {
|
||||
HTML_REPLACE(string, "<u>([^<]*)</u>");
|
||||
}
|
||||
if (~tags & Utils::FONT) {
|
||||
if (~tags & Utils::Font) {
|
||||
HTML_REPLACE(string, "<font.*>([^<]*)</font>");
|
||||
}
|
||||
return string;
|
||||
|
|
|
@ -31,58 +31,58 @@ class SNORE_EXPORT Utils : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* The MARKUP_FLAG enum.
|
||||
* The MarkupFlag enum.
|
||||
* If a falg is not present the markup key will be removed.
|
||||
* If any flag is present, special characters mus be html escaped.
|
||||
*/
|
||||
enum MARKUP_FLAG {
|
||||
enum MarkupFlag {
|
||||
/**
|
||||
* No markup is supported.
|
||||
* All markup will be removed.
|
||||
*/
|
||||
NO_MARKUP = 0,
|
||||
NoMarkup = 0,
|
||||
|
||||
/**
|
||||
* Urls are supprotet.
|
||||
* <a href="www.foo.bar">Foo Bar</a>
|
||||
*/
|
||||
HREF = 1 << 0,
|
||||
Href = 1 << 0,
|
||||
|
||||
/**
|
||||
* Line breeaks <br> are supprotet.
|
||||
* If the flag is not present <br> will be replaced by \\n
|
||||
*/
|
||||
BREAK = 1 << 1,
|
||||
Break = 1 << 1,
|
||||
|
||||
/**
|
||||
* Bold <b> is supportet.
|
||||
*/
|
||||
BOLD = 1 << 2,
|
||||
Bold = 1 << 2,
|
||||
|
||||
/**
|
||||
* Italic <i> is supportet.
|
||||
*/
|
||||
ITALIC = 1 << 3,
|
||||
Italic = 1 << 3,
|
||||
|
||||
/**
|
||||
* Underline <u> is supportet.
|
||||
*/
|
||||
UNDERLINE = 1 << 4,
|
||||
Underline = 1 << 4,
|
||||
|
||||
/**
|
||||
* Fonst are supportet.
|
||||
* <font color="blue"> word </font>
|
||||
*/
|
||||
FONT = 1 << 5,
|
||||
Font = 1 << 5,
|
||||
|
||||
/**
|
||||
* All markup is supported.
|
||||
* No markup will be removed.
|
||||
*/
|
||||
ALL_MARKUP = ~0
|
||||
AllMarkup = ~0
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(MARKUP_FLAGS, MARKUP_FLAG)
|
||||
Q_DECLARE_FLAGS(MarkupFlags, MarkupFlag)
|
||||
|
||||
Utils(QObject *parent = nullptr);
|
||||
~Utils();
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
/**
|
||||
* Removes unsupported markup tags from a string.
|
||||
*/
|
||||
static QString normalizeMarkup(QString string, MARKUP_FLAGS tags);
|
||||
static QString normalizeMarkup(QString string, MarkupFlags tags);
|
||||
|
||||
/**
|
||||
* Version number prefix for the settings.
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
*/
|
||||
static inline QString normalizeSettingsKey(const QString &key, SettingsType type, const QString &application)
|
||||
{
|
||||
if (type == LOCAL_SETTING) {
|
||||
if (type == LocalSettings) {
|
||||
return settingsVersionSchema() + QLatin1String("/LocalSettings/") + application + QLatin1Char('/') + key;
|
||||
} else {
|
||||
return settingsVersionSchema() + QLatin1String("/GlobalSettings/") + key;
|
||||
|
@ -138,6 +138,6 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Utils::MARKUP_FLAGS)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Utils::MarkupFlags)
|
||||
|
||||
#endif // UTILS_H
|
||||
|
|
|
@ -78,8 +78,8 @@ void FreedesktopBackend::slotNotify(Notification noti)
|
|||
m_dbusIdMap.take(updateId);
|
||||
}
|
||||
|
||||
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));
|
||||
QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup);
|
||||
QString body(noti.text(m_supportsRichtext ? Utils::AllMarkup : Utils::NoMarkup));
|
||||
//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);
|
||||
|
@ -126,16 +126,16 @@ void FreedesktopBackend::slotNotificationClosed(const uint &id, const uint &reas
|
|||
Notification::CloseReasons closeReason;
|
||||
switch (reason) {
|
||||
case (1):
|
||||
closeReason = Notification::TIMED_OUT;
|
||||
closeReason = Notification::TimedOut;
|
||||
break;
|
||||
case (2):
|
||||
closeReason = Notification::DISMISSED;
|
||||
closeReason = Notification::Dismissed;
|
||||
break;
|
||||
case (3):
|
||||
closeReason = Notification::CLOSED;
|
||||
closeReason = Notification::Closed;
|
||||
break;
|
||||
default:
|
||||
closeReason = Notification::NONE;
|
||||
closeReason = Notification::None;
|
||||
}
|
||||
|
||||
qCDebug(SNORE) << id << "|" << closeReason << reason;
|
||||
|
|
|
@ -100,9 +100,9 @@ void NotifyWidget::display(const Notification ¬ification)
|
|||
m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize)));
|
||||
emit imageChanged();
|
||||
|
||||
m_title = notification.title(Utils::ALL_MARKUP);
|
||||
m_title = notification.title(Utils::AllMarkup);
|
||||
emit titleChanged();
|
||||
m_body = notification.text(Utils::ALL_MARKUP);
|
||||
m_body = notification.text(Utils::AllMarkup);
|
||||
emit bodyChanged();
|
||||
|
||||
if (!notification.isUpdate()) {
|
||||
|
|
|
@ -34,14 +34,14 @@ SnoreNotifier::SnoreNotifier():
|
|||
m_widgets[i] = w;
|
||||
connect(w, &NotifyWidget::dismissed, [this, w]() {
|
||||
Notification notification = w->notification();
|
||||
closeNotification(notification, Notification::DISMISSED);
|
||||
closeNotification(notification, Notification::Dismissed);
|
||||
slotCloseNotification(notification);
|
||||
});
|
||||
|
||||
connect(w, &NotifyWidget::invoked, [this, w]() {
|
||||
Notification notification = w->notification();
|
||||
slotNotificationActionInvoked(notification);
|
||||
closeNotification(notification, Notification::ACTIVATED);
|
||||
closeNotification(notification, Notification::Activated);
|
||||
slotCloseNotification(notification);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ int main(int argc, char *argv[])
|
|||
app.setOrganizationName(QStringLiteral("SnoreNotify"));
|
||||
app.setApplicationVersion(Snore::Version::version());
|
||||
|
||||
Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::ALL);
|
||||
Snore::SnoreCore::instance().loadPlugins(Snore::SnorePlugin::All);
|
||||
Snore::SnoreCorePrivate::instance()->defaultApplication().hints().setValue("use-markup", QVariant::fromValue(true));
|
||||
|
||||
QCommandLineParser parser;
|
||||
|
@ -108,9 +108,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
QString appName = parser.value(appNameCommand);
|
||||
|
||||
SettingsType type = GLOBAL_SETTING;
|
||||
SettingsType type = GlobalSettings;
|
||||
if (appName != QStringLiteral("global")) {
|
||||
type = LOCAL_SETTING;
|
||||
type = LocalSettings;
|
||||
}
|
||||
|
||||
if (parser.isSet(listAppsCommand)) {
|
||||
|
|
|
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
|
|||
if (parser.isSet(title) && parser.isSet(message)) {
|
||||
SnoreCore &core = SnoreCore::instance();
|
||||
|
||||
core.loadPlugins(SnorePlugin::BACKEND | SnorePlugin::SECONDARY_BACKEND);
|
||||
core.loadPlugins(SnorePlugin::Backend | SnorePlugin::SecondaryBackend);
|
||||
|
||||
Icon icon = Icon::defaultIcon();
|
||||
if (parser.isSet(iconPath)) {
|
||||
|
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
|||
QDebug(&reason) << noti.closeReason();
|
||||
cout << qPrintable(reason) << endl;
|
||||
}
|
||||
if (noti.closeReason() == Notification::CLOSED) {
|
||||
if (noti.closeReason() == Notification::Closed) {
|
||||
if (parser.isSet(_bringProcessToFront)) {
|
||||
bringToFront(parser.value(_bringProcessToFront));
|
||||
} else if (parser.isSet(_bringWindowToFront)) {
|
||||
|
|
Loading…
Reference in New Issue