Skip to content

Commit

Permalink
Save current directory to config file on exit and restore on load. De…
Browse files Browse the repository at this point in the history
…fault to user homedir if not set.

Bump version and validate support for Python3.9.
  • Loading branch information
mikedarcy committed Oct 25, 2021
1 parent 475dcb2 commit 0b06eef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BDBag-mac.spec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ app = BUNDLE(coll,
bundle_identifier='edu.isi.isrd.BDBag',
info_plist={
'CFBundleDisplayName': 'BDBag',
'CFBundleShortVersionString':'1.1.0',
'CFBundleShortVersionString':'1.2.0',
'NSPrincipalClass':'NSApplication',
'NSHighResolutionCapable': 'True'
})
2 changes: 1 addition & 1 deletion bdbag_gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from pkg_resources import get_distribution, DistributionNotFound

__version__ = "1.1.0"
__version__ = "1.2.0"

try:
version = get_distribution("bdbag_gui").version
Expand Down
17 changes: 13 additions & 4 deletions bdbag_gui/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import platform

from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import Qt, QMetaObject, QModelIndex, QThreadPool, QTimer, QMutex, pyqtSlot
from PyQt5.QtCore import Qt, QDir, QMetaObject, QModelIndex, QThreadPool, QTimer, QMutex, pyqtSlot
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QAction, QMenu, QMenuBar, QMessageBox, QStyle, \
QProgressBar, QToolBar, QStatusBar, QVBoxLayout, QTreeView, QFileSystemModel, qApp
QProgressBar, QToolBar, QStatusBar, QVBoxLayout, QTreeView, QFileSystemModel, QAbstractItemView, qApp
from PyQt5.QtGui import QIcon
from bdbag import VERSION as BDBAG_VERSION, BAGIT_VERSION, BAGIT_PROFILE_VERSION, bdbag_api as bdb
from bdbag_gui import resources, VERSION
Expand All @@ -33,16 +33,22 @@ def __init__(self):
self.fileSystemModel = QFileSystemModel()
self.fileSystemModel.setReadOnly(False)
self.ui.treeView.setModel(self.fileSystemModel)
self.fileSystemModel.setRootPath(self.fileSystemModel.myComputer())
self.ui.treeView.setAnimated(True)
self.ui.treeView.setAcceptDrops(True)
self.ui.treeView.setAutoScroll(True)
self.ui.treeView.setAutoExpandDelay(0)
self.ui.treeView.setSortingEnabled(True)
self.ui.treeView.sortByColumn(0, Qt.AscendingOrder)
self.ui.treeView.setColumnWidth(0, 300)
self.ui.treeView.setRootIndex(self.fileSystemModel.setRootPath(self.fileSystemModel.myComputer()))

self.loadOptions()
homedir_index = self.fileSystemModel.index(self.options.get("current_dir", QDir.home().path()))
self.ui.treeView.setCurrentIndex(homedir_index)
self.ui.treeView.setExpanded(homedir_index, True)
QTimer.singleShot(1300, self.selectionChanged)

self.enableControls(True)
self.ui.actionCreateOrUpdate.setEnabled(False)

def loadOptions(self, options_file=DEFAULT_OPTIONS_FILE):
if not os.path.isfile(options_file):
Expand Down Expand Up @@ -162,9 +168,12 @@ def selectionChanged(self):
self.ui.progressBar.reset()
self.ui.logTextBrowser.widget.clear()
self.enableControls()
self.ui.treeView.scrollTo(self.ui.treeView.currentIndex(), QAbstractItemView.PositionAtCenter)
self.options["current_dir"] = self.getCurrentPath()

def closeEvent(self, event):
self.cancelTasks()
self.saveOptions()
event.accept()

def cancelTasks(self):
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
]
)

0 comments on commit 0b06eef

Please sign in to comment.