comunicwatcher/refreshservice.cpp

66 lines
1.5 KiB
C++
Raw Normal View History

2020-06-13 08:19:49 +00:00
#include "refreshservice.h"
#include <QGuiApplication>
2020-06-13 08:19:49 +00:00
RefreshService *RefreshService::svc = nullptr;
void RefreshService::startService()
{
if(svc != nullptr)
return;
QGuiApplication::setQuitOnLastWindowClosed(false);
2020-06-13 08:19:49 +00:00
svc = new RefreshService();
}
void RefreshService::stopService()
{
if(svc != nullptr)
svc->deleteLater();
QGuiApplication::setQuitOnLastWindowClosed(true);
2020-06-13 08:19:49 +00:00
svc = nullptr;
}
void RefreshService::connectedToWebSocket()
{
mNotifsHelper.getNewNotificationsNumbers();
}
void RefreshService::onNewNumberNotifications(NotificationsNumber numbers)
{
mNumbers = numbers;
mTrayIcon.onNewNumber(numbers);
}
void RefreshService::onNewNeumberUnreadNotifs(int num)
{
mNumbers.setNewNotifs(num);
mTrayIcon.onNewNumber(mNumbers);
}
void RefreshService::onNewNeumberUnreadConvs(int num)
{
mNumbers.setUnreadConversations(num);
mTrayIcon.onNewNumber(mNumbers);
}
2020-06-13 08:19:49 +00:00
RefreshService::RefreshService()
{
qDebug("Start refresh service");
connect(&mWsClient, &WsClient::connected, this, &RefreshService::connectedToWebSocket);
connect(&mNotifsHelper, &NotificationsHelper::onNewNumber, this, &RefreshService::onNewNumberNotifications);
connect(&mWsClient, &WsClient::newNumberNotifs, this, &RefreshService::onNewNeumberUnreadNotifs);
connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs);
2020-06-13 08:19:49 +00:00
}
RefreshService::~RefreshService()
{
qDebug("Stop refresh service");
}