Skip to content

Commit b754ea1

Browse files
committed
bug fix: Button mapping failed under specific conditions
1 parent a749a06 commit b754ea1

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

modules/button_config.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,25 +217,24 @@ def press_button(self, button_hard, press_button, index):
217217

218218
w_index = self.config.gui.stack_widget.currentIndex()
219219
if w_index == 1:
220-
if (
221-
self.config.gui.main_page.widget(
222-
self.config.gui.main_page.currentIndex()
223-
)
224-
== self.config.gui.map_widget
225-
):
226-
if not self.G_BUTTON_MODE_IS_CHANGE:
227-
self.G_PAGE_MODE = "MAP"
228-
elif (
229-
self.config.gui.main_page.widget(
230-
self.config.gui.main_page.currentIndex()
231-
)
232-
== self.config.gui.course_profile_graph_widget
233-
):
234-
if not self.G_BUTTON_MODE_IS_CHANGE:
235-
self.G_PAGE_MODE = "COURSE_PROFILE"
220+
current_widget = self.config.gui.main_page.widget(
221+
self.config.gui.main_page.currentIndex()
222+
)
223+
if current_widget == self.config.gui.map_widget:
224+
mode_key = "MAP"
225+
elif current_widget == self.config.gui.course_profile_graph_widget:
226+
mode_key = "COURSE_PROFILE"
227+
else:
228+
mode_key = "MAIN"
229+
230+
pages = self.G_BUTTON_MODE_PAGES.get(mode_key)
231+
if pages:
232+
mode_index = self.G_BUTTON_MODE_INDEX.get(mode_key, 0)
233+
if mode_index < 0 or mode_index >= len(pages):
234+
mode_index = 0
235+
self.G_PAGE_MODE = pages[mode_index]
236236
else:
237-
if not self.G_BUTTON_MODE_IS_CHANGE:
238-
self.G_PAGE_MODE = "MAIN"
237+
self.G_PAGE_MODE = mode_key
239238
# for no implementation
240239
if self.G_PAGE_MODE not in self.G_BUTTON_DEF[button_hard]:
241240
self.G_PAGE_MODE = "MAIN"

0 commit comments

Comments
 (0)