mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[console] Better handling of default paths for open/save dialogs
This commit is contained in:
parent
15e452e918
commit
46da64a88e
@ -20,7 +20,7 @@ Some portions of code were taken from https://code.google.com/p/pydee/
|
||||
"""
|
||||
import os
|
||||
|
||||
from PyQt4.QtCore import Qt, QTimer, QSettings, QCoreApplication, QSize, QByteArray, QFileInfo, SIGNAL, QUrl
|
||||
from PyQt4.QtCore import Qt, QTimer, QSettings, QCoreApplication, QSize, QByteArray, QFileInfo, SIGNAL, QUrl, QDir
|
||||
from PyQt4.QtGui import QDockWidget, QToolBar, QToolButton, QWidget,\
|
||||
QSplitter, QTreeWidget, QAction, QFileDialog, QCheckBox, QSizePolicy, QMenu, QGridLayout, QApplication, \
|
||||
QDesktopServices
|
||||
@ -627,7 +627,7 @@ class PythonConsoleWidget(QWidget):
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||
|
||||
def openScriptFile(self):
|
||||
lastDirPath = self.settings.value("pythonConsole/lastDirPath", "")
|
||||
lastDirPath = self.settings.value("pythonConsole/lastDirPath", QDir.home())
|
||||
openFileTr = QCoreApplication.translate("PythonConsole", "Open File")
|
||||
fileList = QFileDialog.getOpenFileNames(
|
||||
self, openFileTr, lastDirPath, "Script file (*.py)")
|
||||
@ -661,7 +661,9 @@ class PythonConsoleWidget(QWidget):
|
||||
if not index:
|
||||
index = self.tabEditorWidget.currentIndex()
|
||||
if not tabWidget.path:
|
||||
pathFileName = self.tabEditorWidget.tabText(index) + '.py'
|
||||
fileName = self.tabEditorWidget.tabText(index) + '.py'
|
||||
folder = self.settings.value("pythonConsole/lastDirPath", QDir.home())
|
||||
pathFileName = os.path.join(folder,fileName)
|
||||
fileNone = True
|
||||
else:
|
||||
pathFileName = tabWidget.path
|
||||
|
@ -19,7 +19,7 @@ email : lrssvtml (at) gmail (dot) com
|
||||
Some portions of code were taken from https://code.google.com/p/pydee/
|
||||
"""
|
||||
|
||||
from PyQt4.QtCore import Qt, QObject, QEvent, QSettings, QCoreApplication, QFileInfo, QSize, SIGNAL
|
||||
from PyQt4.QtCore import Qt, QObject, QEvent, QSettings, QCoreApplication, QFileInfo, QSize, QDir, SIGNAL
|
||||
from PyQt4.QtGui import QFont, QFontMetrics, QColor, QShortcut, QKeySequence, QMenu, QApplication, QCursor, QWidget, QGridLayout, QSpacerItem, QSizePolicy, QFileDialog, QTabWidget, QTreeWidgetItem, QFrame, QLabel, QToolButton, QMessageBox
|
||||
from PyQt4.Qsci import (QsciScintilla,
|
||||
QsciLexerPython,
|
||||
@ -828,6 +828,8 @@ class EditorTab(QWidget):
|
||||
self.newEditor.lastModified = QFileInfo(path).lastModified()
|
||||
self.pc.updateTabListScript(path, action='append')
|
||||
self.tw.listObject(self)
|
||||
lastDirPath = QFileInfo(path).path()
|
||||
self.pc.settings.setValue("pythonConsole/lastDirPath", lastDirPath)
|
||||
|
||||
def modified(self, modified):
|
||||
self.tw.tabModified(self, modified)
|
||||
@ -1250,7 +1252,7 @@ class EditorTabWidget(QTabWidget):
|
||||
|
||||
def changeLastDirPath(self, tab):
|
||||
tabWidget = self.widget(tab)
|
||||
if tabWidget:
|
||||
if tabWidget and tabWidget.path:
|
||||
self.settings.setValue("pythonConsole/lastDirPath", tabWidget.path)
|
||||
|
||||
def widgetMessageBar(self, iface, text, level, timed=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user