mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 21:44:22 +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 -->
|
<!-- Copyright (C) 2016-2018 by David Capello -->
|
||||||
<gui>
|
<gui>
|
||||||
<window id="export_file" text="@.title">
|
<window id="export_file" text="@.title">
|
||||||
<grid columns="2">
|
<grid columns="3">
|
||||||
<label text="@.output_file" />
|
<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" />
|
<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="25%" value="0.25" />
|
||||||
<listitem text="50%" value="0.5" />
|
<listitem text="50%" value="0.5" />
|
||||||
<listitem text="100%" value="1" />
|
<listitem text="100%" value="1" />
|
||||||
@ -23,17 +24,17 @@
|
|||||||
</combobox>
|
</combobox>
|
||||||
|
|
||||||
<label id="layers_label" text="@.layers" />
|
<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" />
|
<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" />
|
<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 />
|
<boxfiller />
|
||||||
<hbox homogeneous="true">
|
<hbox homogeneous="true">
|
||||||
<button text="@.export" minwidth="60" closewindow="true" id="ok" magnet="true" />
|
<button text="@.export" minwidth="60" closewindow="true" id="ok" magnet="true" />
|
||||||
|
@ -310,12 +310,15 @@ again:;
|
|||||||
if (!win.show())
|
if (!win.show())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (askOverwrite) {
|
std::string outputFilename = win.outputFilenameValue();
|
||||||
|
|
||||||
|
if (askOverwrite &&
|
||||||
|
base::is_file(outputFilename)) {
|
||||||
int ret = OptionalAlert::show(
|
int ret = OptionalAlert::show(
|
||||||
Preferences::instance().exportFile.showOverwriteFilesAlert,
|
Preferences::instance().exportFile.showOverwriteFilesAlert,
|
||||||
1, // Yes is the default option when the alert dialog is disabled
|
1, // Yes is the default option when the alert dialog is disabled
|
||||||
fmt::format(Strings::alerts_overwrite_files_on_export(),
|
fmt::format(Strings::alerts_overwrite_files_on_export(),
|
||||||
win.outputFilenameValue()));
|
outputFilename));
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -384,7 +387,7 @@ again:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveDocumentInBackground(
|
saveDocumentInBackground(
|
||||||
context, doc, win.outputFilenameValue(), false);
|
context, doc, outputFilename, false);
|
||||||
|
|
||||||
m_aniDir.clear();
|
m_aniDir.clear();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
|||||||
{
|
{
|
||||||
// Is a default output filename in the preferences?
|
// Is a default output filename in the preferences?
|
||||||
if (!m_docPref.saveCopy.filename().empty()) {
|
if (!m_docPref.saveCopy.filename().empty()) {
|
||||||
m_outputFilename = m_docPref.saveCopy.filename();
|
setOutputFilename(m_docPref.saveCopy.filename());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string newFn = base::replace_extension(
|
std::string newFn = base::replace_extension(
|
||||||
@ -39,9 +39,8 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
|||||||
base::get_file_path(newFn),
|
base::get_file_path(newFn),
|
||||||
base::get_file_title(newFn) + "-export." + base::get_file_extension(newFn));
|
base::get_file_title(newFn) + "-export." + base::get_file_extension(newFn));
|
||||||
}
|
}
|
||||||
m_outputFilename = newFn;
|
setOutputFilename(newFn);
|
||||||
}
|
}
|
||||||
updateOutputFilenameButton();
|
|
||||||
|
|
||||||
// Default export configuration
|
// Default export configuration
|
||||||
resize()->setValue(
|
resize()->setValue(
|
||||||
@ -53,12 +52,18 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
|||||||
|
|
||||||
updateAniDir();
|
updateAniDir();
|
||||||
|
|
||||||
outputFilename()->Click.connect(base::Bind<void>(
|
outputFilename()->Change.connect(
|
||||||
|
base::Bind<void>(
|
||||||
|
[this]{
|
||||||
|
m_outputFilename = outputFilename()->text();
|
||||||
|
onOutputFilenameEntryChange();
|
||||||
|
}));
|
||||||
|
outputFilenameBrowse()->Click.connect(
|
||||||
|
base::Bind<void>(
|
||||||
[this]{
|
[this]{
|
||||||
std::string fn = SelectOutputFile();
|
std::string fn = SelectOutputFile();
|
||||||
if (!fn.empty()) {
|
if (!fn.empty()) {
|
||||||
m_outputFilename = fn;
|
setOutputFilename(fn);
|
||||||
updateOutputFilenameButton();
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -80,6 +85,12 @@ void ExportFileWindow::savePref()
|
|||||||
m_docPref.saveCopy.applyPixelRatio(applyPixelRatio());
|
m_docPref.saveCopy.applyPixelRatio(applyPixelRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ExportFileWindow::outputFilenameValue() const
|
||||||
|
{
|
||||||
|
return base::join_path(m_outputPath,
|
||||||
|
m_outputFilename);
|
||||||
|
}
|
||||||
|
|
||||||
double ExportFileWindow::resizeValue() const
|
double ExportFileWindow::resizeValue() const
|
||||||
{
|
{
|
||||||
return base::convert_to<double>(resize()->getValue());
|
return base::convert_to<double>(resize()->getValue());
|
||||||
@ -105,9 +116,22 @@ bool ExportFileWindow::applyPixelRatio() const
|
|||||||
return pixelRatio()->isSelected();
|
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());
|
ok()->setEnabled(!m_outputFilename.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace app {
|
|||||||
bool show();
|
bool show();
|
||||||
void savePref();
|
void savePref();
|
||||||
|
|
||||||
const std::string& outputFilenameValue() const { return m_outputFilename; }
|
std::string outputFilenameValue() const;
|
||||||
double resizeValue() const;
|
double resizeValue() const;
|
||||||
std::string layersValue() const;
|
std::string layersValue() const;
|
||||||
std::string framesValue() const;
|
std::string framesValue() const;
|
||||||
@ -35,11 +35,14 @@ namespace app {
|
|||||||
obs::signal<std::string()> SelectOutputFile;
|
obs::signal<std::string()> SelectOutputFile;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateOutputFilenameButton();
|
void setOutputFilename(const std::string& pathAndFilename);
|
||||||
|
void updateOutputFilenameEntry();
|
||||||
|
void onOutputFilenameEntryChange();
|
||||||
void updateAniDir();
|
void updateAniDir();
|
||||||
|
|
||||||
const Document* m_doc;
|
const Document* m_doc;
|
||||||
DocumentPreferences& m_docPref;
|
DocumentPreferences& m_docPref;
|
||||||
|
std::string m_outputPath;
|
||||||
std::string m_outputFilename;
|
std::string m_outputFilename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user