fix filter bug

add settings
This commit is contained in:
copper 2022-11-09 21:23:49 +08:00
parent 398fb21cb0
commit cb9a09f23d
4 changed files with 43 additions and 7 deletions

View File

@ -88,12 +88,6 @@ class MainPlugin(BasicPlugin):
toolbar.addAction(action)
ActionManager().filter_menu.addAction(action)
# self.action = QAction('均值滤波', self.mainwindow)
# # self.action.setCheckable)
# # self.action.setChecked(False)
# self.action.triggered.connect(self.run)
# ActionManager().filter_menu.addAction(self.action)
self.alg_ok.connect(self.alg_oked)
# basic

View File

@ -12,6 +12,7 @@ from rscder.utils.misc import singleton
from rscder.gui.plugins import PluginDialog
from rscder.utils.setting import Settings
from rscder.gui.load import loader
from functools import partial
def get_action_manager() -> 'ActionManager':
return ActionManager()
@ -101,6 +102,21 @@ class ActionManager(QtCore.QObject):
def set_status_bar(self, status_bar):
self.status_bar = status_bar
def on_project_setup(self, path=None):
if path is not None:
Settings.General().history = path
history = Settings.General().history
print(history)
def reopen(p):
if Project().is_init:
Project().save()
Project().setup(p)
self.project_list.clear()
for h in history:
action = self.project_list.addAction(IconInstance().OPEN, h[-100:])
func = partial(reopen, h)
action.triggered.connect(func)
def set_actions(self):
'''
File menu
@ -108,6 +124,8 @@ class ActionManager(QtCore.QObject):
project_create = self.add_action(QAction(IconInstance().CREATE, '&工程创建', self.w_parent), 'File')
project_open = self.add_action(QAction(IconInstance().OPEN, '&打开工程', self.w_parent), 'File')
project_save = self.add_action(QAction(IconInstance().SAVE,'&保存工程', self.w_parent), 'File')
self.project_list = self.file_menu.addMenu(IconInstance().OPEN, '最近项目')
self.on_project_setup(None)
data_load = self.add_action(QAction(IconInstance().DATA_LOAD,'&数据加载', self.w_parent), 'File')
view_setting = self.add_action(QAction(IconInstance().VIEW_SETTING,'&界面定制', self.w_parent), 'File')
exit_app = self.add_action(QAction(IconInstance().EXCIT,'&退出', self.w_parent), 'File')
@ -188,6 +206,7 @@ class ActionManager(QtCore.QObject):
project_open.setEnabled(True)
Project().project_init.connect(self.project_init)
Project().project_setup.connect(self.on_project_setup)
if self.status_bar is not None:
corr_widget = QLabel(self.status_bar)

View File

@ -40,6 +40,7 @@ class Project(QObject):
instance:'Project'
project_init = pyqtSignal(bool)
project_setup = pyqtSignal(str)
# layer_load = pyqtSignal()
layer_tree_update = pyqtSignal()
layer_show_update = pyqtSignal()
@ -125,7 +126,7 @@ class Project(QObject):
pass
else:
self.load()
self.project_setup.emit(self.file)
self.is_init = True
self.project_init.emit(True)
except:

View File

@ -4,6 +4,7 @@ from typing import Tuple
from PyQt5.QtCore import QSettings
from rscder.utils.license import LicenseHelper
import yaml
from collections import OrderedDict
BASE_DIR = os.environ['ECD_BASEDIR']
class Settings(QSettings):
@ -83,6 +84,27 @@ class Settings(QSettings):
PRE='general'
@property
def history(self):
with Settings(Settings.General.PRE) as s:
history = s.value('history', [])
return history
@history.setter
def history(self, v:str):
print(v)
with Settings(Settings.General.PRE) as s:
history:list = s.value('history', [])
if v in history:
history.remove(v)
history.insert(0, v)
if len(history) > 10:
history = history[:10]
with Settings(Settings.General.PRE) as s:
s.setValue('history', history)
@property
def size(self):
with Settings(Settings.General.PRE) as s: