cfg editor: fixes

Change-Id: I1ea9f96f6c39c25ff8d4c51163aabccc5698dace
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30507
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
This commit is contained in:
Georg Brandl 2023-02-23 13:23:07 +01:00 committed by Markus Zolliker
parent 05cf4a791a
commit ef1664e1a2
7 changed files with 38 additions and 34 deletions

View File

@ -83,8 +83,8 @@ def write_config(file_name, tree_widget):
def read_config(file_path): def read_config(file_path):
# TODO datatype of params and properties # TODO datatype of params and properties
node = TreeWidgetItem(NODE) node = TreeWidgetItem(NODE)
ifs = TreeWidgetItem(name='interfaces') ifs = TreeWidgetItem(name='Interfaces')
mods = TreeWidgetItem(name='modules') mods = TreeWidgetItem(name='Modules')
node.addChild(ifs) node.addChild(ifs)
node.addChild(mods) node.addChild(mods)
config = configparser.ConfigParser() config = configparser.ConfigParser()

View File

@ -167,7 +167,7 @@ class ValueWidget(QWidget):
self.value_display.textChanged.connect(self.emit_save_status_changed) self.value_display.textChanged.connect(self.emit_save_status_changed)
self.set_value(value) self.set_value(value)
else: else:
self.value_display = QLabel(value) self.value_display = QLabel(str(value))
self.layout.addWidget(self.value_display) self.layout.addWidget(self.value_display)
self.setLayout(self.layout) self.setLayout(self.layout)

View File

@ -7,11 +7,11 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>239</width> <width>239</width>
<height>81</height> <height>84</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>change name</string> <string>Change name</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="0" column="1">
@ -20,7 +20,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>name:</string> <string>Name:</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -34,7 +34,7 @@
<string>create new SEC node</string> <string>create new SEC node</string>
</property> </property>
<property name="text"> <property name="text">
<string>new</string> <string>New</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -67,7 +67,7 @@
<string>open file</string> <string>open file</string>
</property> </property>
<property name="text"> <property name="text">
<string>open</string> <string>Open</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -100,7 +100,7 @@
<string>save</string> <string>save</string>
</property> </property>
<property name="text"> <property name="text">
<string>save</string> <string>Save</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -140,7 +140,7 @@
<string>add interface</string> <string>add interface</string>
</property> </property>
<property name="text"> <property name="text">
<string>add interface</string> <string>Add interface</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -173,7 +173,7 @@
<string>add module</string> <string>add module</string>
</property> </property>
<property name="text"> <property name="text">
<string>add module</string> <string>Add module</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -206,7 +206,7 @@
<string>add parameter</string> <string>add parameter</string>
</property> </property>
<property name="text"> <property name="text">
<string>add parameter</string> <string>Add parameter</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -239,7 +239,7 @@
<string>add property</string> <string>add property</string>
</property> </property>
<property name="text"> <property name="text">
<string>add property</string> <string>Add property</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset> <iconset>
@ -272,7 +272,7 @@
<string>add comment</string> <string>add comment</string>
</property> </property>
<property name="text"> <property name="text">
<string>add comment</string> <string>Add comment</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -319,7 +319,7 @@
<string>duplicate module or interface</string> <string>duplicate module or interface</string>
</property> </property>
<property name="text"> <property name="text">
<string>duplicate</string> <string>Duplicate</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -352,7 +352,7 @@
<string>delete</string> <string>delete</string>
</property> </property>
<property name="text"> <property name="text">
<string>delete</string> <string>Delete</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="icons/cfg-editor.qrc"> <iconset resource="icons/cfg-editor.qrc">
@ -409,7 +409,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>977</width> <width>977</width>
<height>20</height> <height>26</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@ -106,6 +106,7 @@ def get_file_paths(widget, open_file=True):
def get_modules(): def get_modules():
modules = {} modules = {}
generalConfig.init()
base_path = generalConfig.basedir base_path = generalConfig.basedir
# pylint: disable=too-many-nested-blocks # pylint: disable=too-many-nested-blocks
for dirname in listdir(base_path): for dirname in listdir(base_path):
@ -156,6 +157,7 @@ def get_interface_class_from_name(name):
def get_interfaces(): def get_interfaces():
# TODO class must be found out like for modules # TODO class must be found out like for modules
interfaces = [] interfaces = []
generalConfig.init()
interface_path = path.join(generalConfig.basedir, 'frappy', interface_path = path.join(generalConfig.basedir, 'frappy',
'protocol', 'interface') 'protocol', 'interface')
for filename in listdir(interface_path): for filename in listdir(interface_path):

View File

@ -60,14 +60,14 @@ class TreeWidget(QTreeWidget):
self.customContextMenuRequested.connect(self.on_context_menu_requested) self.customContextMenuRequested.connect(self.on_context_menu_requested)
def setup_context_actions(self): def setup_context_actions(self):
edit = self.menu.addAction('rename') edit = self.menu.addAction('Rename')
a_m = self.menu.addAction('add module') a_m = self.menu.addAction('Add module')
a_i = self.menu.addAction('add interface') a_i = self.menu.addAction('Add interface')
a_pa = self.menu.addAction('add parameter') a_pa = self.menu.addAction('Add parameter')
a_pr = self.menu.addAction('add property') a_pr = self.menu.addAction('Add property')
a_c = self.menu.addAction('add comment') a_c = self.menu.addAction('Add comment')
dup = self.menu.addAction('duplicate') dup = self.menu.addAction('Duplicate')
dele = self.menu.addAction('delete') dele = self.menu.addAction('Delete')
self.context_actions = [edit, a_m, a_i, a_pa, a_pr, a_c, dup, dele] self.context_actions = [edit, a_m, a_i, a_pa, a_pr, a_c, dup, dele]
setActionIcon(edit, 'edit.png') setActionIcon(edit, 'edit.png')
setActionIcon(a_m, 'add_module.png') setActionIcon(a_m, 'add_module.png')
@ -115,8 +115,8 @@ class TreeWidget(QTreeWidget):
None) None)
self.addTopLevelItem(sec_node) self.addTopLevelItem(sec_node)
sec_node.setExpanded(True) sec_node.setExpanded(True)
self.mods = self.get_tree_widget_item(name='modules') self.mods = self.get_tree_widget_item(name='Modules')
self.ifs = self.get_tree_widget_item(name='interfaces') self.ifs = self.get_tree_widget_item(name='Interfaces')
sec_node.addChild(self.ifs) sec_node.addChild(self.ifs)
sec_node.addChild(self.mods) sec_node.addChild(self.mods)
self.emit_save_status_changed(False) self.emit_save_status_changed(False)
@ -337,7 +337,7 @@ class AddDialog(QDialog):
the value from self.value""" the value from self.value"""
super().__init__(parent) super().__init__(parent)
loadUi(self, 'add_dialog.ui') loadUi(self, 'add_dialog.ui')
self.setWindowTitle('add %s' % kind) self.setWindowTitle('Add %s' % kind)
self.kind = kind self.kind = kind
self.invalid_names = invalid_names self.invalid_names = invalid_names
if self.invalid_names: if self.invalid_names:
@ -348,15 +348,15 @@ class AddDialog(QDialog):
self.name = QLineEdit() self.name = QLineEdit()
# TODO: input mask # TODO: input mask
self.name.textChanged.connect(self.check_input) self.name.textChanged.connect(self.check_input)
self.add_layout.addWidget(QLabel('name:'), 0, 0) self.add_layout.addWidget(QLabel('Name:'), 0, 0)
self.add_layout.addWidget(self.name, 0, 1) self.add_layout.addWidget(self.name, 0, 1)
if kind == NODE: if kind == NODE:
label_text = 'description:' label_text = 'Description:'
self.value = QTextEdit() self.value = QTextEdit()
self.get_value = self.value.toPlainText self.get_value = self.value.toPlainText
self.value.text = self.value.toPlainText self.value.text = self.value.toPlainText
else: else:
label_text = 'kind:' label_text = 'Kind:'
self.value = QComboBox() self.value = QComboBox()
self.get_value = self.value.currentText self.get_value = self.value.currentText
if type(possible_values) == dict: if type(possible_values) == dict:
@ -368,18 +368,20 @@ class AddDialog(QDialog):
self.value.setCurrentIndex(len(possible_values)-1) self.value.setCurrentIndex(len(possible_values)-1)
self.add_layout.addWidget(QLabel(label_text), 1, 0) self.add_layout.addWidget(QLabel(label_text), 1, 0)
self.add_layout.addWidget(self.value, 1, 1) self.add_layout.addWidget(self.value, 1, 1)
self.name.setFocus()
else: else:
if kind in [PARAMETER, PROPERTY]: if kind in [PARAMETER, PROPERTY]:
label_text = 'kind:' label_text = 'Kind:'
self.value = QComboBox() self.value = QComboBox()
self.get_value = self.value.currentText self.get_value = self.value.currentText
self.value.addItems(possible_values) self.value.addItems(possible_values)
else: else:
label_text = 'comment:' label_text = 'Comment:'
self.value = QTextEdit() self.value = QTextEdit()
self.get_value = self.value.toPlainText self.get_value = self.value.toPlainText
self.add_layout.addWidget(QLabel(label_text), 0, 0) self.add_layout.addWidget(QLabel(label_text), 0, 0)
self.add_layout.addWidget(self.value, 0, 1) self.add_layout.addWidget(self.value, 0, 1)
self.value.setFocus()
if self.add_layout.rowCount() == 2: if self.add_layout.rowCount() == 2:
self.setTabOrder(self.name, self.value) self.setTabOrder(self.name, self.value)
self.setTabOrder(self.value, self.button_box.button(QDialogButtonBox.Ok)) self.setTabOrder(self.value, self.button_box.button(QDialogButtonBox.Ok))

View File

@ -57,7 +57,7 @@ class TextWidget(QTextEdit):
self.setEnabled(False) self.setEnabled(False)
def get_value(self): def get_value(self):
res = self.text() res = self.toPlainText()
return self.datatype(res) return self.datatype(res)
def set_value(self, value): def set_value(self, value):