18#include "exportmoviedialog.h"
19#include "ui_exportmovieoptions.h"
22ExportMovieDialog::ExportMovieDialog(
QWidget *parent, Mode mode, FileType fileType) :
24 ui(new Ui::ExportMovieOptions)
26 ui->
setupUi(getOptionsGroupBox());
28 if (fileType == FileType::GIF) {
29 setWindowTitle(tr(
"Export Animated GIF"));
30 ui->exporterGroupBox->hide();
32 setWindowTitle(tr(
"Export Movie"));
35 QSizePolicy policy = ui->unevenWidthLabel->sizePolicy();
37 ui->unevenWidthLabel->setSizePolicy(policy);
38 policy = ui->unevenHeightLabel->sizePolicy();
40 ui->unevenHeightLabel->setSizePolicy(policy);
42 connect(
this, &ExportMovieDialog::filePathsChanged,
this, &ExportMovieDialog::onFilePathsChanged);
47ExportMovieDialog::~ExportMovieDialog()
52void ExportMovieDialog::setCamerasInfo(
const std::vector<std::pair<QString, QSize>> camerasInfo)
54 if ( ui->cameraCombo->count() > 0 )
56 ui->cameraCombo->clear();
59 for (
const std::pair<QString, QSize>& camera : camerasInfo)
61 ui->cameraCombo->addItem( camera.first, camera.second );
65 connect( ui->cameraCombo, indexChanged,
this, &ExportMovieDialog::updateResolutionCombo );
67 updateResolutionCombo( 0 );
70void ExportMovieDialog::updateResolutionCombo(
int index )
72 QSize camSize = ui->cameraCombo->itemData( index ).toSize();
77 ui->widthSpinBox->setValue( camSize.
width() );
78 ui->heightSpinBox->setValue( camSize.
height() );
82void ExportMovieDialog::setDefaultRange(
int startFrame,
int endFrame,
int endFrameWithSounds)
85 mEndFrameWithSounds = endFrameWithSounds;
90 ui->startSpinBox->setValue( startFrame );
91 ui->endSpinBox->setValue( endFrame );
96QString ExportMovieDialog::getSelectedCameraName()
98 return ui->cameraCombo->currentText();
101QSize ExportMovieDialog::getExportSize()
103 return QSize( ui->widthSpinBox->value(), ui->heightSpinBox->value() );
106bool ExportMovieDialog::getTransparency()
const
108 return ui->transparencyCheckBox->isChecked() && supportsTransparency(getFilePath());
111int ExportMovieDialog::getStartFrame()
113 return ui->startSpinBox->value();
116int ExportMovieDialog::getEndFrame()
118 return ui->endSpinBox->value();
121bool ExportMovieDialog::getLoop()
123 return ui->loopCheckBox->isChecked();
126void ExportMovieDialog::frameCheckboxClicked(
bool checked)
128 int e = (checked) ? mEndFrameWithSounds : mEndFrame;
129 ui->endSpinBox->setValue(e);
132void ExportMovieDialog::onFilePathsChanged(
QStringList filePaths)
135 bool canLoop = supportsLooping(filePath);
136 ui->loopCheckBox->setEnabled(canLoop);
139 ui->loopCheckBox->setChecked(
false);
141 ui->transparencyCheckBox->setEnabled(supportsTransparency(filePath));
142 validateResolution();
145bool ExportMovieDialog::supportsLooping(
QString filePath)
const
151bool ExportMovieDialog::supportsTransparency(
QString filePath)
const
157void ExportMovieDialog::validateResolution()
160 const bool widthValid = !isMp4 || ui->widthSpinBox->value() % 2 == 0;
161 const bool heightValid = !isMp4 || ui->heightSpinBox->value() % 2 == 0;
162 ui->unevenWidthLabel->setHidden(widthValid);
163 ui->unevenHeightLabel->setHidden(heightValid);
164 setOkButtonEnabled(widthValid && heightValid);
void currentIndexChanged(int index)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setRetainSizeWhenHidden(bool retainSize)
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const