Ready to implement who am I dialog

This commit is contained in:
Pierre HUBERT 2020-06-13 18:05:06 +02:00
parent ca6b675ac2
commit cbbf4b43c8
8 changed files with 81 additions and 3 deletions

View File

@ -24,6 +24,7 @@ SOURCES += \
notificationsnumber.cpp \ notificationsnumber.cpp \
refreshservice.cpp \ refreshservice.cpp \
trayicon.cpp \ trayicon.cpp \
whoamidialog.cpp \
wsclient.cpp wsclient.cpp
HEADERS += \ HEADERS += \
@ -37,11 +38,13 @@ HEADERS += \
notificationsnumber.h \ notificationsnumber.h \
refreshservice.h \ refreshservice.h \
trayicon.h \ trayicon.h \
whoamidialog.h \
wsclient.h wsclient.h
FORMS += \ FORMS += \
loginsuccessfuldialog.ui \ loginsuccessfuldialog.ui \
loginwindow.ui loginwindow.ui \
whoamidialog.ui
TRANSLATIONS += \ TRANSLATIONS += \
ComunicWatcher_fr_FR.ts ComunicWatcher_fr_FR.ts

View File

@ -6,6 +6,7 @@
#include "loginwindow.h" #include "loginwindow.h"
#include "refreshservice.h" #include "refreshservice.h"
#include "config.h" #include "config.h"
#include "whoamidialog.h"
RefreshService *RefreshService::svc = nullptr; RefreshService *RefreshService::svc = nullptr;
@ -66,6 +67,11 @@ void RefreshService::openComunic()
QDesktopServices::openUrl(QUrl(COMUNIC_URL)); QDesktopServices::openUrl(QUrl(COMUNIC_URL));
} }
void RefreshService::openWhoAmIDialog()
{
WhoAmIDialog().exec();
}
void RefreshService::confirmSignOut() void RefreshService::confirmSignOut()
{ {
if(QMessageBox::question(nullptr, tr("Sign out"), tr("Do you really want to disconnect ComunicWatcher from your Comunic account?")) != QMessageBox::Yes) 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::newNumberNotifs, this, &RefreshService::onNewNeumberUnreadNotifs);
connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs); connect(&mWsClient, &WsClient::newNumberConvs, this, &RefreshService::onNewNeumberUnreadConvs);
connect(&mTrayIcon, &TrayIcon::askForSignOut, this, &RefreshService::confirmSignOut); connect(&mTrayIcon, &TrayIcon::askForSignOut, this, &RefreshService::confirmSignOut);
connect(&mTrayIcon, &TrayIcon::whoAmI, this, &RefreshService::openWhoAmIDialog);
connect(&mTrayIcon, &TrayIcon::onOpenComunic, this, &RefreshService::openComunic); connect(&mTrayIcon, &TrayIcon::onOpenComunic, this, &RefreshService::openComunic);
} }

View File

@ -28,6 +28,7 @@ private slots:
void onNewNeumberUnreadNotifs(int num); void onNewNeumberUnreadNotifs(int num);
void onNewNeumberUnreadConvs(int num); void onNewNeumberUnreadConvs(int num);
void openComunic(); void openComunic();
void openWhoAmIDialog();
void confirmSignOut(); void confirmSignOut();
private: private:

View File

@ -20,9 +20,16 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
mMenu->addSeparator(); 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); connect(signOutAction, &QAction::triggered, this, &TrayIcon::askForSignOut);
mMenu->addSeparator();
QAction *closeAction = mMenu->addAction(tr("Quit")); QAction *closeAction = mMenu->addAction(tr("Quit"));
connect(closeAction, &QAction::triggered, this, &TrayIcon::onQuit); connect(closeAction, &QAction::triggered, this, &TrayIcon::onQuit);

View File

@ -23,8 +23,9 @@ public slots:
void onNewNumber(const NotificationsNumber &number); void onNewNumber(const NotificationsNumber &number);
signals: signals:
void askForSignOut();
void onOpenComunic(); void onOpenComunic();
void whoAmI();
void askForSignOut();
private slots: private slots:
void onQuit(); void onQuit();

14
whoamidialog.cpp Normal file
View File

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

20
whoamidialog.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include <QDialog>
namespace Ui {
class WhoAmIDialog;
}
class WhoAmIDialog : public QDialog
{
Q_OBJECT
public:
explicit WhoAmIDialog(QWidget *parent = nullptr);
~WhoAmIDialog();
private:
Ui::WhoAmIDialog *ui;
};

25
whoamidialog.ui Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WhoAmIDialog</class>
<widget class="QDialog" name="WhoAmIDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Who am I</string>
</property>
<property name="windowIcon">
<iconset resource="ressources.qrc">
<normaloff>:/logo_large.png</normaloff>:/logo_large.png</iconset>
</property>
</widget>
<resources>
<include location="ressources.qrc"/>
</resources>
<connections/>
</ui>