fixed tray icon
This commit is contained in:
parent
39191c146b
commit
2171ed455b
|
@ -14,7 +14,13 @@ Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer)
|
||||||
TrayIconNotifer::TrayIconNotifer () :
|
TrayIconNotifer::TrayIconNotifer () :
|
||||||
SnoreBackend ( "SystemTray",false,false ),
|
SnoreBackend ( "SystemTray",false,false ),
|
||||||
m_trayIcon(NULL),
|
m_trayIcon(NULL),
|
||||||
m_displayed(-1)
|
m_displayed(-1),
|
||||||
|
m_currentlyDisplaying(false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TrayIconNotifer::~TrayIconNotifer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,25 +52,26 @@ bool TrayIconNotifer::deinitialize()
|
||||||
void TrayIconNotifer::slotNotify( Notification notification )
|
void TrayIconNotifer::slotNotify( Notification notification )
|
||||||
{
|
{
|
||||||
m_notificationQue.append(notification);
|
m_notificationQue.append(notification);
|
||||||
if(m_lastNotify.elapsed()> Notification::defaultTimeout() * 1000)
|
qDebug() << notification << m_currentlyDisplaying;
|
||||||
|
if(!m_currentlyDisplaying)
|
||||||
{
|
{
|
||||||
|
m_currentlyDisplaying = true;
|
||||||
displayNotification();
|
displayNotification();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::displayNotification()
|
void TrayIconNotifer::displayNotification()
|
||||||
{
|
{
|
||||||
qDebug()<<"Display"<<m_notificationQue.size();
|
if(m_notificationQue.isEmpty())
|
||||||
Notification notification = m_notificationQue.takeFirst();
|
|
||||||
if(!m_notificationQue.isEmpty())
|
|
||||||
{
|
{
|
||||||
QTimer::singleShot(notification.timeout()*1000,this,SLOT(slotCloseNotificationByTimeout()));
|
m_currentlyDisplaying = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
m_currentlyDisplaying = true;
|
||||||
qDebug()<<"taking"<<notification.title();
|
Notification notification = m_notificationQue.takeFirst();
|
||||||
m_displayed = notification.id();
|
m_displayed = notification.id();
|
||||||
m_trayIcon->showMessage ( Snore::toPlainText(notification.title()),Snore::toPlainText(notification.text()),QSystemTrayIcon::NoIcon,notification.timeout() *1000 );
|
m_trayIcon->showMessage ( Snore::toPlainText(notification.title()),Snore::toPlainText(notification.text()),QSystemTrayIcon::NoIcon,notification.timeout() *1000 );
|
||||||
m_lastNotify.restart();
|
QTimer::singleShot(notification.timeout()*1000,this,SLOT(slotCloseNotificationByTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIconNotifer::slotCloseNotificationByTimeout()
|
void TrayIconNotifer::slotCloseNotificationByTimeout()
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "core/plugins/snorebackend.h"
|
#include "core/plugins/snorebackend.h"
|
||||||
|
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
namespace Snore{
|
namespace Snore{
|
||||||
class SnoreCore;
|
class SnoreCore;
|
||||||
|
@ -18,6 +17,7 @@ class TrayIconNotifer:public Snore::SnoreBackend
|
||||||
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0")
|
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0")
|
||||||
public:
|
public:
|
||||||
TrayIconNotifer ();
|
TrayIconNotifer ();
|
||||||
|
virtual ~TrayIconNotifer();
|
||||||
virtual bool initialize(Snore::SnoreCore *snore);
|
virtual bool initialize(Snore::SnoreCore *snore);
|
||||||
virtual bool deinitialize();
|
virtual bool deinitialize();
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ public slots:
|
||||||
private:
|
private:
|
||||||
QSystemTrayIcon *m_trayIcon;
|
QSystemTrayIcon *m_trayIcon;
|
||||||
QList<Snore::Notification > m_notificationQue;
|
QList<Snore::Notification > m_notificationQue;
|
||||||
QTime m_lastNotify;
|
|
||||||
uint m_displayed;
|
uint m_displayed;
|
||||||
|
bool m_currentlyDisplaying;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void displayNotification();
|
void displayNotification();
|
||||||
|
|
Loading…
Reference in New Issue