Skip to content
Permalink
Browse files

[pyqgis-console] fix for save as in tabbar context menu

  • Loading branch information
slarosa committed May 22, 2013
1 parent 2a9e0ae commit 022ca43995bff86b43709026acb753aff8bab3e5
Showing with 13 additions and 6 deletions.
  1. +3 −1 python/console/console.py
  2. +10 −5 python/console/console_editor.py
@@ -640,8 +640,10 @@ def saveScriptFile(self):
.arg(unicode(tabWidget.path)).arg(error.strerror)
self.callWidgetMessageBarEditor(msgText, 2, False)

def saveAsScriptFile(self):
def saveAsScriptFile(self, index=None):
tabWidget = self.tabEditorWidget.currentWidget()
if index:
tabWidget = self.tabEditorWidget.widget(index)
index = self.tabEditorWidget.currentIndex()
if tabWidget is None:
return
@@ -742,10 +742,10 @@ def loadFile(self, filename, modified):
self.newEditor.recolor()

def save(self, fileName=None):
index = self.tw.indexOf(self)
if fileName:
self.path = fileName
if self.path is None:
index = self.tw.currentIndex()
saveTr = QCoreApplication.translate('PythonConsole',
'Python Console: Save file')
self.path = str(QFileDialog().getSaveFileName(self,
@@ -756,6 +756,7 @@ def save(self, fileName=None):
if len(self.path) == 0:
self.path = None
return
self.tw.setCurrentWidget(self)
msgText = QCoreApplication.translate('PythonConsole',
'Script was correctly saved.')
self.pc.callWidgetMessageBarEditor(msgText, 0, True)
@@ -782,8 +783,8 @@ def save(self, fileName=None):
if self.newEditor.isReadOnly():
self.newEditor.setReadOnly(False)
fN = path.split('/')[-1]
self.tw.setTabTitle(self.tw.currentIndex(), fN)
self.tw.setTabToolTip(self.tw.currentIndex(), path)
self.tw.setTabTitle(index, fN)
self.tw.setTabToolTip(index, path)
self.newEditor.setModified(False)
self.pc.saveFileButton.setEnabled(False)
self.newEditor.lastModified = QFileInfo(path).lastModified()
@@ -931,7 +932,7 @@ def contextMenuEvent(self, e):
saveAction = menu.addAction("Save",
cW.save)
saveAsAction = menu.addAction("Save As",
self.parent.saveAsScriptFile)
self.saveAs)
closeTabAction.setEnabled(False)
closeAllTabAction.setEnabled(False)
closeOthersTabAction.setEnabled(False)
@@ -957,7 +958,11 @@ def closeAll(self):
self._removeTab(i)
self.newTabEditor(tabName='Untitled-0')
self._removeTab(0)


def saveAs(self):
idx = self.idx
self.parent.saveAsScriptFile(idx)

def enableSaveIfModified(self, tab):
tabWidget = self.widget(tab)
if tabWidget:

0 comments on commit 022ca43

Please sign in to comment.
You can’t perform that action at this time.