Добавлен диалог сохранения файла при закрытии вкладки редактора и при выходе из программы если есть несохраненные файлы

This commit is contained in:
svkalinin 2022-07-21 16:01:28 +03:00
parent dadf1eb964
commit 48a97e7026
5 changed files with 32 additions and 6 deletions

View File

@ -31,3 +31,7 @@
- Fixed indent text - Fixed indent text
- Fixed insert " and ' - Fixed insert " and '
- Added a main window geometry option into config, and autosave current geometry - Added a main window geometry option into config, and autosave current geometry
21/07/2022
- Added Save file dialog before tab was closed
- Added Save file dialog when exiting, if file was modify

View File

@ -17,4 +17,4 @@ dpkg-buildpackage
#cp ../projman_${VERSION}-${RELEASE}_amd64.deb /files/ #cp ../projman_${VERSION}-${RELEASE}_amd64.deb /files/
rm projman rm projman

View File

@ -47,13 +47,32 @@ namespace eval FileOper {
return $fullPath return $fullPath
} }
proc CloseAll {} {
global nbEditor modified
foreach nbItem [array names modified] {
if {$modified($nbItem) eq "true"} {
$nbEditor select $nbItem
puts "close tab $nbItem"
if {[Close] eq "cancel"} {return "cancel"}
}
}
}
proc Close {} { proc Close {} {
global nbEditor modified tree global nbEditor modified tree
set nbItem [$nbEditor select] set nbItem [$nbEditor select]
puts "close tab $nbItem"
if {$nbItem == ""} {return} if {$nbItem == ""} {return}
if {$modified($nbItem) eq "true"} { if {$modified($nbItem) eq "true"} {
Save set answer [tk_messageBox -message [::msgcat::mc "File was modifyed"] \
-icon question -type yesnocancel \
-detail [::msgcat::mc "Do you want to save it?"]]
switch $answer {
yes Save
no {}
cancel {return "cancel"}
}
} }
$nbEditor forget $nbItem $nbEditor forget $nbItem
destroy $nbItem destroy $nbItem
@ -61,6 +80,7 @@ namespace eval FileOper {
if {[$tree parent $treeItem] eq "" } { if {[$tree parent $treeItem] eq "" } {
$tree delete $treeItem $tree delete $treeItem
} }
unset modified($nbItem)
} }
proc Save {} { proc Save {} {

View File

@ -161,4 +161,3 @@ if {$cfgVariables(toolBarShow) eq "true"} {
} }
.frmBody.panel add $frm_work -weight 1 .frmBody.panel add $frm_work -weight 1
# # # #

View File

@ -12,7 +12,11 @@
proc Quit {} { proc Quit {} {
global dir global dir
Config::write $dir(cfg) Config::write $dir(cfg)
exit if {[FileOper::CloseAll] eq "cancel"} {
return "cancel"
} else {
exit
}
} }
proc ViewFilesTree {} { proc ViewFilesTree {} {
@ -70,4 +74,3 @@ proc SetModifiedFlag {w} {
$nbEditor tab $w -text $lbl $nbEditor tab $w -text $lbl
} }