@@ -155,19 +155,22 @@ def getColorAndToolTip(self, index):
155155 state = TabStates .Linked
156156 toolTip = "Linked to file on disk"
157157
158+ if hasattr (widget , "__filename__" ):
159+ filename = widget .__filename__ ()
160+ if filename :
161+ toolTip += "\n filename: {}" .format (filename )
162+
158163 window = self .window ()
159164 if window .uiExtraTooltipInfoCHK .isChecked ():
160165
161166 if hasattr (widget , "__workbox_id__" ):
162167 workbox_id = widget .__workbox_id__ ()
163- toolTip += "\n \n {}" .format (workbox_id )
168+ if toolTip :
169+ toolTip += "\n \n "
170+ toolTip += workbox_id
164171
165172 toolTip += "\n is dirty: {}" .format (widget .__is_dirty__ ())
166- toolTip += "\n state: {}" .format (state )
167-
168- if hasattr (widget , "__filename__" ):
169- filename = widget .__filename__ ()
170- toolTip += "\n \n filename: {}" .format (filename )
173+ toolTip += "\n state: {}" .format (state .name )
171174
172175 if hasattr (widget , "__backup_file__" ):
173176 backup_file = widget .__backup_file__ ()
@@ -179,24 +182,24 @@ def getColorAndToolTip(self, index):
179182 _changed_by_instance
180183 )
181184
182- if hasattr (widget , "_changed_saved" ):
183- _changed_saved = widget ._changed_saved
184- toolTip += "\n _changed_saved: {}" .format (_changed_saved )
185-
186185 if hasattr (widget , "__orphaned_by_instance__" ):
187186 __orphaned_by_instance__ = widget .__orphaned_by_instance__ ()
188187 toolTip += "\n __orphaned_by_instance__: {}" .format (
189188 __orphaned_by_instance__
190189 )
191190
191+ if hasattr (widget , "_changed_saved" ):
192+ _changed_saved = widget ._changed_saved
193+ toolTip += "\n _changed_saved: {}" .format (_changed_saved )
194+
192195 if hasattr (widget , "__last_workbox_name__" ):
193196 last_workbox_name = widget .__last_workbox_name__ ()
194- toolTip += "\n \ n last_workbox_name: {}" .format (last_workbox_name )
197+ toolTip += "\n last_workbox_name: {}" .format (last_workbox_name )
195198
196199 if hasattr (widget , "__last_saved_text__" ):
197200 last_saved_text = widget .__last_saved_text__ ()
198201 last_saved_text = window .truncate_text_lines (last_saved_text )
199- toolTip += "\n \ n last_saved_text: \n {}" .format (last_saved_text )
202+ toolTip += "\n last_saved_text: \n {}" .format (last_saved_text )
200203
201204 color = self .bg_color_map .get (state )
202205 return color , toolTip
@@ -370,54 +373,108 @@ def tab_menu(self, pos, popup=True):
370373 if hasattr (workbox , '__filename__' ):
371374 if not workbox .__filename__ ():
372375 act = menu .addAction ('Rename' )
376+ tip = "Rename this tab."
377+ act .setToolTip (tip )
373378 act .triggered .connect (self .rename_tab )
374379
375380 act = menu .addAction ('Link File' )
381+ tip = (
382+ "Choose an existing file on disk to link this workbox to.\n "
383+ "The current workbox contents will be replaced, but will be "
384+ "backed up, accessible with Ctrl+Alt+Left"
385+ )
386+ act .setToolTip (tip )
376387 act .triggered .connect (partial (self .link_file , workbox ))
377388
378389 act = menu .addAction ('Save and Link File' )
390+ tip = (
391+ "Choose a filename to save the workbox contents to, and"
392+ "link to that file."
393+ )
394+ act .setToolTip (tip )
379395 act .triggered .connect (partial (self .save_and_link_file , workbox ))
380396 else :
381397 if Path (workbox .__filename__ ()).is_file ():
382398 act = menu .addAction ('Explore File' )
399+ tip = "Open a file explorer at the linked file's location"
400+ act .setToolTip (tip )
383401 act .triggered .connect (partial (self .explore_file , workbox ))
384402
385403 act = menu .addAction ('Unlink File' )
404+ tip = (
405+ "Disconnect the link to the file on disk. The workbox "
406+ "contents will remain unchanged."
407+ )
408+ act .setToolTip (tip )
386409 act .triggered .connect (partial (self .unlink_file , workbox ))
387410
388411 act = menu .addAction ('Save As' )
412+ tip = (
413+ "Save contents as a new file and link to it. If you "
414+ "choose an existing file, that file's contents will be"
415+ "overwritten."
416+ )
417+ act .setToolTip (tip )
389418 act .triggered .connect (partial (self .save_and_link_file , workbox ))
390419
391420 act = menu .addAction ('Copy Filename' )
421+ tip = "Copy this workbox's filename to the clipboard."
422+ act .setToolTip (tip )
392423 act .triggered .connect (partial (self .copyFilename , workbox ))
393424 else :
394425 act = menu .addAction ('Explore File' )
426+ tip = "Open a file explorer at the linked file's location"
427+ act .setToolTip (tip )
395428 act .triggered .connect (partial (self .explore_file , workbox ))
396429
397- act = menu .addAction ('Save As' )
430+ act = menu .addAction ('Save As and Link File' )
431+ tip = (
432+ "Save contents as a new file and link to it. If you "
433+ "choose an existing file, that file's contents will be"
434+ "overwritten."
435+ )
436+ act .setToolTip (tip )
398437 act .triggered .connect (partial (self .save_and_link_file , workbox ))
399438
400439 act = menu .addAction ('Relink File' )
401- act .triggered .connect (partial (self .link_file , workbox ))
440+ tip = (
441+ "Current linked file is not found. Choose a new file "
442+ "to link to."
443+ )
444+ act .setToolTip (tip )
445+ act .triggered .connect (
446+ partial (self .link_file , workbox , saveLinkedFile = False )
447+ )
402448
403449 act = menu .addAction ('Unlink File' )
450+ tip = (
451+ "Disconnect the link to the file on disk. The workbox "
452+ "contents will remain unchanged."
453+ )
454+ act .setToolTip (tip )
404455 act .triggered .connect (partial (self .unlink_file , workbox ))
405456 else :
406457 act = menu .addAction ('Rename' )
458+ tip = "Rename this tab."
459+ act .setToolTip (tip )
407460 act .triggered .connect (self .rename_tab )
408461
409462 act = menu .addAction ('Copy Workbox Name' )
463+ tip = "Copy this workbox's name to the clipboard."
464+ act .setToolTip (tip )
410465 act .triggered .connect (partial (self .copy_workbox_name , workbox , index ))
411466
412467 act = menu .addAction ('Copy Workbox Id' )
468+ tip = "Copy this workbox's id to the clipboard."
469+ act .setToolTip (tip )
413470 act .triggered .connect (partial (self .copy_workbox_id , workbox , index ))
414471
415472 if popup :
416473 menu .popup (self .mapToGlobal (pos ))
417474
418475 return menu
419476
420- def link_file (self , workbox ):
477+ def link_file (self , workbox , saveLinkedFile = True ):
421478 """Link the given workbox to a file on disk.
422479
423480 Args:
@@ -429,7 +486,7 @@ def link_file(self, workbox):
429486 workbox .__set_file_monitoring_enabled__ (False )
430487
431488 # First, save any unsaved text
432- workbox .__save_prefs__ ()
489+ workbox .__save_prefs__ (saveLinkedFile = saveLinkedFile )
433490
434491 # Now, load file
435492 workbox .__load__ (filename )
0 commit comments