Re-use better dialog for timeline change clip speed (with slider)

parent b20a1bd8
Pipeline #14117 passed with stage
in 14 minutes and 28 seconds
#include "speeddialog.h"
#include "ui_speeddialog_ui.h"
#include "ui_clipspeed_ui.h"
#include <QPushButton>
SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double maxSpeed, bool reversed)
: QDialog(parent)
, ui(new Ui::SpeedDialog)
, ui(new Ui::ClipSpeed_UI)
{
ui->setupUi(this);
setWindowTitle(i18n("Clip Speed"));
ui->doubleSpinBox->setDecimals(2);
ui->doubleSpinBox->setMinimum(minSpeed);
ui->doubleSpinBox->setMaximum(maxSpeed);
ui->doubleSpinBox->setValue(speed);
ui->doubleSpinBox->selectAll();
ui->speedSpin->setDecimals(2);
ui->speedSpin->setMinimum(minSpeed);
ui->speedSpin->setMaximum(maxSpeed);
ui->speedSlider->setMinimum(100 * minSpeed);
ui->speedSlider->setMaximum(qMin(100 * minSpeed + 100000, 100 *maxSpeed));
ui->speedSpin->setValue(speed);
ui->speedSlider->setValue(100 * speed);
ui->speedSlider->setTickInterval((ui->speedSlider->maximum() - ui->speedSlider->minimum()) / 10);
ui->speedSpin->selectAll();
ui->label_dest->setVisible(false);
ui->kurlrequester->setVisible(false);
ui->toolButton->setVisible(false);
if (reversed) {
ui->checkBox->setChecked(true);
}
connect(ui->doubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&] (double value) {
connect(ui->speedSpin, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&] (double value) {
ui->speedSlider->setValue(100 * value);
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(!qFuzzyIsNull(value));
});
connect(ui->speedSlider, &QSlider::valueChanged, [&] (int value) {
ui->speedSpin->setValue(value / 100.);
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(value != 0);
});
}
SpeedDialog::~SpeedDialog()
......@@ -28,7 +40,7 @@ SpeedDialog::~SpeedDialog()
double SpeedDialog::getValue() const
{
double val = ui->doubleSpinBox->value();
double val = ui->speedSpin->value();
if (ui->checkBox->checkState() == Qt::Checked) {
val *= -1;
}
......
......@@ -4,7 +4,7 @@
#include <QDialog>
namespace Ui {
class SpeedDialog;
class ClipSpeed_UI;
}
class SpeedDialog : public QDialog
......@@ -18,7 +18,7 @@ public:
double getValue() const;
private:
Ui::SpeedDialog *ui;
Ui::ClipSpeed_UI *ui;
};
#endif // SPEEDDIALOG_H
......@@ -6,48 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>158</height>
<width>389</width>
<height>132</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_dest">
<property name="text">
<string>Destination</string>
</property>
</widget>
</item>
<item>
<widget class="KUrlRequester" name="kurlrequester">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......@@ -72,10 +38,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>50</number>
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
......@@ -107,7 +70,7 @@
</item>
</layout>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -117,13 +80,55 @@
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="destination_layout">
<item>
<widget class="QLabel" name="label_dest">
<property name="text">
<string>Destination</string>
</property>
</widget>
</item>
<item>
<widget class="KUrlRequester" name="kurlrequester">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Reverse clip</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QWidget</extends>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SpeedDialog</class>
<widget class="QDialog" name="SpeedDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>186</width>
<height>132</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Speed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Reverse clip</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SpeedDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SpeedDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment