Skip to content

Commit 889247b

Browse files
committed
qtvcp gcode_display: add preference for last view
Will automatically show last view (when last closed)
1 parent 5c96036 commit 889247b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/python/qtvcp/widgets/gcode_graphics.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ def _hal_init(self):
115115
lon = self.PREFS_.getpref(self.HAL_NAME_+'-user-lon', lon, float, 'SCREEN_CONTROL_LAST_SETTING')
116116
self.presetViewSettings(v,z,x,y,lat,lon)
117117

118-
# when qtvcp closes this gets called
118+
self.set_preferred_view()
119+
120+
# when qtvcp closes, this gets called
119121
def _hal_cleanup(self):
120122
if self.PREFS_:
121123
v,z,x,y,lat,lon = self.getRecordedViewSettings()
@@ -126,6 +128,15 @@ def _hal_cleanup(self):
126128
self.PREFS_.putpref(self.HAL_NAME_+'-user-pany', y, float, 'SCREEN_CONTROL_LAST_SETTING')
127129
self.PREFS_.putpref(self.HAL_NAME_+'-user-lat', lat, float, 'SCREEN_CONTROL_LAST_SETTING')
128130
self.PREFS_.putpref(self.HAL_NAME_+'-user-lon', lon, float, 'SCREEN_CONTROL_LAST_SETTING')
131+
self.PREFS_.putpref(self.HAL_NAME_+'-current-view', self.get_current_view(), str, 'SCREEN_CONTROL_LAST_SETTING')
132+
133+
def set_preferred_view(self):
134+
if self.PREFS_:
135+
view = self.PREFS_.getpref(self.HAL_NAME_+'-current-view', 'p', str, 'SCREEN_CONTROL_LAST_SETTING')
136+
# set graphics view variable
137+
self.current_view = view
138+
# tell any other interested widgets that the view changed
139+
STATUS.emit('graphics-view-changed', self.current_view, None)
129140

130141
# external source asked for highlight,
131142
# make sure we block the propagation

0 commit comments

Comments
 (0)