mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 21:19:10 +00:00
Clear save_copy preference values of saved copies (related to #1964)
This commit is contained in:
parent
b190cc985e
commit
70ff67e890
@ -433,7 +433,7 @@
|
||||
<option id="current_layer" type="bool" default="false" />
|
||||
<option id="position" type="render::OnionskinPosition" default="render::OnionskinPosition::BEHIND" />
|
||||
</section>
|
||||
<section id="save_copy">
|
||||
<section id="save_copy" canclear="true">
|
||||
<option id="filename" type="std::string" />
|
||||
<option id="resize_scale" type="double" default="1" />
|
||||
<option id="layer" type="std::string" />
|
||||
|
@ -189,13 +189,7 @@ std::string SaveFileBaseCommand::saveAsDialog(
|
||||
// https://github.com/aseprite/aseprite/issues/1964
|
||||
//
|
||||
auto& docPref = Preferences::instance().document(document);
|
||||
docPref.saveCopy.filename(docPref.saveCopy.filename.defaultValue());
|
||||
docPref.saveCopy.aniDir(docPref.saveCopy.aniDir.defaultValue());
|
||||
docPref.saveCopy.applyPixelRatio(docPref.saveCopy.applyPixelRatio.defaultValue());
|
||||
docPref.saveCopy.frameTag(docPref.saveCopy.frameTag.defaultValue());
|
||||
docPref.saveCopy.layer(docPref.saveCopy.layer.defaultValue());
|
||||
docPref.saveCopy.forTwitter(docPref.saveCopy.forTwitter.defaultValue());
|
||||
docPref.saveCopy.resizeScale(docPref.saveCopy.resizeScale.defaultValue());
|
||||
docPref.saveCopy.clearSection();
|
||||
}
|
||||
|
||||
return filename;
|
||||
|
@ -105,8 +105,10 @@ namespace app {
|
||||
void cleanDirtyFlag() { m_dirty = false; }
|
||||
|
||||
void setValue(const T& newValue) {
|
||||
if (m_value == newValue)
|
||||
if (m_value == newValue) {
|
||||
m_dirty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
BeforeChange(newValue);
|
||||
if (m_section)
|
||||
@ -120,6 +122,11 @@ namespace app {
|
||||
m_section->AfterChange();
|
||||
}
|
||||
|
||||
void clearValue() {
|
||||
m_value = m_default;
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
void pushLua(lua_State* L) override {
|
||||
script::push_value_to_lua<T>(L, m_value);
|
||||
|
@ -17,19 +17,23 @@ namespace app {
|
||||
|
||||
template<typename T>
|
||||
void load_option(Option<T>& opt) {
|
||||
opt(get_config_value(opt.section(), opt.id(), opt.defaultValue()));
|
||||
if (get_config_string(opt.section(), opt.id(), nullptr))
|
||||
opt(get_config_value(opt.section(), opt.id(), opt.defaultValue()));
|
||||
else
|
||||
opt.setValueAndDefault(opt.defaultValue());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void load_option_with_migration(Option<T>& opt, const char* oldSection, const char* oldName) {
|
||||
if (get_config_string(oldSection, oldName, NULL)) {
|
||||
if (get_config_string(oldSection, oldName, nullptr)) {
|
||||
opt(get_config_value(oldSection, oldName, opt.defaultValue()));
|
||||
del_config_value(oldSection, oldName);
|
||||
|
||||
opt.forceDirtyFlag();
|
||||
}
|
||||
else
|
||||
opt(get_config_value(opt.section(), opt.id(), opt.defaultValue()));
|
||||
else {
|
||||
load_option<T>(opt);
|
||||
}
|
||||
}
|
||||
|
||||
// Save
|
||||
|
@ -30,6 +30,8 @@ static void print_pref_class_def(TiXmlElement* elem, const std::string& classNam
|
||||
|
||||
if (elem->Attribute("canforce"))
|
||||
std::cout << indent << " void forceSection();\n";
|
||||
if (elem->Attribute("canclear"))
|
||||
std::cout << indent << " void clearSection();\n";
|
||||
|
||||
std::cout
|
||||
<< indent << " void load();\n"
|
||||
@ -126,7 +128,30 @@ static void print_pref_class_impl(TiXmlElement* elem, const std::string& prefix,
|
||||
}
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
std::cout
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
// Section::clearSection()
|
||||
if (elem->Attribute("canclear")) {
|
||||
std::cout
|
||||
<< "\n"
|
||||
<< "void " << prefix << className << "::clearSection()\n"
|
||||
<< "{\n";
|
||||
|
||||
child = (elem->FirstChild() ? elem->FirstChild()->ToElement(): nullptr);
|
||||
while (child) {
|
||||
if (child->Value()) {
|
||||
std::string name = child->Value();
|
||||
const char* childId = child->Attribute("id");
|
||||
|
||||
if (name == "option") {
|
||||
std::string memberName = convert_xmlid_to_cppid(childId, false);
|
||||
std::cout << " " << memberName << ".clearValue();\n";
|
||||
}
|
||||
}
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
std::cout
|
||||
<< "}\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user