From cbbf4b43c8b08098fa02608c70c679f7efa3ee87 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Jun 2020 18:05:06 +0200 Subject: [PATCH] Ready to implement who am I dialog --- ComunicWatcher.pro | 5 ++++- refreshservice.cpp | 7 +++++++ refreshservice.h | 1 + trayicon.cpp | 9 ++++++++- trayicon.h | 3 ++- whoamidialog.cpp | 14 ++++++++++++++ whoamidialog.h | 20 ++++++++++++++++++++ whoamidialog.ui | 25 +++++++++++++++++++++++++ 8 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 whoamidialog.cpp create mode 100644 whoamidialog.h create mode 100644 whoamidialog.ui diff --git a/ComunicWatcher.pro b/ComunicWatcher.pro index c2e9135..4e05da2 100644 --- a/ComunicWatcher.pro +++ b/ComunicWatcher.pro @@ -24,6 +24,7 @@ SOURCES += \ notificationsnumber.cpp \ refreshservice.cpp \ trayicon.cpp \ + whoamidialog.cpp \ wsclient.cpp HEADERS += \ @@ -37,11 +38,13 @@ HEADERS += \ notificationsnumber.h \ refreshservice.h \ trayicon.h \ + whoamidialog.h \ wsclient.h FORMS += \ loginsuccessfuldialog.ui \ - loginwindow.ui + loginwindow.ui \ + whoamidialog.ui TRANSLATIONS += \ ComunicWatcher_fr_FR.ts diff --git a/refreshservice.cpp b/refreshservice.cpp index 57ba270..9c57bc3 100644 --- a/refreshservice.cpp +++ b/refreshservice.cpp @@ -6,6 +6,7 @@ #include "loginwindow.h" #include "refreshservice.h" #include "config.h" +#include "whoamidialog.h" RefreshService *RefreshService::svc = nullptr; @@ -66,6 +67,11 @@ void RefreshService::openComunic() QDesktopServices::openUrl(QUrl(COMUNIC_URL)); } +void RefreshService::openWhoAmIDialog() +{ + WhoAmIDialog().exec(); +} + void RefreshService::confirmSignOut() { if(QMessageBox::question(nullptr, tr("Sign out"), tr("Do you really want to disconnect ComunicWatcher from your Comunic account?")) != QMessageBox::Yes) @@ -83,6 +89,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::whoAmI, this, &RefreshService::openWhoAmIDialog); connect(&mTrayIcon, &TrayIcon::onOpenComunic, this, &RefreshService::openComunic); } diff --git a/refreshservice.h b/refreshservice.h index 537a446..c6a8fcb 100644 --- a/refreshservice.h +++ b/refreshservice.h @@ -28,6 +28,7 @@ private slots: void onNewNeumberUnreadNotifs(int num); void onNewNeumberUnreadConvs(int num); void openComunic(); + void openWhoAmIDialog(); void confirmSignOut(); private: diff --git a/trayicon.cpp b/trayicon.cpp index fdc171f..3d4d3d6 100644 --- a/trayicon.cpp +++ b/trayicon.cpp @@ -20,9 +20,16 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent) mMenu->addSeparator(); - QAction *signOutAction = mMenu->addAction(tr("Sign out")); + QMenu *subMenu = mMenu->addMenu(tr("Other actions")); + + QAction *whoAmIAction = subMenu->addAction(tr("Who am I")); + connect(whoAmIAction, &QAction::triggered, this, &TrayIcon::whoAmI); + + QAction *signOutAction = subMenu->addAction(tr("Sign out")); connect(signOutAction, &QAction::triggered, this, &TrayIcon::askForSignOut); + mMenu->addSeparator(); + QAction *closeAction = mMenu->addAction(tr("Quit")); connect(closeAction, &QAction::triggered, this, &TrayIcon::onQuit); diff --git a/trayicon.h b/trayicon.h index db25c78..2eace8f 100644 --- a/trayicon.h +++ b/trayicon.h @@ -23,8 +23,9 @@ public slots: void onNewNumber(const NotificationsNumber &number); signals: - void askForSignOut(); void onOpenComunic(); + void whoAmI(); + void askForSignOut(); private slots: void onQuit(); diff --git a/whoamidialog.cpp b/whoamidialog.cpp new file mode 100644 index 0000000..6df49d6 --- /dev/null +++ b/whoamidialog.cpp @@ -0,0 +1,14 @@ +#include "whoamidialog.h" +#include "ui_whoamidialog.h" + +WhoAmIDialog::WhoAmIDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::WhoAmIDialog) +{ + ui->setupUi(this); +} + +WhoAmIDialog::~WhoAmIDialog() +{ + delete ui; +} diff --git a/whoamidialog.h b/whoamidialog.h new file mode 100644 index 0000000..5ce00a6 --- /dev/null +++ b/whoamidialog.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace Ui { +class WhoAmIDialog; +} + +class WhoAmIDialog : public QDialog +{ + Q_OBJECT + +public: + explicit WhoAmIDialog(QWidget *parent = nullptr); + ~WhoAmIDialog(); + +private: + Ui::WhoAmIDialog *ui; +}; + diff --git a/whoamidialog.ui b/whoamidialog.ui new file mode 100644 index 0000000..9449c6d --- /dev/null +++ b/whoamidialog.ui @@ -0,0 +1,25 @@ + + + WhoAmIDialog + + + + 0 + 0 + 400 + 300 + + + + Who am I + + + + :/logo_large.png:/logo_large.png + + + + + + +