Skip to content

Commit

Permalink
Merge pull request #18 from Lyaaaaaaaaaaaaaaa/Release_1.2.0
Browse files Browse the repository at this point in the history
### Release 1.2.0

- It is now possible to drop a file directly into the software instead of using the file chooser dialog.
- Added two buttons to quickly increase/decrease the font size.
  • Loading branch information
Lyaaaaaaaaaaaaaaa authored Jul 27, 2021
2 parents 6ccdccd + 578b22a commit b3ad981
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 218 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/godot_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
godot_export_templates_download_url : https://downloads.tuxfamily.org/godotengine/3.3/Godot_v3.3-stable_export_templates.tpz
relative_project_path : ./Godot
archive_export_output : true
base_version : 1.1.0
base_version : 1.2.0
create_release : true
generate_release_notes : true
generate_release_notes : false
relative_export_path : ./releases/
#Set export_debug : true for test branches only
export_debug : false
Expand Down
Binary file added Godot/assets/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Godot/assets/minus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/minus.png-4762f967f2398859383593e0213c863b.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/minus.png"
dest_files=[ "res://.import/minus.png-4762f967f2398859383593e0213c863b.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added Godot/assets/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Godot/assets/plus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/plus.png-4edcf3a95e8f281c366463cbe7a974c3.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/plus.png"
dest_files=[ "res://.import/plus.png-4edcf3a95e8f281c366463cbe7a974c3.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
2 changes: 1 addition & 1 deletion Godot/src/dialogs/about_dialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ margin_bottom = 50.0
[node name="VersionLabel" type="Label" parent="MarginContainer/VBoxContainer/CenterContainer2/VBoxContainer"]
margin_right = 279.0
margin_bottom = 14.0
text = "Version : 1.1.0"
text = "Version : 1.2.0"
align = 1

[node name="LicenseLabel" type="Label" parent="MarginContainer/VBoxContainer/CenterContainer2/VBoxContainer"]
Expand Down
62 changes: 44 additions & 18 deletions Godot/src/interface/output_display.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,54 @@
#-- - Updated _ready to call _load_preferences
#-- - Added _load_preferences fonction.
#-- - Added the signal handlers to update in real time the display.
#--
#-- - 27/07/2021 Lyaaaaa
#-- - Declared a preferences object.
#-- - Added _on_PlusButton_pressed and _on_MinusButton_pressed functions.
#-- - preferences object is used in these two functions to save the new value
#-- of the font size.
#-- - Updated _load_preferences to adapt to the changes. preferences becomes
#-- settings.
#-- - Deleted the _clipboard_button and replaced it with _buttons_container.
#-- - Declared the return type of the forgotten functions.
#------------------------------------------------------------------------------
extends Panel

var _rich_label : RichTextLabel
var _clipboard_button : Button
var _rich_label_font : DynamicFont
var font_data_path := "res://assets/fonts/"
var _rich_label : RichTextLabel
var _buttons_container : HBoxContainer
var _rich_label_font : DynamicFont
var font_data_path := "res://assets/fonts/"
var preferences := Preferences.new()


func _ready() -> void:
_init_variables()
_load_preferences()


func append_text(p_text : String) -> void:
_rich_label.add_text(p_text + "\n")
_clipboard_button.visible = true
_buttons_container.visible = true


func clear() -> void:
_rich_label.clear()
_clipboard_button.visible = false
_buttons_container.visible = false


func _init_variables() -> void:
_rich_label = find_node("RichLabel")
_clipboard_button = find_node("ClipboardButton")
_buttons_container = find_node("ButtonsContainer")
_rich_label_font = _rich_label.get_font("normal_font")


func _load_preferences() -> void:
var preferences = Preferences.new().output_display
var font_name = preferences["font"]
var font_color = preferences["font_color"]
var font_size = preferences["font_size"]
var line_separation = preferences["line_separation"]
var selection_color = preferences["selection_color"]
var settings = preferences.output_display
var font_name = settings["font"]
var font_color = settings["font_color"]
var font_size = settings["font_size"]
var line_separation = settings["line_separation"]
var selection_color = settings["selection_color"]

_rich_label_font.font_data = load(font_data_path + font_name + ".ttf")
_rich_label_font.size = font_size
Expand All @@ -70,21 +84,33 @@ func _on_ClipboardButton_pressed() -> void:
Os.set_clipboard(_rich_label.text)


func _on_PreferencesDialog_font_changed(p_font_name : String):
func _on_PreferencesDialog_font_changed(p_font_name : String) -> void:
_rich_label_font.font_data = load(font_data_path + p_font_name + ".ttf")


func _on_PreferencesDialog_font_color_changed(p_color : Color):
func _on_PreferencesDialog_font_color_changed(p_color : Color) -> void:
_rich_label.add_color_override("default_color", p_color)


func _on_PreferencesDialog_font_size_changed(p_value : int):
func _on_PreferencesDialog_font_size_changed(p_value : int) -> void:
_rich_label_font.size = p_value


func _on_PreferencesDialog_line_separation_changed(p_value : int):
func _on_PreferencesDialog_line_separation_changed(p_value : int) -> void:
_rich_label.add_constant_override("line_separation", p_value)


func _on_PreferencesDialog_selection_color_changed(p_color : Color):
func _on_PreferencesDialog_selection_color_changed(p_color : Color) -> void:
_rich_label.add_color_override("selection_color", p_color)


func _on_PlusButton_pressed() -> void:
_rich_label_font.size += 1
preferences.output_display["font_size"] += 1
preferences.save()


func _on_MinusButton_pressed() -> void:
_rich_label_font.size -= 1
preferences.output_display["font_size"] -= 1
preferences.save()
42 changes: 39 additions & 3 deletions Godot/src/interface/output_display.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://src/interface/output_display.gd" type="Script" id=1]
[ext_resource path="res://assets/clipboard.png" type="Texture" id=2]
[ext_resource path="res://assets/fonts/DejaVuSansMono.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://assets/plus.png" type="Texture" id=4]
[ext_resource path="res://assets/minus.png" type="Texture" id=5]

[sub_resource type="Theme" id=1]

Expand Down Expand Up @@ -56,14 +58,46 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="ClipboardButton" type="Button" parent="."]
[node name="ButtonsContainer" type="HBoxContainer" parent="."]
visible = false
anchor_left = 1.0
anchor_right = 1.0
margin_left = -74.0
margin_top = 4.0
margin_right = -12.0
margin_bottom = 60.0
grow_horizontal = 0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="PlusButton" type="Button" parent="ButtonsContainer"]
margin_right = 60.0
margin_bottom = 66.0
hint_tooltip = "Increase font size."
mouse_default_cursor_shape = 2
icon = ExtResource( 4 )
flat = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="MinusButton" type="Button" parent="ButtonsContainer"]
margin_left = 64.0
margin_right = 124.0
margin_bottom = 66.0
hint_tooltip = "Decrease font size."
mouse_default_cursor_shape = 2
icon = ExtResource( 5 )
flat = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ClipboardButton" type="Button" parent="ButtonsContainer"]
margin_left = 128.0
margin_right = 190.0
margin_bottom = 66.0
hint_tooltip = "Save to clipboard"
mouse_default_cursor_shape = 2
icon = ExtResource( 2 )
Expand All @@ -72,4 +106,6 @@ __meta__ = {
"_edit_use_anchors_": false
}

[connection signal="pressed" from="ClipboardButton" to="." method="_on_ClipboardButton_pressed"]
[connection signal="pressed" from="ButtonsContainer/PlusButton" to="." method="_on_PlusButton_pressed"]
[connection signal="pressed" from="ButtonsContainer/MinusButton" to="." method="_on_MinusButton_pressed"]
[connection signal="pressed" from="ButtonsContainer/ClipboardButton" to="." method="_on_ClipboardButton_pressed"]
32 changes: 27 additions & 5 deletions Godot/src/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#--
#-- Implementation Notes:
#-- -
#--
#-- Anticipated changes:
#-- - Update _on_files_dropped to open a tab for each file.
#--
#-- Changelog:
#-- - 27/04/2021 Lyaaaaa
#-- - Created the empty file.
Expand Down Expand Up @@ -50,6 +54,14 @@
#-- - 23/07/2021 Lyaaaaa
#-- - Added preferences_dialog variable.
#-- - Added _on_TopMenu_preferences_button_pressed.
#--
#-- - 27/07/2021 Lyaaaaa
#-- - Added _ready function. It connects the signal "files_dropped" to
#-- _on_files_dropped.
#-- - Added _on_files_dropped function which calls open_file.
#-- - Added open_file function.
#-- - Updated _on_FileDialog_file_selected to call open_file.
#-- - Declared _on_TopMenu_preferences_button_pressed return type is void.
#------------------------------------------------------------------------------
extends Control

Expand All @@ -67,6 +79,8 @@ onready var about_dialog = find_node("AboutDialog")
onready var file_dialog = find_node("FileDialog")
onready var preferences_dialog = find_node("PreferencesDialog")

func _ready():
get_tree().connect("files_dropped", self, "_on_files_dropped")

func search_file(p_display_all : bool = false) -> void:
var line : String
Expand Down Expand Up @@ -109,6 +123,13 @@ func reset_counters() -> void:
total_lines = 0


func open_file(p_path : String) -> void:
tool_bar.enable_buttons()
top_menu.set_text_top_label(p_path)

file.open(p_path, File.READ)


func _on_ToolBar_search_button_pressed(p_filters : Array) -> void:
reset_counters()
output_display.clear()
Expand All @@ -126,10 +147,7 @@ func _on_ToolBar_switch_case_sensitive_button_pressed() -> void:


func _on_FileDialog_file_selected(p_path : String) -> void:
tool_bar.enable_buttons()
top_menu.set_text_top_label(p_path)

file.open(p_path, File.READ)
open_file(p_path)


func _on_TopMenu_open_file_button_pressed() -> void:
Expand All @@ -148,5 +166,9 @@ func _on_ToolBar_display_all_button_pressed() -> void:
search_file(display_all)


func _on_TopMenu_preferences_button_pressed():
func _on_TopMenu_preferences_button_pressed() -> void:
preferences_dialog.popup_centered()


func _on_files_dropped(p_files : Array, p_screen : int) -> void:
open_file(p_files[0])
17 changes: 12 additions & 5 deletions Godot/tests/preferences.test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#-- Changelog:
#-- - 26/07/2021 Lyaaaaa
#-- - Created the file.
#--
#-- - 27/07/2021
#-- - Fixed some errors
#-- - Renamed file_path into _file_path
#-- - Updated post to delete the saved file between two functions.
#-- - Deleted the lines changing the file_path. No need to use a specific
#-- path to test.
#------------------------------------------------------------------------------

extends WAT.Test
Expand All @@ -22,10 +29,11 @@ var context : String

func pre() -> void:
preferences = Preferences.new()
preferences.file_path = "user://test"


func post() -> void:
var directory = Directory.new()
directory.remove(preferences._file_path)
preferences.free()
context = ""

Expand All @@ -41,8 +49,8 @@ func test_save() -> void:
old_value = preferences.output_display["font"]
preferences.output_display["font"] = "Test"
preferences.save()

file.open(preferences.file_path, File.READ)
file.open(preferences._file_path, File.READ)

output_display = file.get_var()
new_value = output_display["font"]
Expand All @@ -60,8 +68,7 @@ func test_load() -> void:
preferences.save()
preferences.free()

preferences = Preferences.new()
preferences.file_path = "user://test"
preferences = Preferences.new()
preferences.load()

output_display = preferences.output_display
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ right-hand corner of the application.
clipboard.
- **Saved preferences** - You can change the size, style or color of the font
and more.
- **Drag and drop** - Don't waste time! Drag your log file directly into the software.


## Why is this project useful?
Expand Down
Loading

0 comments on commit b3ad981

Please sign in to comment.