mirror of
https://github.com/tnodir/fort
synced 2024-11-14 22:36:08 +00:00
Installer: Don't show "My Fort" window of running instance on launch
This commit is contained in:
parent
a510435c58
commit
283f674d9a
@ -100,7 +100,7 @@ Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Flags: runasoriginaluser; Tas
|
||||
Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; \
|
||||
Flags: nowait; Tasks: service
|
||||
|
||||
Filename: "{#APP_EXE}"; Parameters: "--lang {code:LanguageName}"; \
|
||||
Filename: "{#APP_EXE}"; Parameters: "--launch --lang {code:LanguageName}"; \
|
||||
Description: {cm:LaunchProgram,{#APP_NAME}}; Flags: nowait postinstall; Check: ShouldLaunch
|
||||
|
||||
[UninstallRun]
|
||||
|
@ -155,7 +155,7 @@ FortManager::~FortManager()
|
||||
OsUtil::closeMutex(m_instanceMutex);
|
||||
}
|
||||
|
||||
bool FortManager::checkRunningInstance(bool isService)
|
||||
bool FortManager::checkRunningInstance(bool isService, bool isLaunch)
|
||||
{
|
||||
bool isSingleInstance;
|
||||
m_instanceMutex =
|
||||
@ -165,7 +165,7 @@ bool FortManager::checkRunningInstance(bool isService)
|
||||
|
||||
if (isService) {
|
||||
qCWarning(LC) << "Quit due Service is already running!";
|
||||
} else {
|
||||
} else if (!isLaunch) {
|
||||
if (!IoC<ControlManager>()->postCommand(Control::CommandHome, { "show" })) {
|
||||
QMessageBox::warning(nullptr, QString(), tr("Application is already running!"));
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
~FortManager() override;
|
||||
CLASS_DELETE_COPY_MOVE(FortManager)
|
||||
|
||||
bool checkRunningInstance(bool isService);
|
||||
bool checkRunningInstance(bool isService, bool isLaunch);
|
||||
|
||||
void initialize();
|
||||
|
||||
|
@ -203,12 +203,12 @@ void FortSettings::processLangOption(
|
||||
}
|
||||
}
|
||||
|
||||
void FortSettings::processRestartedOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &restartedOption)
|
||||
void FortSettings::processLaunchOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &launchOption)
|
||||
{
|
||||
// Restarted by Installer
|
||||
if (parser.isSet(restartedOption)) {
|
||||
m_isRestarted = true;
|
||||
// Launched by Installer
|
||||
if (parser.isSet(launchOption)) {
|
||||
m_isLaunch = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ void FortSettings::processArguments(const QStringList &args)
|
||||
QCommandLineParser parser;
|
||||
|
||||
const QCommandLineOption profileOption(
|
||||
QStringList() << "p" << "profile", "Directory to store settings.", "profile");
|
||||
{ "p", "profile" }, "Directory to store settings.", "profile");
|
||||
parser.addOption(profileOption);
|
||||
|
||||
const QCommandLineOption statOption("stat", "Directory to store statistics.", "stat");
|
||||
@ -266,14 +266,18 @@ void FortSettings::processArguments(const QStringList &args)
|
||||
const QCommandLineOption langOption("lang", "Default language.", "lang", "en");
|
||||
parser.addOption(langOption);
|
||||
|
||||
// TODO: COMPAT: Remove after v4.1.0 (via v4.0.0)
|
||||
const QCommandLineOption restartedOption("restarted", "Restarted by Installer?");
|
||||
parser.addOption(restartedOption);
|
||||
|
||||
const QCommandLineOption launchOption("launch", "Launched by Installer?");
|
||||
parser.addOption(launchOption);
|
||||
|
||||
const QCommandLineOption serviceOption("service", "Is running as a service?");
|
||||
parser.addOption(serviceOption);
|
||||
|
||||
const QCommandLineOption controlOption(QStringList() << "c" << "control",
|
||||
"Control running instance by executing the command.", "control");
|
||||
const QCommandLineOption controlOption(
|
||||
{ "c", "control" }, "Control running instance by executing the command.", "control");
|
||||
parser.addOption(controlOption);
|
||||
|
||||
parser.addVersionOption();
|
||||
@ -288,7 +292,8 @@ void FortSettings::processArguments(const QStringList &args)
|
||||
processNoCacheOption(parser, noCacheOption);
|
||||
processNoSplashOption(parser, noSplashOption);
|
||||
processLangOption(parser, langOption);
|
||||
processRestartedOption(parser, restartedOption);
|
||||
processLaunchOption(parser, restartedOption);
|
||||
processLaunchOption(parser, launchOption);
|
||||
processServiceOption(parser, serviceOption);
|
||||
processControlOption(parser, controlOption);
|
||||
processOtherOptions(parser);
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
bool canInstallDriver() const { return m_canInstallDriver; }
|
||||
bool canStartService() const { return m_canStartService; }
|
||||
|
||||
bool isRestarted() const { return m_isRestarted; }
|
||||
bool isLaunch() const { return m_isLaunch; }
|
||||
|
||||
bool isService() const { return m_isService; }
|
||||
bool hasService() const { return m_hasService; }
|
||||
@ -118,8 +118,8 @@ private:
|
||||
void processNoSplashOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &noSplashOption);
|
||||
void processLangOption(const QCommandLineParser &parser, const QCommandLineOption &langOption);
|
||||
void processRestartedOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &restartedOption);
|
||||
void processLaunchOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &launchOption);
|
||||
void processServiceOption(
|
||||
const QCommandLineParser &parser, const QCommandLineOption &serviceOption);
|
||||
void processControlOption(
|
||||
@ -137,7 +137,7 @@ private:
|
||||
uint m_forceDebug : 1 = false;
|
||||
uint m_canInstallDriver : 1 = false;
|
||||
uint m_canStartService : 1 = false;
|
||||
uint m_isRestarted : 1 = false;
|
||||
uint m_isLaunch : 1 = false;
|
||||
uint m_isService : 1 = false;
|
||||
uint m_hasService : 1 = false;
|
||||
uint m_isUserAdmin : 1 = false;
|
||||
|
@ -176,8 +176,7 @@ bool OsUtil::allowOtherForegroundWindows()
|
||||
|
||||
bool OsUtil::registerAppRestart()
|
||||
{
|
||||
return SUCCEEDED(
|
||||
RegisterApplicationRestart(L"--restarted", RESTART_NO_CRASH | RESTART_NO_REBOOT));
|
||||
return SUCCEEDED(RegisterApplicationRestart(L"--launch", RESTART_NO_CRASH | RESTART_NO_REBOOT));
|
||||
}
|
||||
|
||||
void OsUtil::beginRestartClients()
|
||||
@ -198,7 +197,7 @@ void OsUtil::restartClient()
|
||||
|
||||
const auto command = QString("for /L %i in (1,1,30) do ("
|
||||
"ping -n 2 127.0.0.1 >NUL"
|
||||
" & if not exist inst.tmp start %1 --restarted & exit)")
|
||||
" & if not exist inst.tmp start %1 --launch & exit)")
|
||||
.arg(fi.fileName());
|
||||
|
||||
const QStringList args = { "/c", command };
|
||||
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
||||
ioc.set<FortManager>(fortManager);
|
||||
|
||||
// Check running instance
|
||||
if (!fortManager.checkRunningInstance(settings.isService()))
|
||||
if (!fortManager.checkRunningInstance(settings.isService(), settings.isLaunch()))
|
||||
return FortErrorInstance;
|
||||
|
||||
fortManager.initialize();
|
||||
|
Loading…
Reference in New Issue
Block a user