From 815aae5a4d06d840f6623d2cd5c81fe7e22d94da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Wed, 29 Jun 2022 16:22:53 +0300 Subject: [PATCH] implement open in browser button --- ServerUI.gd | 7 +++++++ 1 file changed, 7 insertions(+) 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