diff --git a/pasta_eln/GUI/configGUI.py b/pasta_eln/GUI/configGUI.py index b1c3c07d..0390d81c 100644 --- a/pasta_eln/GUI/configGUI.py +++ b/pasta_eln/GUI/configGUI.py @@ -2,7 +2,7 @@ import json from pathlib import Path from typing import Callable, Any -from PySide6.QtWidgets import QWidget, QFormLayout # pylint: disable=no-name-in-module +from PySide6.QtWidgets import QWidget, QFormLayout, QVBoxLayout, QGroupBox, QLabel # pylint: disable=no-name-in-module from ..miscTools import restart from ..guiStyle import TextButton, addRowList from ..guiCommunicate import Communicate @@ -20,16 +20,18 @@ def __init__(self, comm:Communicate, callbackFinished:Callable[[],None]): """ super().__init__() self.comm = comm - #GUI elements if hasattr(self.comm.backend, 'configuration'): onDisk = self.comm.backend.configuration['GUI'] - self.mainL = QFormLayout(self) - for items in configurationGUI.values(): + mainL = QVBoxLayout(self) + for label, items in configurationGUI.items(): + groupbox = QGroupBox(label) + mainL.addWidget(groupbox) + sectionL = QFormLayout(groupbox) for k,v in items.items(): setattr(self, k, - addRowList(self.mainL, label=v[0], default=str(onDisk[k]), itemList=[str(i) for i in v[2]])) - self.mainL.addRow('Save changes', TextButton('Save changes', self, [], None)) + addRowList(sectionL, label=v[0], default=str(onDisk[k]), itemList=[str(i) for i in v[2]])) + mainL.addWidget(TextButton('Save changes', self, [], None)) def execute(self, _:list[Any]) -> None: diff --git a/pasta_eln/database.py b/pasta_eln/database.py index c0079edb..a009bc28 100644 --- a/pasta_eln/database.py +++ b/pasta_eln/database.py @@ -48,8 +48,20 @@ def __init__(self, user:str, password:str, databaseName:str, configuration:dict[ if '-version' in self.dataHierarchy and self.dataHierarchy['-version'] < 4: logging.info('Convert data hierarchy to V4.0') dataHierarchy_pre_to_V4(self.dataHierarchy) - self.db['-dataHierarchy-'].delete() + if '-dataHierarchy-' in self.db: + self.db['-dataHierarchy-'].delete() self.db.create_document(self.dataHierarchy) + if '-ontology-' in self.db: + self.db['-ontology-'].delete() + # temporary changes for version 2.5: remove afterwards: code does not harm but would be legacy then + testDocIDs = [doc['_id'] for doc in self.db if doc['_id'].startswith('x-')] + if testDocIDs and '-gui' not in self.db[testDocIDs[0]]: + for doc in self.db: + if doc['_id'].startswith('_') or doc['_id'].endswith('-'): + continue + if '-gui' not in doc: + doc['-gui'] = [True, True] + doc.save() if '-version' not in self.dataHierarchy or self.dataHierarchy['-version']!=4: print(F"**ERROR wrong dataHierarchy version: {self.dataHierarchy['-version']}") raise ValueError(f"Wrong dataHierarchy version {self.dataHierarchy['-version']}") @@ -804,9 +816,6 @@ def checkDB(self, outputStyle:str='text', repair:bool=False, minimal:bool=False) outstring+= outputString(outputStyle,'h2','List all database entries') if repair: print('REPAIR MODE IS ON: afterwards, full-reload and create views') - ## loop all documents - if repair and '-ontology-' in self.db: - self.db['-ontology-'].delete() for doc in self.db: try: if '_design' in doc['_id']: @@ -837,15 +846,6 @@ def checkDB(self, outputStyle:str='text', repair:bool=False, minimal:bool=False) # doc['-branch'][0]['path'] = newPath # doc.save() - # change database to version 4 - if '-gui' not in doc: - outstring+= outputString(outputStyle,'error',f"dch00: gui does not exist {doc['_id']}") - if repair: - doc['-gui'] = [True, True] - doc.save() - - - #branch test if '-branch' not in doc: outstring+= outputString(outputStyle,'error',f"dch01: branch does not exist {doc['_id']}") diff --git a/pasta_eln/gui.py b/pasta_eln/gui.py index 72df0665..51533e19 100644 --- a/pasta_eln/gui.py +++ b/pasta_eln/gui.py @@ -86,7 +86,6 @@ def __init__(self) -> None: helpMenu = menu.addMenu("&Help") Action('&Website', self, [Command.WEBSITE], helpMenu) Action('&Verify database', self, [Command.VERIFY_DB], helpMenu, shortcut='Ctrl+?') - Action('&Repair database', self, [Command.REPAIR_DB], helpMenu) Action('Shortcuts', self, [Command.SHORTCUTS], helpMenu) # shortcuts for advanced usage (user should not need) QShortcut('F9', self, lambda: self.execute([Command.RESTART])) @@ -197,14 +196,6 @@ def execute(self, command: list[Any]) -> None: elif command[0] is Command.VERIFY_DB: report = self.comm.backend.checkDB(outputStyle='html', minimal=True) showMessage(self, 'Report of database verification', report, style='QLabel {min-width: 800px}') - elif command[0] is Command.REPAIR_DB: - ret = QMessageBox.critical(self, 'Warning', 'Are you sure you want to repair the database as it can destroy information?', \ - QMessageBox.StandardButton.No | QMessageBox.StandardButton.Yes, # type: ignore[operator] - QMessageBox.StandardButton.No) - if ret==QMessageBox.StandardButton.Yes: - self.comm.backend.checkDB(outputStyle='html', minimal=True, repair=True) - showMessage(self, 'Report of database verification', 'Rerun verification to test success', - style='QLabel {min-width: 800px}') elif command[0] is Command.SHORTCUTS: showMessage(self, 'Keyboard shortcuts', shortcuts) @@ -266,9 +257,8 @@ class Command(Enum): CONFIG = 12 WEBSITE = 13 VERIFY_DB = 14 - REPAIR_DB = 15 - SHORTCUTS = 16 - RESTART = 17 + SHORTCUTS = 15 + RESTART = 16 def startMain() -> None: diff --git a/pasta_eln/guiStyle.py b/pasta_eln/guiStyle.py index 8224e820..8e351d18 100644 --- a/pasta_eln/guiStyle.py +++ b/pasta_eln/guiStyle.py @@ -28,7 +28,10 @@ def getColor(backend:Backend, color:str) -> str: str: #123456 color code """ if not hasattr(backend, 'configuration') or backend.configuration['GUI']['theme']=='none': - return '#000000' + if color=='primary': + return '#000000' + else: + return '#BBBBBB' themeName = backend.configuration['GUI']['theme'] return get_theme(f'{themeName}.xml')[f'{color}Color']