From d0b75bcd54d899a78be3583ee08515c3fe6f6bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 11 Nov 2023 03:18:29 +0100 Subject: [PATCH] Some fixes about profile file management. [DEVELOPMENT ENVIRONMENT] * OPT: Do not load recent file settings twice at startup. * BUG: Fix layout of some confirmation messages. * BUG: The open profile dialog correctly remembers its directory. * BUG: Fix popup menu of external files. * NEW: Add "Remove all profile files" action to the 'Debug' menu. --- app/src/gambas3/.src/CRecentProject.class | 6 +-- .../gambas3/.src/Dialog/FFileProperty.class | 2 +- .../.src/Editor/Browse/FProjectBrowser.class | 2 +- .../.src/Editor/Profile/FProfile.class | 5 +- .../gambas3/.src/Editor/Profile/FProfile.form | 1 - app/src/gambas3/.src/FMain.class | 49 +++++++++---------- app/src/gambas3/.src/FMain.form | 9 +++- app/src/gambas3/.src/Project.module | 2 +- .../VersionControl/CVersionControlGit.class | 18 +++---- 9 files changed, 48 insertions(+), 46 deletions(-) diff --git a/app/src/gambas3/.src/CRecentProject.class b/app/src/gambas3/.src/CRecentProject.class index 7ea795a0f..f514c4553 100644 --- a/app/src/gambas3/.src/CRecentProject.class +++ b/app/src/gambas3/.src/CRecentProject.class @@ -98,11 +98,11 @@ Static Public Sub Load() If Not $hSettings Then $hSettings = New Settings("gambas3.recent") + Else + If Not IsOutOfDate(LastLoad) Then Return + $hSettings.Reload Endif - - If Not IsOutOfDate(LastLoad) Then Return - $hSettings.Reload nRecent = $hSettings["/Recent/Count", 0] If nRecent = 0 Then diff --git a/app/src/gambas3/.src/Dialog/FFileProperty.class b/app/src/gambas3/.src/Dialog/FFileProperty.class index ba1c17df6..de0f2eb63 100644 --- a/app/src/gambas3/.src/Dialog/FFileProperty.class +++ b/app/src/gambas3/.src/Dialog/FFileProperty.class @@ -49,7 +49,7 @@ Public Sub fprInfo_Data() Return Endif - Else If Project.IsProfilePath(sPath) Then + Else If File.Ext(sPath) = "prof" Then Try fprInfo.Data.Icon = Project.GetFileIcon(sPath, 64) fprInfo.Data.Type = ("Gambas profile file") diff --git a/app/src/gambas3/.src/Editor/Browse/FProjectBrowser.class b/app/src/gambas3/.src/Editor/Browse/FProjectBrowser.class index 1efd5d106..6f8040d08 100644 --- a/app/src/gambas3/.src/Editor/Browse/FProjectBrowser.class +++ b/app/src/gambas3/.src/Editor/Browse/FProjectBrowser.class @@ -373,7 +373,7 @@ Public Sub mnuDelete_Click() Try Project.DeleteFile(sPath) Endif If Error Then - Select Case Message.Warning(Project.GetMessagePrefix(sPath) & "\n\n" & If(IsDir(sPath), ("Cannot delete directory"), ("Cannot delete file")) & "\n\n" & Error.Text, ("Ignore"), ("Cancel")) + Select Case Message.Warning(Project.GetMessagePrefix(sPath) & "" & If(IsDir(sPath), ("Cannot delete directory"), ("Cannot delete file")) & "\n\n" & Error.Text, ("Ignore"), ("Cancel")) Case 1 Continue Case 2 diff --git a/app/src/gambas3/.src/Editor/Profile/FProfile.class b/app/src/gambas3/.src/Editor/Profile/FProfile.class index 28b967132..e890b282a 100644 --- a/app/src/gambas3/.src/Editor/Profile/FProfile.class +++ b/app/src/gambas3/.src/Editor/Profile/FProfile.class @@ -289,6 +289,9 @@ Public Sub Form_Close() Settings.Write(Me) Settings.Write(splProfile) + Project.AddRecentFile(Me) + Project.Files[Path] = Null + End Public Sub Form_Open() @@ -709,7 +712,7 @@ Public Sub btnSave_Click() Dialog.Title = ("Save profile") Dialog.Filter = ["*.prof", ("Profile files")] - Dialog.Path = Settings["/FProfile/Path", User.Home] &/ Project.Name & File.Name(Path) + Dialog.Path = Settings["/FProfile/Path", User.Home] &/ File.Name(Path) If Dialog.SaveFile() Then Return Settings["/FProfile/Path"] = File.Dir(Dialog.Path) diff --git a/app/src/gambas3/.src/Editor/Profile/FProfile.form b/app/src/gambas3/.src/Editor/Profile/FProfile.form index 28054e0a6..5f32ffd7f 100644 --- a/app/src/gambas3/.src/Editor/Profile/FProfile.form +++ b/app/src/gambas3/.src/Editor/Profile/FProfile.form @@ -3,7 +3,6 @@ { Form Form MoveScaled(0,0,117,80) Icon = Picture["icon:/medium/clock"] - Persistent = True Arrangement = Arrange.Vertical { panToolbar ToolBar MoveScaled(2,2,110,4) diff --git a/app/src/gambas3/.src/FMain.class b/app/src/gambas3/.src/FMain.class index b9bfe37ff..ef999cdea 100644 --- a/app/src/gambas3/.src/FMain.class +++ b/app/src/gambas3/.src/FMain.class @@ -295,7 +295,7 @@ Public Sub mnuDeleteFile_Click() sName = File.Name(sPath) Endif - If Message.Delete(Project.GetMessagePrefix(sName) & "\n\n" & ("Do you really want to delete this file ?"), ("Delete"), ("Cancel")) <> 1 Then Return + If Message.Delete(Project.GetMessagePrefix(sName) & ("Do you really want to delete this file ?"), ("Delete"), ("Cancel")) <> 1 Then Return Project.DeleteFile(sPath) Endif @@ -537,20 +537,6 @@ Public Sub mnuPopup_Show() Endif - Else If sRoot = Project.KEY_PROFILE Then - - mnuNew.Hide - mnuImportFile.Hide - mnuRenameFile.Hide - mnuDeleteFile.Visible = CanDelete(sCurrent) - mnuStartup.Hide - mnuRunThat.Hide - mnuDoNotTranslate.Hide - mnuCompressFile.Hide - mnuCut.Hide - mnuCopy.Hide - mnuPaste.Hide - Else ' If sRoot = Project.KEY_EXTERN Or If sRoot Begins "/" Or If sRoot = Project.KEY_PROFILE Then @@ -587,13 +573,22 @@ Public Sub mnuPopup_Show() mnuDoNotTranslate.Hide - mnuCompressNow.Visible = MCompressFile.CanCompress(sCurrent, True) + If bProject Then - If MCompressFile.CanCompress(sCurrent, False) Then - mnuCompressFile.Show - mnuCompressFile.Checked = Project.ShouldCompress(sCurrent) + mnuCompressNow.Visible = MCompressFile.CanCompress(sCurrent, True) + + If MCompressFile.CanCompress(sCurrent, False) Then + mnuCompressFile.Show + mnuCompressFile.Checked = Project.ShouldCompress(sCurrent) + Else + mnuCompressFile.Hide + Endif + Else + + mnuCompressNow.Hide mnuCompressFile.Hide + Endif bFile = bCurrent @@ -678,15 +673,11 @@ Public Sub mnuPopup_Show() If VersionControl.Enabled Then If $sKey = Project.Dir Then mnuInfoVC.Show - Else If Not bIsDir And If Not bIsSpecial And If sRoot Not Begins "/" And If Not Project.HasFlag($sKey, Project.FLAG_ADDED) Then + Else If bProject And If Not bIsDir And If Not bIsSpecial And If sRoot Not Begins "/" And If Not Project.HasFlag($sKey, Project.FLAG_ADDED) Then mnuInfoVC.Show Endif Endif - If $sKey = Project.KEY_PROFILE And If IsDir(Project.Dir &/ ".profile") And If Dir(Project.Dir &/ ".profile", "*.prof").Count Then - mnuRemoveAllProfile.Show - Endif - UpdateRecentFile(mnuOpenRecentFile) End @@ -720,7 +711,11 @@ Public Sub mnuProfile_Show() mnuDeleteProfile.Visible = bVisible mnuInfoProfile.Show - mnuRemoveAllProfile.Visible = Not bVisible + If Not bVisible And If IsDir(Project.Dir &/ ".profile") And If Dir(Project.Dir &/ ".profile", "*.prof").Count Then + mnuRemoveAllProfile.Show + Else + mnuRemoveAllProfile.Hide + Endif UpdateRecentFile(mnuOpenRecentFile3) @@ -2715,8 +2710,8 @@ Private Sub OpenProfile() Dialog.Path = Settings["/FMain/OpenProfile"] If Dialog.OpenFile() Then Return - Settings["/FMain/OpenProfile"] = File.Dir(Dialog.Path) - Project.OpenExternFile(Dialog.Path) + Settings["/FMain/OpenProfile"] = Dialog.Path + Project.OpenFile(Dialog.Path) End diff --git a/app/src/gambas3/.src/FMain.form b/app/src/gambas3/.src/FMain.form index f85918f53..de76d598c 100644 --- a/app/src/gambas3/.src/FMain.form +++ b/app/src/gambas3/.src/FMain.form @@ -393,6 +393,11 @@ Text = Shortcut(("Open profile"), "O") & "..." Picture = Picture["icon:/small/clock"] } + { Menu46 Menu + Action = "remove-all-profile" + Text = ("Remove all profile files") & "..." + Picture = Picture["icon:/small/trash"] + } { Menu9 Menu } { mnuClearBreakpoints Menu @@ -892,7 +897,7 @@ { mnuRemoveAllProfile Menu Action = "remove-all-profile" Text = ("Remove all profile files") & "..." - Picture = Picture["icon:/small/delete"] + Picture = Picture["icon:/small/trash"] } { Menu57 Menu } @@ -2003,7 +2008,7 @@ { Action remove-all-profile Text = "Remove all profile files" Shortcut = "" - Picture = "icon:/small/delete" + Picture = "icon:/small/trash" } { Action rename Text = "Rename" diff --git a/app/src/gambas3/.src/Project.module b/app/src/gambas3/.src/Project.module index e59e1453e..9f756d9ab 100644 --- a/app/src/gambas3/.src/Project.module +++ b/app/src/gambas3/.src/Project.module @@ -7107,7 +7107,7 @@ End Public Sub GetMessagePrefix(sPath As String) As String If sPath Begins Project.Dir & "/" Then sPath = Mid$(sPath, Len(Project.Dir) + 2) - Return "" & Html(sPath) & "\n" + Return "" & Html(sPath) & "\n\n" End diff --git a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class index 8214e2158..74b881b63 100644 --- a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class +++ b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class @@ -487,15 +487,15 @@ Public Sub SolveConflict(sPath As String, Optional iAccept As Integer) As Boolea End -Private Sub FormatDate(sDate As String) As String - - Dim dDate As Date - - Try dDate = Date.FromRFC822(sDate) - If Not dDate Then Return "?" - Return Format(dDate, gb.LongDate) - -End +' Private Sub FormatDate(sDate As String) As String +' +' Dim dDate As Date +' +' Try dDate = Date.FromRFC822(sDate) +' If Not dDate Then Return "?" +' Return Format(dDate, gb.LongDate) +' +' End Public Sub InitHistory(hEditor As TextEditor)