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