mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
FontEditor: Save scale to config file
This commit is contained in:
parent
4d4764e0fb
commit
22b3c25f10
4 changed files with 51 additions and 14 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/UnicodeUtils.h>
|
#include <AK/UnicodeUtils.h>
|
||||||
#include <Applications/FontEditor/FontEditorWindowGML.h>
|
#include <Applications/FontEditor/FontEditorWindowGML.h>
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -296,23 +297,22 @@ FontEditorWidget::FontEditorWidget()
|
||||||
toolbar.add_action(*m_next_glyph_action);
|
toolbar.add_action(*m_next_glyph_action);
|
||||||
toolbar.add_action(*m_go_to_glyph_action);
|
toolbar.add_action(*m_go_to_glyph_action);
|
||||||
|
|
||||||
m_scale_five_action = GUI::Action::create_checkable("500%", { Mod_Ctrl, Key_1 }, [&](auto&) {
|
i32 scale = Config::read_i32("FontEditor", "GlyphEditor", "Scale", 10);
|
||||||
m_glyph_editor_widget->set_scale(5);
|
|
||||||
did_resize_glyph_editor();
|
m_scale_five_action = GUI::Action::create_checkable("500%", { Mod_Ctrl, Key_1 }, [this](auto&) {
|
||||||
|
set_scale_and_save(5);
|
||||||
});
|
});
|
||||||
m_scale_five_action->set_checked(false);
|
m_scale_five_action->set_checked(scale == 5);
|
||||||
m_scale_five_action->set_status_tip("Scale the editor in proportion to the current font");
|
m_scale_five_action->set_status_tip("Scale the editor in proportion to the current font");
|
||||||
m_scale_ten_action = GUI::Action::create_checkable("1000%", { Mod_Ctrl, Key_2 }, [&](auto&) {
|
m_scale_ten_action = GUI::Action::create_checkable("1000%", { Mod_Ctrl, Key_2 }, [this](auto&) {
|
||||||
m_glyph_editor_widget->set_scale(10);
|
set_scale_and_save(10);
|
||||||
did_resize_glyph_editor();
|
|
||||||
});
|
});
|
||||||
m_scale_ten_action->set_checked(true);
|
m_scale_ten_action->set_checked(scale == 10);
|
||||||
m_scale_ten_action->set_status_tip("Scale the editor in proportion to the current font");
|
m_scale_ten_action->set_status_tip("Scale the editor in proportion to the current font");
|
||||||
m_scale_fifteen_action = GUI::Action::create_checkable("1500%", { Mod_Ctrl, Key_3 }, [&](auto&) {
|
m_scale_fifteen_action = GUI::Action::create_checkable("1500%", { Mod_Ctrl, Key_3 }, [this](auto&) {
|
||||||
m_glyph_editor_widget->set_scale(15);
|
set_scale_and_save(15);
|
||||||
did_resize_glyph_editor();
|
|
||||||
});
|
});
|
||||||
m_scale_fifteen_action->set_checked(false);
|
m_scale_fifteen_action->set_checked(scale == 15);
|
||||||
m_scale_fifteen_action->set_status_tip("Scale the editor in proportion to the current font");
|
m_scale_fifteen_action->set_status_tip("Scale the editor in proportion to the current font");
|
||||||
|
|
||||||
m_glyph_editor_scale_actions.add_action(*m_scale_five_action);
|
m_glyph_editor_scale_actions.add_action(*m_scale_five_action);
|
||||||
|
@ -483,6 +483,8 @@ FontEditorWidget::FontEditorWidget()
|
||||||
GUI::Application::the()->on_action_leave = [this](GUI::Action&) {
|
GUI::Application::the()->on_action_leave = [this](GUI::Action&) {
|
||||||
m_statusbar->set_override_text({});
|
m_statusbar->set_override_text({});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
set_scale(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontEditorWidget::~FontEditorWidget()
|
FontEditorWidget::~FontEditorWidget()
|
||||||
|
@ -777,3 +779,27 @@ void FontEditorWidget::did_resize_glyph_editor()
|
||||||
m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
|
m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
|
||||||
m_left_column_container->set_fixed_width(max(m_glyph_editor_widget->preferred_width(), glyph_toolbars_width));
|
m_left_column_container->set_fixed_width(max(m_glyph_editor_widget->preferred_width(), glyph_toolbars_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontEditorWidget::config_i32_did_change(String const& domain, String const& group, String const& key, i32 value)
|
||||||
|
{
|
||||||
|
if (domain == "FontEditor"sv && group == "GlyphEditor"sv && key == "Scale"sv) {
|
||||||
|
set_scale(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontEditorWidget::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
|
||||||
|
{
|
||||||
|
config_i32_did_change(domain, group, key, value.to_int().value_or(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontEditorWidget::set_scale(i32 scale)
|
||||||
|
{
|
||||||
|
m_glyph_editor_widget->set_scale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontEditorWidget::set_scale_and_save(i32 scale)
|
||||||
|
{
|
||||||
|
set_scale(scale);
|
||||||
|
Config::write_i32("FontEditor", "GlyphEditor", "Scale", scale);
|
||||||
|
did_resize_glyph_editor();
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UndoGlyph.h"
|
#include "UndoGlyph.h"
|
||||||
|
#include <LibConfig/Listener.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/UndoStack.h>
|
#include <LibGUI/UndoStack.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
|
@ -15,7 +16,9 @@
|
||||||
class GlyphEditorWidget;
|
class GlyphEditorWidget;
|
||||||
class GlyphMapWidget;
|
class GlyphMapWidget;
|
||||||
|
|
||||||
class FontEditorWidget final : public GUI::Widget {
|
class FontEditorWidget final
|
||||||
|
: public GUI::Widget
|
||||||
|
, public Config::Listener {
|
||||||
C_OBJECT(FontEditorWidget)
|
C_OBJECT(FontEditorWidget)
|
||||||
public:
|
public:
|
||||||
virtual ~FontEditorWidget() override;
|
virtual ~FontEditorWidget() override;
|
||||||
|
@ -40,12 +43,17 @@ private:
|
||||||
|
|
||||||
virtual void drop_event(GUI::DropEvent&) override;
|
virtual void drop_event(GUI::DropEvent&) override;
|
||||||
|
|
||||||
|
virtual void config_i32_did_change(String const& domain, String const& group, String const& key, i32 value) override;
|
||||||
|
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
|
||||||
|
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
void did_modify_font();
|
void did_modify_font();
|
||||||
void did_resize_glyph_editor();
|
void did_resize_glyph_editor();
|
||||||
void update_statusbar();
|
void update_statusbar();
|
||||||
void update_preview();
|
void update_preview();
|
||||||
|
void set_scale(i32);
|
||||||
|
void set_scale_and_save(i32);
|
||||||
|
|
||||||
RefPtr<Gfx::BitmapFont> m_edited_font;
|
RefPtr<Gfx::BitmapFont> m_edited_font;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
Function<void()> on_undo_event;
|
Function<void()> on_undo_event;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlyphEditorWidget() {};
|
GlyphEditorWidget() = default;
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "FontEditor.h"
|
#include "FontEditor.h"
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
|
@ -27,6 +28,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") }));
|
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") }));
|
||||||
TRY(Desktop::Launcher::seal_allowlist());
|
TRY(Desktop::Launcher::seal_allowlist());
|
||||||
|
|
||||||
|
Config::pledge_domains("FontEditor");
|
||||||
|
Config::monitor_domain("FontEditor");
|
||||||
TRY(Core::System::pledge("stdio recvfd sendfd thread rpath cpath wpath"));
|
TRY(Core::System::pledge("stdio recvfd sendfd thread rpath cpath wpath"));
|
||||||
|
|
||||||
char const* path = nullptr;
|
char const* path = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue