|
@@ -64,8 +64,8 @@ MainWidget::MainWidget()
|
|
|
};
|
|
|
|
|
|
m_tab_widget->on_tab_close_click = [&](auto& widget) {
|
|
|
- if (request_close_editor()) {
|
|
|
- auto& image_editor = verify_cast<PixelPaint::ImageEditor>(widget);
|
|
|
+ auto& image_editor = verify_cast<PixelPaint::ImageEditor>(widget);
|
|
|
+ if (image_editor.request_close()) {
|
|
|
m_tab_widget->deferred_invoke([&] {
|
|
|
m_tab_widget->remove_tab(image_editor);
|
|
|
if (m_tab_widget->children().size() == 1) {
|
|
@@ -728,32 +728,12 @@ void MainWidget::create_image_from_clipboard()
|
|
|
m_layer_list_widget->set_selected_layer(layer);
|
|
|
}
|
|
|
|
|
|
-bool MainWidget::request_close_editor()
|
|
|
-{
|
|
|
- auto* editor = current_image_editor();
|
|
|
- VERIFY(editor);
|
|
|
-
|
|
|
- if (!editor->undo_stack().is_current_modified()) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), editor->path(), editor->undo_stack().last_unmodified_timestamp());
|
|
|
-
|
|
|
- if (result == GUI::MessageBox::ExecYes) {
|
|
|
- m_save_image_action->activate();
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- if (result == GUI::MessageBox::ExecNo)
|
|
|
- return true;
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
bool MainWidget::request_close()
|
|
|
{
|
|
|
while (!m_tab_widget->children().is_empty()) {
|
|
|
- if (!request_close_editor())
|
|
|
+ auto* editor = current_image_editor();
|
|
|
+ VERIFY(editor);
|
|
|
+ if (!editor->request_close())
|
|
|
return false;
|
|
|
m_tab_widget->remove_tab(*m_tab_widget->active_widget());
|
|
|
}
|