summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/MainWidget.cpp
diff options
context:
space:
mode:
authormeiskam <634802+meiskam@users.noreply.github.com>2022-12-11 04:12:37 -0500
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-15 00:14:35 -0700
commitb33aa1bc9b0e853a2d7da028d079981b9b4a3ea7 (patch)
tree6c272c46d01ea2a65d1f2fc543edea59f68aac5c /Userland/Applications/PixelPaint/MainWidget.cpp
parentfb4315d121c14a61c50466949e6564139a6a87a1 (diff)
downloadserenity-b33aa1bc9b0e853a2d7da028d079981b9b4a3ea7.zip
PixelPaint: Update window `modified` to look at all tabs
This causes the corner X to correctly have dots when any of the open tabs have unsaved changes. Event calls and undo stack modifications have been collected to one spot.
Diffstat (limited to 'Userland/Applications/PixelPaint/MainWidget.cpp')
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index 76a918acda..fb09611a9e 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -95,12 +95,7 @@ MainWidget::MainWidget()
m_vectorscope_widget->set_image(&image_editor.image());
m_layer_list_widget->set_image(&image_editor.image());
m_layer_properties_widget->set_layer(image_editor.active_layer());
- window()->set_modified(image_editor.is_modified());
- image_editor.on_modified_change = [this](bool modified) {
- window()->set_modified(modified);
- m_histogram_widget->image_changed();
- m_vectorscope_widget->image_changed();
- };
+ update_window_modified();
if (auto* active_tool = m_toolbox->active_tool())
image_editor.set_active_tool(active_tool);
m_show_guides_action->set_checked(image_editor.guide_visibility());
@@ -166,7 +161,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto& editor = create_new_editor(*image);
auto image_title = dialog->image_name().trim_whitespace();
editor.set_title(image_title.is_empty() ? "Untitled" : image_title);
- editor.undo_stack().set_current_unmodified();
+ editor.set_unmodified();
m_histogram_widget->set_image(image);
m_vectorscope_widget->set_image(image);
@@ -1005,7 +1000,7 @@ void MainWidget::open_image(Core::File& file)
auto& editor = create_new_editor(image);
editor.set_loaded_from_image(m_loader.is_raw_image());
editor.set_path(file.filename());
- editor.undo_stack().set_current_unmodified();
+ editor.set_unmodified();
m_layer_list_widget->set_image(&image);
}
@@ -1022,7 +1017,7 @@ void MainWidget::create_default_image()
auto& editor = create_new_editor(*image);
editor.set_title("Untitled");
editor.set_active_layer(bg_layer);
- editor.undo_stack().set_current_unmodified();
+ editor.set_unmodified();
}
void MainWidget::create_image_from_clipboard()
@@ -1078,6 +1073,13 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
m_tab_widget->set_tab_title(image_editor, title);
};
+ image_editor.on_modified_change = [&](auto const modified) {
+ m_tab_widget->set_tab_modified(image_editor, modified);
+ update_window_modified();
+ m_histogram_widget->image_changed();
+ m_vectorscope_widget->image_changed();
+ };
+
image_editor.on_image_mouse_position_change = [&](auto const& mouse_position) {
auto const& image_size = current_image_editor()->image().size();
auto image_rectangle = Gfx::IntRect { 0, 0, image_size.width(), image_size.height() };
@@ -1177,4 +1179,9 @@ void MainWidget::drop_event(GUI::DropEvent& event)
open_image(response.value());
}
}
+
+void MainWidget::update_window_modified()
+{
+ window()->set_modified(m_tab_widget->is_any_tab_modified());
+}
}