From b56f0b75b72043fb777a57cb2d9bc466f0c38e20 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 24 Mar 2021 17:05:30 +0300 Subject: [PATCH] Installer: Add "Add to Explorer's Context Menu" option. --- deploy/FortFirewall.iss | 21 ++++++++++++++++++--- src/ui/control/controlmanager.cpp | 26 +++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index dc1b4222..67918fdf 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -6,6 +6,8 @@ #define APP_EXE_NAME "FortFirewall.exe" #define APP_ICO_NAME "FortFirewall.ico" +#define APP_EXE StringChange("{app}\%exe%", "%exe%", APP_EXE_NAME) + [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. @@ -40,19 +42,32 @@ Name: ru; MessagesFile: "compiler:Languages\Russian.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; Flags: unchecked +Name: "explorer"; Description: "Add to Explorer's Context Menu"; Flags: unchecked Name: "portable"; Description: "Portable"; Flags: unchecked [Files] Source: "build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "README.portable"; DestDir: "{app}"; Check: IsTaskSelected('portable') +[Registry] +; Explorer's Context Menu +#define REG_SHELL_MENU "SystemFileAssociations\.exe\Shell\Fort Firewall" +Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; Flags: deletekey uninsdeletekey +Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; ValueType: string; ValueName: "icon"; ValueData: "{#APP_EXE}"; \ + Check: IsTaskSelected('explorer') +Root: HKCR; Subkey: "{#REG_SHELL_MENU}"; ValueType: string; ValueName: "MUIVerb"; ValueData: "Fort Firewall ..."; \ + Check: IsTaskSelected('explorer') +Root: HKCR; Subkey: "{#REG_SHELL_MENU}\command"; ValueType: string; ValueData: """{#APP_EXE}"" -c prog add ""%1"""; \ + Check: IsTaskSelected('explorer') + [Icons] ; Start menu shortcut -Name: "{group}\{#APP_NAME}"; Filename: "{app}\{#APP_EXE_NAME}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}" +Name: "{group}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}" ; Uninstaller shortcut Name: "{group}\{cm:UninstallProgram,{#APP_NAME}}"; Filename: "{uninstallexe}" ; Desktop shortcut -Name: "{commondesktop}\{#APP_NAME}"; Filename: "{app}\{#APP_EXE_NAME}"; WorkingDir: "{app}"; Parameters: "--lang {code:LanguageName}"; Tasks: desktopicon +Name: "{commondesktop}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; \ + Parameters: "--lang {code:LanguageName}"; Tasks: desktopicon [Run] Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"; Flags: runascurrentuser @@ -61,7 +76,7 @@ Filename: "https://support.microsoft.com/en-us/help/2977003/the-latest-supported [UninstallRun] Filename: "{app}\driver\scripts\uninstall.bat"; RunOnceId: "DelDriver"; Flags: runascurrentuser -Filename: "{app}\{#APP_EXE_NAME}"; Parameters: "-b=0"; RunOnceId: "DelProvider"; Flags: runascurrentuser +Filename: "{#APP_EXE}"; Parameters: "-b=0"; RunOnceId: "DelProvider"; Flags: runascurrentuser [InstallDelete] Type: filesandordirs; Name: "{app}" diff --git a/src/ui/control/controlmanager.cpp b/src/ui/control/controlmanager.cpp index 18942d9c..92ab64fe 100644 --- a/src/ui/control/controlmanager.cpp +++ b/src/ui/control/controlmanager.cpp @@ -75,8 +75,8 @@ bool ControlManager::processCommand( { const int argsSize = args.size(); - if (command == QLatin1String("ini")) { - if (argsSize < 3) { + if (command == "ini") { + if (argsSize < 2) { errorMessage = "ini "; return false; } @@ -84,8 +84,8 @@ bool ControlManager::processCommand( auto settings = m_fortManager->settings(); settings->setProperty(args.at(0).toLatin1(), QVariant(args.at(1))); - } else if (command == QLatin1String("conf")) { - if (argsSize < 3) { + } else if (command == "conf") { + if (argsSize < 2) { errorMessage = "conf "; return false; } @@ -94,7 +94,7 @@ bool ControlManager::processCommand( const auto confPropName = args.at(0); - if (confPropName == QLatin1String("appGroup")) { + if (confPropName == "appGroup") { if (argsSize < 4) { errorMessage = "conf appGroup "; return false; @@ -107,6 +107,22 @@ bool ControlManager::processCommand( } m_fortManager->saveOriginConf(tr("Control command executed")); + } else if (command == "prog") { + if (argsSize < 1) { + errorMessage = "prog "; + return false; + } + + const auto progCommand = args.at(0); + + if (progCommand == "add") { + if (argsSize < 2) { + errorMessage = "prog add "; + return false; + } + + m_fortManager->showProgramEditForm(args.at(1)); + } } return true;