From e1da318c748c75a6d42055382f68607e75bfff88 Mon Sep 17 00:00:00 2001 From: Hans Unzner Date: Fri, 29 Dec 2023 11:06:29 +0100 Subject: [PATCH] gmoccapy: add setting for smaller keyboard width --- src/emc/usr_intf/gmoccapy/gmoccapy.glade | 90 +++++++++++++++++---- src/emc/usr_intf/gmoccapy/gmoccapy.py | 86 +++++++++++++++----- src/emc/usr_intf/gmoccapy/release_notes.txt | 1 + 3 files changed, 138 insertions(+), 39 deletions(-) diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.glade b/src/emc/usr_intf/gmoccapy/gmoccapy.glade index 954bf7c4dbd..77ca26b140d 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.glade +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.glade @@ -35,6 +35,12 @@ 10 + + 2000 + 1 + 10 + + 1 25 @@ -3060,6 +3066,8 @@ True False + center + center True @@ -3490,42 +3498,90 @@ - + + True False - False - + True False - True - 5 - 5 + False + + + True + True + adj_kbd_height + 250 + + + True + True + 1 + + + + + 1 + 0 + + + + + True + False + False + + + True + True + 250 + adj_kbd_width + 500 + + + True + True + 1 + + + + + 1 + 1 + + + + Height - 0 + True + True + False + True + - False - True - 0 + 0 + 0 - + + Width True True - adj_kbd_height - 250 + False + True + - True - True - 1 + 0 + 1 - True + False True 5 diff --git a/src/emc/usr_intf/gmoccapy/gmoccapy.py b/src/emc/usr_intf/gmoccapy/gmoccapy.py index 68697b48d8a..ae82be614b8 100644 --- a/src/emc/usr_intf/gmoccapy/gmoccapy.py +++ b/src/emc/usr_intf/gmoccapy/gmoccapy.py @@ -592,6 +592,9 @@ def _get_pref_data(self): self.spindle_start_rpm = self.prefs.getpref( 'spindle_start_rpm', default_spindle_speed, float ) self.kbd_height = self.prefs.getpref("kbd_height", 250, int) + self.kbd_width = self.prefs.getpref("kbd_width", 880, int) + self.kbd_set_height = self.prefs.getpref("kbd_set_height", False, bool) + self.kbd_set_width = self.prefs.getpref("kbd_set_width", False, bool) ############################################################################### ## create widgets dynamically ## @@ -2317,7 +2320,6 @@ def _show_offset_tab(self, state): self.widgets.offsetpage1.mark_active((self.system_list[self.stat.g5x_index]).lower()) if self.widgets.chk_use_kb_on_offset.get_active(): self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) else: names = self.widgets.offsetpage1.get_names() for system, name in names: @@ -2328,7 +2330,6 @@ def _show_offset_tab(self, state): self.touch_button_dic["edit_offsets"].set_active(False) self.widgets.ntb_preview.set_current_page(0) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) if self.widgets.ntb_preview.get_n_pages() <= 4: # else user tabs are available self.widgets.ntb_preview.set_property("show-tabs", state) @@ -2344,7 +2345,6 @@ def _show_tooledit_tab(self, state): self.widgets.tooledit1.set_selected_tool(self.stat.tool_in_spindle) if self.widgets.chk_use_kb_on_tooledit.get_active(): self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) else: page.hide() if self.widgets.ntb_preview.get_n_pages() > 4: # user tabs are available @@ -2352,7 +2352,6 @@ def _show_tooledit_tab(self, state): self.widgets.vbx_jog.show() self.widgets.ntb_preview.set_current_page(0) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) def _show_iconview_tab(self, state): page = self.widgets.ntb_preview.get_nth_page(3) @@ -2365,14 +2364,12 @@ def _show_iconview_tab(self, state): if self.widgets.chk_use_kb_on_file_selection.get_active(): self.widgets.box_info.show() self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) else: page.hide() if self.widgets.ntb_preview.get_n_pages() > 4: # user tabs are available self.widgets.ntb_preview.set_property("show-tabs", not state) self.widgets.ntb_preview.set_current_page(0) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) # every 100 milli seconds this gets called # check linuxcnc for status, error and then update the readout @@ -2680,7 +2677,6 @@ def on_hal_status_state_off(self, widget): self.widgets.ntb_main.set_current_page(0) self.widgets.ntb_button.set_current_page(_BB_MANUAL) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_jog.set_current_page(0) def on_hal_status_state_on(self, widget): @@ -2732,10 +2728,8 @@ def on_hal_status_mode_manual(self, widget): if self.widgets.tbtn_user_tabs.get_active(): self.widgets.tbtn_user_tabs.set_active(False) self.widgets.ntb_main.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_button.set_current_page(_BB_MANUAL) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_jog.set_current_page(0) # if the status changed, we reset the key event, otherwise the key press @@ -2760,7 +2754,6 @@ def on_hal_status_mode_mdi(self, widget): self.widgets.ntb_main.set_current_page(0) self.widgets.ntb_button.set_current_page(_BB_MANUAL) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_jog.set_current_page(0) return @@ -2779,10 +2772,8 @@ def on_hal_status_mode_mdi(self, widget): self.widgets.tbtn_user_tabs.set_active(False) if self.widgets.chk_use_kb_on_mdi.get_active(): self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) else: self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_main.set_current_page(0) self.widgets.ntb_button.set_current_page(_BB_MDI) self.widgets.ntb_jog.set_current_page(1) @@ -2812,7 +2803,6 @@ def on_hal_status_mode_auto(self, widget): if self.widgets.tbtn_user_tabs.get_active(): self.widgets.tbtn_user_tabs.set_active(False) self.widgets.ntb_main.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_button.set_current_page(_BB_AUTO) self.widgets.ntb_info.set_current_page(0) self.widgets.ntb_jog.set_current_page(2) @@ -2937,11 +2927,17 @@ def on_window1_show(self, widget, data=None): self.widgets.adj_y_pos.set_value(self.ypos) self.widgets.adj_width.set_value(self.width) self.widgets.adj_height.set_value(self.height) - self.widgets.adj_kbd_height.set_value(self.kbd_height) - # move and resize the window self.widgets.window1.move(self.xpos, self.ypos) self.widgets.window1.resize(self.width, self.height) + + # keyboard size + self.widgets.chk_kbd_set_height.set_active(self.kbd_set_height) + self.widgets.chk_kbd_set_width.set_active(self.kbd_set_width) + self.widgets.adj_kbd_height.set_value(self.kbd_height) + self.widgets.adj_kbd_width.set_value(self.kbd_width) + self._update_kbd_height(self.kbd_set_height) + self._update_kbd_width(self.kbd_set_width) # set initial state of widgets self.touch_button_dic["set_active"].set_sensitive(False) @@ -3010,7 +3006,6 @@ def _on_btn_macro_pressed( self, widget = None, data = None ): if not self.onboard: self.macro_dic["keyboard"].set_sensitive(True) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) # helpers functions start # ========================================================= @@ -3813,7 +3808,6 @@ def on_tbtn_setup_toggled(self, widget, data=None): self.widgets.ntb_main.set_current_page(0) self.widgets.ntb_button.set_current_page(_BB_MANUAL) self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) self.widgets.ntb_jog.set_current_page(0) else: # restore mode @@ -4190,10 +4184,8 @@ def on_btn_show_kbd_clicked(self, widget): self.macro_dic["keyboard"].set_sensitive(False) elif self.widgets.ntb_info.get_current_page() == 1: self.widgets.ntb_info.set_current_page(0) - self.widgets.ntb_info.set_size_request(-1, -1) else: self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) # special case if we are in edit mode if self.widgets.ntb_button.get_current_page() == _BB_EDIT: @@ -4280,7 +4272,6 @@ def on_tbtn_edit_offsets_toggled(self, widget, data=None): # show virtual keyboard? if state and self.widgets.chk_use_kb_on_offset.get_active(): self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) self.widgets.ntb_preview.set_current_page(1) def on_btn_zero_g92_clicked(self, widget, data=None): @@ -4725,6 +4716,57 @@ def on_adj_kbd_height_value_changed(self, widget, data=None): value = int(widget.get_value()) self.prefs.putpref("kbd_height", value, int) self.kbd_height = value + self._update_kbd_height(self.kbd_set_height) + + def on_adj_kbd_width_value_changed(self, widget, data=None): + if not self.initialized: + return + value = int(widget.get_value()) + self.prefs.putpref("kbd_width", value, int) + self.kbd_width = value + self._update_kbd_width(self.kbd_set_width) + + def _update_kbd_height(self, seth): + if seth: + self.widgets.box_kbd_height.set_sensitive(True) + self.widgets.key_box.set_valign(Gtk.Align.CENTER) + if self.kbd_set_width: + self.widgets.key_box.set_size_request(self.kbd_width, self.kbd_height) + else: + self.widgets.key_box.set_size_request(-1, self.kbd_height) + else: + self.widgets.box_kbd_height.set_sensitive(False) + self.widgets.key_box.set_valign(Gtk.Align.FILL) + if self.kbd_set_width: + self.widgets.key_box.set_size_request(self.kbd_width, -1) + else: + self.widgets.key_box.set_size_request(-1, -1) + self.prefs.putpref("kbd_set_height", seth, bool) + + def _update_kbd_width(self, setw): + if setw: + self.widgets.box_kbd_width.set_sensitive(True) + self.widgets.key_box.set_halign(Gtk.Align.CENTER) + if self.kbd_set_height: + self.widgets.key_box.set_size_request(self.kbd_width, self.kbd_height) + else: + self.widgets.key_box.set_size_request(self.kbd_width, -1) + else: + self.widgets.box_kbd_width.set_sensitive(False) + self.widgets.key_box.set_halign(Gtk.Align.FILL) + if self.kbd_set_height: + self.widgets.key_box.set_size_request(-1, self.kbd_height) + else: + self.widgets.key_box.set_size_request(-1, -1) + self.prefs.putpref("kbd_set_width", setw, bool) + + def on_chk_kb_set_height_toggled(self, widget): + self.kbd_set_height = widget.get_active() + self._update_kbd_height(self.kbd_set_height) + + def on_chk_kb_set_width_toggled(self, widget): + self.kbd_set_width = widget.get_active() + self._update_kbd_width(self.kbd_set_width) def on_adj_dro_size_value_changed(self, widget, data=None): value = int(widget.get_value()) @@ -5153,10 +5195,10 @@ def on_btn_edit_clicked(self, widget, data=None): self.widgets.gcode_view.grab_focus() if self.widgets.chk_use_kb_on_edit.get_active(): self.widgets.ntb_info.set_current_page(1) - self.widgets.ntb_info.set_size_request(-1, self.kbd_height) + else: self.widgets.ntb_info.hide() - self.widgets.ntb_info.set_size_request(-1, -1) + self.widgets.grid_search.show() self.gcodeerror = "" self.file_changed = False diff --git a/src/emc/usr_intf/gmoccapy/release_notes.txt b/src/emc/usr_intf/gmoccapy/release_notes.txt index 8e91f1c0aa0..c0e7d1fd211 100644 --- a/src/emc/usr_intf/gmoccapy/release_notes.txt +++ b/src/emc/usr_intf/gmoccapy/release_notes.txt @@ -1,4 +1,5 @@ ver 3.4.7 + - Added setting to allow smaller width of virtual keyboard (for widescreens) - Fixed box_dro_side is displayed in the G-code editor (#2627) - Fixed error on error message when sound is not available (reported on Raspberry Pi) - Fixed increasing of window size when clicking edit button