#include "refreshservice.h" #include RefreshService *RefreshService::svc = nullptr; void RefreshService::startService() { if(svc != nullptr) return; QGuiApplication::setQuitOnLastWindowClosed(false); svc = new RefreshService(); } void RefreshService::stopService() { if(svc != nullptr) svc->deleteLater(); QGuiApplication::setQuitOnLastWindowClosed(true); 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); } 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); } RefreshService::~RefreshService() { qDebug("Stop refresh service"); }