aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-04-04 10:36:26 +0000
committerdam <dam@gudinoff>2022-04-04 10:36:26 +0000
commit0093ad0682e493e5f8115566f71c8cb8a2d7c0d9 (patch)
treebe31c34e5713427fa924e150fa1ceba2caeeb84c
parentf40df1987a35adbc234a1b04b018d92d420b1e92 (diff)
downloadsurgery-log-0093ad0682e493e5f8115566f71c8cb8a2d7c0d9.tar.zst
surgery-log-0093ad0682e493e5f8115566f71c8cb8a2d7c0d9.zip
Implement back button logic.
-rw-r--r--logic/database.gd13
-rw-r--r--logic/popup.gd4
-rw-r--r--main.gd17
-rw-r--r--readme.md3
4 files changed, 20 insertions, 17 deletions
diff --git a/logic/database.gd b/logic/database.gd
index ed39d43..ea27ef2 100644
--- a/logic/database.gd
+++ b/logic/database.gd
@@ -38,19 +38,6 @@ func _ready():
clear_selection()
-func _notification(what: int):
- # @DAM This code should be moved into the main.gd which should check which node was currently
- # active and above, and send the signal there.
- if visible == false || has_focus() == false:
- return
-
- if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
- if selected_idx >= 0:
- clear_selection()
- else:
- get_tree().quit()
-
-
func get_entry_view(database_entry: Dictionary) -> String:
return "%6s | %6s | %s" % [database_entry.process_id, database_entry.surgery_id, DatabaseEntry.get_entry_date(database_entry)]
diff --git a/logic/popup.gd b/logic/popup.gd
index 31897c7..d7c98f9 100644
--- a/logic/popup.gd
+++ b/logic/popup.gd
@@ -21,7 +21,7 @@ func _init():
func _ready():
- dismiss.connect("pressed", self, "_dismiss")
+ dismiss.connect("pressed", self, "dismiss")
func _clear_signals():
@@ -33,7 +33,7 @@ func _clear_signals():
disconnect(it.signal, it.target, it.method)
-func _dismiss():
+func dismiss():
emit_signal("dismissed")
close_popup()
diff --git a/main.gd b/main.gd
index 5612e01..ec449df 100644
--- a/main.gd
+++ b/main.gd
@@ -2,7 +2,10 @@ extends Control
var power_throttle_timeout: float
+onready var popup := get_node("/root/main/popup") as ModalPopup
onready var file_picker := get_node("/root/main/file_picker") as FileDialog
+onready var stage := get_node("/root/main/stage") as Stage
+onready var database := get_node("/root/main/database") as Database
onready var controls_sensible_to_keyboard := [
self,
file_picker,
@@ -46,3 +49,17 @@ func _unhandled_input(event: InputEvent):
power_throttle_timeout = 3.5
+func _notification(what: int):
+ if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
+ if popup.visible:
+ popup.call_deferred("dismiss")
+ elif file_picker.visible:
+ file_picker.hide()
+ elif stage.visible:
+ stage.discard_action()
+ elif database.selected_idx != -1:
+ database.clear_selection()
+ else:
+ get_tree().quit()
+
+
diff --git a/readme.md b/readme.md
index 56f2021..646e94d 100644
--- a/readme.md
+++ b/readme.md
@@ -59,13 +59,12 @@ Surgery Log
- [x] Use popup to display confirmation messages;
- [x] Improve option sets: selecting outside optionset entry should select none; if no options are available, show nothing instead of "--";
- [x] Set stage discard/save buttons side by side;
-- [ ] Fix back button:
+- [x] Implement back button logic;
- on stage screen should show pop-up asking it changes are to be discarded;
- on file-pickers screen should close them;
- on about screen should close it;
- on auto-fill pop-up, should close it;
- on database screen, should deselect selected item, otherwise should quit the app;
- - on popup
- [ ] Improve appearance:
- [ ] database menu;
- [ ] database action buttons;