Skip to content

Commit

Permalink
Merge pull request #10151 from keymanapp/fix/developer/10144-10145-10…
Browse files Browse the repository at this point in the history
…146-10148

fix(developer): various project fixes 🦕
  • Loading branch information
mcdurdin committed Dec 12, 2023
2 parents e65d5c5 + cb8c114 commit 1f06224
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 96 deletions.
1 change: 1 addition & 0 deletions common/windows/delphi/general/RegistryKeys.pas
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ interface
SRegValue_IDEOptDebuggerAutoResetBeforeCompiling = 'debugger auto reset before compilng'; // CU
SRegValue_IDEOptAutoSaveBeforeCompiling = 'auto save before compiling'; // CU
SRegValue_IDEOptOSKAutoSaveBeforeImporting = 'osk auto save before importing'; // CU
SRegValue_IDEOptPromptToUpgradeProjects = 'prompt to upgrade projects'; // CU

// Note: keeping 'web host port' reg value name to ensure settings maintained
// from version 14.0 and earlier of Keyman Developer. Other values are
Expand Down
4 changes: 3 additions & 1 deletion developer/src/kmconvert/kmconvert.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ uses
KeymanPaths in '..\..\..\common\windows\delphi\general\KeymanPaths.pas',
Keyman.System.Standards.LangTagsRegistry in '..\..\..\common\windows\delphi\standards\Keyman.System.Standards.LangTagsRegistry.pas',
Keyman.Developer.System.Project.UrlRenderer in '..\TIKE\project\Keyman.Developer.System.Project.UrlRenderer.pas',
Keyman.System.LexicalModelUtils in '..\common\delphi\lexicalmodels\Keyman.System.LexicalModelUtils.pas';
Keyman.System.LexicalModelUtils in '..\common\delphi\lexicalmodels\Keyman.System.LexicalModelUtils.pas',
KeymanDeveloperOptions in '..\tike\main\KeymanDeveloperOptions.pas',
Keyman.Developer.System.KeymanDeveloperPaths in '..\tike\main\Keyman.Developer.System.KeymanDeveloperPaths.pas';

{$R icons.RES}
{$R version.res}
Expand Down
2 changes: 2 additions & 0 deletions developer/src/kmconvert/kmconvert.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@
<DCCReference Include="..\..\..\common\windows\delphi\standards\Keyman.System.Standards.LangTagsRegistry.pas"/>
<DCCReference Include="..\TIKE\project\Keyman.Developer.System.Project.UrlRenderer.pas"/>
<DCCReference Include="..\common\delphi\lexicalmodels\Keyman.System.LexicalModelUtils.pas"/>
<DCCReference Include="..\tike\main\KeymanDeveloperOptions.pas"/>
<DCCReference Include="..\tike\main\Keyman.Developer.System.KeymanDeveloperPaths.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
Expand Down
6 changes: 5 additions & 1 deletion developer/src/tike/actions/dmActionsMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,11 @@ procedure TmodActionsMain.actProjectSettingsExecute(Sender: TObject);
then frm := TfrmProjectSettings.Create(Screen.ActiveForm) // I4688
else frm := TfrmProjectSettings20.Create(Screen.ActiveForm);
try
frm.ShowModal;
if frm.ShowModal = mrOk then
begin
if IsGlobalProjectUIReady then
FGlobalProject.Refresh;
end;
finally
frm.Free;
end;
Expand Down
22 changes: 15 additions & 7 deletions developer/src/tike/dialogs/UfrmOptions.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ inherited frmOptions: TfrmOptions
Top = 185
Width = 125
Height = 25
Caption = '&Proxy Settings...'
Caption = 'Prox&y Settings...'
TabOrder = 4
OnClick = cmdProxySettingsClick
end
Expand All @@ -38,7 +38,7 @@ inherited frmOptions: TfrmOptions
Top = 47
Width = 401
Height = 45
Caption = '&External Editor Path'
Caption = 'E&xternal Editor Path'
TabOrder = 1
object editExternalEditorPath: TEdit
Left = 8
Expand All @@ -61,7 +61,7 @@ inherited frmOptions: TfrmOptions
Top = 216
Width = 125
Height = 25
Caption = 'S&MTP Settings...'
Caption = '&SMTP Settings...'
TabOrder = 5
OnClick = cmdSMTPSettingsClick
end
Expand Down Expand Up @@ -101,7 +101,7 @@ inherited frmOptions: TfrmOptions
Top = 16
Width = 69
Height = 21
Caption = '&Browse...'
Caption = 'Bro&wse...'
TabOrder = 1
OnClick = cmdBrowseDefaultProjectPathClick
end
Expand All @@ -119,7 +119,7 @@ inherited frmOptions: TfrmOptions
Top = 181
Width = 218
Height = 17
Caption = '&Automatically save before importing OSK'
Caption = 'Au&tomatically save before importing OSK'
TabOrder = 7
end
object gbPrivacy: TGroupBox
Expand All @@ -128,13 +128,13 @@ inherited frmOptions: TfrmOptions
Width = 401
Height = 73
Caption = 'Privacy'
TabOrder = 8
TabOrder = 9
object chkReportUsage: TCheckBox
Left = 8
Top = 44
Width = 311
Height = 17
Caption = '&Share anonymous usage statistics with keyman.com'
Caption = 'Share anonymous &usage statistics with keyman.com'
TabOrder = 1
end
object chkReportErrors: TCheckBox
Expand All @@ -146,6 +146,14 @@ inherited frmOptions: TfrmOptions
TabOrder = 0
end
end
object chkPromptToUpgradeProjects: TCheckBox
Left = 151
Top = 204
Width = 218
Height = 17
Caption = '&Prompt to upgrade projects to 17.0 format'
TabOrder = 8
end
end
object tabEditor: TTabSheet
Caption = 'Editor'
Expand Down
3 changes: 3 additions & 0 deletions developer/src/tike/dialogs/UfrmOptions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ TfrmOptions = class(TTikeForm)
gbServer: TGroupBox;
chkListLocalURLs: TCheckBox;
cmdConfigureServer: TButton;
chkPromptToUpgradeProjects: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure cmdOKClick(Sender: TObject);
procedure cmdDefaultFontClick(Sender: TObject);
Expand Down Expand Up @@ -192,6 +193,7 @@ procedure TfrmOptions.FormCreate(Sender: TObject);
chkDebuggerAutoResetBeforeCompiling.Checked := DebuggerAutoResetBeforeCompiling;
chkAutoSaveBeforeCompiling.Checked := AutoSaveBeforeCompiling;
chkOSKAutoSaveBeforeImporting.Checked := OSKAutoSaveBeforeImporting;
chkPromptToUpgradeProjects.Checked := PromptToUpgradeProjects;

chkCharMapAutoLookup.Checked := CharMapAutoLookup;
chkCharMapDisableDatabaseLookups.Checked := CharMapDisableDatabaseLookups;
Expand Down Expand Up @@ -291,6 +293,7 @@ procedure TfrmOptions.cmdOKClick(Sender: TObject);
DebuggerAutoResetBeforeCompiling := chkDebuggerAutoResetBeforeCompiling.Checked;
AutoSaveBeforeCompiling := chkAutoSaveBeforeCompiling.Checked;
OSKAutoSaveBeforeImporting := chkOSKAutoSaveBeforeImporting.Checked;
PromptToUpgradeProjects := chkPromptToUpgradeProjects.Checked;

ServerUseLocalAddresses := chkListLocalURLs.Checked;

Expand Down
4 changes: 4 additions & 0 deletions developer/src/tike/main/KeymanDeveloperOptions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ TKeymanDeveloperOptions = class
FServerNgrokToken: string;
FServerNgrokRegion: string;
FServerKeepAlive: Boolean;
FPromptToUpgradeProjects: Boolean;
procedure CloseRegistry;
procedure OpenRegistry;
function regReadString(const nm, def: string): string;
Expand Down Expand Up @@ -102,6 +103,7 @@ TKeymanDeveloperOptions = class
property DebuggerAutoResetBeforeCompiling: Boolean read FDebuggerAutoResetBeforeCompiling write FDebuggerAutoResetBeforeCompiling;
property AutoSaveBeforeCompiling: Boolean read FAutoSaveBeforeCompiling write FAutoSaveBeforeCompiling;
property OSKAutoSaveBeforeImporting: Boolean read FOSKAutoSaveBeforeImporting write FOSKAutoSaveBeforeImporting;
property PromptToUpgradeProjects: Boolean read FPromptToUpgradeProjects write FPromptToUpgradeProjects;

property ReportErrors: Boolean read FReportErrors write FReportErrors;
property ReportUsage: Boolean read FReportUsage write FReportUsage;
Expand Down Expand Up @@ -211,6 +213,7 @@ procedure TKeymanDeveloperOptions.Read;
FDebuggerAutoResetBeforeCompiling := regReadBool(SRegValue_IDEOptDebuggerAutoResetBeforeCompiling, False);
FAutoSaveBeforeCompiling := regReadBool(SRegValue_IDEOptAutoSaveBeforeCompiling, False);
FOSKAutoSaveBeforeImporting := regReadBool(SRegValue_IDEOptOSKAutoSaveBeforeImporting, False);
FPromptToUpgradeProjects := regReadBool(SRegValue_IDEOptPromptToUpgradeProjects, True);

FServerDefaultPort := regReadInt(SRegValue_IDEOptServerPort, 8008);
FServerKeepAlive := regReadBool(SRegValue_IDEOptServerKeepAlive, False);
Expand Down Expand Up @@ -270,6 +273,7 @@ procedure TKeymanDeveloperOptions.Write;
regWriteBool(SRegValue_IDEOptDebuggerAutoResetBeforeCompiling, FDebuggerAutoResetBeforeCompiling);
regWriteBool(SRegValue_IDEOptAutoSaveBeforeCompiling, FAutoSaveBeforeCompiling);
regWriteBool(SRegValue_IDEOptOSKAutoSaveBeforeImporting, FOSKAutoSaveBeforeImporting);
regWriteBool(SRegValue_IDEOptPromptToUpgradeProjects, FPromptToUpgradeProjects);

regWriteInt(SRegValue_IDEOptServerPort, FServerDefaultPort);
regWriteBool(SRegValue_IDEOptServerKeepAlive, FServerKeepAlive);
Expand Down
12 changes: 7 additions & 5 deletions developer/src/tike/main/UfrmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1462,17 +1462,19 @@ procedure TfrmKeymanDeveloper.UpdateFileMRU;
begin
m := TMenuItem.Create(Self);
m.Caption := '&'+IntToStr(i+1)+' '+FGlobalProject.MRU.EllipsisFile(i);
m.Hint := FGlobalProject.MRU.Files[i];
m.Tag := i;
m.OnClick := mnuFileRecentFileClick;
mnuFileRecent.Add(m);
end;
end;
end;

procedure TfrmKeymanDeveloper.mnuFileRecentFileClick(Sender: TObject);
var
filename: string;
begin
with Sender as TMenuItem do
OpenFilesInProject([Hint]);
filename := FGlobalProject.MRU.Files[(Sender as TMenuItem).Tag];
OpenFilesInProject([filename]);
end;

{-------------------------------------------------------------------------------
Expand Down Expand Up @@ -1552,7 +1554,7 @@ procedure TfrmKeymanDeveloper.mnuProjectClick(Sender: TObject);
begin
m := TMenuItem.Create(Self);
m.Caption := '&'+IntToStr(i+1)+' '+FProjectMRU.EllipsisFile(i);
m.Hint := FProjectMRU.Files[i];
m.Tag := i;
m.OnClick := mnuProjectRecentFileClick;
mnuProjectsRecent.Add(m);
end;
Expand All @@ -1567,7 +1569,7 @@ procedure TfrmKeymanDeveloper.mnuProjectRecentFileClick(Sender: TObject);
var
filename: string;
begin
filename := (Sender as TMenuItem).Hint;
filename := FProjectMRU.Files[(Sender as TMenuItem).Tag];
OpenProject(filename);
end;

Expand Down
8 changes: 5 additions & 3 deletions developer/src/tike/main/mrulist.pas
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ destructor TMRUList.Destroy;
end;

function TMRUList.EllipsisFile(Index: Integer): string;
var
buffer: array[0..MAX_PATH] of char;
begin
Result := Files[Index];
StrPCopy(buffer, Files[Index]);

if PathCompactPath(0, PWideChar(Result), GetSystemMetrics(SM_CXSCREEN) div 3) then // I4697
Result := string(PChar(Result)) // This removes the terminating nul
if PathCompactPath(0, buffer, GetSystemMetrics(SM_CXSCREEN) div 3) then // I4697
Result := buffer // This removes the terminating nul
else
Result := ExtractFileName(Files[Index]);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ function TProject.Render: WideString;
//

TProjectUrlRenderer.AddUrls(doc.documentElement);
TProjectUrlRenderer.AddProcessState(doc.documentElement);

xsl := MSXMLDOMDocumentFactory.CreateDOMDocument;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ initialization
RegisterProjectFileType('.js', TOpenableProjectFile);
RegisterProjectFileType('.kpj', TOpenableProjectFile);
RegisterProjectFileType('.user', TOpenableProjectFile);
RegisterProjectFileType('.keyman-touch-layout', TOpenableProjectFile);
RegisterProjectFileType('.keyboard_info', TOpenableProjectFile);
end.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@ interface
type
TProjectUrlRenderer = class
class procedure AddUrls(root: IXMLDomNode);
class procedure AddProcessState(root: IXMLDomNode);
end;

implementation

uses
KeymanDeveloperOptions,
Upload_Settings;

{ TProjectUrlRenderer }

class procedure TProjectUrlRenderer.AddProcessState(root: IXMLDomNode);
var
node: IXMLDomElement;
begin
node := root.ownerDocument.createElement('DeveloperState');
node.setAttribute('promptToUpgradeProjects', FKeymanDeveloperOptions.PromptToUpgradeProjects);
root.appendChild(node);
end;

class procedure TProjectUrlRenderer.AddUrls(root: IXMLDomNode);
var
node: IXMLDomNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ TfrmProject = class(TfrmTikeChild) // I2721
procedure SetGlobalProject;
procedure StartClose; override;
procedure CompileAll;
procedure RefreshOptions; override;
end;

implementation
Expand Down Expand Up @@ -202,6 +203,12 @@ procedure TfrmProject.RefreshHTML;
RefreshCaption;
end;

procedure TfrmProject.RefreshOptions;
begin
inherited;
ProjectRefresh(nil);
end;

procedure TfrmProject.ProjectRefresh(Sender: TObject);
begin
if frmKeymanDeveloper.ActiveChild <> Self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,23 @@ implementation
utildir;

procedure TfrmProjectSettings20.cmdOKClick(Sender: TObject);
var
path: string;
begin
path := Trim(DosSlashes(editOutputPath.Text));
if (path <> '') and (not path.StartsWith('$PROJECTPATH') or (path.CountChar('\') > 1)) then
begin
ShowMessage('Output path "'+path+'" should start with "$PROJECTPATH" and be no more than one level deep.');
Exit;
end;

path := Trim(DosSlashes(editSourcePath.Text));
if (path <> '') and (not path.StartsWith('$PROJECTPATH') or (path.CountChar('\') > 1)) then
begin
ShowMessage('Source path "'+path+'" should start with "$PROJECTPATH" and be no more than one level deep.');
Exit;
end;

FGlobalProject.Options.BuildPath := Trim(DosSlashes(editOutputPath.Text));
FGlobalProject.Options.SourcePath := Trim(DosSlashes(editSourcePath.Text));
FGlobalProject.Options.SkipMetadataFiles := not chkBuildMetadataFiles.Checked;
Expand Down
Loading

0 comments on commit 1f06224

Please sign in to comment.