@@ -433,6 +433,7 @@ def save(self):
433
433
return
434
434
msgText = QCoreApplication .translate ('PythonConsole' ,
435
435
'Script was correctly saved.' )
436
+ self .pc .updateTabListScript (self .path , action = 'append' )
436
437
self .pc .callWidgetMessageBarEditor (msgText )
437
438
# Rename the original file, if it exists
438
439
overwrite = os .path .exists (self .path )
@@ -601,26 +602,36 @@ def closeTab(self, tab):
601
602
else :
602
603
self .removeTab (self .indexOf (tab ))
603
604
self .currentWidget ().setFocus (Qt .TabFocusReason )
604
-
605
+
605
606
def setTabTitle (self , tab , title ):
606
607
self .setTabText (self .indexOf (tab ), title )
607
-
608
+
608
609
def _removeTab (self , tab ):
609
- if self .widget (tab ).path in self .restoreTabList :
610
- #print currWidget.path
611
- self .parent .updateTabListScript (self .widget (tab ).path )
612
- if self .count () <= 2 :
613
- self .setTabsClosable (False )
614
- self .removeTab (tab )
610
+ if self .widget (tab ).newEditor .isModified ():
611
+ res = QMessageBox .question ( self , 'Save Script' ,
612
+ 'The script "%s" has been modified, save changes ?'
613
+ % self .tabText (tab ),
614
+ QMessageBox .Save | QMessageBox .Discard | QMessageBox .Cancel )
615
+ if res == QMessageBox .Save :
616
+ self .widget (tab ).save ()
617
+ elif res == QMessageBox .Cancel :
618
+ return
619
+ else :
620
+ self .parent .updateTabListScript (self .widget (tab ).path )
621
+ self .removeTab (tab )
615
622
else :
616
- self .removeTab (tab )
617
-
618
- self .currentWidget ().setFocus (Qt .TabFocusReason )
619
-
623
+ if self .widget (tab ).path in self .restoreTabList :
624
+ self .parent .updateTabListScript (self .widget (tab ).path )
625
+ if self .count () <= 2 :
626
+ self .setTabsClosable (False )
627
+ self .removeTab (tab )
628
+ else :
629
+ self .removeTab (tab )
630
+ self .currentWidget ().setFocus (Qt .TabFocusReason )
620
631
621
632
def buttonClosePressed (self ):
622
633
self .closeCurrentWidget ()
623
-
634
+
624
635
def closeCurrentWidget (self ):
625
636
currWidget = self .currentWidget ()
626
637
if currWidget and currWidget .close ():
@@ -631,24 +642,24 @@ def closeCurrentWidget(self):
631
642
if currWidget .path in self .restoreTabList :
632
643
#print currWidget.path
633
644
self .parent .updateTabListScript (currWidget .path )
634
-
645
+
635
646
def restoreTabs (self ):
636
647
for script in self .restoreTabList :
637
648
pathFile = str (script .toString ())
638
649
tabName = pathFile .split ('/' )[- 1 ]
639
650
self .newTabEditor (tabName , pathFile )
640
651
self .topFrame .close ()
641
-
652
+
642
653
def closeRestore (self ):
643
654
self .parent .updateTabListScript ('empty' )
644
655
self .topFrame .close ()
645
-
656
+
646
657
def showFileTabMenu (self ):
647
658
self .fileTabMenu .clear ()
648
659
for index in range (self .count ()):
649
660
action = self .fileTabMenu .addAction (self .tabIcon (index ), self .tabText (index ))
650
661
action .setData (QVariant (index ))
651
-
662
+
652
663
def showFileTabMenuTriggered (self , action ):
653
664
index , ok = action .data ().toInt ()
654
665
if ok :
0 commit comments