void MainWindow::onGLWidgetImageReady()
{
    Mlt::GLWidget* glw = qobject_cast<Mlt::GLWidget*>(MLT.videoWidget());
    QImage image = glw->image();
    if (Settings.playerGPU() || Settings.playerPreviewScale()) {
        disconnect(glw, SIGNAL(imageReady()), this, 0);
        MLT.setPreviewScale(Settings.playerPreviewScale());
    }
    if (!image.isNull()) {
        QString path = Settings.savePath();
        QString caption = tr("Export Frame");
        QString nameFilter = tr("PNG (*.png);;BMP (*.bmp);;JPEG (*.jpg *.jpeg);;PPM (*.ppm);;TIFF (*.tif *.tiff);;WebP (*.webp);;All Files (*)");
        QString saveFileName = QFileDialog::getSaveFileName(this, caption, path, nameFilter);
        if (!saveFileName.isEmpty()) {
            QFileInfo fi(saveFileName);
            if (fi.suffix().isEmpty())
                saveFileName += ".png";
            if (Util::warnIfNotWritable(saveFileName, this, caption))
                return;
            // Convert to square pixels if needed.
            qreal aspectRatio = (qreal) image.width() / image.height();
            if (qFloor(aspectRatio * 1000) != qFloor(MLT.profile().dar() * 1000)) {
                image = image.scaled(qRound(image.height() * MLT.profile().dar()), image.height(),
                                     Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            }
            image.save(saveFileName, Q_NULLPTR,
                (QFileInfo(saveFileName).suffix() == "webp")? 80 : -1);
            Settings.setSavePath(fi.path());
            m_recentDock->add(saveFileName);
        }
    } else {
        showStatusMessage(tr("Unable to export frame."));
    }
}
void MainWindow::onGLWidgetImageReady()
{
    Mlt::GLWidget* glw = qobject_cast<Mlt::GLWidget*>(MLT.videoWidget());
    QImage image = glw->image();
    if (Settings.playerGPU() || Settings.playerPreviewScale()) {
        disconnect(glw, SIGNAL(imageReady()), this, 0);
        MLT.setPreviewScale(Settings.playerPreviewScale());
    }
    if (!image.isNull()) {
        QString path = Settings.savePath();
        QString caption = tr("Export Frame");
        QString nameFilter = tr("PNG (*.png);;BMP (*.bmp);;JPEG (*.jpg *.jpeg);;PPM (*.ppm);;TIFF (*.tif *.tiff);;WebP (*.webp);;All Files (*)");
        QString saveFileName = QFileDialog::getSaveFileName(this, caption, path, nameFilter);
        if (!saveFileName.isEmpty()) {
            QFileInfo fi(saveFileName);
            if (fi.suffix().isEmpty())
                saveFileName += ".png";
            if (Util::warnIfNotWritable(saveFileName, this, caption))
                return;
             
            qreal aspectRatio = (qreal) image.width() / image.height();
            if (qFloor(aspectRatio * 1000) != qFloor(MLT.profile().dar() * 1000)) {
                image = image.scaled(qRound(image.height() * MLT.profile().dar()), image.height(),
                                     Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            }
            image.save(saveFileName, Q_NULLPTR,
                (QFileInfo(saveFileName).suffix() == "webp")? 80 : -1);
            Settings.setSavePath(fi.path());
            m_recentDock->add(saveFileName);
        }
    } else {
        showStatusMessage(tr("Unable to export frame."));
    }
}