Can open Comunic from Tray Icon

This commit is contained in:
Pierre HUBERT 2020-06-13 17:56:09 +02:00
parent 951cde4c4e
commit 47ed7f40b5
5 changed files with 16 additions and 1 deletions

View File

@ -25,5 +25,5 @@
#define API_BASE_PATH "/comunic/api-v2/"
#define API_SERVICE_NAME "ComunicWatcher"
#define API_SERVICE_TOKEN "ComunicWatcher"
#define COMUNIC_URL "https://devweb.local/comunic/v2/"
#endif

View File

@ -1,9 +1,11 @@
#include <QGuiApplication>
#include <QMessageBox>
#include <QDesktopServices>
#include "accounthelper.h"
#include "loginwindow.h"
#include "refreshservice.h"
#include "config.h"
RefreshService *RefreshService::svc = nullptr;
@ -59,6 +61,11 @@ void RefreshService::onNewNeumberUnreadConvs(int num)
mTrayIcon.onNewNumber(mNumbers);
}
void RefreshService::openComunic()
{
QDesktopServices::openUrl(QUrl(COMUNIC_URL));
}
void RefreshService::confirmSignOut()
{
if(QMessageBox::question(nullptr, tr("Sign out"), tr("Do you really want to disconnect ComunicWatcher from your Comunic account?")) != QMessageBox::Yes)
@ -76,6 +83,7 @@ RefreshService::RefreshService()
connect(&mWsClient, &WsClient::newNumberNotifs, this, &RefreshService::onNewNeumberUnreadNotifs);
connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs);
connect(&mTrayIcon, &TrayIcon::askForSignOut, this, &RefreshService::confirmSignOut);
connect(&mTrayIcon, &TrayIcon::onOpenComunic, this, &RefreshService::openComunic);
}
RefreshService::~RefreshService()

View File

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

View File

@ -15,6 +15,9 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
mUnreadConversations = mMenu->addAction(tr("Loading..."));
mUnreadConversations->setDisabled(true);
QAction *openComunicAction = mMenu->addAction(tr("Open Comunic"));
connect(openComunicAction, &QAction::triggered, this, &TrayIcon::onOpenComunic);
mMenu->addSeparator();
QAction *signOutAction = mMenu->addAction(tr("Sign out"));
@ -26,6 +29,8 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
mTrayIcon.setIcon(QIcon(":/logo_large.png"));
mTrayIcon.setContextMenu(mMenu);
mTrayIcon.show();
connect(&mTrayIcon, &QSystemTrayIcon::messageClicked, this, &TrayIcon::onOpenComunic);
}
TrayIcon::~TrayIcon()

View File

@ -24,6 +24,7 @@ public slots:
signals:
void askForSignOut();
void onOpenComunic();
private slots:
void onQuit();