diff --git a/windows/src/desktop/kmshell/main/Keyman.Configuration.System.BaseKeyboard.pas b/windows/src/desktop/kmshell/main/Keyman.Configuration.System.BaseKeyboard.pas index c47d90a1a5..d91b439f33 100644 --- a/windows/src/desktop/kmshell/main/Keyman.Configuration.System.BaseKeyboard.pas +++ b/windows/src/desktop/kmshell/main/Keyman.Configuration.System.BaseKeyboard.pas @@ -7,7 +7,28 @@ uses System.SysUtils, keymanapi_TLB; +(** + Returns true if the keyboard files need to be compiled for the specified KLID. + @param BaseKeyboardID KLID of the base keyboard to compile. + @returns True If the keyboard files need to be compiled. +*) +function BaseKeyboardNeedsMCompile(BaseKeyboardID: Integer): Boolean; + +(** + Sets the base keyboard KLID for the current user and compiles the keyboard + files if necessary. In the case the compiled keyboard files are not present, + it will require elevation. + @param WindowHandle Window handle to own the elevation prompt. + @param BaseKeyboardID KLID of the base keyboard KLID to set. + @returns True when the base keyboard setting has been applied. +*) function SetBaseKeyboard(WindowHandle: THandle; BaseKeyboardID: Integer): Boolean; + +(** + Compiles the base keyboard files for the specified KLID. + @param BaseKeyboardID KLID of the base keyboard to compile. + @returns True when the compilation is successful. +*) function MCompileBaseKeyboard(BaseKeyboardID: Integer): Boolean; implementation @@ -38,20 +59,20 @@ end; function SetBaseKeyboard(WindowHandle: THandle; BaseKeyboardID: Integer): Boolean; begin - Result := False; + Result := True; if BaseKeyboardNeedsMCompile(BaseKeyboardID) then begin if not kmcom.SystemInfo.IsAdministrator then begin - WaitForElevatedConfiguration(WindowHandle, '-mcompilekbds ' + IntToHex(BaseKeyboardID, 8)); + Result := WaitForElevatedConfiguration(WindowHandle, '-mcompilekbds ' + IntToHex(BaseKeyboardID, 8)) = 0; end else - MCompileBaseKeyboard(BaseKeyboardID); + Result := MCompileBaseKeyboard(BaseKeyboardID); end; - + if not Result then + Exit; kmcom.Options['koBaseLayout'].Value := BaseKeyboardID; kmcom.Options.Apply; - Result := True; end; function MCompileBaseKeyboard(BaseKeyboardID: Integer): Boolean; diff --git a/windows/src/desktop/kmshell/main/UfrmBaseKeyboard.pas b/windows/src/desktop/kmshell/main/UfrmBaseKeyboard.pas index 91a6710112..dd298a8642 100644 --- a/windows/src/desktop/kmshell/main/UfrmBaseKeyboard.pas +++ b/windows/src/desktop/kmshell/main/UfrmBaseKeyboard.pas @@ -18,6 +18,14 @@ type procedure FireCommand(const command: WideString; params: TStringList); override; end; + +(** + Form for the user to select a base keyboard. If the user selects a base + keyboard, the KLID of the selected base keyboard is returned in + BaseKeyboardID. + @param [out] BaseKeyboardID KLID of the base keyboard selected by the user. + @returns True if the user selected a base keyboard. +*) function ConfigureBaseKeyboard(out BaseKeyboardID: Integer): Boolean; implementation