mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-01-06 00:54:00 +00:00
Add notification on second simultaneous launch
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QtNetwork/QLocalServer>
|
||||
#include <QtNetwork/QLocalSocket>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <signal.h>
|
||||
@@ -415,6 +417,26 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
|
||||
|
||||
d->connectToPrimary( timeout, SingleApplicationPrivate::NewInstance );
|
||||
delete d;
|
||||
|
||||
// show message box with inforation that Flameshot is already launched
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("Hi, I'm already running!\nYou can find me in the system tray."));
|
||||
int cnt = 3;
|
||||
QTimer cntDown;
|
||||
QObject::connect(
|
||||
&cntDown,
|
||||
&QTimer::timeout,
|
||||
[&msgBox,&cnt, &cntDown]()->void{
|
||||
if(--cnt < 0){
|
||||
cntDown.stop();
|
||||
msgBox.close();
|
||||
} else {
|
||||
msgBox.setWindowTitle(QString("Flameshot (%1)").arg(cnt + 1));
|
||||
}
|
||||
});
|
||||
cntDown.start(1000);
|
||||
msgBox.exec();
|
||||
|
||||
::exit( EXIT_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user