mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-03 23:41:56 +00:00
Use BoolPrefWidget for alert options in Preferences dialog
This commit is contained in:
parent
b8445956ae
commit
7d96968ac3
@ -309,13 +309,20 @@
|
||||
<!-- Alerts -->
|
||||
<vbox id="section_alerts">
|
||||
<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" />
|
||||
<check id="advanced_mode_alert" text="@.advanced_mode_alert" />
|
||||
<check id="file_format_doesnt_support_alert" text="@.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"
|
||||
pref="save_file.show_export_animation_in_sequence_alert" />
|
||||
<check id="overwrite_files_on_export_alert" text="@.overwrite_files_on_export_alert"
|
||||
pref="export_file.show_overwrite_files_alert" />
|
||||
<check id="overwrite_files_on_export_sprite_sheet_alert" text="@.overwrite_files_on_export_sprite_sheet_alert"
|
||||
pref="sprite_sheet.show_overwrite_files_alert" />
|
||||
<check id="gif_options_alert" text="@.gif_options_alert"
|
||||
pref="gif.show_alert" />
|
||||
<check id="jpeg_options_alert" text="@.jpeg_options_alert"
|
||||
pref="jpeg.show_alert" />
|
||||
<check id="advanced_mode_alert" text="@.advanced_mode_alert"
|
||||
pref="advanced_mode.show_alert" />
|
||||
<separator horizontal="true" />
|
||||
<hbox>
|
||||
<hbox expansive="true" />
|
||||
|
@ -154,13 +154,6 @@ public:
|
||||
clearRecentFiles()->Click.connect(base::Bind<void>(&OptionsWindow::onClearRecentFiles, this));
|
||||
|
||||
// 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());
|
||||
advancedModeAlert()->setSelected(m_pref.advancedMode.showAlert());
|
||||
resetAlerts()->Click.connect(base::Bind<void>(&OptionsWindow::onResetAlerts, this));
|
||||
|
||||
// Cursor
|
||||
@ -430,14 +423,6 @@ public:
|
||||
warnings += "<<- " + Strings::alerts_restart_by_preferences_save_recovery_data_period();
|
||||
}
|
||||
|
||||
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());
|
||||
m_pref.advancedMode.showAlert(advancedModeAlert()->isSelected());
|
||||
|
||||
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
|
||||
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
|
||||
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
|
||||
@ -642,13 +627,13 @@ 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());
|
||||
advancedModeAlert()->setSelected(m_pref.advancedMode.showAlert.defaultValue());
|
||||
fileFormatDoesntSupportAlert()->resetWithDefaultValue();
|
||||
exportAnimationInSequenceAlert()->resetWithDefaultValue();
|
||||
overwriteFilesOnExportAlert()->resetWithDefaultValue();
|
||||
overwriteFilesOnExportSpriteSheetAlert()->resetWithDefaultValue();
|
||||
gifOptionsAlert()->resetWithDefaultValue();
|
||||
jpegOptionsAlert()->resetWithDefaultValue();
|
||||
advancedModeAlert()->resetWithDefaultValue();
|
||||
}
|
||||
|
||||
void onChangeBgScope() {
|
||||
|
@ -50,6 +50,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void resetWithDefaultValue() {
|
||||
// Reset to default value in preferences
|
||||
if (m_option)
|
||||
this->setSelected(m_option->defaultValue());
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(ui::Message* msg) override {
|
||||
if (msg->type() == kSavePreferencesMessage) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Code Generator
|
||||
// Copyright (c) 2014-2017 David Capello
|
||||
// Copyright (c) 2014-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -47,7 +47,8 @@ static void collect_widgets_with_ids(TiXmlElement* elem, XmlElements& widgets)
|
||||
}
|
||||
}
|
||||
|
||||
static std::string convert_type(const std::string& name)
|
||||
static std::string convert_type(const std::string& name,
|
||||
const bool hasPref)
|
||||
{
|
||||
static std::string parent;
|
||||
if (name != "item")
|
||||
@ -56,7 +57,12 @@ static std::string convert_type(const std::string& name)
|
||||
if (name == "box") return "ui::Box";
|
||||
if (name == "button") return "ui::Button";
|
||||
if (name == "buttonset") return "app::ButtonSet";
|
||||
if (name == "check") return "ui::CheckBox";
|
||||
if (name == "check") {
|
||||
if (hasPref)
|
||||
return "BoolPrefWidget<ui::CheckBox>";
|
||||
else
|
||||
return "ui::CheckBox";
|
||||
}
|
||||
if (name == "colorpicker") return "app::ColorButton";
|
||||
if (name == "combobox") return "ui::ComboBox";
|
||||
if (name == "dropdownbutton") return "app::DropDownButton";
|
||||
@ -102,7 +108,7 @@ void gen_ui_class(TiXmlDocument* doc,
|
||||
|
||||
std::string className = convert_xmlid_to_cppid(widgetId, true);
|
||||
std::string fnUpper = base::string_to_upper(base::get_file_title(inputFn));
|
||||
std::string widgetType = convert_type(elem->Value());
|
||||
std::string widgetType = convert_type(elem->Value(), false);
|
||||
|
||||
std::cout
|
||||
<< "#ifndef GENERATED_" << fnUpper << "_H_INCLUDED\n"
|
||||
@ -111,6 +117,7 @@ void gen_ui_class(TiXmlDocument* doc,
|
||||
<< "\n"
|
||||
<< "#include \"app/find_widget.h\"\n"
|
||||
<< "#include \"app/load_widget.h\"\n"
|
||||
<< "#include \"app/ui/pref_widget.h\"\n"
|
||||
<< "#include \"ui/ui.h\"\n"
|
||||
<< "\n"
|
||||
<< "namespace app {\n"
|
||||
@ -149,8 +156,9 @@ void gen_ui_class(TiXmlDocument* doc,
|
||||
<< "\n";
|
||||
|
||||
for (TiXmlElement* elem : widgets) {
|
||||
std::string childType = convert_type(elem->Value());
|
||||
const char* id = elem->Attribute("id");
|
||||
const char* pref = elem->Attribute("pref");
|
||||
std::string childType = convert_type(elem->Value(), (pref != nullptr));
|
||||
std::string cppid = convert_xmlid_to_cppid(id, false);
|
||||
std::cout
|
||||
<< " " << childType << "* " << cppid << "() const { return m_" << cppid << "; }\n";
|
||||
@ -161,8 +169,9 @@ void gen_ui_class(TiXmlDocument* doc,
|
||||
<< " private:\n";
|
||||
|
||||
for (TiXmlElement* elem : widgets) {
|
||||
std::string childType = convert_type(elem->Value());
|
||||
const char* id = elem->Attribute("id");
|
||||
const char* pref = elem->Attribute("pref");
|
||||
std::string childType = convert_type(elem->Value(), (pref != nullptr));
|
||||
std::string cppid = convert_xmlid_to_cppid(id, false);
|
||||
std::cout
|
||||
<< " " << childType << "* m_" << cppid << ";\n";
|
||||
|
Loading…
Reference in New Issue
Block a user