Skip to content

Commit 34fb8d8

Browse files
committed
qtplasmac: disable tabs by hiding them
Originally the tabs were disabled, however the interlocking interferes with this, so we are now disabling them by hiding them instead.
1 parent 4840684 commit 34fb8d8

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

share/qtvcp/screens/qtplasmac/qtplasmac_handler.py

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def initialized__(self):
338338
self.set_mode()
339339
self.user_button_setup()
340340
self.set_buttons_state([self.estopOnList], True)
341+
self.get_main_tab_widgets()
341342
self.check_material_file()
342343
self.load_materials()
343344
self.offset_peripherals()
@@ -2241,24 +2242,6 @@ def chk_override_limits_changed(self, state):
22412242
if state:
22422243
ACTION.TOGGLE_LIMITS_OVERRIDE()
22432244

2244-
def param_tab_changed(self, state):
2245-
if state:
2246-
self.w.main_tab_widget.setTabEnabled(2, False)
2247-
else:
2248-
self.w.main_tab_widget.setTabEnabled(2, True)
2249-
2250-
def settings_tab_changed(self, state):
2251-
if state:
2252-
self.w.main_tab_widget.setTabEnabled(3, False)
2253-
else:
2254-
self.w.main_tab_widget.setTabEnabled(3, True)
2255-
2256-
def conv_tab_changed(self, state):
2257-
if state:
2258-
self.w.main_tab_widget.setTabEnabled(1, False)
2259-
else:
2260-
self.w.main_tab_widget.setTabEnabled(1, True)
2261-
22622245
def save_shutdown_message_clicked(self):
22632246
self.PREFS.putpref('Exit warning text', self.w.sd_text.text(), str, 'GUI_OPTIONS')
22642247
self.exitMessage = self.w.sd_text.text()
@@ -2421,6 +2404,32 @@ def wcs_rotation(self, wcs):
24212404
self.w.gcodegraphics.set_current_view()
24222405
ACTION.SET_MANUAL_MODE()
24232406

2407+
2408+
def get_main_tab_widgets(self):
2409+
# 1 of 2 this is a work around for pyqt5.11 not having setTabVisible(index, bool) that is present in pyqt5.15
2410+
self.widgetMain = self.w.main_tab_widget.findChild(QWidget, 'main_tab')
2411+
self.widgetConversational = self.w.main_tab_widget.findChild(QWidget, 'conv_tab')
2412+
self.widgetParameters = self.w.main_tab_widget.findChild(QWidget, 'param_tab')
2413+
self.widgetSettings = self.w.main_tab_widget.findChild(QWidget, 'settings_tab')
2414+
self.widgetStatistics = self.w.main_tab_widget.findChild(QWidget, 'stats_tab')
2415+
2416+
def disable_tabs(self):
2417+
# remove all tabs, then add them back based on their pin state (this keeps them in order)
2418+
# 2 of 2 this is a work around for pyqt5.11 not having setTabVisible(index, bool) that is present in pyqt5.15
2419+
while self.w.main_tab_widget.count() > 1:
2420+
self.w.main_tab_widget.removeTab(1)
2421+
if not self.convTabDisable.get():
2422+
self.w.main_tab_widget.insertTab(1, self.widgetConversational, 'CONVERSATIONAL')
2423+
if not self.paramTabDisable.get():
2424+
self.w.main_tab_widget.insertTab(2, self.widgetParameters, 'PARAMETERS')
2425+
if not self.settingsTabDisable.get():
2426+
self.w.main_tab_widget.insertTab(3, self.widgetSettings, 'SETTINGS')
2427+
self.w.main_tab_widget.insertTab(4, self.widgetStatistics, 'STATISTICS')
2428+
# reorder the indexes to account for any missing tabs, any missing will be -1 (which doesn't matter)
2429+
self.CONVERSATIONAL = self.w.main_tab_widget.indexOf(self.widgetConversational)
2430+
self.PARAMETERS = self.w.main_tab_widget.indexOf(self.widgetParameters)
2431+
self.SETTINGS = self.w.main_tab_widget.indexOf(self.widgetSettings)
2432+
self.STATISTICS = self.w.main_tab_widget.indexOf(self.widgetStatistics)
24242433
def set_buttons_state(self, buttonLists, state):
24252434
for buttonList in buttonLists:
24262435
for button in buttonList:
@@ -2755,9 +2764,9 @@ def set_signal_connections(self):
27552764
self.w.feed_label.pressed.connect(self.feed_label_pressed)
27562765
self.w.rapid_label.pressed.connect(self.rapid_label_pressed)
27572766
self.w.jogs_label.pressed.connect(self.jogs_label_pressed)
2758-
self.paramTabDisable.value_changed.connect(lambda v:self.param_tab_changed(v))
2759-
self.settingsTabDisable.value_changed.connect(lambda v:self.settings_tab_changed(v))
2760-
self.convTabDisable.value_changed.connect(lambda v:self.conv_tab_changed(v))
2767+
self.paramTabDisable.value_changed.connect(self.disable_tabs)
2768+
self.settingsTabDisable.value_changed.connect(self.disable_tabs)
2769+
self.convTabDisable.value_changed.connect(self.disable_tabs)
27612770
self.w.cut_time_reset.pressed.connect(lambda:self.statistic_reset('cut_time', 'Cut time'))
27622771
self.w.probe_time_reset.pressed.connect(lambda:self.statistic_reset('probe_time', 'Probe time'))
27632772
self.w.paused_time_reset.pressed.connect(lambda:self.statistic_reset('paused_time', 'Paused time'))

0 commit comments

Comments
 (0)