Пример #1
0
 def _on_tab_close_requested(self, index):
     widget = self.widget(index)
     try:
         if not widget.dirty:
             self.removeTab(index)
         else:
             dlg = DlgUnsavedFiles(self, files=[widget.file.path if widget.file.path else widget._tab_name])
             if dlg.exec_() == dlg.Accepted:
                 if not dlg.discarded:
                     self._save_editor(widget)
                 self.removeTab(index)
     except AttributeError:
         _logger().warning("Failed to close tab %d", index)
     if self.count() == 0:
         self.last_tab_closed.emit()
Пример #2
0
 def _on_tab_close_requested(self, index):
     widget = self.widget(index)
     try:
         if not widget.dirty:
             self.removeTab(index)
         else:
             dlg = DlgUnsavedFiles(self,
                                   files=[
                                       widget.file.path if widget.file.path
                                       else widget._tab_name
                                   ])
             if dlg.exec_() == dlg.Accepted:
                 if not dlg.discarded:
                     self._save_editor(widget)
                 self.removeTab(index)
     except AttributeError:
         _logger().warning('Failed to close tab %d', index)
     if self.count() == 0:
         self.last_tab_closed.emit()
Пример #3
0
 def _try_close_dirty_tabs(self, exept=None):
     """
     Tries to close dirty tabs. Uses DlgUnsavedFiles to ask the user
     what he wants to do.
     """
     widgets, filenames = self._collect_dirty_tabs(exept=exept)
     if not len(filenames):
         return True
     dlg = DlgUnsavedFiles(self, files=filenames)
     if dlg.exec_() == dlg.Accepted:
         if not dlg.discarded:
             for item in dlg.listWidget.selectedItems():
                 filename = item.text()
                 widget = None
                 for widget in widgets:
                     if widget.file.path == filename:
                         break
                 if widget != exept:
                     self._save_editor(widget)
                     self.removeTab(self.indexOf(widget))
         return True
     return False
Пример #4
0
 def _try_close_dirty_tabs(self, exept=None):
     """
     Tries to close dirty tabs. Uses DlgUnsavedFiles to ask the user
     what he wants to do.
     """
     widgets, filenames = self._collect_dirty_tabs(exept=exept)
     if not len(filenames):
         return True
     dlg = DlgUnsavedFiles(self, files=filenames)
     if dlg.exec_() == dlg.Accepted:
         if not dlg.discarded:
             for item in dlg.listWidget.selectedItems():
                 filename = item.text()
                 widget = None
                 for widget in widgets:
                     if widget.file.path == filename:
                         break
                 if widget != exept:
                     self._save_editor(widget)
                     self.removeTab(self.indexOf(widget))
         return True
     return False