diff --git a/data/strings/en.ini b/data/strings/en.ini
index 023b0d408..3672f8eff 100644
--- a/data/strings/en.ini
+++ b/data/strings/en.ini
@@ -468,6 +468,7 @@ for_twitter_tooltip = <<
-
+
+
+
+
diff --git a/src/app/ui/export_file_window.cpp b/src/app/ui/export_file_window.cpp
index 0d90ffb6b..290e0cbd9 100644
--- a/src/app/ui/export_file_window.cpp
+++ b/src/app/ui/export_file_window.cpp
@@ -11,6 +11,7 @@
#include "app/ui/export_file_window.h"
#include "app/document.h"
+#include "app/i18n/strings.h"
#include "app/ui/layer_frame_comboboxes.h"
#include "app/ui_context.h"
#include "base/bind.h"
@@ -19,12 +20,14 @@
#include "doc/frame_tag.h"
#include "doc/selected_frames.h"
#include "doc/site.h"
+#include "fmt/format.h"
namespace app {
ExportFileWindow::ExportFileWindow(const Document* doc)
: m_doc(doc)
, m_docPref(Preferences::instance().document(doc))
+ , m_preferredResize(1)
{
// Is a default output filename in the preferences?
if (!m_docPref.saveCopy.filename().empty()) {
@@ -50,8 +53,10 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
fill_anidir_combobox(anidir(), m_docPref.saveCopy.aniDir());
pixelRatio()->setSelected(m_docPref.saveCopy.applyPixelRatio());
forTwitter()->setSelected(m_docPref.saveCopy.forTwitter());
+ adjustResize()->setVisible(false);
updateAniDir();
+ updateAdjustResizeButton();
outputFilename()->Change.connect(
base::Bind(
@@ -68,7 +73,10 @@ ExportFileWindow::ExportFileWindow(const Document* doc)
}
}));
+ resize()->Change.connect(base::Bind(&ExportFileWindow::updateAdjustResizeButton, this));
frames()->Change.connect(base::Bind(&ExportFileWindow::updateAniDir, this));
+ forTwitter()->Click.connect(base::Bind(&ExportFileWindow::updateAdjustResizeButton, this));
+ adjustResize()->Click.connect(base::Bind(&ExportFileWindow::onAdjustResize, this));
}
bool ExportFileWindow::show()
@@ -158,4 +166,35 @@ void ExportFileWindow::updateAniDir()
anidir()->setSelectedItemIndex(int(doc::AniDir::FORWARD));
}
+void ExportFileWindow::updateAdjustResizeButton()
+{
+ // Calculate a better size for Twitter
+ m_preferredResize = 1;
+ while (m_preferredResize < 10 &&
+ (m_doc->width()*m_preferredResize < 240 ||
+ m_doc->height()*m_preferredResize < 240)) {
+ ++m_preferredResize;
+ }
+
+ const bool newState =
+ forTwitter()->isSelected() &&
+ ((int)resizeValue() < m_preferredResize);
+
+ if (adjustResize()->isVisible() != newState) {
+ adjustResize()->setVisible(newState);
+ if (newState)
+ adjustResize()->setText(fmt::format(Strings::export_file_adjust_resize(),
+ 100 * m_preferredResize));
+ adjustResize()->parent()->layout();
+ }
+}
+
+void ExportFileWindow::onAdjustResize()
+{
+ resize()->setValue(base::convert_to(m_preferredResize));
+
+ adjustResize()->setVisible(false);
+ adjustResize()->parent()->layout();
+}
+
} // namespace app
diff --git a/src/app/ui/export_file_window.h b/src/app/ui/export_file_window.h
index 3ce0e05a2..13d2df068 100644
--- a/src/app/ui/export_file_window.h
+++ b/src/app/ui/export_file_window.h
@@ -40,11 +40,14 @@ namespace app {
void updateOutputFilenameEntry();
void onOutputFilenameEntryChange();
void updateAniDir();
+ void updateAdjustResizeButton();
+ void onAdjustResize();
const Document* m_doc;
DocumentPreferences& m_docPref;
std::string m_outputPath;
std::string m_outputFilename;
+ int m_preferredResize;
};
}