Add notification on second simultaneous launch

This commit is contained in:
Yuriy Puchkov
2020-08-12 20:28:39 +03:00
parent c8dd2e088a
commit a5cb99707d
18 changed files with 203 additions and 80 deletions

View File

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