mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-16 18:36:45 +00:00
use install snoretoast, fixed crash
This commit is contained in:
parent
6e43a0a872
commit
64f88f84e9
Binary file not shown.
@ -47,10 +47,12 @@ public:
|
||||
m_closeReason(NotificationEnums::CloseReasons::NONE)
|
||||
{
|
||||
qDebug()<<"Creating Notification: ActiveNotifications"<<++notificationCount;
|
||||
m_ref.ref();
|
||||
}
|
||||
|
||||
|
||||
~NotificationData(){
|
||||
qDebug() << "Cloasing Notification:" << m_id << m_ref;
|
||||
qDebug() << "Deleting Notification: ActiveNotifications"<<--notificationCount;
|
||||
}
|
||||
|
||||
@ -90,7 +92,6 @@ Notification::Notification () :
|
||||
Notification::Notification ( const QString &application, const QString &alert, const QString &title, const QString &text, const SnoreIcon &icon, int timeout, uint id, NotificationEnums::Prioritys::prioritys priority )
|
||||
{
|
||||
d = new NotificationData(application,alert,title,text,icon,timeout,id,priority);
|
||||
d->m_ref.ref();
|
||||
}
|
||||
|
||||
Notification::Notification ( const Notification &other )
|
||||
|
@ -31,6 +31,21 @@ bool SnoreToast::init(SnoreCore *snore)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_appID = QString("%1.%2.SnoreToast").arg(qApp->organizationName(), qApp->applicationName());
|
||||
|
||||
QProcess *p = new QProcess(this);
|
||||
|
||||
QStringList arguements;
|
||||
arguements << "-install"
|
||||
<< qApp->applicationName()
|
||||
<< qApp->applicationFilePath()
|
||||
<< m_appID;
|
||||
qDebug() << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
p->waitForFinished();
|
||||
if(p->exitCode() != 0)
|
||||
return false;
|
||||
|
||||
return SnoreBackend::init(snore);
|
||||
}
|
||||
|
||||
@ -60,7 +75,9 @@ uint SnoreToast::notify(Notification notification)
|
||||
<< "-p"
|
||||
// << notification.icon().isLocalFile()?QDir::toNativeSeparators(notification.icon().localUrl()):notification.icon().url()
|
||||
<< QDir::toNativeSeparators(notification.icon().localUrl())
|
||||
<< "-w";
|
||||
<< "-w"
|
||||
<< "-appID"
|
||||
<< m_appID;
|
||||
qDebug() << "SnoreToast" << arguements;
|
||||
p->start("SnoreToast", arguements);
|
||||
|
||||
|
@ -23,6 +23,9 @@ public slots:
|
||||
private slots:
|
||||
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
||||
|
||||
private:
|
||||
QString m_appID;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -61,8 +61,8 @@ void FreedesktopFrontend::notificationClosed(Notification notification) {
|
||||
}
|
||||
|
||||
uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
const QString &app_icon, const QString &summary, const QString &body,
|
||||
const QStringList &actions, const QVariantMap &hints, int timeout)
|
||||
const QString &app_icon, const QString &summary, const QString &body,
|
||||
const QStringList &actions, const QVariantMap &hints, int timeout)
|
||||
{
|
||||
qDebug()<<app_name<<summary<<body<<app_icon<<timeout;
|
||||
SnoreIcon icon;
|
||||
@ -74,7 +74,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
icon = SnoreIcon(image.toQImage());
|
||||
}
|
||||
|
||||
if(!snore()->aplications().contains(app_name)){
|
||||
if(!snore()->aplications().contains(app_name)){
|
||||
#ifdef HAVE_KDE
|
||||
SnoreIcon appIcon = SnoreIcon(KIconLoader::global()->iconPath(app_icon, KIconLoader::Desktop));
|
||||
#else
|
||||
@ -105,7 +105,10 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
|
||||
void FreedesktopFrontend::CloseNotification(uint id){
|
||||
Notification noti = snore()->getActiveNotificationByID(id);
|
||||
snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||
if(noti.isValid())
|
||||
{
|
||||
snore()->closeNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList FreedesktopFrontend::GetCapabilities()
|
||||
|
@ -34,6 +34,8 @@ using namespace Snore;
|
||||
SnoreNotify::SnoreNotify():
|
||||
m_settings("TheOneRing","SnoreNotify")
|
||||
{
|
||||
qApp->setApplicationName("SnoreNotify");
|
||||
qApp->setOrganizationName("TheOneRing");
|
||||
m_trayIcon = new TrayIcon();
|
||||
m_snore = new SnoreCore(m_trayIcon->trayIcon());
|
||||
m_snore->loadPlugins(PluginContainer::ALL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user