Qt: More GIF view UX fixes
Vicki Pfau vi@endrift.com
Fri, 14 Feb 2020 19:21:37 -0800
2 files changed,
20 insertions(+),
0 deletions(-)
M
src/platform/qt/GIFView.cpp
→
src/platform/qt/GIFView.cpp
@@ -25,6 +25,8 @@ connect(m_ui.stop, &QAbstractButton::clicked, this, &GIFView::stopRecording);
connect(m_ui.selectFile, &QAbstractButton::clicked, this, &GIFView::selectFile); connect(m_ui.filename, &QLineEdit::textChanged, this, &GIFView::setFilename); + connect(m_ui.fmtGif, &QAbstractButton::clicked, this, &GIFView::changeExtension); + connect(m_ui.fmtApng, &QAbstractButton::clicked, this, &GIFView::changeExtension); FFmpegEncoderInit(&m_encoder); FFmpegEncoderSetAudio(&m_encoder, nullptr, 0);@@ -90,6 +92,23 @@ } else if (filename.endsWith(".png") || filename.endsWith(".apng")) {
m_ui.fmtApng->setChecked(Qt::Checked); } } +} + +void GIFView::changeExtension() { + if (m_filename.isEmpty()) { + return; + } + QString filename = m_filename; + int index = m_filename.lastIndexOf("."); + if (index >= 0) { + filename.truncate(index); + } + if (m_ui.fmtGif->isChecked()) { + filename += ".gif"; + } else if (m_ui.fmtApng->isChecked()) { + filename += ".png"; + } + m_ui.filename->setText(filename); } #endif
M
src/platform/qt/GIFView.h
→
src/platform/qt/GIFView.h
@@ -41,6 +41,7 @@
private slots: void selectFile(); void setFilename(const QString&); + void changeExtension(); private: Ui::GIFView m_ui;