Add a "save as" action to text and image editors.

[DEVELOPMENT ENVIRONMENT]
* NEW: Text editor: Add a "save as" action.
* NEW: Image editor: Add a "save as" action.
This commit is contained in:
gambas 2021-05-25 01:16:38 +02:00
parent 212d0bdcb5
commit 0bf8f99f28
8 changed files with 481 additions and 179 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@ Component=gb.signal
Description="Integrated Development Environment for Gambas"
Authors="Benoît Minisini\nFabien Bodard\nCharlie Reinl\nJosé Luis Redrejo\nRobert Rowe\nTobias Boege"
Arguments=[["-L"],["-t","/home/benoit/gambas/git/master/app/src/gambas3"],["--help"]]
Environment="GB_GUI=gb.gtk3\n GTK_DEBUG=interactive"
Environment="GB_GUI=gb.qt5\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en

View file

@ -1205,7 +1205,7 @@ Private Sub UpdateMenu()
bVisible = Not edtEditor.ReadOnly
Action[".save,.undo,.redo,.cut,.paste,.color,.indent,.unindent,.lcase,.ucase,.sort-ascent,.sort-descent,.eol,.date,.char", Me].Visible = bVisible
Action[".save,.save-as,.undo,.redo,.cut,.paste,.color,.indent,.unindent,.lcase,.ucase,.sort-ascent,.sort-descent,.eol,.date,.char", Me].Visible = bVisible
mnuAdvanced.Visible = bVisible
mnuEndOfLine.Visible = bVisible
@ -2024,3 +2024,10 @@ Public Sub PaintStatus()
FEditor.PaintEditorStatus($hEditor)
End
Public Sub mnuSaveAs_Click()
If Save() Then Return
Project.SaveFileAs(Path)
End

View file

@ -231,6 +231,12 @@
Picture = Picture["icon:/small/save"]
Shortcut = "Ctrl+S"
}
{ mnuSaveAs Menu
Action = ".save-as"
Text = ("Save as") & "..."
Picture = Picture["icon:/small/save-as"]
Shortcut = "Ctrl+Shift+S"
}
{ Menu11 Menu
}
{ mnuClose Menu
@ -437,6 +443,14 @@
Action = ".pretty"
Picture = Picture["icon:/small/wizard"]
}
{ btnSaveAs ToolButton mnuSaveAs
Name = "btnSaveAs"
MoveScaled(78,0,4,4)
Visible = False
ToolTip = ("Save as")
Action = ".save-as"
Picture = Picture["icon:/small/save-as"]
}
{ Separator2 Separator
MoveScaled(95,0,1,4)
}
@ -764,6 +778,11 @@
Shortcut = "Ctrl+S"
Picture = "icon:/small/save"
}
{ Action save-as
Text = "Save as"
Shortcut = "Ctrl+Shift+S"
Picture = "icon:/small/save-as"
}
{ Action select-all
Text = "Select All"
Shortcut = "Ctrl+A"
@ -842,7 +861,7 @@
}
{ Toolbar text
Text = "Text editor"
List = "show-class,diff,diff-previous,diff-next,save,reload,print,undo,redo,cut,copy,paste,bookmark,color,date,char,indent,unindent,comment,uncomment,pretty,view-nosplit,view-hsplit,view-vsplit,proc,wrap,tab-indent,eol,locked,preview"
List = "show-class,diff,diff-previous,diff-next,save,reload,print,undo,redo,cut,copy,paste,bookmark,color,date,char,indent,unindent,comment,uncomment,pretty,save-as,view-nosplit,view-hsplit,view-vsplit,proc,wrap,tab-indent,eol,locked,preview"
Default = "show-class,diff,diff-previous,diff-next,|,save,reload,print,|,undo,redo,|,paste,color,date,char,comment,uncomment,|,|,proc,|,~,wrap,tab-indent,locked,preview"
}
}

View file

@ -3080,7 +3080,7 @@ Public Sub mnuFormat_Show()
End
Public Sub mnuSaveAs_Click()
Public Sub mnuSaveAsFormat_Click()
Dim sFormat As String = Last.Tag
@ -3387,3 +3387,10 @@ Private Sub HasSelection() As Boolean
If $hSelect And If Not $hSelect.IsVoid() Then Return True
End
Public Sub mnuSaveAs_Click()
If Save() Then Return
Project.SaveFileAs(Path)
End

View file

@ -239,6 +239,12 @@
Picture = Picture["icon:/small/save"]
Shortcut = "Ctrl+S"
}
{ mnuSaveAs Menu
Action = ".save-as"
Text = ("Save as") & "..."
Picture = Picture["icon:/small/save-as"]
Shortcut = "Ctrl+Shift+S"
}
{ Menu6 Menu
}
{ mnuClose Menu
@ -250,22 +256,22 @@
}
{ mnuFormat Menu
#Translate = False
{ mnuFormatJPEG Menu mnuSaveAs
{ mnuFormatJPEG Menu mnuSaveAsFormat
Name = "mnuFormatJPEG"
Text = ("Save as JPEG")
Tag = "jpeg"
}
{ mnuFormatPNG Menu mnuSaveAs
{ mnuFormatPNG Menu mnuSaveAsFormat
Name = "mnuFormatPNG"
Text = ("Save as PNG")
Tag = "png"
}
{ mnuFormatBMP Menu mnuSaveAs
{ mnuFormatBMP Menu mnuSaveAsFormat
Name = "mnuFormatBMP"
Text = ("Save as BMP")
Tag = "bmp"
}
{ mnuFormatTIFF Menu mnuSaveAs
{ mnuFormatTIFF Menu mnuSaveAsFormat
Name = "mnuFormatTIFF"
Action = "tiff"
Text = ("Save as TIFF")
@ -566,6 +572,14 @@
AutoResize = True
Picture = Picture["icon:/small/rotate"]
}
{ btnSaveAs ToolButton mnuSaveAs
Name = "btnSaveAs"
MoveScaled(142,0,4,4)
Visible = False
ToolTip = ("Save as")
Action = ".save-as"
Picture = Picture["icon:/small/save-as"]
}
{ Spring1 Spring
MoveScaled(153,0,8,4)
}
@ -731,6 +745,11 @@
Shortcut = "Ctrl+S"
Picture = "icon:/small/save"
}
{ Action save-as
Text = "Save as"
Shortcut = "Ctrl+Shift+S"
Picture = "icon:/small/save-as"
}
{ Action select-all
Text = "Select All"
Shortcut = "Ctrl+A"
@ -822,7 +841,7 @@
{ Toolbars
{ Toolbar image
Text = "Image editor"
List = "save,reload,undo,redo,zoom-in,zoom,zoom-out,zoom-normal,zoom-fit,grid,tooltip,copy,cut,tool-paste,tool-move,tool-draw,tool-erase,tool-line,tool-rectangle,tool-ellipse,tool-text,tool-magic,hide,tool-change,union,difference,intersection,exclusive,invert,duplicate,offset,crop,flip-h,flip-v,rotate-r,rotate-l,resize,rotate,locked"
List = "save,reload,undo,redo,zoom-in,zoom,zoom-out,zoom-normal,zoom-fit,grid,tooltip,copy,cut,tool-paste,tool-move,tool-draw,tool-erase,tool-line,tool-rectangle,tool-ellipse,tool-text,tool-magic,hide,tool-change,union,difference,intersection,exclusive,invert,duplicate,offset,crop,flip-h,flip-v,rotate-r,rotate-l,resize,rotate,save-as,locked"
Default = "save,reload,|,undo,redo,|,zoom-in,zoom,zoom-out,zoom-normal,zoom-fit,grid,tooltip,|,copy,cut,tool-paste,|,tool-move,tool-draw,tool-erase,tool-line,tool-rectangle,tool-ellipse,tool-text,tool-magic,hide,tool-change,|,union,difference,invert,duplicate,offset,|,flip-h,flip-v,rotate-r,rotate-l,resize,~,locked"
}
}

View file

@ -7139,3 +7139,18 @@ Public Sub UpdateStatus(Optional bForce As Boolean)
End
Public Sub SaveFileAs(sPath As String)
Dialog.Title = ("Save file as")
Dialog.Path = Settings["/Editor/SaveAsDir", User.Home] &/ File.Name(sPath)
Dialog.AutoExt = True
Dialog.Key = "SaveFileAs"
If Dialog.SaveFile() Then Return
Settings["/Editor/SaveAsDir"] = File.Dir(Dialog.Path)
Try Kill Dialog.Path
Try Copy sPath To Dialog.Path
If Error Then Message.Error(("Unable to save file.") & "\n\n" & Error.Text)
End

View file

@ -54,7 +54,7 @@ Public Function Error() As Boolean
Try Move $sPath & "~" To $sPath
Endif
FMain.ShowError("<b>" & ("Cannot save file !") & "</b>\n\n" & sError, $sPath)
FMain.ShowError("<b>" & ("Unable to save file.") & "</b>\n\n" & sError, $sPath)
Try Save.End
Return True