Add option to disable the "open sequence of files" dialog

This commit is contained in:
David Capello 2021-04-12 16:57:02 -03:00
parent 5e98b39944
commit 8b4746e813
10 changed files with 82 additions and 32 deletions

View File

@ -121,6 +121,11 @@
<value id="HSV" value="1" /> <value id="HSV" value="1" />
<value id="HSL" value="2" /> <value id="HSL" value="2" />
</enum> </enum>
<enum id="SequenceDecision">
<value id="ASK" value="0" />
<value id="YES" value="1" />
<value id="NO" value="2" />
</enum>
</types> </types>
<global> <global>
@ -313,6 +318,9 @@
<section id="advanced_mode"> <section id="advanced_mode">
<option id="show_alert" type="bool" default="true" /> <option id="show_alert" type="bool" default="true" />
</section> </section>
<section id="open_file">
<option id="open_sequence" type="SequenceDecision" default="SequenceDecision::ASK" />
</section>
<section id="save_file"> <section id="save_file">
<option id="show_file_format_doesnt_support_alert" type="bool" default="true" /> <option id="show_file_format_doesnt_support_alert" type="bool" default="true" />
<option id="show_export_animation_in_sequence_alert" type="bool" default="true" /> <option id="show_export_animation_in_sequence_alert" type="bool" default="true" />

View File

@ -1,5 +1,5 @@
# Aseprite # Aseprite
# Copyright (C) 2018-2020 Igara Studio S.A. # Copyright (C) 2018-2021 Igara Studio S.A.
# Copyright (C) 2016-2018 David Capello # Copyright (C) 2016-2018 David Capello
[advanced_mode] [advanced_mode]
@ -1228,6 +1228,10 @@ the current frame & layer will be modified
to focus the undid/redid change. to focus the undid/redid change.
END END
undo_allow_nonlinear_history = Allow non-linear history undo_allow_nonlinear_history = Allow non-linear history
open_sequence_alert = Open a sequence of static files as an animation
open_sequence_alert_ask = Ask
open_sequence_alert_no = No
open_sequence_alert_yes = Yes
file_format_doesnt_support_alert = Show warning when saving a file with unsupported features 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 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_alert = Show warning when overwriting files on File > Export

View File

@ -1,4 +1,5 @@
<!-- Aseprite --> <!-- Aseprite -->
<!-- Copyright (C) 2021 by Igara Studio S.A. -->
<!-- Copyright (C) 2016 by David Capello --> <!-- Copyright (C) 2016 by David Capello -->
<gui> <gui>
<window id="open_sequence" text="@.title"> <window id="open_sequence" text="@.title">
@ -9,6 +10,7 @@
</view> </view>
<separator horizontal="true" /> <separator horizontal="true" />
<check id="repeat" text="@.repeat" /> <check id="repeat" text="@.repeat" />
<check id="dont_show" text="@general.dont_show" />
<hbox> <hbox>
<boxfiller /> <boxfiller />
<hbox homogeneous="true"> <hbox homogeneous="true">

View File

@ -426,6 +426,14 @@
<!-- Alerts --> <!-- Alerts -->
<vbox id="section_alerts"> <vbox id="section_alerts">
<separator text="@.section_alerts" horizontal="true" /> <separator text="@.section_alerts" horizontal="true" />
<hbox>
<label text="@.open_sequence_alert" />
<combobox id="open_sequence">
<listitem text="@.open_sequence_alert_ask" value="0" />
<listitem text="@.open_sequence_alert_yes" value="1" />
<listitem text="@.open_sequence_alert_no" value="2" />
</combobox>
</hbox>
<check id="file_format_doesnt_support_alert" text="@.file_format_doesnt_support_alert" <check id="file_format_doesnt_support_alert" text="@.file_format_doesnt_support_alert"
pref="save_file.show_file_format_doesnt_support_alert" /> pref="save_file.show_file_format_doesnt_support_alert" />
<check id="export_animation_in_sequence_alert" text="@.export_animation_in_sequence_alert" <check id="export_animation_in_sequence_alert" text="@.export_animation_in_sequence_alert"

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A. // Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -78,7 +78,7 @@ OpenFileCommand::OpenFileCommand()
: Command(CommandId::OpenFile(), CmdRecordableFlag) : Command(CommandId::OpenFile(), CmdRecordableFlag)
, m_repeatCheckbox(false) , m_repeatCheckbox(false)
, m_oneFrame(false) , m_oneFrame(false)
, m_seqDecision(SequenceDecision::Ask) , m_seqDecision(gen::SequenceDecision::ASK)
{ {
} }
@ -90,12 +90,18 @@ void OpenFileCommand::onLoadParams(const Params& params)
m_oneFrame = params.get_as<bool>("oneframe"); m_oneFrame = params.get_as<bool>("oneframe");
std::string sequence = params.get("sequence"); std::string sequence = params.get("sequence");
if (m_oneFrame || sequence == "skip") if (m_oneFrame ||
m_seqDecision = SequenceDecision::Skip; sequence == "skip" ||
else if (sequence == "agree") sequence == "no") {
m_seqDecision = SequenceDecision::Agree; m_seqDecision = gen::SequenceDecision::NO;
else }
m_seqDecision = SequenceDecision::Ask; else if (sequence == "agree" ||
sequence == "yes") {
m_seqDecision = gen::SequenceDecision::YES;
}
else {
m_seqDecision = gen::SequenceDecision::ASK;
}
} }
void OpenFileCommand::onExecute(Context* context) void OpenFileCommand::onExecute(Context* context)
@ -143,14 +149,25 @@ void OpenFileCommand::onExecute(Context* context)
FILE_LOAD_CREATE_PALETTE | FILE_LOAD_CREATE_PALETTE |
(m_repeatCheckbox ? FILE_LOAD_SEQUENCE_ASK_CHECKBOX: 0); (m_repeatCheckbox ? FILE_LOAD_SEQUENCE_ASK_CHECKBOX: 0);
if (context->isUIAvailable() &&
m_seqDecision == gen::SequenceDecision::ASK) {
if (Preferences::instance().openFile.openSequence() == gen::SequenceDecision::ASK) {
// Do nothing (ask by default, or whatever the command params
// specified)
}
else {
m_seqDecision = Preferences::instance().openFile.openSequence();
}
}
switch (m_seqDecision) { switch (m_seqDecision) {
case SequenceDecision::Ask: case gen::SequenceDecision::ASK:
flags |= FILE_LOAD_SEQUENCE_ASK; flags |= FILE_LOAD_SEQUENCE_ASK;
break; break;
case SequenceDecision::Agree: case gen::SequenceDecision::YES:
flags |= FILE_LOAD_SEQUENCE_YES; flags |= FILE_LOAD_SEQUENCE_YES;
break; break;
case SequenceDecision::Skip: case gen::SequenceDecision::NO:
flags |= FILE_LOAD_SEQUENCE_NONE; flags |= FILE_LOAD_SEQUENCE_NONE;
break; break;
} }
@ -179,12 +196,12 @@ void OpenFileCommand::onExecute(Context* context)
else { else {
if (fop->isSequence()) { if (fop->isSequence()) {
if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_YES) { if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_YES) {
m_seqDecision = SequenceDecision::Agree; m_seqDecision = gen::SequenceDecision::YES;
flags &= ~FILE_LOAD_SEQUENCE_ASK; flags &= ~FILE_LOAD_SEQUENCE_ASK;
flags |= FILE_LOAD_SEQUENCE_YES; flags |= FILE_LOAD_SEQUENCE_YES;
} }
else if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_NONE) { else if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_NONE) {
m_seqDecision = SequenceDecision::Skip; m_seqDecision = gen::SequenceDecision::NO;
flags &= ~FILE_LOAD_SEQUENCE_ASK; flags &= ~FILE_LOAD_SEQUENCE_ASK;
flags |= FILE_LOAD_SEQUENCE_NONE; flags |= FILE_LOAD_SEQUENCE_NONE;
} }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello // Copyright (C) 2016-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -10,6 +10,7 @@
#pragma once #pragma once
#include "app/commands/command.h" #include "app/commands/command.h"
#include "app/pref/preferences.h"
#include "base/paths.h" #include "base/paths.h"
#include <string> #include <string>
@ -18,17 +19,13 @@ namespace app {
class OpenFileCommand : public Command { class OpenFileCommand : public Command {
public: public:
enum class SequenceDecision {
Ask, Agree, Skip,
};
OpenFileCommand(); OpenFileCommand();
const base::paths& usedFiles() const { const base::paths& usedFiles() const {
return m_usedFiles; return m_usedFiles;
} }
SequenceDecision seqDecision() const { gen::SequenceDecision seqDecision() const {
return m_seqDecision; return m_seqDecision;
} }
@ -42,7 +39,7 @@ namespace app {
bool m_repeatCheckbox; bool m_repeatCheckbox;
bool m_oneFrame; bool m_oneFrame;
base::paths m_usedFiles; base::paths m_usedFiles;
SequenceDecision m_seqDecision; gen::SequenceDecision m_seqDecision;
}; };
} // namespace app } // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -235,6 +235,7 @@ public:
} }
// Alerts // Alerts
openSequence()->setSelectedItemIndex(int(m_pref.openFile.openSequence()));
resetAlerts()->Click.connect([this]{ onResetAlerts(); }); resetAlerts()->Click.connect([this]{ onResetAlerts(); });
// Cursor // Cursor
@ -681,6 +682,9 @@ public:
m_curPref->bg.color1(checkedBgColor1()->getColor()); m_curPref->bg.color1(checkedBgColor1()->getColor());
m_curPref->bg.color2(checkedBgColor2()->getColor()); m_curPref->bg.color2(checkedBgColor2()->getColor());
// Alerts preferences
m_pref.openFile.openSequence(gen::SequenceDecision(openSequence()->getSelectedItemIndex()));
int undo_size_limit_value; int undo_size_limit_value;
undo_size_limit_value = undoSizeLimit()->textInt(); undo_size_limit_value = undoSizeLimit()->textInt();
undo_size_limit_value = base::clamp(undo_size_limit_value, 0, 999999); undo_size_limit_value = base::clamp(undo_size_limit_value, 0, 999999);

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -261,10 +261,19 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context,
window.openWindowInForeground(); window.openWindowInForeground();
// Don't show this alert again.
if (window.dontShow()->isSelected()) {
Preferences::instance().openFile.openSequence(
window.closer() == window.agree() ?
gen::SequenceDecision::YES:
gen::SequenceDecision::NO);
}
// If the user selected the "do the same for other files" // If the user selected the "do the same for other files"
// checkbox, we've to save what the user want to do for the // checkbox, we've to save what the user want to do for the
// following files. // following files.
if (window.repeat()->isSelected()) { if (window.repeat()->isSelected() ||
window.dontShow()->isSelected()) {
if (window.closer() == window.agree()) if (window.closer() == window.agree())
fop->m_seq.flags = FILE_LOAD_SEQUENCE_YES; fop->m_seq.flags = FILE_LOAD_SEQUENCE_YES;
else else

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A. // Copyright (C) 2019-2021 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -174,11 +174,12 @@ FOR_ENUM(app::gen::PivotPosition)
FOR_ENUM(app::gen::PixelConnectivity) FOR_ENUM(app::gen::PixelConnectivity)
FOR_ENUM(app::gen::RightClickMode) FOR_ENUM(app::gen::RightClickMode)
FOR_ENUM(app::gen::SelectionMode) FOR_ENUM(app::gen::SelectionMode)
FOR_ENUM(app::gen::SequenceDecision)
FOR_ENUM(app::gen::StopAtGrid) FOR_ENUM(app::gen::StopAtGrid)
FOR_ENUM(app::gen::SymmetryMode) FOR_ENUM(app::gen::SymmetryMode)
FOR_ENUM(app::gen::TimelinePosition) FOR_ENUM(app::gen::TimelinePosition)
FOR_ENUM(app::gen::WindowColorProfile)
FOR_ENUM(app::gen::ToGrayAlgorithm) FOR_ENUM(app::gen::ToGrayAlgorithm)
FOR_ENUM(app::gen::WindowColorProfile)
FOR_ENUM(app::tools::FreehandAlgorithm) FOR_ENUM(app::tools::FreehandAlgorithm)
FOR_ENUM(app::tools::RotationAlgorithm) FOR_ENUM(app::tools::RotationAlgorithm)
FOR_ENUM(doc::AniDir) FOR_ENUM(doc::AniDir)

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2020-2021 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -29,14 +29,14 @@ namespace app {
params.set("oneframe", "true"); params.set("oneframe", "true");
else { else {
switch (m_lastDecision) { switch (m_lastDecision) {
case OpenFileCommand::SequenceDecision::Ask: case gen::SequenceDecision::ASK:
params.set("sequence", "ask"); params.set("sequence", "ask");
params.set("repeat_checkbox", "true"); params.set("repeat_checkbox", "true");
break; break;
case OpenFileCommand::SequenceDecision::Skip: case gen::SequenceDecision::NO:
params.set("sequence", "skip"); params.set("sequence", "skip");
break; break;
case OpenFileCommand::SequenceDecision::Agree: case gen::SequenceDecision::YES:
params.set("sequence", "agree"); params.set("sequence", "agree");
break; break;
} }
@ -49,7 +49,7 @@ namespace app {
// Future decision for other files in the CLI // Future decision for other files in the CLI
auto d = m_cmd.seqDecision(); auto d = m_cmd.seqDecision();
if (d != OpenFileCommand::SequenceDecision::Ask) if (d != gen::SequenceDecision::ASK)
m_lastDecision = d; m_lastDecision = d;
} }
@ -59,7 +59,7 @@ namespace app {
private: private:
OpenFileCommand m_cmd; OpenFileCommand m_cmd;
OpenFileCommand::SequenceDecision m_lastDecision = OpenFileCommand::SequenceDecision::Ask; gen::SequenceDecision m_lastDecision = gen::SequenceDecision::ASK;
}; };
} // namespace app } // namespace app