@@ -687,6 +687,7 @@ def save(self):
687
687
self .tw .setTabTitle (self , fN )
688
688
self .tw .setTabToolTip (self .tw .currentIndex (), path )
689
689
self .newEditor .setModified (False )
690
+ self .pc .saveFileButton .setEnabled (False )
690
691
self .newEditor .mtime = os .stat (path ).st_mtime
691
692
self .pc .updateTabListScript (path , action = 'append' )
692
693
self .tw .listObject (self )
@@ -792,8 +793,7 @@ def __init__(self, parent):
792
793
self .fileTabButton .setMenu (self .fileTabMenu )
793
794
self .setCornerWidget (self .fileTabButton , Qt .TopRightCorner )
794
795
self .connect (self , SIGNAL ("tabCloseRequested(int)" ), self ._removeTab )
795
- self .connect (self , SIGNAL ('currentChanged(int)' ), self .listObject )
796
- self .connect (self , SIGNAL ('currentChanged(int)' ), self .changeLastDirPath )
796
+ self .connect (self , SIGNAL ('currentChanged(int)' ), self ._currentWidgetChanged )
797
797
798
798
# Open button
799
799
self .newTabButton = QToolButton ()
@@ -806,6 +806,11 @@ def __init__(self, parent):
806
806
self .setCornerWidget (self .newTabButton , Qt .TopLeftCorner )
807
807
self .connect (self .newTabButton , SIGNAL ('clicked()' ), self .newTabEditor )
808
808
809
+ def _currentWidgetChanged (self , tab ):
810
+ self .listObject (tab )
811
+ self .changeLastDirPath (tab )
812
+ self .enableSaveIfModified (tab )
813
+
809
814
def contextMenuEvent (self , e ):
810
815
tabBar = self .tabBar ()
811
816
self .idx = tabBar .tabAt (e .pos ())
@@ -830,10 +835,13 @@ def contextMenuEvent(self, e):
830
835
closeTabAction .setEnabled (False )
831
836
closeAllTabAction .setEnabled (False )
832
837
closeOthersTabAction .setEnabled (False )
838
+ saveAction .setEnabled (False )
833
839
if self .count () > 1 :
834
840
closeTabAction .setEnabled (True )
835
841
closeAllTabAction .setEnabled (True )
836
842
closeOthersTabAction .setEnabled (True )
843
+ if self .widget (self .idx ).newEditor .isModified ():
844
+ saveAction .setEnabled (True )
837
845
action = menu .exec_ (self .mapToGlobal (e .pos ()))
838
846
839
847
def closeOthers (self ):
@@ -850,6 +858,9 @@ def closeAll(self):
850
858
self .newTabEditor (tabName = 'Untitled-0' )
851
859
self ._removeTab (0 )
852
860
861
+ def enableSaveIfModified (self , tab ):
862
+ self .parent .saveFileButton .setEnabled (self .widget (tab ).newEditor .isModified ())
863
+
853
864
def enableToolBarEditor (self , enable ):
854
865
if self .topFrame .isVisible ():
855
866
enable = False
@@ -872,11 +883,13 @@ def newTabEditor(self, tabName=None, filename=None):
872
883
self .setTabToolTip (self .currentIndex (), unicode (filename ))
873
884
else :
874
885
self .setTabToolTip (self .currentIndex (), tabName )
886
+ self .parent .saveFileButton .setEnabled (False )
875
887
876
888
def tabModified (self , tab , modified ):
877
889
index = self .indexOf (tab )
878
890
color = Qt .darkGray if modified else Qt .black
879
891
self .tabBar ().setTabTextColor (index , color )
892
+ self .parent .saveFileButton .setEnabled (modified )
880
893
881
894
def closeTab (self , tab ):
882
895
# Check if file has been saved
0 commit comments