Skip to content
Snippets Groups Projects

Guirecentfiles

Merged Olle Hansson requested to merge guirecentfiles into master
1 file
+ 26
15
Compare changes
  • Side-by-side
  • Inline
+ 26
15
@@ -12,7 +12,7 @@ from collections import deque
from pprint import pprint
from typing import Dict, List, Optional, Tuple
from qtpy.QtCore import QFileInfo, QSettings, QSize, Qt
from qtpy.QtCore import QCoreApplication, QFileInfo, QSettings, QSize, Qt
from qtpy.QtGui import QCursor, QIcon, QKeySequence, QPainter
from qtpy.QtWidgets import (
QAction,
@@ -31,6 +31,7 @@ from qtpy.QtWidgets import (
import b_asic.core_operations
import b_asic.special_operations
from b_asic._version import __version__
from b_asic.GUI._preferences import GAP, GRID, MINBUTTONSIZE, PORTHEIGHT
from b_asic.GUI.arrow import Arrow
from b_asic.GUI.drag_button import DragButton
@@ -57,6 +58,11 @@ from b_asic.special_operations import Input, Output
logging.basicConfig(level=logging.INFO)
QCoreApplication.setOrganizationName("Linköping University")
QCoreApplication.setOrganizationDomain("liu.se")
QCoreApplication.setApplicationName("B-ASIC SFG GUI")
QCoreApplication.setApplicationVersion(__version__)
@decorate_class(handle_error)
class MainWindow(QMainWindow):
@@ -319,19 +325,20 @@ class MainWindow(QMainWindow):
def updateRecentActionList(self):
settings = QSettings()
rfp = settings.value("recentFiles")
dequelen = len(rfp)
rfp = settings.value("SFG/recentFiles")
if dequelen > 0:
for i in range(dequelen):
action = self.recentFilesList[i]
action.setText(rfp[i].fileName())
action.setData(rfp[i])
action.setVisible(True)
# print(rfp)
if rfp:
dequelen = len(rfp)
if dequelen > 0:
for i in range(dequelen):
action = self.recentFilesList[i]
action.setText(rfp[i].fileName())
action.setData(rfp[i])
action.setVisible(True)
for i in range(dequelen, self.maxFileNr):
self.recentFilesList[i].setVisible(False)
for i in range(dequelen, self.maxFileNr):
self.recentFilesList[i].setVisible(False)
def openRecent(self, action):
self._load_from_file(action.data().filePath())
@@ -339,13 +346,17 @@ class MainWindow(QMainWindow):
def addRecentFile(self, module):
settings = QSettings()
rfp = settings.value("recentFiles")
rfp = settings.value("SFG/recentFiles")
recentFile = QFileInfo(module)
if recentFile not in rfp:
if rfp:
if recentFile not in rfp:
rfp.append(recentFile)
else:
rfp = deque(maxlen=self.maxFileNr)
rfp.append(recentFile)
settings.setValue("recentFiles", rfp)
settings.setValue("SFG/recentFiles", rfp)
self.updateRecentActionList()
Loading