more doc and cleanup
This commit is contained in:
parent
0b46a81f35
commit
48ec634993
|
@ -733,7 +733,7 @@ WARN_LOGFILE =
|
|||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/src/"
|
||||
INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/src/core"
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
@ -768,7 +768,7 @@ RECURSIVE = YES
|
|||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE =
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
|
|
@ -44,6 +44,14 @@ public:
|
|||
const QHash<QString,Alert> &alerts() const;
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* Application specific hints:
|
||||
* <table>
|
||||
* <tr><td>desktop-entry</td><td>The name of the desktop enty associated with the application</td><td>Used for The freedesktop backend</td></tr>
|
||||
* <tr><td>windows-app-id</td><td>The app id associated with the application</td><td>Needed for the Windows 8 backend <a href="http://msdn.microsoft.com/en-us/library/windows/apps/dd378459.aspx">See MSDN</a></td></tr>
|
||||
* </table>
|
||||
* @return the hints
|
||||
*/
|
||||
Hint &hints();
|
||||
const Hint &constHints() const;
|
||||
private:
|
||||
|
|
|
@ -24,21 +24,17 @@ Hint::Hint()
|
|||
{
|
||||
}
|
||||
|
||||
Hint::Hint(const Hint &other):
|
||||
m_data(other.m_data)
|
||||
{
|
||||
}
|
||||
|
||||
void Hint::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
m_data[key] = value;
|
||||
m_data.insert(key.toLower(), value);
|
||||
}
|
||||
|
||||
QVariant Hint::value(const QString &key, const QVariant &defaultValue) const
|
||||
QVariant Hint::value(const QString &k, const QVariant &defaultValue) const
|
||||
{
|
||||
QString key(k.toLower());
|
||||
if(m_data.contains(key))
|
||||
{
|
||||
return m_data[key];
|
||||
return m_data.value(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,7 +44,32 @@ QVariant Hint::value(const QString &key, const QVariant &defaultValue) const
|
|||
|
||||
bool Hint::contains(const QString &key) const
|
||||
{
|
||||
return m_data.contains(key);
|
||||
return m_data.contains(key.toLower());
|
||||
}
|
||||
|
||||
void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value)
|
||||
{
|
||||
m_privateData.insert(QPair<const void*,QString>(owner,key.toLower()), value);
|
||||
}
|
||||
|
||||
|
||||
QVariant Hint::privateValue(const void *owner, const QString &k, const QVariant &defaultValue) const
|
||||
{
|
||||
QPair<const void*,QString> key(owner,k.toLower());
|
||||
if(m_privateData.contains(key))
|
||||
{
|
||||
return m_privateData.value(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Hint::containsPrivateValue(const void *owner, const QString &key) const
|
||||
{
|
||||
return m_privateData.contains(QPair<const void*,QString>(owner,key.toLower()));
|
||||
}
|
||||
|
||||
QDebug operator<<( QDebug debug, const Snore::Hint &hint )
|
||||
|
@ -73,29 +94,3 @@ QDebug operator<<( QDebug debug, const Snore::Hint &hint )
|
|||
debug << ")" ;
|
||||
return debug.maybeSpace();
|
||||
}
|
||||
|
||||
|
||||
void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value)
|
||||
{
|
||||
m_privateData.insert(QPair<const void*,QString>(owner,key), value);
|
||||
}
|
||||
|
||||
|
||||
QVariant Hint::privateValue(const void *owner, const QString &k, const QVariant &defaultValue) const
|
||||
{
|
||||
QPair<const void*,QString> key(owner,k);
|
||||
if(m_privateData.contains(key))
|
||||
{
|
||||
return m_privateData.value(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Hint::containsPrivateValue(const void *owner, const QString &key) const
|
||||
{
|
||||
return m_privateData.contains(QPair<const void*,QString>(owner,key));
|
||||
}
|
||||
|
|
|
@ -34,13 +34,14 @@ SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::Hint &);
|
|||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
/**
|
||||
* Hint contains extra information for Notifications and Applications
|
||||
*/
|
||||
|
||||
class SNORE_EXPORT Hint
|
||||
{
|
||||
public:
|
||||
Hint();
|
||||
Hint(const Hint &other);
|
||||
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
QVariant value(const QString & key, const QVariant & defaultValue = QVariant() ) const;
|
||||
|
@ -49,13 +50,13 @@ public:
|
|||
void setPrivateValue(const void *owner, const QString &key, const QVariant &value);
|
||||
QVariant privateValue(const void *owner, const QString & key, const QVariant & defaultValue = QVariant() ) const;
|
||||
bool containsPrivateValue(const void *owner, const QString & key ) const;
|
||||
|
||||
|
||||
private:
|
||||
QVariantHash m_data;
|
||||
QHash<QPair<const void*,QString>, QVariant> m_privateData;
|
||||
|
||||
friend SNORE_EXPORT QDebug (::operator<<) ( QDebug, const Snore::Hint &);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -263,12 +263,6 @@ bool SnoreCore::primaryBackendSupportsRichtext()
|
|||
return d->m_notificationBackend->supportsRichtext();
|
||||
}
|
||||
|
||||
Hint &SnoreCore::hints()
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
return d->m_hints;
|
||||
}
|
||||
|
||||
const SnoreCorePrivate *SnoreCore::d()
|
||||
{
|
||||
Q_D(SnoreCore);
|
||||
|
|
|
@ -166,12 +166,6 @@ public:
|
|||
*/
|
||||
bool primaryBackendSupportsRichtext();
|
||||
|
||||
/**
|
||||
* @deprecated Use Application::hints() instead
|
||||
* @return a Hint object which contains extra information used by the backends etc.
|
||||
*/
|
||||
SNORE_DEPRECATED Hint &hints();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a pointer to the private class, for internal use only.
|
||||
|
|
|
@ -60,7 +60,6 @@ private slots:
|
|||
|
||||
private:
|
||||
SnoreCore *q_ptr;
|
||||
Hint m_hints;
|
||||
|
||||
QHash<QString,Application> m_applications;
|
||||
|
||||
|
|
|
@ -33,32 +33,6 @@ bool SnoreToast::initialize(SnoreCore *snore)
|
|||
snoreDebug( SNORE_DEBUG ) << "SnoreToast does not work on windows" << QSysInfo::windowsVersion();
|
||||
return false;
|
||||
}
|
||||
if(snore->hints().contains("WINDOWS_APP_ID"))
|
||||
{
|
||||
m_appID = snore->hints().value("WINDOWS_APP_ID").toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_appID = QString("%1.%2.SnoreToast").arg(qApp->organizationName(), qApp->applicationName()).remove(" ");
|
||||
|
||||
QProcess *p = new QProcess(this);
|
||||
p->setReadChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-install"
|
||||
<< QString("SnoreNotify\\%1").arg(qApp->applicationName())
|
||||
<< QDir::toNativeSeparators(qApp->applicationFilePath())
|
||||
<< m_appID;
|
||||
snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
p->waitForFinished(-1);
|
||||
snoreDebug( SNORE_DEBUG ) << p->readAll();
|
||||
if(p->exitCode() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return SnoreBackend::initialize(snore);
|
||||
}
|
||||
|
||||
|
@ -83,7 +57,7 @@ void SnoreToast::slotNotify(Notification notification)
|
|||
}
|
||||
arguements << "-w"
|
||||
<< "-appID"
|
||||
<< m_appID;
|
||||
<< appId(notification.application());
|
||||
;
|
||||
if(notification.hints().value("silent",true).toBool())
|
||||
{
|
||||
|
@ -95,10 +69,36 @@ void SnoreToast::slotNotify(Notification notification)
|
|||
p->setProperty("SNORE_NOTIFICATION_ID",notification.id());
|
||||
}
|
||||
|
||||
void SnoreToast::slotRegisterApplication(const Application &application)
|
||||
{
|
||||
if(!application.constHints().contains("windows_app_id"))
|
||||
{
|
||||
QProcess *p = new QProcess(this);
|
||||
p->setReadChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-install"
|
||||
<< QString("SnoreNotify\\%1").arg(qApp->applicationName())
|
||||
<< QDir::toNativeSeparators(qApp->applicationFilePath())
|
||||
<< appId(application);
|
||||
snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
|
||||
connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
|
||||
connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill()));
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
||||
{
|
||||
QProcess *p = qobject_cast<QProcess*>(sender());
|
||||
Notification n = getActiveNotificationByID(p->property("SNORE_NOTIFICATION_ID").toUInt());
|
||||
bool ok;
|
||||
Notification n = getActiveNotificationByID(p->property("SNORE_NOTIFICATION_ID").toUInt(&ok));
|
||||
snoreDebug( SNORE_DEBUG ) << p->readAll();
|
||||
if(!ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationEnums::CloseReasons::closeReason reason = NotificationEnums::CloseReasons::CLOSED;
|
||||
|
||||
|
@ -126,3 +126,14 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
|||
closeNotification(n,reason);
|
||||
|
||||
}
|
||||
|
||||
QString SnoreToast::appId(const Application &application)
|
||||
{
|
||||
|
||||
QString appID = application.constHints().value("windows_app_id").toString();
|
||||
if(appID.isEmpty())
|
||||
{
|
||||
appID = QString("%1.%2.SnoreToast").arg(qApp->organizationName(), qApp->applicationName()).remove(" ");
|
||||
}
|
||||
return appID;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,13 @@ public:
|
|||
|
||||
public slots:
|
||||
void slotNotify(Snore::Notification notification);
|
||||
void slotRegisterApplication(const Snore::Application &application);
|
||||
|
||||
private slots:
|
||||
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
||||
|
||||
private:
|
||||
QString m_appID;
|
||||
QString appId(const Snore::Application &application);
|
||||
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue