make sure that test notifications uses the correct markup value

This commit is contained in:
Patrick von Reth 2015-06-26 15:37:22 +02:00
parent 361ee29e94
commit e0b751cc93
5 changed files with 21 additions and 45 deletions

View File

@ -96,39 +96,7 @@ QSystemTrayIcon *TrayIcon::trayIcon()
void TrayIcon::slotTestNotification() void TrayIcon::slotTestNotification()
{ {
Application app = SnoreCorePrivate::instance()->defaultApplication(); SnoreCore::instance().displayExapleNotification();
Notification noti(app, app.defaultAlert(), "Hello World",
"<i>This is Snore</i><br>"
"<a href=\"https://github.com/TheOneRing/Snorenotify\">Project Website</a><br>"
"1<br>"
"2<br>"
"3<br>"
"4<br>"
"5<br>", app.icon());
noti.addAction(Action(1, "Test Action"));
SnoreCore::instance().broadcastNotification(noti);
QTimer *timer = new QTimer(this);
m_notifications[timer] = noti;
timer->setSingleShot(true);
timer->setInterval(noti.timeout() / 2 * 1000);
connect(timer, SIGNAL(timeout()), this, SLOT(sloutUpdateTestNotification()));
timer->start();
// SnoreCore::instance().deregisterApplication(app);
}
void TrayIcon::sloutUpdateTestNotification()
{
QTimer *timer = qobject_cast<QTimer *>(sender());
Notification noti = m_notifications.take(timer);
Notification update(noti, "Hello World",
"<b>This is Snore</b><br>"
"<u>This icon is quite a long line of text, isnt it I think it is what do you think? btw the icon should be in color</u><br>"
"<a href=\"https://github.com/TheOneRing/Snorenotify\">Project Website</a>",
Icon("http://winkde.org/~pvonreth/other/kde-logo.png"));
SnoreCore::instance().broadcastNotification(update);
timer->deleteLater();
} }
void TrayIcon::slotSettings() void TrayIcon::slotSettings()

View File

@ -42,11 +42,8 @@ private:
QActionGroup *m_backendActions; QActionGroup *m_backendActions;
Snore::SettingsDialog *m_settings; Snore::SettingsDialog *m_settings;
QHash<QTimer *, Snore::Notification> m_notifications;
public slots: public slots:
void slotTestNotification(); void slotTestNotification();
void sloutUpdateTestNotification();
void slotSettings(); void slotSettings();
}; };

View File

@ -74,13 +74,7 @@ void SettingsDialog::initTabs()
void Snore::SettingsDialog::on_pushButton_clicked() void Snore::SettingsDialog::on_pushButton_clicked()
{ {
Application app = SnoreCorePrivate::instance()->defaultApplication(); SnoreCore::instance().displayExapleNotification();
Notification noti(app, app.defaultAlert(), tr("Hello World"),
QString("<i>%1</i><br>"
"<a href=\"https://github.com/Snorenotify/Snorenotify\">%2</a><br>").arg(tr("This is Snore"), tr("Project Website")),
app.icon());
noti.addAction(Action(1, tr("Test Action")));
SnoreCore::instance().broadcastNotification(noti);
} }
void SettingsDialog::load() void SettingsDialog::load()

View File

@ -27,8 +27,6 @@
#include "version.h" #include "version.h"
#include <memory>
#include <QSettings> #include <QSettings>
#include <QThread> #include <QThread>
@ -232,3 +230,17 @@ Notification SnoreCore::getActiveNotificationByID(uint id) const
Q_D(const SnoreCore); Q_D(const SnoreCore);
return d->m_activeNotifications.value(id); return d->m_activeNotifications.value(id);
} }
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"));
if(!app.constHints().value("use-markup").toBool()) {
text = Utils::normaliseMarkup(text, Utils::NO_MARKUP);
}
Notification noti(app, app.defaultAlert(), tr("Hello World"), text, app.icon());
noti.addAction(Action(1, tr("Test Action")));
broadcastNotification(noti);
}

View File

@ -77,6 +77,11 @@ public:
*/ */
void broadcastNotification(Notification notification); void broadcastNotification(Notification notification);
/**
* Displays a example notification.
*/
void displayExapleNotification();
/** /**
* Register an application. * Register an application.
* Each application should only be registered once. * Each application should only be registered once.