mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
FontEditor: Add show_error() helper
This commit is contained in:
parent
c044a556db
commit
e9a150c87c
2 changed files with 17 additions and 14 deletions
|
@ -178,7 +178,7 @@ ErrorOr<void> MainWidget::create_actions()
|
||||||
m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) {
|
m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) {
|
||||||
if (!m_font_preview_window) {
|
if (!m_font_preview_window) {
|
||||||
if (auto maybe_window = create_preview_window(); maybe_window.is_error())
|
if (auto maybe_window = create_preview_window(); maybe_window.is_error())
|
||||||
warnln("Failed to create preview window: {}", maybe_window.error());
|
show_error("Failed to create preview window"sv, maybe_window.error());
|
||||||
else
|
else
|
||||||
m_font_preview_window = maybe_window.release_value();
|
m_font_preview_window = maybe_window.release_value();
|
||||||
}
|
}
|
||||||
|
@ -715,19 +715,13 @@ bool MainWidget::open_file(String const& path)
|
||||||
void MainWidget::push_undo()
|
void MainWidget::push_undo()
|
||||||
{
|
{
|
||||||
auto maybe_state = m_undo_selection->save_state();
|
auto maybe_state = m_undo_selection->save_state();
|
||||||
if (maybe_state.is_error()) {
|
if (maybe_state.is_error())
|
||||||
warnln("Failed to save undo state: {}", maybe_state.error());
|
return show_error("Failed to save undo state"sv, maybe_state.error());
|
||||||
return;
|
auto maybe_command = try_make<SelectionUndoCommand>(*m_undo_selection, move(maybe_state.value()));
|
||||||
}
|
if (maybe_command.is_error())
|
||||||
auto state = maybe_state.release_value();
|
return show_error("Failed to make undo command"sv, maybe_command.error());
|
||||||
auto maybe_command = try_make<SelectionUndoCommand>(*m_undo_selection, move(state));
|
if (auto maybe_push = m_undo_stack->try_push(move(maybe_command.value())); maybe_push.is_error())
|
||||||
if (maybe_command.is_error()) {
|
show_error("Failed to push undo stack"sv, maybe_push.error());
|
||||||
warnln("Failed to make undo command: {}", maybe_command.error());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto command = maybe_command.release_value();
|
|
||||||
if (auto maybe_push = m_undo_stack->try_push(move(command)); maybe_push.is_error())
|
|
||||||
warnln("Failed to push undo stack: {}", maybe_push.error());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::reset_selection_and_push_undo()
|
void MainWidget::reset_selection_and_push_undo()
|
||||||
|
@ -993,4 +987,11 @@ void MainWidget::delete_selected_glyphs()
|
||||||
update_statusbar();
|
update_statusbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::show_error(StringView preface, Error error)
|
||||||
|
{
|
||||||
|
auto formatted_error = String::formatted("{}: {}", preface, error);
|
||||||
|
GUI::MessageBox::show_error(window(), formatted_error);
|
||||||
|
warnln(formatted_error);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ private:
|
||||||
void push_undo();
|
void push_undo();
|
||||||
void reset_selection_and_push_undo();
|
void reset_selection_and_push_undo();
|
||||||
|
|
||||||
|
void show_error(StringView preface, Error);
|
||||||
|
|
||||||
RefPtr<Gfx::BitmapFont> m_edited_font;
|
RefPtr<Gfx::BitmapFont> m_edited_font;
|
||||||
|
|
||||||
RefPtr<GUI::GlyphMapWidget> m_glyph_map_widget;
|
RefPtr<GUI::GlyphMapWidget> m_glyph_map_widget;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue