Qt: More GIF view UX fixes

This commit is contained in:
Vicki Pfau 2020-02-14 19:21:37 -08:00
parent 458a95e11f
commit a5fc8429eb
2 changed files with 20 additions and 0 deletions

View File

@ -25,6 +25,8 @@ GIFView::GIFView(QWidget* parent)
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);
@ -92,4 +94,21 @@ void GIFView::setFilename(const QString& filename) {
}
}
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

View File

@ -41,6 +41,7 @@ signals:
private slots:
void selectFile();
void setFilename(const QString&);
void changeExtension();
private:
Ui::GIFView m_ui;