drop defaults from hints

This commit is contained in:
Patrick von Reth 2015-06-23 18:32:57 +02:00
parent 080d615b1a
commit 6946b0db9f
9 changed files with 26 additions and 18 deletions

View File

@ -25,6 +25,7 @@ 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");
}
ApplicationData::~ApplicationData()

View File

@ -36,14 +36,9 @@ void Hint::setValue(const QString &key, QObject *value)
connect(value, SIGNAL(destroyed()), this, SLOT(slotValueDestroyed()), Qt::DirectConnection);
}
QVariant Hint::value(const QString &k, const QVariant &defaultValue) const
QVariant Hint::value(const QString &k) const
{
QString key(k.toLower());
if (m_data.contains(key)) {
return m_data.value(key);
} else {
return defaultValue;
}
return m_data.value(k.toLower());
}
bool Hint::contains(const QString &key) const

View File

@ -63,7 +63,7 @@ public:
* @param key the key
* @param defaultValue the fallback value
*/
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
QVariant value(const QString &key) const;
/**
*

View File

@ -166,14 +166,14 @@ public:
const Application &application() const;
/**
*
* @return the title
* Returns the title of the notification.
* @param flags the supported markup flags.
*/
QString title(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const;
/**
*
* @return the text body
* Returns the notification text.
* @param flags the supported markup flags.
*/
QString text(Utils::MARKUP_FLAGS flags = Utils::NO_MARKUP) const;
@ -222,8 +222,11 @@ public:
const Notification::CloseReasons &closeReason();
/**
*
* @return hints associated with this notification
* Returns notification specific hints:
* Key | Type | Value | Used In
* ------------- | ----------- | ----------- | -----------
* silent | bool | Don't play notification sounds. | Multiple backends.
* sound | QString | Local uri to a sound file. | Secondary Backend Sound.
*/
Hint &hints();

View File

@ -44,6 +44,7 @@ NotificationData::NotificationData(const Snore::Application &application, const
{
notificationCount++;
snoreDebug(SNORE_INFO) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
initHints();
}
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
@ -59,6 +60,7 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
m_toReplace(old)
{
notificationCount++;
initHints();
snoreDebug(SNORE_INFO) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
}
@ -87,3 +89,8 @@ void NotificationData::setTimeoutTimer(QTimer *timer)
m_timeoutTimer.reset(timer);
}
void NotificationData::initHints()
{
m_hints.setValue("silent", QVariant::fromValue(false));
}

View File

@ -51,6 +51,8 @@ public:
private:
Q_DISABLE_COPY(NotificationData)
void initHints();
uint m_id;
uint m_updateID;
int m_timeout;

View File

@ -56,7 +56,7 @@ void SnoreToast::slotNotify(Notification notification)
<< "-id"
<< QString::number(notification.id());
//TODO: could clash with sound backend
if (notification.hints().value("silent", true).toBool() || notification.hints().value("sound").isValid()) {
if (notification.hints().value("silent").toBool() || notification.hints().value("sound").isValid()) {
arguements << "-silent";
}
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;

View File

@ -68,7 +68,7 @@ void Pushover::slotNotify(Notification notification)
QHttpPart sound;
sound.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"sound\""));
if (notification.hints().value("silent", false).toBool()) {
if (notification.hints().value("silent").toBool()) {
sound.setBody("none");
} else {
sound.setBody(value("Sound", LOCAL_SETTING).toString().toUtf8().constData());
@ -84,7 +84,7 @@ void Pushover::slotNotify(Notification notification)
QHttpPart token;
token.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"token\""));
token.setBody(notification.application().constHints().value("pushover-token","aFB1TPCyZkkr7mubCGEKy5vJEWak9t").toString().toUtf8().constData());
token.setBody(notification.application().constHints().value("pushover-token").toString().toUtf8().constData());
mp->append(token);
QHttpPart user;

View File

@ -49,7 +49,7 @@ PluginSettingsWidget *Sound::settingsWidget()
void Sound::slotNotificationDisplayed(Snore::Notification notification)
{
if (notification.hints().value("silent", false).toBool()) {
if (notification.hints().value("silent").toBool()) {
return;
}