Skip to content

Commit

Permalink
remove Export > Resample and warning dialog
Browse files Browse the repository at this point in the history
Replace with inline warning message.
  • Loading branch information
ddennedy committed Sep 29, 2024
1 parent 055bb60 commit 25c6072
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 90 deletions.
112 changes: 50 additions & 62 deletions src/docks/encodedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,8 @@ EncodeDock::EncodeDock(QWidget *parent) :
LOG_DEBUG() << "begin";
initSpecialCodecLists();
ui->setupUi(this);
auto tip = ui->widthSpinner->toolTip();
ui->heightSpinner->setToolTip(tip);
ui->resolutionComboBox->setToolTip(tip);
ui->aspectNumSpinner->setToolTip(tip);
ui->aspectDenSpinner->setToolTip(tip);
ui->fpsSpinner->setToolTip(tip);
ui->fpsComboBox->setToolTip(tip);
Util::setColorsToHighlight(ui->resampleWarningLabel);
hideResampleWarning(true);
ui->stopCaptureButton->hide();
ui->advancedButton->setChecked(Settings.encodeAdvanced());
ui->advancedCheckBox->setChecked(Settings.encodeAdvanced());
Expand Down Expand Up @@ -438,11 +433,6 @@ bool EncodeDock::isExportInProgress() const
return !m_immediateJob.isNull();
}

bool EncodeDock::isResampleEnabled() const
{
return ui->resampleButton->isEnabled();
}

void EncodeDock::onProducerOpened()
{
int index = 0;
Expand Down Expand Up @@ -1923,6 +1913,7 @@ void EncodeDock::onProfileChanged()
auto producer = fromProducer();
ui->reframeButton->setEnabled(producer && producer == MAIN.multitrack());
auto reframe = getReframeFilter(producer);
setReframeEnabled(false);
if (reframe.is_valid()) {
auto rect = reframe.anim_get_rect("rect", 0);
if (rect.w > 0 && rect.h > 0) {
Expand All @@ -1931,13 +1922,10 @@ void EncodeDock::onProfileChanged()
auto gcd = Util::greatestCommonDivisor(rect.w, rect.h);
ui->aspectNumSpinner->setValue(rect.w / gcd);
ui->aspectDenSpinner->setValue(rect.h / gcd);
ui->resampleButton->setDisabled(true);
setReframeEnabled(true);
hideResampleWarning();
}
} else {
ui->resampleButton->setEnabled(producer && producer->is_valid());
}
ui->resampleButton->setChecked(false);
setResampleEnabled(false);
}

void EncodeDock::on_streamButton_clicked()
Expand Down Expand Up @@ -2243,7 +2231,6 @@ void EncodeDock::on_fromCombo_currentIndexChanged(int index)
Q_UNUSED(index)
auto producer = fromProducer();
ui->reframeButton->setEnabled(producer && producer == MAIN.multitrack());
ui->resampleButton->setEnabled(!getReframeFilter(producer).is_valid());
if (MLT.isSeekable(producer))
ui->encodeButton->setText(tr("Export File"));
else
Expand Down Expand Up @@ -2405,13 +2392,16 @@ void EncodeDock::on_fpsSpinner_editingFinished()
Util::showFrameRateDialog(caption, 60000, ui->fpsSpinner, this);
}
m_fps = ui->fpsSpinner->value();
checkFrameRate();
}
}

void EncodeDock::on_fpsComboBox_activated(int arg1)
{
if (!ui->fpsComboBox->itemText(arg1).isEmpty())
if (!ui->fpsComboBox->itemText(arg1).isEmpty()) {
ui->fpsSpinner->setValue(ui->fpsComboBox->itemText(arg1).toDouble());
checkFrameRate();
}
}

void EncodeDock::on_videoQualitySpinner_valueChanged(int vq)
Expand Down Expand Up @@ -2770,53 +2760,51 @@ void EncodeDock::on_reframeButton_clicked()
emit createOrEditFilterOnOutput(&filter);
}

void EncodeDock::on_aspectNumSpinner_valueChanged(int value)
{
if (!ui->reframeButton->isChecked()
&& double(ui->aspectNumSpinner->value()) / double(ui->aspectDenSpinner->value()) !=
MLT.profile().dar())
showResampleWarning(tr("Aspect ratio does not match project Video Mode, which causes black bars."));
else
hideResampleWarning();
}

void EncodeDock::on_resampleButton_clicked(bool checked)
void EncodeDock::on_aspectDenSpinner_valueChanged(int value)
{
if (!Settings.askResample() || ("clip" == ui->fromCombo->currentData().toString()
&& !MLT.profile().is_explicit())) {
setResampleEnabled(checked);
} else if (checked) {
QMessageBox dialog(QMessageBox::Question,
tr("Resample Export"),
tr("<p>Are you sure you want to resample instead of change the <b>Video Mode</b>?</p>"
"<p>Changing the aspect ratio adds black bars.</p>"
"<p>Increasing resolution or frame rate is limited by <b>Video Mode</b>.</p>"),
QMessageBox::No | QMessageBox::Yes,
this);
dialog.addButton(tr("Open Settings > Video Mode"), QMessageBox::ResetRole);
dialog.setDefaultButton(QMessageBox::Yes);
dialog.setEscapeButton(QMessageBox::Cancel);
dialog.setWindowModality(QmlApplication::dialogModality());
dialog.setCheckBox(new QCheckBox(tr("Do not show this anymore.",
"Resample export warning dialog")));
switch (dialog.exec()) {
case QMessageBox::Yes:
setResampleEnabled(checked);
break;
case QMessageBox::No:
ui->resampleButton->setChecked(false);
break;
default:
ui->resampleButton->setChecked(false);
MAIN.showSettingsMenu();
break;
}
if (dialog.checkBox()->isChecked())
Settings.setAskResample(false);
} else {
setResampleEnabled(false);
}
on_aspectNumSpinner_valueChanged(value);
}

void EncodeDock::setResampleEnabled(bool enabled)

void EncodeDock::setReframeEnabled(bool enabled)
{
ui->widthSpinner->setEnabled(enabled);
ui->heightSpinner->setEnabled(enabled);
ui->resolutionComboBox->setEnabled(enabled);
ui->aspectNumSpinner->setEnabled(enabled);
ui->aspectDenSpinner->setEnabled(enabled);
ui->fpsSpinner->setEnabled(enabled);
ui->fpsComboBox->setEnabled(enabled);
ui->widthSpinner->setDisabled(enabled);
ui->heightSpinner->setDisabled(enabled);
ui->resolutionComboBox->setDisabled(enabled);
ui->aspectNumSpinner->setDisabled(enabled);
ui->aspectDenSpinner->setDisabled(enabled);
ui->fpsSpinner->setDisabled(enabled);
ui->fpsComboBox->setDisabled(enabled);
}

void EncodeDock::showResampleWarning(const QString &message)
{
ui->resampleWarningLabel->setText(message);
hideResampleWarning(false);
}

void EncodeDock::hideResampleWarning(bool hide)
{
ui->resampleWarningIcon->setVisible(!hide);
ui->resampleWarningLabel->setVisible(!hide);
}

void EncodeDock::checkFrameRate()
{
if (ui->fromCombo->currentData().toString() != "clip"
&& qFloor(ui->fpsSpinner->value() * 10000.0) > qFloor(MLT.profile().fps() * 10000.0))
showResampleWarning(
tr("Frame rate is higher than project Video Mode, which causes frames to simply repeat."));
else
hideResampleWarning();
}
10 changes: 7 additions & 3 deletions src/docks/encodedock.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class EncodeDock : public QDockWidget

void loadPresetFromProperties(Mlt::Properties &);
bool isExportInProgress() const;
bool isResampleEnabled() const;

signals:
void captureStateChanged(bool);
Expand Down Expand Up @@ -134,7 +133,9 @@ private slots:

void on_reframeButton_clicked();

void on_resampleButton_clicked(bool checked);
void on_aspectNumSpinner_valueChanged(int value);

void on_aspectDenSpinner_valueChanged(int value);

private:
enum {
Expand Down Expand Up @@ -181,7 +182,10 @@ private slots:
bool checkForMissingFiles();
QString &defaultFormatExtension();
void initSpecialCodecLists();
void setResampleEnabled(bool enabled);
void setReframeEnabled(bool enabled);
void showResampleWarning(const QString &message);
void hideResampleWarning(bool hide = true);
void checkFrameRate();
};

#endif // ENCODEDOCK_H
80 changes: 55 additions & 25 deletions src/docks/encodedock.ui
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resampleButton">
<property name="text">
<string>Resample</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_26">
<property name="orientation">
Expand All @@ -356,7 +346,47 @@
</item>
</layout>
</item>
<item row="3" column="1">
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="resampleWarningLayout" stretch="0,10">
<property name="leftMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<item>
<widget class="QPushButton" name="resampleWarningIcon">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../icons/resources.qrc">
<normaloff>:/icons/oxygen/32x32/status/task-attempt.png</normaloff>:/icons/oxygen/32x32/status/task-attempt.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="resampleWarningLabel">
<property name="text">
<string></string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QDoubleSpinBox" name="fpsSpinner">
Expand Down Expand Up @@ -449,7 +479,7 @@
</item>
</layout>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Interpolation</string>
Expand All @@ -459,7 +489,7 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QComboBox" name="interpolationCombo">
Expand Down Expand Up @@ -503,7 +533,7 @@
</item>
</layout>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Field order</string>
Expand All @@ -523,7 +553,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Deinterlacer</string>
Expand All @@ -533,7 +563,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Frames/sec</string>
Expand All @@ -543,7 +573,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Scan mode</string>
Expand All @@ -553,7 +583,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Color range</string>
Expand All @@ -563,7 +593,7 @@
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QCheckBox" name="parallelCheckbox">
<property name="toolTip">
<string>This enables multiple image processing threads.
Expand Down Expand Up @@ -591,7 +621,7 @@ with parallel processing enabled.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QComboBox" name="rangeComboBox">
Expand Down Expand Up @@ -622,7 +652,7 @@ with parallel processing enabled.</string>
</item>
</layout>
</item>
<item row="5" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QComboBox" name="scanModeCombo">
Expand Down Expand Up @@ -656,7 +686,7 @@ with parallel processing enabled.</string>
</item>
</layout>
</item>
<item row="11" column="1">
<item row="12" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down Expand Up @@ -778,14 +808,14 @@ with parallel processing enabled.</string>
</item>
</layout>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="previewScaleCheckBox">
<property name="text">
<string>Use preview scaling</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QComboBox" name="fieldOrderCombo">
Expand Down Expand Up @@ -819,7 +849,7 @@ with parallel processing enabled.</string>
</item>
</layout>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="deinterlacerCombo">
Expand Down

0 comments on commit 25c6072

Please sign in to comment.