Преглед изворни кода

TextEditor+HexEditor: Warn about unsaved changes after dropping files

Karol Kosek пре 2 година
родитељ
комит
6b8d351b40

+ 2 - 0
Userland/Applications/HexEditor/HexEditorWidget.cpp

@@ -573,6 +573,8 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event)
         if (urls.is_empty())
         if (urls.is_empty())
             return;
             return;
         window()->move_to_front();
         window()->move_to_front();
+        if (!request_close())
+            return;
 
 
         // TODO: A drop event should be considered user consent for opening a file
         // TODO: A drop event should be considered user consent for opening a file
         auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
         auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);

+ 2 - 0
Userland/Applications/TextEditor/MainWidget.cpp

@@ -761,6 +761,8 @@ void MainWidget::drop_event(GUI::DropEvent& event)
             GUI::MessageBox::show(window(), "TextEditor can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error);
             GUI::MessageBox::show(window(), "TextEditor can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error);
             return;
             return;
         }
         }
+        if (!request_close())
+            return;
 
 
         // TODO: A drop event should be considered user consent for opening a file
         // TODO: A drop event should be considered user consent for opening a file
         auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
         auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);