优化界面断开连接时隐藏侧边栏
This commit is contained in:
@@ -30,11 +30,12 @@ class BasePanel(ScreenPanel):
|
|||||||
self.control['back'].set_no_show_all(True)
|
self.control['back'].set_no_show_all(True)
|
||||||
self.control['home'] = self._gtk.Button('main', scale=abscale)
|
self.control['home'] = self._gtk.Button('main', scale=abscale)
|
||||||
self.control['home'].connect("clicked", self._screen._menu_go_back, True)
|
self.control['home'].connect("clicked", self._screen._menu_go_back, True)
|
||||||
|
self.control['home'].set_no_show_all(True)
|
||||||
self.move = {
|
self.move = {
|
||||||
"panel": "move",
|
"panel": "move",
|
||||||
}
|
}
|
||||||
self.control['move'] = self._gtk.Button('move', scale=abscale)
|
self.control['move'] = self._gtk.Button('move', scale=abscale)
|
||||||
self.control['move'].connect("clicked", self.menu_item_clicked, self.move)
|
self.control['move'].connect("clicked", self.menu_item_clicked, self.move)
|
||||||
self.control['move'].set_no_show_all(True)
|
self.control['move'].set_no_show_all(True)
|
||||||
self.extrude = {
|
self.extrude = {
|
||||||
"panel": "extrude",
|
"panel": "extrude",
|
||||||
@@ -82,7 +83,6 @@ class BasePanel(ScreenPanel):
|
|||||||
self.action_bar.set_hexpand(False)
|
self.action_bar.set_hexpand(False)
|
||||||
self.action_bar.set_vexpand(True)
|
self.action_bar.set_vexpand(True)
|
||||||
self.action_bar.get_style_context().add_class('action_bar')
|
self.action_bar.get_style_context().add_class('action_bar')
|
||||||
self.action_bar.set_size_request(self._gtk.action_bar_width, self._gtk.action_bar_height)
|
|
||||||
self.action_bar.add(self.control['back'])
|
self.action_bar.add(self.control['back'])
|
||||||
self.action_bar.add(self.control['home'])
|
self.action_bar.add(self.control['home'])
|
||||||
self.action_bar.add(self.control['move'])
|
self.action_bar.add(self.control['move'])
|
||||||
@@ -229,10 +229,15 @@ class BasePanel(ScreenPanel):
|
|||||||
panels_has_back = ['gcodes', 'temperature']
|
panels_has_back = ['gcodes', 'temperature']
|
||||||
cur_panel_count = len(self._screen._cur_panels)
|
cur_panel_count = len(self._screen._cur_panels)
|
||||||
is_last_panel_in_back_list = self._screen._cur_panels[-1] in panels_has_back
|
is_last_panel_in_back_list = self._screen._cur_panels[-1] in panels_has_back
|
||||||
if cur_panel_count > 2 or is_last_panel_in_back_list:
|
|
||||||
self.control['back'].set_visible(True)
|
should_show_back = (cur_panel_count > 2 or is_last_panel_in_back_list or
|
||||||
|
(self._screen._cur_panels[0] != 'main_menu' and cur_panel_count >= 2))
|
||||||
|
self.control['back'].set_visible(should_show_back)
|
||||||
|
if any(child.get_visible() for child in self.action_bar.get_children()):
|
||||||
|
self.show_action_bar()
|
||||||
else:
|
else:
|
||||||
self.control['back'].set_visible(False)
|
self.hide_action_bar()
|
||||||
|
|
||||||
self.current_panel = panel
|
self.current_panel = panel
|
||||||
self.set_title(panel.title)
|
self.set_title(panel.title)
|
||||||
self.content.add(panel.content)
|
self.content.add(panel.content)
|
||||||
@@ -321,7 +326,7 @@ class BasePanel(ScreenPanel):
|
|||||||
|
|
||||||
def set_control_sensitive(self, value=True, control='home'):
|
def set_control_sensitive(self, value=True, control='home'):
|
||||||
self.control[control].set_sensitive(value)
|
self.control[control].set_sensitive(value)
|
||||||
|
|
||||||
def show_shortcut(self, show=True):
|
def show_shortcut(self, show=True):
|
||||||
show = (
|
show = (
|
||||||
show
|
show
|
||||||
@@ -335,6 +340,14 @@ class BasePanel(ScreenPanel):
|
|||||||
self.set_control_sensitive(self._screen._cur_panels[-1] != self.files['panel'], control='files')
|
self.set_control_sensitive(self._screen._cur_panels[-1] != self.files['panel'], control='files')
|
||||||
self.set_control_sensitive(self._screen._cur_panels[-1] != self.more['panel'], control='more')
|
self.set_control_sensitive(self._screen._cur_panels[-1] != self.more['panel'], control='more')
|
||||||
|
|
||||||
|
def show_action_bar(self):
|
||||||
|
self.action_bar.set_size_request(self._gtk.action_bar_width, self._gtk.action_bar_height)
|
||||||
|
self.control['home'].set_visible(True)
|
||||||
|
|
||||||
|
def hide_action_bar(self):
|
||||||
|
self.action_bar.set_size_request(-1, -1)
|
||||||
|
self.control['home'].set_visible(False)
|
||||||
|
|
||||||
def show_printer_select(self, show=True):
|
def show_printer_select(self, show=True):
|
||||||
self.control['printer_select'].set_visible(
|
self.control['printer_select'].set_visible(
|
||||||
show and 'printer_select' not in self._screen._cur_panels
|
show and 'printer_select' not in self._screen._cur_panels
|
||||||
|
@@ -50,7 +50,7 @@ class Panel(ScreenPanel):
|
|||||||
scroll.add(self.labels["text"])
|
scroll.add(self.labels["text"])
|
||||||
|
|
||||||
info = Gtk.Box()
|
info = Gtk.Box()
|
||||||
info.pack_start(image, False, True, 8)
|
info.pack_start(image, False, True, 50)
|
||||||
info.pack_end(scroll, True, True, 8)
|
info.pack_end(scroll, True, True, 8)
|
||||||
|
|
||||||
main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
@@ -717,8 +717,9 @@ class KlipperScreen(Gtk.Window):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def show_printer_select(self, widget=None):
|
def show_printer_select(self, widget=None):
|
||||||
self.base_panel.show_heaters(False)
|
if 'printer_select' not in self._cur_panels:
|
||||||
self.show_panel("printer_select", remove_all=True)
|
self.base_panel.show_heaters(False)
|
||||||
|
self.show_panel("printer_select", remove_all=True)
|
||||||
|
|
||||||
def websocket_connection_cancel(self):
|
def websocket_connection_cancel(self):
|
||||||
self.printer_initializing(
|
self.printer_initializing(
|
||||||
@@ -938,7 +939,8 @@ class KlipperScreen(Gtk.Window):
|
|||||||
|
|
||||||
def printer_initializing(self, msg, go_to_splash=False):
|
def printer_initializing(self, msg, go_to_splash=False):
|
||||||
if 'splash_screen' not in self.panels or go_to_splash:
|
if 'splash_screen' not in self.panels or go_to_splash:
|
||||||
self.show_panel("splash_screen", remove_all=True)
|
if self._cur_panels != ['splash_screen']:
|
||||||
|
self.show_panel("splash_screen", remove_all=True)
|
||||||
self.panels['splash_screen'].update_text(msg)
|
self.panels['splash_screen'].update_text(msg)
|
||||||
self.log_notification(msg, 0)
|
self.log_notification(msg, 0)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user