@@ -1397,6 +1397,8 @@ class InvalidProfileHash(Exception):
13971397#class ApplicationWindow():
13981398class ApplicationWindow(QMainWindow):
13991399
1400+ NUMBER_OF_EXTRABUTTON_ROWS:Final[int] = 10 # max number of extra button rows
1401+
14001402 singleShotPhidgetsPulseOFF = pyqtSignal(int,int,str) # signal to be called from the eventaction thread to realise Phidgets pulse via QTimer in the main thread
14011403 singleShotPhidgetsPulseOFFSerial = pyqtSignal(int,int,str,str)
14021404 updatePlusStatusSignal = pyqtSignal() # can be called from another thread or a QTimer to trigger to update the plus icon status
@@ -1500,9 +1502,7 @@ class ApplicationWindow(QMainWindow):
15001502 'buttonpalettemaxlen_default', 'buttonpalettemaxlen', 'buttonpalette_shortcuts', 'buttonsize_default', 'buttonsize',
15011503 'mark_last_button_pressed_default', 'mark_last_button_pressed', 'show_extrabutton_tooltips_default', 'show_extrabutton_tooltips',
15021504 'buttonpalette_buttonsize', 'buttonpalette_mark_last_button_pressed', 'buttonpalette_tooltips', 'buttonpalette_slider_alternative_layout', 'eventbuttontablecolumnwidths',
1503- 'lowerbuttondialogLayout', 'lowerbuttondialog', 'lowerbuttondialogLayout', 'e1buttonbarLayout', 'e1buttondialog', 'e2buttonbarLayout', 'e2buttondialog',
1504- 'e3buttonbarLayout', 'e3buttondialog', 'e4buttonbarLayout', 'e4buttondialog','e5buttonbarLayout', 'e5buttondialog', 'e6buttonbarLayout', 'e6buttondialog',
1505- 'e7buttonbarLayout', 'e7buttondialog', 'e8buttonbarLayout', 'e8buttondialog', 'e9buttonbarLayout', 'e9buttondialog', 'e10buttonbarLayout', 'e10buttondialog',
1505+ 'lowerbuttondialogLayout', 'lowerbuttondialog', 'lowerbuttondialogLayout', 'extrabuttonbars',
15061506 'keyboardmove', 'keyboardButtonList', 'keyboardmoveindex',
15071507 'keyboardmoveflag', 'lastkeyboardcmd', 'error_dlg', 'serial_dlg', 'message_dlg', 'ETname', 'BTname', 'level1frame', 'level1layout', 'qpc', 'splitter', 'scroller', 'EventsGroupLayout',
15081508 'LCD2frame', 'LCD3frame', 'LCD4frame', 'LCD5frame', 'LCD6frame', 'LCD7frame', 'TPlabel', 'TPlcd', 'TPlcdFrame', 'TP2DRYlabel', 'TP2DRYframe',
@@ -3582,86 +3582,21 @@ def __init__(self, parent:QWidget|None = None, *, locale:str, artisanviewerFirst
35823582
35833583 #initiate configuration
35843584 self.lowerbuttondialogLayout.addStretch()
3585- self.lowerbuttondialogLayout.addWidget(self.buttonCHARGE)
3586- self.lowerbuttondialogLayout.addWidget(self.buttonDRY)
3587- self.lowerbuttondialogLayout.addWidget(self.buttonFCs)
3588- self.lowerbuttondialogLayout.addWidget(self.buttonFCe)
3589- self.lowerbuttondialogLayout.addWidget(self.buttonSCs)
3590- self.lowerbuttondialogLayout.addWidget(self.buttonSCe)
3591- self.lowerbuttondialogLayout.addWidget(self.buttonDROP)
3592- self.lowerbuttondialogLayout.addWidget(self.buttonCOOL)
3593- self.lowerbuttondialogLayout.addWidget(self.buttonEVENT)
3585+ for button_widget in [self.buttonCHARGE, self.buttonDRY, self.buttonFCs, self.buttonFCe,
3586+ self.buttonSCs, self.buttonSCe, self.buttonDROP, self.buttonCOOL, self.buttonEVENT]:
3587+ self.lowerbuttondialogLayout.addWidget(cast(EventPushButton, button_widget))
35943588 self.lowerbuttondialogLayout.addStretch()
35953589
3596- self.e1buttonbarLayout = QHBoxLayout()
3597- self.e1buttonbarLayout.setSpacing(1)
3598- self.e1buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3599- self.e1buttondialog = QFrame()
3600- self.e1buttondialog.setContentsMargins(0, 0, 0, 0)
3601- self.e1buttondialog.setLayout(self.e1buttonbarLayout)
3602-
3603- self.e2buttonbarLayout = QHBoxLayout()
3604- self.e2buttonbarLayout.setSpacing(1)
3605- self.e2buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3606- self.e2buttondialog = QFrame()
3607- self.e2buttondialog.setContentsMargins(0, 0, 0, 0)
3608- self.e2buttondialog.setLayout(self.e2buttonbarLayout)
3609-
3610- self.e3buttonbarLayout = QHBoxLayout()
3611- self.e3buttonbarLayout.setSpacing(1)
3612- self.e3buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3613- self.e3buttondialog = QFrame()
3614- self.e3buttondialog.setContentsMargins(0, 0, 0, 0)
3615- self.e3buttondialog.setLayout(self.e3buttonbarLayout)
3616-
3617- self.e4buttonbarLayout = QHBoxLayout()
3618- self.e4buttonbarLayout.setSpacing(1)
3619- self.e4buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3620- self.e4buttondialog = QFrame()
3621- self.e4buttondialog.setContentsMargins(0, 0, 0, 0)
3622- self.e4buttondialog.setLayout(self.e4buttonbarLayout)
3623-
3624- self.e5buttonbarLayout = QHBoxLayout()
3625- self.e5buttonbarLayout.setSpacing(1)
3626- self.e5buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3627- self.e5buttondialog = QFrame()
3628- self.e5buttondialog.setContentsMargins(0, 0, 0, 0)
3629- self.e5buttondialog.setLayout(self.e5buttonbarLayout)
3630-
3631- self.e6buttonbarLayout = QHBoxLayout()
3632- self.e6buttonbarLayout.setSpacing(1)
3633- self.e6buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3634- self.e6buttondialog = QFrame()
3635- self.e6buttondialog.setContentsMargins(0, 0, 0, 0)
3636- self.e6buttondialog.setLayout(self.e6buttonbarLayout)
3637-
3638- self.e7buttonbarLayout = QHBoxLayout()
3639- self.e7buttonbarLayout.setSpacing(1)
3640- self.e7buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3641- self.e7buttondialog = QFrame()
3642- self.e7buttondialog.setContentsMargins(0, 0, 0, 0)
3643- self.e7buttondialog.setLayout(self.e7buttonbarLayout)
3644-
3645- self.e8buttonbarLayout = QHBoxLayout()
3646- self.e8buttonbarLayout.setSpacing(1)
3647- self.e8buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3648- self.e8buttondialog = QFrame()
3649- self.e8buttondialog.setContentsMargins(0, 0, 0, 0)
3650- self.e8buttondialog.setLayout(self.e8buttonbarLayout)
3651-
3652- self.e9buttonbarLayout = QHBoxLayout()
3653- self.e9buttonbarLayout.setSpacing(1)
3654- self.e9buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3655- self.e9buttondialog = QFrame()
3656- self.e9buttondialog.setContentsMargins(0, 0, 0, 0)
3657- self.e9buttondialog.setLayout(self.e9buttonbarLayout)
3658-
3659- self.e10buttonbarLayout = QHBoxLayout()
3660- self.e10buttonbarLayout.setSpacing(1)
3661- self.e10buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3662- self.e10buttondialog = QFrame()
3663- self.e10buttondialog.setContentsMargins(0, 0, 0, 0)
3664- self.e10buttondialog.setLayout(self.e10buttonbarLayout)
3590+ def makeButtonbar() -> QFrame:
3591+ buttonbarLayout = QHBoxLayout()
3592+ buttonbarLayout.setSpacing(1)
3593+ buttonbarLayout.setContentsMargins(0, 0, 0, 0)
3594+ buttonbar = QFrame()
3595+ buttonbar.setContentsMargins(0, 0, 0, 0)
3596+ buttonbar.setLayout(buttonbarLayout)
3597+ return buttonbar
3598+
3599+ self.extrabuttonbars:list[QFrame] = [makeButtonbar() for _ in range(self.NUMBER_OF_EXTRABUTTON_ROWS)]
36653600
36663601 # set the focus on the main widget
36673602 self.main_widget.setFocus()
@@ -3951,27 +3886,9 @@ def __init__(self, parent:QWidget|None = None, *, locale:str, artisanviewerFirst
39513886 self.extrabuttonsLayout = QVBoxLayout()
39523887 self.extrabuttonsLayout.setContentsMargins(0,0,0,7)
39533888 self.extrabuttonsLayout.setSpacing(5)
3954- self.extrabuttonsLayout.addWidget(self.e1buttondialog)
3955- self.extrabuttonsLayout.addWidget(self.e2buttondialog)
3956- self.extrabuttonsLayout.addWidget(self.e3buttondialog)
3957- self.extrabuttonsLayout.addWidget(self.e4buttondialog)
3958- self.extrabuttonsLayout.addWidget(self.e5buttondialog)
3959- self.extrabuttonsLayout.addWidget(self.e6buttondialog)
3960- self.extrabuttonsLayout.addWidget(self.e7buttondialog)
3961- self.extrabuttonsLayout.addWidget(self.e8buttondialog)
3962- self.extrabuttonsLayout.addWidget(self.e9buttondialog)
3963- self.extrabuttonsLayout.addWidget(self.e10buttondialog)
3964-
3965- self.e1buttondialog.setVisible(False)
3966- self.e2buttondialog.setVisible(False)
3967- self.e3buttondialog.setVisible(False)
3968- self.e4buttondialog.setVisible(False)
3969- self.e5buttondialog.setVisible(False)
3970- self.e6buttondialog.setVisible(False)
3971- self.e7buttondialog.setVisible(False)
3972- self.e8buttondialog.setVisible(False)
3973- self.e9buttondialog.setVisible(False)
3974- self.e10buttondialog.setVisible(False)
3889+ for buttonbar in self.extrabuttonbars:
3890+ buttonbar.setVisible(False)
3891+ self.extrabuttonsLayout.addWidget(buttonbar)
39753892
39763893 self.extrabuttondialogs = QFrame()
39773894 self.extrabuttondialogs.setLayout(self.extrabuttonsLayout)
@@ -26838,43 +26755,18 @@ def substButtonLabel(self, buttonNr:int, label:str, eventtype:int, eventvalue:fl
2683826755 @pyqtSlot()
2683926756 def realignbuttons(self) -> None:
2684026757 #clear buttons
26841- self.clearBoxLayout(self.e1buttonbarLayout)
26842- self.clearBoxLayout(self.e2buttonbarLayout)
26843- self.clearBoxLayout(self.e3buttonbarLayout)
26844- self.clearBoxLayout(self.e4buttonbarLayout)
26845- self.clearBoxLayout(self.e5buttonbarLayout)
26846- self.clearBoxLayout(self.e6buttonbarLayout)
26847- self.clearBoxLayout(self.e7buttonbarLayout)
26848- self.clearBoxLayout(self.e8buttonbarLayout)
26849- self.clearBoxLayout(self.e9buttonbarLayout)
26850- self.clearBoxLayout(self.e10buttonbarLayout)
26758+ for buttonbar in self.extrabuttonbars:
26759+ buttondialogLayout = buttonbar.layout()
26760+ if buttondialogLayout is not None:
26761+ self.clearBoxLayout(buttondialogLayout)
26762+ #hide all extra button rows
26763+ buttonbar.setVisible(False)
2685126764
2685226765 self.extraeventbuttonround = []
2685326766
2685426767 self.buttonlist = []
2685526768 self.buttonStates = []
26856- #hide all extra button rows
26857- self.e1buttondialog.setVisible(False)
26858- self.e2buttondialog.setVisible(False)
26859- self.e3buttondialog.setVisible(False)
26860- self.e4buttondialog.setVisible(False)
26861- self.e5buttondialog.setVisible(False)
26862- self.e6buttondialog.setVisible(False)
26863- self.e7buttondialog.setVisible(False)
26864- self.e8buttondialog.setVisible(False)
26865- self.e9buttondialog.setVisible(False)
26866- self.e10buttondialog.setVisible(False)
26867-
26868- row1count = 0
26869- row2count = 0
26870- row3count = 0
26871- row4count = 0
26872- row5count = 0
26873- row6count = 0
26874- row7count = 0
26875- row8count = 0
26876- row9count = 0
26877- row10count = 0
26769+
2687826770
2687926771 # hidden buttons at the top of the table are for actions and don't count in the first row
2688026772 # find the index of the first visible button
@@ -26884,6 +26776,8 @@ def realignbuttons(self) -> None:
2688426776 first_visible_idx = i
2688526777 break
2688626778
26779+ rowcounts:list[int] = [0 for _ in range(len(self.extrabuttonbars))]
26780+
2688726781 for i, eet in enumerate(self.extraeventstypes):
2688826782 # next button in this group is hidden
2688926783 next_hidden = ((i - first_visible_idx)%self.buttonlistmaxlen < self.buttonlistmaxlen -1 and # at least one more places in the group
@@ -26935,99 +26829,24 @@ def realignbuttons(self) -> None:
2693526829 #add button to row
2693626830 if i < first_visible_idx:
2693726831 pass
26938- elif row1count < self.buttonlistmaxlen:
26939- self.e1buttonbarLayout.addWidget(self.buttonlist[i])
26940- if not self.extraeventsvisibility[i]:
26941- self.e1buttonbarLayout.addSpacing(5)
26942- row1count += 1
26943- elif row2count < self.buttonlistmaxlen:
26944- self.e2buttonbarLayout.addWidget(self.buttonlist[i])
26945- if not self.extraeventsvisibility[i]:
26946- self.e2buttonbarLayout.addSpacing(5)
26947- row2count += 1
26948- elif row3count < self.buttonlistmaxlen:
26949- self.e3buttonbarLayout.addWidget(self.buttonlist[i])
26950- if not self.extraeventsvisibility[i]:
26951- self.e3buttonbarLayout.addSpacing(5)
26952- row3count += 1
26953- elif row4count < self.buttonlistmaxlen:
26954- self.e4buttonbarLayout.addWidget(self.buttonlist[i])
26955- if not self.extraeventsvisibility[i]:
26956- self.e4buttonbarLayout.addSpacing(5)
26957- row4count += 1
26958- elif row5count < self.buttonlistmaxlen:
26959- self.e5buttonbarLayout.addWidget(self.buttonlist[i])
26960- if not self.extraeventsvisibility[i]:
26961- self.e5buttonbarLayout.addSpacing(5)
26962- row5count += 1
26963- elif row6count < self.buttonlistmaxlen:
26964- self.e6buttonbarLayout.addWidget(self.buttonlist[i])
26965- if not self.extraeventsvisibility[i]:
26966- self.e6buttonbarLayout.addSpacing(5)
26967- row6count += 1
26968- elif row7count < self.buttonlistmaxlen:
26969- self.e7buttonbarLayout.addWidget(self.buttonlist[i])
26970- if not self.extraeventsvisibility[i]:
26971- self.e7buttonbarLayout.addSpacing(5)
26972- row7count += 1
26973- elif row8count < self.buttonlistmaxlen:
26974- self.e8buttonbarLayout.addWidget(self.buttonlist[i])
26975- if not self.extraeventsvisibility[i]:
26976- self.e8buttonbarLayout.addSpacing(5)
26977- row8count += 1
26978- elif row9count < self.buttonlistmaxlen:
26979- self.e9buttonbarLayout.addWidget(self.buttonlist[i])
26980- if not self.extraeventsvisibility[i]:
26981- self.e9buttonbarLayout.addSpacing(5)
26982- row9count += 1
2698326832 else:
26984- self.e10buttonbarLayout.addWidget(self.buttonlist[i])
26985- if not self.extraeventsvisibility[i]:
26986- self.e10buttonbarLayout.addSpacing(5)
26987- row10count += 1
26988- if row10count == self.buttonlistmaxlen:
26989- break
26833+ for j, rowcount in enumerate(rowcounts):
26834+ if rowcount < self.buttonlistmaxlen:
26835+ buttondialogLayout = self.extrabuttonbars[j].layout()
26836+ if buttondialogLayout is not None and isinstance(buttondialogLayout, QHBoxLayout):
26837+ buttondialogLayout.addWidget(self.buttonlist[i])
26838+ if not self.extraeventsvisibility[i]:
26839+ buttondialogLayout.addSpacing(5)
26840+ rowcounts[j] += 1
26841+ break
26842+
26843+ for buttondialog in self.extrabuttonbars:
26844+ buttondialogLayout = buttondialog.layout()
26845+ if buttondialogLayout is not None and isinstance(buttondialogLayout, QHBoxLayout) and buttondialogLayout.count() > 0:
26846+ buttondialog.setVisible(True)
26847+ buttondialogLayout.insertStretch(0)
26848+ buttondialogLayout.insertStretch(buttondialogLayout.count())
2699026849
26991- if self.e1buttonbarLayout.count() > 0:
26992- self.e1buttondialog.setVisible(True)
26993- self.e1buttonbarLayout.insertStretch(0)
26994- self.e1buttonbarLayout.insertStretch(self.e1buttonbarLayout.count())
26995- if self.e2buttonbarLayout.count() > 0:
26996- self.e2buttondialog.setVisible(True)
26997- self.e2buttonbarLayout.insertStretch(0)
26998- self.e2buttonbarLayout.insertStretch(self.e2buttonbarLayout.count())
26999- if self.e3buttonbarLayout.count() > 0:
27000- self.e3buttondialog.setVisible(True)
27001- self.e3buttonbarLayout.insertStretch(0)
27002- self.e3buttonbarLayout.insertStretch(self.e3buttonbarLayout.count())
27003- if self.e4buttonbarLayout.count() > 0:
27004- self.e4buttondialog.setVisible(True)
27005- self.e4buttonbarLayout.insertStretch(0)
27006- self.e4buttonbarLayout.insertStretch(self.e4buttonbarLayout.count())
27007- if self.e5buttonbarLayout.count() > 0:
27008- self.e5buttondialog.setVisible(True)
27009- self.e5buttonbarLayout.insertStretch(0)
27010- self.e5buttonbarLayout.insertStretch(self.e5buttonbarLayout.count())
27011- if self.e6buttonbarLayout.count() > 0:
27012- self.e6buttondialog.setVisible(True)
27013- self.e6buttonbarLayout.insertStretch(0)
27014- self.e6buttonbarLayout.insertStretch(self.e6buttonbarLayout.count())
27015- if self.e7buttonbarLayout.count() > 0:
27016- self.e7buttondialog.setVisible(True)
27017- self.e7buttonbarLayout.insertStretch(0)
27018- self.e7buttonbarLayout.insertStretch(self.e7buttonbarLayout.count())
27019- if self.e8buttonbarLayout.count() > 0:
27020- self.e8buttondialog.setVisible(True)
27021- self.e8buttonbarLayout.insertStretch(0)
27022- self.e8buttonbarLayout.insertStretch(self.e8buttonbarLayout.count())
27023- if self.e9buttonbarLayout.count() > 0:
27024- self.e9buttondialog.setVisible(True)
27025- self.e9buttonbarLayout.insertStretch(0)
27026- self.e9buttonbarLayout.insertStretch(self.e9buttonbarLayout.count())
27027- if self.e10buttonbarLayout.count() > 0:
27028- self.e10buttondialog.setVisible(True)
27029- self.e10buttonbarLayout.insertStretch(0)
27030- self.e10buttonbarLayout.insertStretch(self.e10buttonbarLayout.count())
2703126850 self.settooltip()
2703226851 if self.app.artisanviewerMode:
2703326852 self.buttonsAction.setEnabled(False)
0 commit comments