mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-12-24 12:38:55 +00:00
Can sign out from account
This commit is contained in:
parent
f190572d42
commit
10cd03b167
@ -1,9 +1,10 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "accounthelper.h"
|
||||
#include "loginwindow.h"
|
||||
#include "refreshservice.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
RefreshService *RefreshService::svc = nullptr;
|
||||
|
||||
|
||||
@ -31,7 +32,7 @@ void RefreshService::signOutUser()
|
||||
{
|
||||
AccountHelper::RemoveLoginToken();
|
||||
RefreshService::stopService();
|
||||
LoginWindow().exec();
|
||||
(new LoginWindow())->show();
|
||||
}
|
||||
|
||||
void RefreshService::connectedToWebSocket()
|
||||
@ -58,6 +59,14 @@ void RefreshService::onNewNeumberUnreadConvs(int num)
|
||||
mTrayIcon.onNewNumber(mNumbers);
|
||||
}
|
||||
|
||||
void RefreshService::confirmSignOut()
|
||||
{
|
||||
if(QMessageBox::question(nullptr, tr("Sign out"), tr("Do you really want to disconnect ComunicWatcher from your Comunic account?")) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
signOutUser();
|
||||
}
|
||||
|
||||
RefreshService::RefreshService()
|
||||
{
|
||||
qDebug("Start refresh service");
|
||||
@ -66,6 +75,7 @@ RefreshService::RefreshService()
|
||||
connect(&mNotifsHelper, &NotificationsHelper::onNewNumber, this, &RefreshService::onNewNumberNotifications);
|
||||
connect(&mWsClient, &WsClient::newNumberNotifs, this, &RefreshService::onNewNeumberUnreadNotifs);
|
||||
connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs);
|
||||
connect(&mTrayIcon, &TrayIcon::askForSignOut, this, &RefreshService::confirmSignOut);
|
||||
}
|
||||
|
||||
RefreshService::~RefreshService()
|
||||
|
@ -27,6 +27,7 @@ private slots:
|
||||
void onNewNumberNotifications(NotificationsNumber number);
|
||||
void onNewNeumberUnreadNotifs(int num);
|
||||
void onNewNeumberUnreadConvs(int num);
|
||||
void confirmSignOut();
|
||||
|
||||
private:
|
||||
RefreshService();
|
||||
|
@ -9,6 +9,9 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mMenu = new QMenu;
|
||||
|
||||
QAction *signOutAction = mMenu->addAction(tr("Sign out"));
|
||||
connect(signOutAction, &QAction::triggered, this, &TrayIcon::askForSignOut);
|
||||
|
||||
QAction *closeAction = mMenu->addAction(tr("Quit"));
|
||||
connect(closeAction, &QAction::triggered, this, &TrayIcon::onQuit);
|
||||
|
||||
@ -37,6 +40,7 @@ void TrayIcon::onQuit()
|
||||
QApplication::exit();
|
||||
}
|
||||
|
||||
|
||||
void TrayIcon::showNotification(const NotificationsNumber &n)
|
||||
{
|
||||
QString msg;
|
||||
|
@ -22,6 +22,7 @@ public slots:
|
||||
void onNewNumber(const NotificationsNumber &number);
|
||||
|
||||
signals:
|
||||
void askForSignOut();
|
||||
|
||||
private slots:
|
||||
void onQuit();
|
||||
|
Loading…
Reference in New Issue
Block a user