Update project load dialog
This commit is contained in:
@@ -29,8 +29,8 @@ from typing import TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QCloseEvent, QKeySequence
|
||||
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
||||
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut,
|
||||
@@ -112,8 +112,7 @@ class GuiProjectLoad(QDialog):
|
||||
self.selPath = QLineEdit("")
|
||||
self.selPath.setReadOnly(True)
|
||||
|
||||
self.browseButton = QPushButton("...")
|
||||
self.browseButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||
self.browseButton = QPushButton(SHARED.theme.getIcon("browse"), "", self)
|
||||
self.browseButton.clicked.connect(self._doBrowse)
|
||||
|
||||
self.projectForm.addWidget(self.lblRecent, 0, 0, 1, 3)
|
||||
@@ -159,12 +158,12 @@ class GuiProjectLoad(QDialog):
|
||||
return
|
||||
|
||||
##
|
||||
# Buttons
|
||||
# Private Slots
|
||||
##
|
||||
|
||||
def _doOpenRecent(self):
|
||||
"""Close the dialog window with a recent project selected.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doOpenRecent(self) -> None:
|
||||
"""Close the dialog window with a recent project selected."""
|
||||
self._saveSettings()
|
||||
|
||||
self.openPath = None
|
||||
@@ -178,17 +177,17 @@ class GuiProjectLoad(QDialog):
|
||||
|
||||
return
|
||||
|
||||
def _doSelectRecent(self):
|
||||
"""A recent item has been selected.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doSelectRecent(self) -> None:
|
||||
"""Update path when a recent item has been selected."""
|
||||
selList = self.listBox.selectedItems()
|
||||
if selList:
|
||||
self.selPath.setText(selList[0].data(self.C_NAME, self.D_PATH))
|
||||
return
|
||||
|
||||
def _doBrowse(self):
|
||||
"""Browse for a folder path.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doBrowse(self) -> None:
|
||||
"""Browse for a folder path."""
|
||||
extFilter = [
|
||||
self.tr("novelWriter Project File ({0})").format(nwFiles.PROJ_FILE),
|
||||
self.tr("All files ({0})").format("*"),
|
||||
@@ -205,26 +204,26 @@ class GuiProjectLoad(QDialog):
|
||||
|
||||
return
|
||||
|
||||
def _doCancel(self):
|
||||
"""Close the dialog window without doing anything.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doCancel(self) -> None:
|
||||
"""Close the dialog window without doing anything."""
|
||||
self.openPath = None
|
||||
self.openState = self.NONE_STATE
|
||||
self.close()
|
||||
return
|
||||
|
||||
def _doNewProject(self):
|
||||
"""Create a new project.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doNewProject(self) -> None:
|
||||
"""Create a new project."""
|
||||
self._saveSettings()
|
||||
self.openPath = None
|
||||
self.openState = self.NEW_STATE
|
||||
self.accept()
|
||||
return
|
||||
|
||||
def _doDeleteRecent(self):
|
||||
"""Remove an entry from the recent projects list.
|
||||
"""
|
||||
@pyqtSlot()
|
||||
def _doDeleteRecent(self) -> None:
|
||||
"""Remove an entry from the recent projects list."""
|
||||
selList = self.listBox.selectedItems()
|
||||
if selList:
|
||||
projName = selList[0].text(self.C_NAME)
|
||||
@@ -244,20 +243,18 @@ class GuiProjectLoad(QDialog):
|
||||
# Events
|
||||
##
|
||||
|
||||
def closeEvent(self, theEvent):
|
||||
"""Capture the user closing the dialog so we can save settings.
|
||||
"""
|
||||
def closeEvent(self, event: QCloseEvent) -> None:
|
||||
"""Capture the user closing the dialog and save settings."""
|
||||
self._saveSettings()
|
||||
theEvent.accept()
|
||||
event.accept()
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
def _saveSettings(self):
|
||||
"""Save the changes made to the dialog.
|
||||
"""
|
||||
def _saveSettings(self) -> None:
|
||||
"""Save the changes made to the dialog."""
|
||||
colWidths = [0, 0, 0]
|
||||
colWidths[self.C_NAME] = self.listBox.columnWidth(self.C_NAME)
|
||||
colWidths[self.C_COUNT] = self.listBox.columnWidth(self.C_COUNT)
|
||||
@@ -265,9 +262,8 @@ class GuiProjectLoad(QDialog):
|
||||
CONFIG.setProjLoadColWidths(colWidths)
|
||||
return
|
||||
|
||||
def _populateList(self):
|
||||
"""Populate the list box with recent project data.
|
||||
"""
|
||||
def _populateList(self) -> None:
|
||||
"""Populate the list box with recent project data."""
|
||||
self.listBox.clear()
|
||||
dataList = CONFIG.recentProjects.listEntries()
|
||||
sortList = sorted(dataList, key=lambda x: x[3], reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user