feat: add keyboard to keypad switchs to macro panel
This commit is contained in:
@@ -209,7 +209,7 @@ class Keyboard(Gtk.Box):
|
|||||||
if key == "⌫":
|
if key == "⌫":
|
||||||
Gtk.Entry.do_backspace(self.entry)
|
Gtk.Entry.do_backspace(self.entry)
|
||||||
elif key == "↓":
|
elif key == "↓":
|
||||||
self.close_cb()
|
self.close_cb(entry=self.entry)
|
||||||
return
|
return
|
||||||
elif key == "↑":
|
elif key == "↑":
|
||||||
self.toggle_shift()
|
self.toggle_shift()
|
||||||
|
@@ -86,18 +86,40 @@ class Panel(ScreenPanel):
|
|||||||
if result:
|
if result:
|
||||||
result = result.groupdict()
|
result = result.groupdict()
|
||||||
default = result["default"] if "default" in result else ""
|
default = result["default"] if "default" in result else ""
|
||||||
entry = Gtk.Entry(placeholder_text=default)
|
entry = Gtk.Entry(placeholder_text=default, input_purpose=Gtk.InputPurpose.ALPHA)
|
||||||
|
icon = self._gtk.PixbufFromIcon("hashtag")
|
||||||
|
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
|
||||||
|
entry.connect("icon-press", self.on_icon_pressed)
|
||||||
self.macros[macro]["params"].update({result["param"]: entry})
|
self.macros[macro]["params"].update({result["param"]: entry})
|
||||||
|
|
||||||
for param in self.macros[macro]["params"]:
|
for param in self.macros[macro]["params"]:
|
||||||
labels.add(Gtk.Label(param))
|
labels.add(Gtk.Label(param))
|
||||||
self.macros[macro]["params"][param].connect("focus-in-event", self._screen.show_keyboard)
|
self.macros[macro]["params"][param].connect("focus-in-event", self._screen.show_keyboard)
|
||||||
|
self.macros[macro]["params"][param].connect("focus-in-event", self.scroll_to_entry)
|
||||||
self.macros[macro]["params"][param].connect("focus-out-event", self._screen.remove_keyboard)
|
self.macros[macro]["params"][param].connect("focus-out-event", self._screen.remove_keyboard)
|
||||||
labels.add(self.macros[macro]["params"][param])
|
labels.add(self.macros[macro]["params"][param])
|
||||||
|
|
||||||
|
def scroll_to_entry(self, entry, event):
|
||||||
|
self.labels['macros_list'].get_vadjustment().set_value(
|
||||||
|
entry.get_allocation().y - 50
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_icon_pressed(self, entry, icon_pos, event):
|
||||||
|
entry.grab_focus()
|
||||||
|
self._screen.remove_keyboard()
|
||||||
|
if entry.get_input_purpose() == Gtk.InputPurpose.ALPHA:
|
||||||
|
entry.set_input_purpose(Gtk.InputPurpose.DIGITS)
|
||||||
|
entry.get_style_context().add_class("active")
|
||||||
|
else:
|
||||||
|
entry.set_input_purpose(Gtk.InputPurpose.ALPHA)
|
||||||
|
entry.get_style_context().remove_class("active")
|
||||||
|
self._screen.show_keyboard(entry)
|
||||||
|
|
||||||
def run_gcode_macro(self, widget, macro):
|
def run_gcode_macro(self, widget, macro):
|
||||||
params = ""
|
params = ""
|
||||||
for param in self.macros[macro]["params"]:
|
for param in self.macros[macro]["params"]:
|
||||||
|
self.macros[macro]["params"][param].set_sensitive(False) # Move focus to prevent
|
||||||
|
self.macros[macro]["params"][param].set_sensitive(True) # reopening the osk
|
||||||
value = self.macros[macro]["params"][param].get_text()
|
value = self.macros[macro]["params"][param].get_text()
|
||||||
if value:
|
if value:
|
||||||
if re.findall(r'[G|M]\d{1,3}', macro):
|
if re.findall(r'[G|M]\d{1,3}', macro):
|
||||||
|
@@ -1207,13 +1207,16 @@ class KlipperScreen(Gtk.Window):
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
def remove_keyboard(self, widget=None, event=None):
|
def remove_keyboard(self, entry=None, event=None):
|
||||||
if self.keyboard is None:
|
if self.keyboard is None:
|
||||||
return
|
return
|
||||||
if 'process' in self.keyboard:
|
if 'process' in self.keyboard:
|
||||||
os.kill(self.keyboard['process'].pid, SIGTERM)
|
os.kill(self.keyboard['process'].pid, SIGTERM)
|
||||||
self.base_panel.content.remove(self.keyboard['box'])
|
self.base_panel.content.remove(self.keyboard['box'])
|
||||||
self.keyboard = None
|
self.keyboard = None
|
||||||
|
if entry:
|
||||||
|
entry.set_sensitive(False) # Move the focus
|
||||||
|
entry.set_sensitive(True)
|
||||||
|
|
||||||
def _key_press_event(self, widget, event):
|
def _key_press_event(self, widget, event):
|
||||||
keyval_name = Gdk.keyval_name(event.keyval)
|
keyval_name = Gdk.keyval_name(event.keyval)
|
||||||
|
@@ -73,6 +73,7 @@ button {
|
|||||||
-gtk-icon-shadow: none;
|
-gtk-icon-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button:active,
|
button:active,
|
||||||
.button_active,
|
.button_active,
|
||||||
button.active {
|
button.active {
|
||||||
@@ -166,6 +167,13 @@ entry {
|
|||||||
background-color: @active;
|
background-color: @active;
|
||||||
border: .2em solid @bg;
|
border: .2em solid @bg;
|
||||||
padding: .2em;
|
padding: .2em;
|
||||||
|
margin-right: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry image {
|
||||||
|
margin: 0 .1em;
|
||||||
|
border-radius: 1em;
|
||||||
|
padding: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
@@ -32,6 +32,7 @@ button {
|
|||||||
background-color: @solarized-base03;
|
background-color: @solarized-base03;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button:active {
|
button:active {
|
||||||
background-color: @solarized-orange;
|
background-color: @solarized-orange;
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,7 @@ button.color4 {
|
|||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button.color1:active,
|
button.color1:active,
|
||||||
button.color2:active,
|
button.color2:active,
|
||||||
button.color3:active,
|
button.color3:active,
|
||||||
|
@@ -66,6 +66,7 @@ button.invalid:active,
|
|||||||
background-color: #424242;
|
background-color: #424242;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button.update {
|
button.update {
|
||||||
color: #2196f3;
|
color: #2196f3;
|
||||||
background-color: #121212;
|
background-color: #121212;
|
||||||
|
@@ -31,6 +31,7 @@ button label{
|
|||||||
color: @text;
|
color: @text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button:active {
|
button:active {
|
||||||
background-color: @active;
|
background-color: @active;
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,7 @@ button.active {
|
|||||||
background-color: @active;
|
background-color: @active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active image,
|
||||||
button.update {
|
button.update {
|
||||||
background: @color3;
|
background: @color3;
|
||||||
border-color: @color3;
|
border-color: @color3;
|
||||||
|
Reference in New Issue
Block a user