Skip to content

Commit

Permalink
add windows special characters warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Aug 14, 2024
1 parent e19a2cc commit efbb69c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
13 changes: 10 additions & 3 deletions app/src/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ const PDF_LINK_KEY: String = "pdf presentation"
@onready var result_container: VBoxContainer = $Result

@onready var errors: RichTextLabel = $Result/Errors
@onready var errors2: RichTextLabel = $Result/Errors2
@onready var log: RichTextLabel = $Result/Log

@onready var settings: VBoxContainer = $Settings
@onready var example: Label = $Settings/Example

@onready var time_checkbox: CheckBox = $Settings/PdfConfig/TimeCheckbox
@onready var title_checkbox: CheckBox = $Settings/PdfConfig/TitleCheckBox
@onready var regex_checkbox: CheckBox = $Settings/PdfConfig/RegexCheckbox
@onready var windows_warning = $Settings/WindowsWarning

@onready var submit: Button = $Settings/Submit

Expand Down Expand Up @@ -101,7 +102,9 @@ func _load_config() -> void:
pdf_path = config.get_value("settings", "pdf_path", "")
include_title = config.get_value("settings", "include_title", true)
include_time = config.get_value("settings", "include_time", true)
include_special_characters = config.get_value("settings", "include_special_characters", true)
include_special_characters = config.get_value("settings", "include_special_characters", false)

windows_warning.visible = OS.get_name() == "Windows" and include_special_characters


func _save_config(path: String) -> void:
Expand Down Expand Up @@ -235,12 +238,15 @@ func _request_completed(_result, _response_code, _headers, body: PackedByteArray
# remove new lines, double points and tabs
file_path = file_path.replace("..",".")
print(file_path)

log.append_text(str(counter_done + 1) + ") Saving: " + file_path + "\n")

var file:FileAccess = FileAccess.open(file_path, FileAccess.WRITE)
file.store_buffer(body)
file.flush()

if not FileAccess.file_exists(file_path):
errors2.append_text(str(errors2.get_line_count()) + ") " + file_path + "\n")
log.append_text(str(counter_done + 1) + ") " + file_path + "\n")
counter_done += 1


Expand Down Expand Up @@ -335,6 +341,7 @@ func _on_title_check_box_toggled(button_pressed) -> void:
func _on_regex_checkbox_toggled(button_pressed) -> void:
include_special_characters = button_pressed
_update_example()
windows_warning.visible = OS.get_name() == "Windows" and include_special_characters


func _on_submit_pressed() -> void:
Expand Down
32 changes: 25 additions & 7 deletions app/src/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -59.0
offset_top = -18.5
offset_right = 59.0
offset_bottom = 18.5
offset_left = -400.0
offset_top = -204.0
offset_right = 400.0
offset_bottom = 190.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 5
Expand Down Expand Up @@ -67,6 +67,24 @@ layout_mode = 2
text = "1030 - Märio Rössi - Talk about $$$.pdf"
horizontal_alignment = 1

[node name="HSeparator2" type="HSeparator" parent="Settings"]
modulate = Color(1, 1, 1, 0)
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
size_flags_vertical = 3

[node name="WindowsWarning" type="Label" parent="Settings"]
layout_mode = 2
text = "WARNING! Using special characters on Windows
might cause crashes during download."
horizontal_alignment = 1

[node name="HSeparator3" type="HSeparator" parent="Settings"]
modulate = Color(1, 1, 1, 0)
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
size_flags_vertical = 3

[node name="Submit" type="Button" parent="Settings"]
layout_mode = 2
size_flags_horizontal = 4
Expand Down Expand Up @@ -130,12 +148,12 @@ size_flags_vertical = 3
focus_mode = 2
selection_enabled = true

[node name="ErrorsLabel2" type="Label" parent="Result"]
[node name="LogLabel" type="Label" parent="Result"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
text = "PROBLEMS SAVING PDF"
text = "LOG"

[node name="Errors2" type="RichTextLabel" parent="Result"]
[node name="Log" type="RichTextLabel" parent="Result"]
layout_mode = 2
size_flags_vertical = 3
focus_mode = 2
Expand Down

0 comments on commit efbb69c

Please sign in to comment.