mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Convert the output filename field on Export to a Entry field
This commit is contained in:
parent
834fd962f6
commit
d9a848a32c
@ -2,12 +2,13 @@
|
||||
<!-- Copyright (C) 2016-2018 by David Capello -->
|
||||
<gui>
|
||||
<window id="export_file" text="@.title">
|
||||
<grid columns="2">
|
||||
<grid columns="3">
|
||||
<label text="@.output_file" />
|
||||
<button id="output_filename" cell_align="horizontal" maxwidth="256" />
|
||||
<entry id="output_filename" cell_align="horizontal" maxsize="1024" maxwidth="256" />
|
||||
<button id="output_filename_browse" text="..." style="mini_button" />
|
||||
|
||||
<label id="resize_label" text="@.resize" />
|
||||
<combobox id="resize" cell_align="horizontal">
|
||||
<combobox id="resize" cell_align="horizontal" cell_hspan="2">
|
||||
<listitem text="25%" value="0.25" />
|
||||
<listitem text="50%" value="0.5" />
|
||||
<listitem text="100%" value="1" />
|
||||
@ -23,17 +24,17 @@
|
||||
</combobox>
|
||||
|
||||
<label id="layers_label" text="@.layers" />
|
||||
<combobox id="layers" text="" cell_align="horizontal" />
|
||||
<combobox id="layers" text="" cell_align="horizontal" cell_hspan="2" />
|
||||
|
||||
<label id="frames_label" text="@.frames" />
|
||||
<combobox id="frames" text="" cell_align="horizontal" />
|
||||
<combobox id="frames" text="" cell_align="horizontal" cell_hspan="2" />
|
||||
|
||||
<label id="anidir_label" text="@.anidir" />
|
||||
<combobox id="anidir" text="" cell_align="horizontal" />
|
||||
<combobox id="anidir" text="" cell_align="horizontal" cell_hspan="2" />
|
||||
|
||||
<check id="pixel_ratio" text="@.pixel_ratio" cell_hspan="2" />
|
||||
<check id="pixel_ratio" text="@.pixel_ratio" cell_hspan="3" />
|
||||
|
||||
<hbox cell_hspan="2">
|
||||
<hbox cell_hspan="3">
|
||||
<boxfiller />
|
||||
<hbox homogeneous="true">
|
||||
<button text="@.export" minwidth="60" closewindow="true" id="ok" magnet="true" />
|
||||
|
@ -310,12 +310,15 @@ again:;
|
||||
if (!win.show())
|
||||
return;
|
||||
|
||||
if (askOverwrite) {
|
||||
std::string outputFilename = win.outputFilenameValue();
|
||||
|
||||
if (askOverwrite &&
|
||||
base::is_file(outputFilename)) {
|
||||
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()));
|
||||
outputFilename));
|
||||
if (ret != 1)
|
||||
goto again;
|
||||
}
|
||||
@ -384,7 +387,7 @@ again:;
|
||||
}
|
||||
|
||||
saveDocumentInBackground(
|
||||
context, doc, win.outputFilenameValue(), false);
|
||||
context, doc, outputFilename, false);
|
||||
|
||||
m_aniDir.clear();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
{
|
||||
// Is a default output filename in the preferences?
|
||||
if (!m_docPref.saveCopy.filename().empty()) {
|
||||
m_outputFilename = m_docPref.saveCopy.filename();
|
||||
setOutputFilename(m_docPref.saveCopy.filename());
|
||||
}
|
||||
else {
|
||||
std::string newFn = base::replace_extension(
|
||||
@ -39,9 +39,8 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
base::get_file_path(newFn),
|
||||
base::get_file_title(newFn) + "-export." + base::get_file_extension(newFn));
|
||||
}
|
||||
m_outputFilename = newFn;
|
||||
setOutputFilename(newFn);
|
||||
}
|
||||
updateOutputFilenameButton();
|
||||
|
||||
// Default export configuration
|
||||
resize()->setValue(
|
||||
@ -53,14 +52,20 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
|
||||
updateAniDir();
|
||||
|
||||
outputFilename()->Click.connect(base::Bind<void>(
|
||||
[this]{
|
||||
std::string fn = SelectOutputFile();
|
||||
if (!fn.empty()) {
|
||||
m_outputFilename = fn;
|
||||
updateOutputFilenameButton();
|
||||
}
|
||||
}));
|
||||
outputFilename()->Change.connect(
|
||||
base::Bind<void>(
|
||||
[this]{
|
||||
m_outputFilename = outputFilename()->text();
|
||||
onOutputFilenameEntryChange();
|
||||
}));
|
||||
outputFilenameBrowse()->Click.connect(
|
||||
base::Bind<void>(
|
||||
[this]{
|
||||
std::string fn = SelectOutputFile();
|
||||
if (!fn.empty()) {
|
||||
setOutputFilename(fn);
|
||||
}
|
||||
}));
|
||||
|
||||
frames()->Change.connect(base::Bind<void>(&ExportFileWindow::updateAniDir, this));
|
||||
}
|
||||
@ -80,6 +85,12 @@ void ExportFileWindow::savePref()
|
||||
m_docPref.saveCopy.applyPixelRatio(applyPixelRatio());
|
||||
}
|
||||
|
||||
std::string ExportFileWindow::outputFilenameValue() const
|
||||
{
|
||||
return base::join_path(m_outputPath,
|
||||
m_outputFilename);
|
||||
}
|
||||
|
||||
double ExportFileWindow::resizeValue() const
|
||||
{
|
||||
return base::convert_to<double>(resize()->getValue());
|
||||
@ -105,9 +116,22 @@ bool ExportFileWindow::applyPixelRatio() const
|
||||
return pixelRatio()->isSelected();
|
||||
}
|
||||
|
||||
void ExportFileWindow::updateOutputFilenameButton()
|
||||
void ExportFileWindow::setOutputFilename(const std::string& pathAndFilename)
|
||||
{
|
||||
m_outputPath = base::get_file_path(pathAndFilename);
|
||||
m_outputFilename = base::get_file_name(pathAndFilename);
|
||||
|
||||
updateOutputFilenameEntry();
|
||||
}
|
||||
|
||||
void ExportFileWindow::updateOutputFilenameEntry()
|
||||
{
|
||||
outputFilename()->setText(m_outputFilename);
|
||||
onOutputFilenameEntryChange();
|
||||
}
|
||||
|
||||
void ExportFileWindow::onOutputFilenameEntryChange()
|
||||
{
|
||||
outputFilename()->setText(base::get_file_name(m_outputFilename));
|
||||
ok()->setEnabled(!m_outputFilename.empty());
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace app {
|
||||
bool show();
|
||||
void savePref();
|
||||
|
||||
const std::string& outputFilenameValue() const { return m_outputFilename; }
|
||||
std::string outputFilenameValue() const;
|
||||
double resizeValue() const;
|
||||
std::string layersValue() const;
|
||||
std::string framesValue() const;
|
||||
@ -35,11 +35,14 @@ namespace app {
|
||||
obs::signal<std::string()> SelectOutputFile;
|
||||
|
||||
private:
|
||||
void updateOutputFilenameButton();
|
||||
void setOutputFilename(const std::string& pathAndFilename);
|
||||
void updateOutputFilenameEntry();
|
||||
void onOutputFilenameEntryChange();
|
||||
void updateAniDir();
|
||||
|
||||
const Document* m_doc;
|
||||
DocumentPreferences& m_docPref;
|
||||
std::string m_outputPath;
|
||||
std::string m_outputFilename;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user