mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Improve UX in File > Export in special cases for output filename extension
* When the extension is unknown, an error is shown. * When the extension is not written, the default extension will be added (the default extension is different depending on if the file format is image format or an animation format).
This commit is contained in:
parent
49106817d4
commit
51ce52981a
@ -95,6 +95,11 @@ Warning
|
||||
<<Do you really want to uninstall '{0}' extension?
|
||||
||&Yes||&No
|
||||
END
|
||||
unknown_output_file_format_error = <<<END
|
||||
Aseprite
|
||||
<<Unknown file format '{0}' in output filename
|
||||
||&OK
|
||||
END
|
||||
update_screen_ui_scaling_with_theme_values = <<<END
|
||||
Update Screen/UI Scaling
|
||||
<<The new theme '{0}' wants to adjust some values for you:
|
||||
|
@ -42,7 +42,7 @@
|
||||
<hbox cell_hspan="3">
|
||||
<boxfiller />
|
||||
<hbox homogeneous="true">
|
||||
<button text="@.export" minwidth="60" closewindow="true" id="ok" magnet="true" />
|
||||
<button text="@.export" minwidth="60" id="ok" magnet="true" />
|
||||
<button text="@.cancel" minwidth="60" closewindow="true" />
|
||||
</hbox>
|
||||
</hbox>
|
||||
|
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 8cf772813063d25116dcf38a5f3a41a34a6a32b8
|
||||
Subproject commit b135dbfb5adb32f9b14f85eef1e5fa744d1c553e
|
@ -11,16 +11,21 @@
|
||||
#include "app/ui/export_file_window.h"
|
||||
|
||||
#include "app/document.h"
|
||||
#include "app/file/file.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/ui/layer_frame_comboboxes.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/selected_frames.h"
|
||||
#include "doc/site.h"
|
||||
#include "fmt/format.h"
|
||||
#include "ui/alert.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -29,8 +34,6 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
, m_docPref(Preferences::instance().document(doc))
|
||||
, m_preferredResize(1)
|
||||
{
|
||||
auto& pref = Preferences::instance();
|
||||
|
||||
// Is a default output filename in the preferences?
|
||||
if (!m_docPref.saveCopy.filename().empty()) {
|
||||
setOutputFilename(m_docPref.saveCopy.filename());
|
||||
@ -38,8 +41,7 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
else {
|
||||
std::string newFn = base::replace_extension(
|
||||
doc->filename(),
|
||||
(doc->sprite()->totalFrames() > 1 ? pref.exportFile.animationDefaultExtension():
|
||||
pref.exportFile.imageDefaultExtension()));
|
||||
defaultExtension());
|
||||
if (newFn == doc->filename()) {
|
||||
newFn = base::join_path(
|
||||
base::get_file_path(newFn),
|
||||
@ -80,6 +82,7 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
|
||||
frames()->Change.connect(base::Bind<void>(&ExportFileWindow::updateAniDir, this));
|
||||
forTwitter()->Click.connect(base::Bind<void>(&ExportFileWindow::updateAdjustResizeButton, this));
|
||||
adjustResize()->Click.connect(base::Bind<void>(&ExportFileWindow::onAdjustResize, this));
|
||||
ok()->Click.connect(base::Bind<void>(&ExportFileWindow::onOK, this));
|
||||
}
|
||||
|
||||
bool ExportFileWindow::show()
|
||||
@ -200,4 +203,36 @@ void ExportFileWindow::onAdjustResize()
|
||||
adjustResize()->parent()->layout();
|
||||
}
|
||||
|
||||
void ExportFileWindow::onOK()
|
||||
{
|
||||
base::paths exts = get_writable_extensions();
|
||||
std::string ext = base::string_to_lower(
|
||||
base::get_file_extension(m_outputFilename));
|
||||
|
||||
// Add default extension to output filename
|
||||
if (std::find(exts.begin(), exts.end(), ext) == exts.end()) {
|
||||
if (ext.empty()) {
|
||||
m_outputFilename =
|
||||
base::replace_extension(m_outputFilename,
|
||||
defaultExtension());
|
||||
}
|
||||
else {
|
||||
ui::Alert::show(
|
||||
fmt::format(Strings::alerts_unknown_output_file_format_error(), ext));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
closeWindow(ok());
|
||||
}
|
||||
|
||||
std::string ExportFileWindow::defaultExtension() const
|
||||
{
|
||||
auto& pref = Preferences::instance();
|
||||
if (m_doc->sprite()->totalFrames() > 1)
|
||||
return pref.exportFile.animationDefaultExtension();
|
||||
else
|
||||
return pref.exportFile.imageDefaultExtension();
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -42,6 +42,8 @@ namespace app {
|
||||
void updateAniDir();
|
||||
void updateAdjustResizeButton();
|
||||
void onAdjustResize();
|
||||
void onOK();
|
||||
std::string defaultExtension() const;
|
||||
|
||||
const Document* m_doc;
|
||||
DocumentPreferences& m_docPref;
|
||||
|
Loading…
x
Reference in New Issue
Block a user