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