Skip to content

Commit bdd1e35

Browse files
committed
limit initial mdi commands to 8 which fills the area
Signed-off-by: John Thornton <[email protected]>
1 parent 58ef5c2 commit bdd1e35

File tree

2 files changed

+37
-44
lines changed

2 files changed

+37
-44
lines changed

mesact/src/libmesact/mdi.py

+36-43
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,51 @@
11
from PyQt5.QtWidgets import QGridLayout, QLabel, QLineEdit
22

3-
43
def get_mdi_commands_count(parent):
5-
# Workaround for QGridLayout.rowCount() that returns 1 for empty grid
6-
grid_layout: QGridLayout = parent.mdiCommandsListGL
7-
rows = 0
8-
grid_layout.rowCount()
9-
for i in range(grid_layout.count()):
10-
row, _, span, _ = grid_layout.getItemPosition(i)
11-
rows = max(1, row + span)
12-
return rows
13-
4+
# Workaround for QGridLayout.rowCount() that returns 1 for empty grid
5+
grid_layout: QGridLayout = parent.mdiCommandsListGL
6+
rows = 0
7+
grid_layout.rowCount()
8+
for i in range(grid_layout.count()):
9+
row, _, span, _ = grid_layout.getItemPosition(i)
10+
rows = max(1, row + span)
11+
return rows
1412

1513
def add_mdi_command_row(parent):
16-
grid_layout: QGridLayout = parent.mdiCommandsListGL
17-
row = get_mdi_commands_count(parent)
18-
__add_mdi_command_row(grid_layout, row)
19-
14+
grid_layout: QGridLayout = parent.mdiCommandsListGL
15+
row = get_mdi_commands_count(parent)
16+
__add_mdi_command_row(grid_layout, row)
2017

2118
def set_mdi_command(parent, command_number, value):
22-
row_count = get_mdi_commands_count(parent)
23-
i = row_count
24-
while i <= command_number:
25-
add_mdi_command_row(parent)
26-
i += 1
27-
text_box: QLineEdit = parent.findChild(QLineEdit, __get_mdi_command_control_name(command_number))
28-
text_box.setText(value)
29-
19+
row_count = get_mdi_commands_count(parent)
20+
i = row_count
21+
while i <= command_number:
22+
add_mdi_command_row(parent)
23+
i += 1
24+
text_box: QLineEdit = parent.findChild(QLineEdit, __get_mdi_command_control_name(command_number))
25+
text_box.setText(value)
3026

3127
def get_mdi_command(parent, command_number):
32-
rows_count = get_mdi_commands_count(parent)
33-
if rows_count == 0 or command_number >= rows_count:
34-
return ""
35-
text_box: QLineEdit = parent.findChild(QLineEdit, __get_mdi_command_control_name(command_number))
36-
return text_box.text().strip()
37-
28+
rows_count = get_mdi_commands_count(parent)
29+
if rows_count == 0 or command_number >= rows_count:
30+
return ""
31+
text_box: QLineEdit = parent.findChild(QLineEdit, __get_mdi_command_control_name(command_number))
32+
return text_box.text().strip()
3833

3934
def cleanup_mdi_commands(parent):
40-
grid_layout: QGridLayout = parent.mdiCommandsListGL
41-
for i in reversed(range(grid_layout.count())):
42-
widget = grid_layout.itemAt(i).widget()
43-
grid_layout.removeWidget(widget)
44-
widget.setParent(None)
45-
for i in range(10):
46-
__add_mdi_command_row(grid_layout, i)
47-
35+
grid_layout: QGridLayout = parent.mdiCommandsListGL
36+
for i in reversed(range(grid_layout.count())):
37+
widget = grid_layout.itemAt(i).widget()
38+
grid_layout.removeWidget(widget)
39+
widget.setParent(None)
40+
for i in range(8):
41+
__add_mdi_command_row(grid_layout, i)
4842

4943
def __get_mdi_command_control_name(command_number):
50-
return f'mdiCmdLE_{command_number}'
51-
44+
return f'mdiCmdLE_{command_number}'
5245

5346
def __add_mdi_command_row(grid_layout, row):
54-
label = QLabel(f'MDI Command {row}')
55-
grid_layout.addWidget(label, row, 0)
56-
text_box = QLineEdit()
57-
text_box.setObjectName(__get_mdi_command_control_name(row))
58-
grid_layout.addWidget(text_box, row, 1)
47+
label = QLabel(f'MDI Command {row}')
48+
grid_layout.addWidget(label, row, 0)
49+
text_box = QLineEdit()
50+
text_box.setObjectName(__get_mdi_command_control_name(row))
51+
grid_layout.addWidget(text_box, row, 1)

mesact/src/mesact.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -41316,7 +41316,7 @@ to File Open in Axis</string>
4131641316
<x>0</x>
4131741317
<y>0</y>
4131841318
<width>706</width>
41319-
<height>341</height>
41319+
<height>290</height>
4132041320
</rect>
4132141321
</property>
4132241322
<layout class="QGridLayout" name="mdiCommandsListGL"/>

0 commit comments

Comments
 (0)