diff --git a/src/app/commands/cmd_duplicate_sprite.cpp b/src/app/commands/cmd_duplicate_sprite.cpp index 2a332516b..fd606bf49 100644 --- a/src/app/commands/cmd_duplicate_sprite.cpp +++ b/src/app/commands/cmd_duplicate_sprite.cpp @@ -32,6 +32,8 @@ #include "raster/sprite.h" #include "ui/ui.h" +#include "generated_duplicate_sprite.h" + #include namespace app { @@ -62,39 +64,34 @@ bool DuplicateSpriteCommand::onEnabled(Context* context) void DuplicateSpriteCommand::onExecute(Context* context) { - Widget* src_name, *dst_name, *flatten; const ContextReader reader(context); const Document* document = reader.document(); - /* load the window widget */ - base::UniquePtr window(app::load_widget("duplicate_sprite.xml", "duplicate_sprite")); - - src_name = window->findChild("src_name"); - dst_name = window->findChild("dst_name"); - flatten = window->findChild("flatten"); - + // Load the window widget + app::gen::DuplicateSprite window; std::string fn = document->filename(); std::string ext = base::get_file_extension(fn); - src_name->setText(base::get_file_name(fn)); - dst_name->setText(base::get_file_title(fn) + " Copy" + (!ext.empty() ? "." + ext: "")); + window.srcName()->setText(base::get_file_name(fn)); + window.dstName()->setText(base::get_file_title(fn) + + " Copy" + (!ext.empty() ? "." + ext: "")); if (get_config_bool("DuplicateSprite", "Flatten", false)) - flatten->setSelected(true); + window.flatten()->setSelected(true); // Open the window - window->openWindowInForeground(); + window.openWindowInForeground(); - if (window->getKiller() == window->findChild("ok")) { - set_config_bool("DuplicateSprite", "Flatten", flatten->isSelected()); + if (window.getKiller() == window.ok()) { + set_config_bool("DuplicateSprite", "Flatten", window.flatten()->isSelected()); // Make a copy of the document Document* docCopy; - if (flatten->isSelected()) + if (window.flatten()->isSelected()) docCopy = document->duplicate(DuplicateWithFlattenLayers); else docCopy = document->duplicate(DuplicateExactCopy); - docCopy->setFilename(dst_name->getText().c_str()); + docCopy->setFilename(window.dstName()->getText().c_str()); docCopy->setContext(context); } }