mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-18 12:16:33 -04:00
account home in history
This commit is contained in:
parent
ca4cb615b0
commit
a441b81986
3 changed files with 22 additions and 39 deletions
|
@ -89,7 +89,7 @@ theme_override_fonts/font = ExtResource("1_o2a5w")
|
||||||
theme_override_font_sizes/font_size = 20
|
theme_override_font_sizes/font_size = 20
|
||||||
theme_override_styles/focus = SubResource("StyleBoxFlat_w0n18")
|
theme_override_styles/focus = SubResource("StyleBoxFlat_w0n18")
|
||||||
theme_override_styles/normal = SubResource("StyleBoxFlat_w0n18")
|
theme_override_styles/normal = SubResource("StyleBoxFlat_w0n18")
|
||||||
placeholder_text = "Search or type URL"
|
placeholder_text = "What are you looking for today?"
|
||||||
script = ExtResource("2_g181m")
|
script = ExtResource("2_g181m")
|
||||||
gate_events = ExtResource("3_bulmv")
|
gate_events = ExtResource("3_bulmv")
|
||||||
prompt_panel = NodePath("Prompt/Panel")
|
prompt_panel = NodePath("Prompt/Panel")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
class_name History
|
class_name History
|
||||||
|
|
||||||
var history: Array[String]
|
var history: Array[String] = [""]
|
||||||
var index := -1
|
var index := 0
|
||||||
|
|
||||||
|
|
||||||
func get_current() -> String:
|
func get_current() -> String:
|
||||||
|
@ -15,7 +15,7 @@ func can_forw() -> bool:
|
||||||
|
|
||||||
|
|
||||||
func can_back() -> bool:
|
func can_back() -> bool:
|
||||||
return index > -1
|
return index > 0
|
||||||
|
|
||||||
|
|
||||||
func add(url: String) -> void:
|
func add(url: String) -> void:
|
||||||
|
|
|
@ -12,65 +12,48 @@ extends Node
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
gate_events.open_gate.connect(on_new)
|
gate_events.open_gate.connect(on_new)
|
||||||
gate_events.search.connect(on_new)
|
gate_events.search.connect(on_new)
|
||||||
|
gate_events.exit_gate.connect(on_new.bind(""))
|
||||||
|
|
||||||
go_back.pressed.connect(on_go_back)
|
go_back.pressed.connect(on_go_back)
|
||||||
go_forw.pressed.connect(on_go_forw)
|
go_forw.pressed.connect(on_go_forw)
|
||||||
reload.pressed.connect(on_reload)
|
reload.pressed.connect(on_reload)
|
||||||
home.pressed.connect(on_home)
|
home.pressed.connect(gate_events.exit_gate_emit)
|
||||||
|
|
||||||
disable([go_back, go_forw, reload, home])
|
go_back.disable()
|
||||||
|
go_forw.disable()
|
||||||
|
|
||||||
|
|
||||||
func on_new(location: String) -> void:
|
func on_new(location: String) -> void:
|
||||||
history.add(location)
|
history.add(location)
|
||||||
enable([go_back, reload, home])
|
update_buttons()
|
||||||
if not history.can_forw():
|
|
||||||
disable([go_forw])
|
|
||||||
|
|
||||||
|
|
||||||
func on_go_back() -> void:
|
func on_go_back() -> void:
|
||||||
var location = history.back()
|
open(history.back())
|
||||||
|
update_buttons()
|
||||||
enable([go_forw])
|
|
||||||
if history.can_back():
|
|
||||||
open(location)
|
|
||||||
else:
|
|
||||||
disable([go_back, reload, home])
|
|
||||||
gate_events.exit_gate_emit()
|
|
||||||
|
|
||||||
|
|
||||||
func on_go_forw() -> void:
|
func on_go_forw() -> void:
|
||||||
var location = history.forw()
|
open(history.forw())
|
||||||
|
update_buttons()
|
||||||
enable([go_back])
|
|
||||||
if not history.can_forw():
|
|
||||||
disable([go_forw])
|
|
||||||
|
|
||||||
open(location)
|
|
||||||
|
|
||||||
|
|
||||||
func on_reload() -> void:
|
func on_reload() -> void:
|
||||||
open(history.get_current())
|
open(history.get_current())
|
||||||
|
|
||||||
|
|
||||||
func on_home() -> void:
|
|
||||||
history.clear()
|
|
||||||
disable([go_back, go_forw, reload, home])
|
|
||||||
gate_events.exit_gate_emit()
|
|
||||||
|
|
||||||
|
|
||||||
func open(location: String) -> void:
|
func open(location: String) -> void:
|
||||||
if Url.is_valid(location):
|
if location == "":
|
||||||
|
gate_events.exit_gate_emit()
|
||||||
|
elif Url.is_valid(location):
|
||||||
gate_events.open_gate_emit(location)
|
gate_events.open_gate_emit(location)
|
||||||
else:
|
else:
|
||||||
gate_events.search_emit(location)
|
gate_events.search_emit(location)
|
||||||
|
|
||||||
|
|
||||||
func disable(buttons: Array[RoundButton]) -> void:
|
func update_buttons() -> void:
|
||||||
for button in buttons:
|
if history.can_back(): go_back.enable()
|
||||||
button.disable()
|
else: go_back.disable()
|
||||||
|
|
||||||
|
if history.can_forw(): go_forw.enable()
|
||||||
func enable(buttons: Array[RoundButton]) -> void:
|
else: go_forw.disable()
|
||||||
for button in buttons:
|
|
||||||
button.enable()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue