Can sign out from account

This commit is contained in:
Pierre HUBERT 2020-06-13 17:33:43 +02:00
parent f190572d42
commit 10cd03b167
4 changed files with 19 additions and 3 deletions

View File

@ -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()

View File

@ -27,6 +27,7 @@ private slots:
void onNewNumberNotifications(NotificationsNumber number);
void onNewNeumberUnreadNotifs(int num);
void onNewNeumberUnreadConvs(int num);
void confirmSignOut();
private:
RefreshService();

View File

@ -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;

View File

@ -22,6 +22,7 @@ public slots:
void onNewNumber(const NotificationsNumber &number);
signals:
void askForSignOut();
private slots:
void onQuit();