Connected the delete key to remove entries from recent projects list
This commit is contained in:
+16
-5
@@ -288,7 +288,8 @@ class Config:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def loadConfig(self):
|
def loadConfig(self):
|
||||||
|
"""Load preferences from file and replace default settings.
|
||||||
|
"""
|
||||||
logger.debug("Loading config file")
|
logger.debug("Loading config file")
|
||||||
cnfParse = configparser.ConfigParser()
|
cnfParse = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
@@ -453,7 +454,8 @@ class Config:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def saveConfig(self):
|
def saveConfig(self):
|
||||||
|
"""Save the current preferences to file.
|
||||||
|
"""
|
||||||
logger.debug("Saving config file")
|
logger.debug("Saving config file")
|
||||||
cnfParse = configparser.ConfigParser()
|
cnfParse = configparser.ConfigParser()
|
||||||
|
|
||||||
@@ -546,7 +548,6 @@ class Config:
|
|||||||
def loadRecentCache(self):
|
def loadRecentCache(self):
|
||||||
"""Load the cache file for recent projects.
|
"""Load the cache file for recent projects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.dataPath is None:
|
if self.dataPath is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -587,7 +588,6 @@ class Config:
|
|||||||
def saveRecentCache(self):
|
def saveRecentCache(self):
|
||||||
"""Save the cache dictionary of recent projects.
|
"""Save the cache dictionary of recent projects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.dataPath is None:
|
if self.dataPath is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -619,6 +619,18 @@ class Config:
|
|||||||
}
|
}
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def removeFromRecentCache(self, thePath):
|
||||||
|
"""Trying to remove a path from the recent projects cache.
|
||||||
|
"""
|
||||||
|
if thePath in self.recentProj:
|
||||||
|
del self.recentProj[thePath]
|
||||||
|
logger.verbose("Removed recent: %s" % thePath)
|
||||||
|
self.saveRecentCache()
|
||||||
|
else:
|
||||||
|
logger.error("Unknown recent: %s" % thePath)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
##
|
##
|
||||||
# Setters and Getters
|
# Setters and Getters
|
||||||
##
|
##
|
||||||
@@ -737,7 +749,6 @@ class Config:
|
|||||||
def _checkOptionalPackages(self):
|
def _checkOptionalPackages(self):
|
||||||
"""Cheks if we have the optional packages used by some features.
|
"""Cheks if we have the optional packages used by some features.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import enchant
|
import enchant
|
||||||
self.hasEnchant = True
|
self.hasEnchant = True
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ import nw
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
|
from PyQt5.QtGui import QKeySequence
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
||||||
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel
|
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.common import formatInt
|
from nw.common import formatInt
|
||||||
@@ -119,6 +120,10 @@ class GuiProjectLoad(QDialog):
|
|||||||
self._populateList()
|
self._populateList()
|
||||||
self._doSelectRecent()
|
self._doSelectRecent()
|
||||||
|
|
||||||
|
keyDelete = QShortcut(self.listBox)
|
||||||
|
keyDelete.setKey(QKeySequence(Qt.Key_Delete))
|
||||||
|
keyDelete.activated.connect(self._keyPressDelete)
|
||||||
|
|
||||||
logger.debug("GuiProjectLoad initialisation complete")
|
logger.debug("GuiProjectLoad initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -179,6 +184,15 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.accept()
|
self.accept()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _keyPressDelete(self):
|
||||||
|
"""Remove an entry from the recent projects list.
|
||||||
|
"""
|
||||||
|
selList = self.listBox.selectedItems()
|
||||||
|
if selList:
|
||||||
|
self.mainConf.removeFromRecentCache(selList[0].text(3))
|
||||||
|
self._populateList()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user