diff options
author | Mustafa Quraish <mustafaq9@gmail.com> | 2021-09-11 23:40:59 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-12 17:15:30 +0200 |
commit | 677aa7b769bc23fa0d5a141407c94ede74220a2a (patch) | |
tree | dd460f2bed23318ae91a5bef06fb0b40ef9c932a /Userland/Applications | |
parent | dd0cc58d6c2a0a2855341060556c2df6b47cf27f (diff) | |
download | serenity-677aa7b769bc23fa0d5a141407c94ede74220a2a.zip |
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 :^)
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.cpp | 5 | ||||
-rw-r--r-- | 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> image) m_undo_stack = make<GUI::UndoStack>(); m_undo_stack->push(make<ImageUndoCommand>(*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 <Applications/PixelPaint/PixelPaintWindowGML.h> +#include <LibConfig/Client.h> #include <LibCore/File.h> #include <LibCore/MimeData.h> #include <LibFileSystemAccessClient/Client.h> @@ -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"); |