mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-13 17:06:29 +00:00
use default alert also in the daemon and always register the default alert
This commit is contained in:
parent
81d6a3cc82
commit
f95c50111b
@ -29,6 +29,7 @@ Application::Application(const QString &name, const Icon &icon) :
|
|||||||
d(new ApplicationData(name, icon))
|
d(new ApplicationData(name, icon))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
addAlert(Alert("Default", icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::Application(const Application &other):
|
Application::Application(const Application &other):
|
||||||
@ -67,6 +68,11 @@ const QHash<QString, Alert> &Application::alerts() const
|
|||||||
return d->m_alerts;
|
return d->m_alerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Alert Application::defaultAlert() const
|
||||||
|
{
|
||||||
|
return d->m_alerts["Default"];
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::isValid() const
|
bool Application::isValid() const
|
||||||
{
|
{
|
||||||
return d;
|
return d;
|
||||||
|
@ -82,13 +82,20 @@ public:
|
|||||||
const Icon &icon() const;
|
const Icon &icon() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a QHash with the Alers registered with this Application
|
*
|
||||||
|
* @return a QHash with the Alers registered with this Application.
|
||||||
*/
|
*/
|
||||||
const QHash<QString, Alert> &alerts() const;
|
const QHash<QString, Alert> &alerts() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return whether the Application is valid
|
* @return the default alert for notifications.
|
||||||
|
*/
|
||||||
|
const Alert defaultAlert() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return whether the Application is valid.
|
||||||
*/
|
*/
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ void SettingsDialog::initTabs()
|
|||||||
void Snore::SettingsDialog::on_pushButton_clicked()
|
void Snore::SettingsDialog::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||||
Notification noti(app, app.alerts()["Default"], "Hello World",
|
Notification noti(app, app.defaultAlert(), "Hello World",
|
||||||
"<i>This is Snore</i><br>"
|
"<i>This is Snore</i><br>"
|
||||||
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Project Website</a><br>",
|
"<a href=\"https://github.com/Snorenotify/Snorenotify\">Project Website</a><br>",
|
||||||
app.icon());
|
app.icon());
|
||||||
|
@ -193,7 +193,6 @@ bool SnoreCore::primaryBackendSupportsRichtext()
|
|||||||
void SnoreCore::setDefaultApplication(Application app)
|
void SnoreCore::setDefaultApplication(Application app)
|
||||||
{
|
{
|
||||||
Q_D(SnoreCore);
|
Q_D(SnoreCore);
|
||||||
app.addAlert(Alert("Default", Icon(":/root/snore.png")));
|
|
||||||
d->m_defaultApp = app;
|
d->m_defaultApp = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ SnoreCorePrivate::~SnoreCorePrivate()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Application SnoreCorePrivate::defaultApplication() const
|
Application SnoreCorePrivate::defaultApplication()
|
||||||
{
|
{
|
||||||
if (!SnoreCore::instance().aplications().contains(m_defaultApp.name())) {
|
if (!SnoreCore::instance().aplications().contains(m_defaultApp.name())) {
|
||||||
SnoreCore::instance().registerApplication(m_defaultApp);
|
SnoreCore::instance().registerApplication(m_defaultApp);
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static SnoreCorePrivate *instance();
|
static SnoreCorePrivate *instance();
|
||||||
~SnoreCorePrivate();
|
~SnoreCorePrivate();
|
||||||
const Application defaultApplication() const;
|
Application defaultApplication();
|
||||||
|
|
||||||
void notificationActionInvoked(Notification notification) const;
|
void notificationActionInvoked(Notification notification) const;
|
||||||
|
|
||||||
|
@ -33,12 +33,9 @@
|
|||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
|
|
||||||
TrayIcon::TrayIcon():
|
TrayIcon::TrayIcon():
|
||||||
m_trayIcon(new QSystemTrayIcon(QIcon(":/root/snore.png"))),
|
m_trayIcon(new QSystemTrayIcon(QIcon(":/root/snore.png")))
|
||||||
m_app("SnoreNotify Test", Icon(":/root/snore.png")),
|
|
||||||
m_alert("Default", Icon(":/root/snore.png"))
|
|
||||||
{
|
{
|
||||||
m_app.addAlert(m_alert);
|
SnoreCorePrivate::instance()->defaultApplication().hints().setValue("tray-icon", m_trayIcon);
|
||||||
m_app.hints().setValue("tray-icon", m_trayIcon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIcon::initConextMenu()
|
void TrayIcon::initConextMenu()
|
||||||
@ -49,7 +46,7 @@ void TrayIcon::initConextMenu()
|
|||||||
switch (box->buttonRole(button)) {
|
switch (box->buttonRole(button)) {
|
||||||
case QDialogButtonBox::AcceptRole:
|
case QDialogButtonBox::AcceptRole:
|
||||||
m_settings->accept();
|
m_settings->accept();
|
||||||
qApp->quit();
|
m_settings->setVisible(false);
|
||||||
break;
|
break;
|
||||||
case QDialogButtonBox::ApplyRole:
|
case QDialogButtonBox::ApplyRole:
|
||||||
m_settings->accept();
|
m_settings->accept();
|
||||||
@ -58,7 +55,7 @@ void TrayIcon::initConextMenu()
|
|||||||
m_settings->reset();
|
m_settings->reset();
|
||||||
break;
|
break;
|
||||||
case QDialogButtonBox::RejectRole:
|
case QDialogButtonBox::RejectRole:
|
||||||
qApp->quit();
|
m_settings->setVisible(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snoreDebug(SNORE_WARNING) << "unhandled role" << button->text() << box->buttonRole(button);
|
snoreDebug(SNORE_WARNING) << "unhandled role" << button->text() << box->buttonRole(button);
|
||||||
@ -99,18 +96,15 @@ QSystemTrayIcon *TrayIcon::trayIcon()
|
|||||||
|
|
||||||
void TrayIcon::slotTestNotification()
|
void TrayIcon::slotTestNotification()
|
||||||
{
|
{
|
||||||
|
Application app = SnoreCorePrivate::instance()->defaultApplication();
|
||||||
if (!SnoreCore::instance().aplications().contains(m_app.name())) {
|
Notification noti(app, app.defaultAlert(), "Hello World",
|
||||||
SnoreCore::instance().registerApplication(m_app);
|
|
||||||
}
|
|
||||||
Notification noti(m_app, m_alert, "Hello World",
|
|
||||||
"<i>This is Snore</i><br>"
|
"<i>This is Snore</i><br>"
|
||||||
"<a href=\"https://github.com/TheOneRing/Snorenotify\">Project Website</a><br>"
|
"<a href=\"https://github.com/TheOneRing/Snorenotify\">Project Website</a><br>"
|
||||||
"1<br>"
|
"1<br>"
|
||||||
"2<br>"
|
"2<br>"
|
||||||
"3<br>"
|
"3<br>"
|
||||||
"4<br>"
|
"4<br>"
|
||||||
"5<br>", Icon(":/root/snore.png"));
|
"5<br>", app.icon());
|
||||||
noti.addAction(Action(1, "Test Action"));
|
noti.addAction(Action(1, "Test Action"));
|
||||||
SnoreCore::instance().broadcastNotification(noti);
|
SnoreCore::instance().broadcastNotification(noti);
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ private:
|
|||||||
class QSystemTrayIcon *m_trayIcon;
|
class QSystemTrayIcon *m_trayIcon;
|
||||||
class QMenu *m_trayMenu;
|
class QMenu *m_trayMenu;
|
||||||
QActionGroup *m_backendActions;
|
QActionGroup *m_backendActions;
|
||||||
Snore::Application m_app;
|
|
||||||
Snore::Alert m_alert;
|
|
||||||
Snore::SettingsDialog *m_settings;
|
Snore::SettingsDialog *m_settings;
|
||||||
|
|
||||||
QHash<QTimer *, Snore::Notification> m_notifications;
|
QHash<QTimer *, Snore::Notification> m_notifications;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user