Secondary instance fix
This commit is contained in:
parent
40a5b2e3f3
commit
ffbe5107e2
1 changed files with 10 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
@ -30,8 +31,14 @@ int main(int argc, char *argv[])
|
||||||
AllowSetForegroundWindow(ASFW_ANY);
|
AllowSetForegroundWindow(ASFW_ANY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SingleApplication app(argc, argv);
|
SingleApplication app(argc, argv, true, SingleApplication::Mode::User | SingleApplication::Mode::SecondaryNotification);
|
||||||
|
|
||||||
|
if (!app.isPrimary()) {
|
||||||
|
QTimer::singleShot(1000, &app, [&](){
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
AllowSetForegroundWindow(0);
|
AllowSetForegroundWindow(0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,7 +80,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (app.isPrimary()) {
|
if (app.isPrimary()) {
|
||||||
QObject::connect(&app, &SingleApplication::instanceStarted, &mainWindow, [&](){
|
QObject::connect(&app, &SingleApplication::instanceStarted, &mainWindow, [&](){
|
||||||
|
qDebug() << "Secondary instance started, showing this window instead";
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
mainWindow.showNormal();
|
||||||
mainWindow.raise();
|
mainWindow.raise();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue