mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-10 01:13:49 +00:00
Add alert when we will overwrite a file on File > Export
This commit is contained in:
parent
25322d69fe
commit
ca31a79ca5
@ -258,6 +258,9 @@
|
||||
<option id="show_export_animation_in_sequence_alert" type="bool" default="true" />
|
||||
<option id="default_extension" type="std::string" default=""aseprite"" />
|
||||
</section>
|
||||
<section id="export_file">
|
||||
<option id="show_overwrite_files_alert" type="bool" default="true" />
|
||||
</section>
|
||||
<section id="sprite_sheet">
|
||||
<option id="show_overwrite_files_alert" type="bool" default="true" />
|
||||
</section>
|
||||
|
@ -140,6 +140,12 @@ Export Sprite Sheet Warning
|
||||
{0}
|
||||
||&Yes||&No
|
||||
END
|
||||
overwrite_files_on_export = <<<END
|
||||
Export Warning
|
||||
<<Do you want to overwrite the following file?
|
||||
<<{0}
|
||||
||&Yes||&No
|
||||
END
|
||||
|
||||
[brush_slot_params]
|
||||
brush = Brush:
|
||||
@ -959,6 +965,7 @@ END
|
||||
undo_allow_nonlinear_history = Allow non-linear history
|
||||
file_format_doesnt_support_alert = Show warning when saving a file with unsupported features
|
||||
export_animation_in_sequence_alert = Show warning when saving an animation as a sequence of static images
|
||||
overwrite_files_on_export_alert = Show warning when overwriting files on File > Export
|
||||
overwrite_files_on_export_sprite_sheet_alert = Show warning when overwriting files on Export Sprite Sheet
|
||||
gif_options_alert = Show GIF options when saving .gif files
|
||||
jpeg_options_alert = Show JPEG options when saving .jpeg files
|
||||
|
@ -291,6 +291,7 @@
|
||||
<separator text="@.section_alerts" horizontal="true" />
|
||||
<check id="file_format_doesnt_support_alert" text="@.file_format_doesnt_support_alert" />
|
||||
<check id="export_animation_in_sequence_alert" text="@.export_animation_in_sequence_alert" />
|
||||
<check id="overwrite_files_on_export_alert" text="@.overwrite_files_on_export_alert" />
|
||||
<check id="overwrite_files_on_export_sprite_sheet_alert" text="@.overwrite_files_on_export_sprite_sheet_alert" />
|
||||
<check id="gif_options_alert" text="@.gif_options_alert" />
|
||||
<check id="jpeg_options_alert" text="@.jpeg_options_alert" />
|
||||
|
@ -160,6 +160,7 @@ public:
|
||||
// Alerts
|
||||
fileFormatDoesntSupportAlert()->setSelected(m_pref.saveFile.showFileFormatDoesntSupportAlert());
|
||||
exportAnimationInSequenceAlert()->setSelected(m_pref.saveFile.showExportAnimationInSequenceAlert());
|
||||
overwriteFilesOnExportAlert()->setSelected(m_pref.exportFile.showOverwriteFilesAlert());
|
||||
overwriteFilesOnExportSpriteSheetAlert()->setSelected(m_pref.spriteSheet.showOverwriteFilesAlert());
|
||||
gifOptionsAlert()->setSelected(m_pref.gif.showAlert());
|
||||
jpegOptionsAlert()->setSelected(m_pref.jpeg.showAlert());
|
||||
@ -421,6 +422,7 @@ public:
|
||||
|
||||
m_pref.saveFile.showFileFormatDoesntSupportAlert(fileFormatDoesntSupportAlert()->isSelected());
|
||||
m_pref.saveFile.showExportAnimationInSequenceAlert(exportAnimationInSequenceAlert()->isSelected());
|
||||
m_pref.exportFile.showOverwriteFilesAlert(overwriteFilesOnExportAlert()->isSelected());
|
||||
m_pref.spriteSheet.showOverwriteFilesAlert(overwriteFilesOnExportSpriteSheetAlert()->isSelected());
|
||||
m_pref.gif.showAlert(gifOptionsAlert()->isSelected());
|
||||
m_pref.jpeg.showAlert(jpegOptionsAlert()->isSelected());
|
||||
@ -609,6 +611,7 @@ private:
|
||||
void onResetAlerts() {
|
||||
fileFormatDoesntSupportAlert()->setSelected(m_pref.saveFile.showFileFormatDoesntSupportAlert.defaultValue());
|
||||
exportAnimationInSequenceAlert()->setSelected(m_pref.saveFile.showExportAnimationInSequenceAlert.defaultValue());
|
||||
overwriteFilesOnExportAlert()->setSelected(m_pref.exportFile.showOverwriteFilesAlert.defaultValue());
|
||||
overwriteFilesOnExportSpriteSheetAlert()->setSelected(m_pref.spriteSheet.showOverwriteFilesAlert.defaultValue());
|
||||
gifOptionsAlert()->setSelected(m_pref.gif.showAlert.defaultValue());
|
||||
jpegOptionsAlert()->setSelected(m_pref.jpeg.showAlert.defaultValue());
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "app/restore_visible_layers.h"
|
||||
#include "app/ui/export_file_window.h"
|
||||
#include "app/ui/layer_frame_comboboxes.h"
|
||||
#include "app/ui/optional_alert.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/convert_to.h"
|
||||
@ -34,6 +35,7 @@
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
namespace app {
|
||||
@ -278,19 +280,36 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
||||
{
|
||||
Document* doc = context->activeDocument();
|
||||
ExportFileWindow win(doc);
|
||||
bool askOverwrite = true;
|
||||
|
||||
win.SelectOutputFile.connect(
|
||||
[this, &win, context, doc]{
|
||||
return saveAsDialog(
|
||||
context, "Export",
|
||||
win.outputFilenameValue(), false, false,
|
||||
(doc->isAssociatedToFile() ? doc->filename():
|
||||
std::string()));
|
||||
[this, &win, &askOverwrite, context, doc]() -> std::string {
|
||||
std::string result =
|
||||
saveAsDialog(
|
||||
context, "Export",
|
||||
win.outputFilenameValue(), false, false,
|
||||
(doc->isAssociatedToFile() ? doc->filename():
|
||||
std::string()));
|
||||
if (!result.empty())
|
||||
askOverwrite = false; // Already asked in the file selector dialog
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
again:;
|
||||
if (!win.show())
|
||||
return;
|
||||
|
||||
if (askOverwrite) {
|
||||
int ret = OptionalAlert::show(
|
||||
Preferences::instance().exportFile.showOverwriteFilesAlert,
|
||||
1, // Yes is the default option when the alert dialog is disabled
|
||||
fmt::format(Strings::alerts_overwrite_files_on_export(),
|
||||
win.outputFilenameValue()));
|
||||
if (ret != 1)
|
||||
goto again;
|
||||
}
|
||||
|
||||
// Save the preferences used to export the file, so if we open the
|
||||
// window again, we will have the same options.
|
||||
win.savePref();
|
||||
|
Loading…
x
Reference in New Issue
Block a user