mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
mainview: implement systray icon and runguard
- adds a systray icon with and exit option when the app starts - removes the systray icon when the app exits - restores the app when a second instance is run Change-Id: I81e4552bdf0ce76a520cbae90e519efff0b13495
This commit is contained in:
parent
325c46d284
commit
ac50377649
4 changed files with 40 additions and 3 deletions
|
@ -123,4 +123,14 @@ ApplicationWindow {
|
|||
duration: 500
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ClientWrapper.lrcInstance
|
||||
onRestoreAppRequested: {
|
||||
if (mainViewLoader.item)
|
||||
mainViewLoader.item.show()
|
||||
else
|
||||
wizardView.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,6 +444,7 @@ public:
|
|||
signals:
|
||||
void accountListChanged();
|
||||
void currentAccountChanged();
|
||||
void restoreAppRequested();
|
||||
|
||||
private:
|
||||
LRCInstance(migrateCallback willMigrateCb = {}, migrateCallback didMigrateCb = {})
|
||||
|
|
|
@ -58,7 +58,9 @@
|
|||
#include "videoformatresolutionmodel.h"
|
||||
#include "videoinputdevicemodel.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFontDatabase>
|
||||
#include <QMenu>
|
||||
#include <QQmlContext>
|
||||
#include <QtWebEngine>
|
||||
|
||||
|
@ -455,5 +457,28 @@ MainApplication::applicationSetup()
|
|||
*/
|
||||
qmlInitialization();
|
||||
|
||||
/*
|
||||
* Systray menu.
|
||||
*/
|
||||
GlobalSystemTray& sysIcon = GlobalSystemTray::instance();
|
||||
sysIcon.setIcon(QIcon(":images/jami.png"));
|
||||
|
||||
QMenu* systrayMenu = new QMenu();
|
||||
|
||||
QAction* exitAction = new QAction(tr("Exit"), this);
|
||||
connect(exitAction, &QAction::triggered,
|
||||
[this] {
|
||||
QCoreApplication::exit();
|
||||
});
|
||||
|
||||
connect(&sysIcon, &QSystemTrayIcon::activated,
|
||||
[this](QSystemTrayIcon::ActivationReason reason) {
|
||||
emit LRCInstance::instance().restoreAppRequested();
|
||||
});
|
||||
|
||||
systrayMenu->addAction(exitAction);
|
||||
sysIcon.setContextMenu(systrayMenu);
|
||||
sysIcon.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
// Based on: https://stackoverflow.com/a/28172162
|
||||
|
||||
#include "runguard.h"
|
||||
|
||||
#include "lrcinstance.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
namespace {
|
||||
|
@ -52,9 +55,7 @@ RunGuard::~RunGuard()
|
|||
void
|
||||
RunGuard::tryRestorePrimaryInstance()
|
||||
{
|
||||
/*
|
||||
* TODO: relaunch application
|
||||
*/
|
||||
emit LRCInstance::instance().restoreAppRequested();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Add table
Reference in a new issue