From 47ed7f40b5b8de1748e8608e038e72a724c9ab8a Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Jun 2020 17:56:09 +0200 Subject: [PATCH] Can open Comunic from Tray Icon --- config.h | 2 +- refreshservice.cpp | 8 ++++++++ refreshservice.h | 1 + trayicon.cpp | 5 +++++ trayicon.h | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config.h b/config.h index 1c67c5d..88c84b9 100644 --- a/config.h +++ b/config.h @@ -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 diff --git a/refreshservice.cpp b/refreshservice.cpp index 31a1a1a..57ba270 100644 --- a/refreshservice.cpp +++ b/refreshservice.cpp @@ -1,9 +1,11 @@ #include #include +#include #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() diff --git a/refreshservice.h b/refreshservice.h index 4ccdfa1..537a446 100644 --- a/refreshservice.h +++ b/refreshservice.h @@ -27,6 +27,7 @@ private slots: void onNewNumberNotifications(NotificationsNumber number); void onNewNeumberUnreadNotifs(int num); void onNewNeumberUnreadConvs(int num); + void openComunic(); void confirmSignOut(); private: diff --git a/trayicon.cpp b/trayicon.cpp index d58da35..fdc171f 100644 --- a/trayicon.cpp +++ b/trayicon.cpp @@ -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() diff --git a/trayicon.h b/trayicon.h index bb23952..db25c78 100644 --- a/trayicon.h +++ b/trayicon.h @@ -24,6 +24,7 @@ public slots: signals: void askForSignOut(); + void onOpenComunic(); private slots: void onQuit();