From 677aa7b769bc23fa0d5a141407c94ede74220a2a Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Sat, 11 Sep 2021 23:40:59 -0400 Subject: [PATCH] PixelPaint: Use config to get default values for Guides/Rulers/PixelGrid Someone may not want to have these things enabled by default on every startup, but toggle them on manually. So instead of having hard-coded everything to be enabled by default, we now query LibConfig to find out what the preference is. These values can still always be changed from the Menus / with shortcuts. It's not really ideal querying LibConfig twice, but when initializing the menu we may not have an active editor, so we need to get the value for both the menu checkbox as well as the internal property. This shouldn't be too much of a big deal since LibConfig caches the values anyway :^) --- Userland/Applications/PixelPaint/ImageEditor.cpp | 5 +++++ Userland/Applications/PixelPaint/MainWidget.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 3d583ba5fe..3df1a87170 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -30,7 +30,12 @@ ImageEditor::ImageEditor(NonnullRefPtr image) m_undo_stack = make(); m_undo_stack->push(make(*m_image)); m_image->add_client(*this); + m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15); + m_show_pixel_grid = Config::read_bool("PixelPaint", "PixelGrid", "Show", true); + + m_show_rulers = Config::read_bool("PixelPaint", "Rulers", "Show", true); + m_show_guides = Config::read_bool("PixelPaint", "Guides", "Show", true); } ImageEditor::~ImageEditor() diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 144f0f71ee..e22748dc7d 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -12,6 +12,7 @@ #include "EditGuideDialog.h" #include "FilterParams.h" #include +#include #include #include #include @@ -339,7 +340,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) editor->set_guide_visibility(action.is_checked()); } }); - m_show_guides_action->set_checked(true); + m_show_guides_action->set_checked(Config::read_bool("PixelPaint", "Guides", "Show", true)); view_menu.add_action(*m_zoom_in_action); view_menu.add_action(*m_zoom_out_action); @@ -365,7 +366,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) if (auto* editor = current_image_editor()) editor->set_pixel_grid_visibility(action.is_checked()); }); - show_pixel_grid_action->set_checked(true); + show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint", "PixelGrid", "Show", true)); view_menu.add_action(*show_pixel_grid_action); m_show_rulers_action = GUI::Action::create_checkable( @@ -374,7 +375,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) editor->set_ruler_visibility(action.is_checked()); } }); - m_show_rulers_action->set_checked(true); + m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true)); view_menu.add_action(*m_show_rulers_action); auto& tool_menu = window.add_menu("&Tool");