all repos — mgba @ a5fc8429eba86c2cf75546f8520e8e9cb2e6449f

mGBA Game Boy Advance Emulator

Qt: More GIF view UX fixes
Vicki Pfau vi@endrift.com
Fri, 14 Feb 2020 19:21:37 -0800
commit

a5fc8429eba86c2cf75546f8520e8e9cb2e6449f

parent

458a95e11f5c0d23b477328ad31cd5d43be1e149

2 files changed, 20 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/GIFView.cppsrc/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.hsrc/platform/qt/GIFView.h

@@ -41,6 +41,7 @@

private slots: void selectFile(); void setFilename(const QString&); + void changeExtension(); private: Ui::GIFView m_ui;