diff --git a/ServerUI.gd b/ServerUI.gd index 31a265e..d4e19d2 100644 --- a/ServerUI.gd +++ b/ServerUI.gd @@ -24,6 +24,7 @@ onready var server_path_label := $"%ServerPathLabel" onready var port_spin_box := $"%PortSpinBox" onready var start_server_button := $"%StartServerButton" onready var server_status_label := $"%ServerStatusLabel" +onready var open_browser_button := $"%OpenBrowserButton" onready var document_title_lineedit := $"%DocTitleLineEdit" onready var document_date_lineedit := $"%DocDateLineEdit" @@ -160,6 +161,7 @@ func set_server_running(running: bool) -> void: document_date_lineedit.editable = !running document_title_lineedit.editable = !running document_input_textedit.readonly = running + open_browser_button.disabled = !running _set_file_tree_disabled(running) _set_context_menu_disabled(running) @@ -275,6 +277,11 @@ func _on_DocDateLineEdit_text_changed(new_text: String) -> void: current_file.date = new_text +func _on_OpenBrowserButton_pressed() -> void: + if OS.shell_open("http://localhost:%s" % port_spin_box.value) != OK: + push_error("Error opening browser!") # TODO: show a user-facing error + + func _on_DocInputTextEdit_text_changed() -> void: if current_file: var new_text: String = document_input_textedit.text