Commit 7177f9a8 authored by Gary Wang's avatar Gary Wang Committed by Jean-Baptiste Mardelle
Browse files

Guides Exporter: Replace QTimeEdit with TimecodeDisplay

parent 85435a3b
Pipeline #180740 passed with stage
in 6 minutes and 54 seconds
......@@ -30,6 +30,9 @@ ExportGuidesDialog::ExportGuidesDialog(const MarkerListModel *model, const GenTi
setupUi(this);
setWindowTitle(i18n("Export guides as chapters description"));
// We should setup TimecodeDisplay since it requires a proper Timecode
offsetTime->setTimecode(Timecode(Timecode::HH_MM_SS_FF, pCore->getCurrentFps()));
const QString defaultFormat(YT_FORMAT);
formatEdit->setText(defaultFormat);
......@@ -63,7 +66,7 @@ ExportGuidesDialog::ExportGuidesDialog(const MarkerListModel *model, const GenTi
updateContentByModel();
});
connect(offsetTime, QOverload<const QTime &>::of(&QDateTimeEdit::timeChanged), this, [this]() {
connect(offsetTime, &TimecodeDisplay::timeCodeUpdated, this, [this]() {
updateContentByModel();
});
......@@ -87,9 +90,9 @@ double ExportGuidesDialog::offsetTimeMs() const
{
switch (offsetTimeComboBox->currentIndex()) {
case 1: // Add
return offsetTime->time().msecsSinceStartOfDay();
return offsetTime->gentime().ms();
case 2: // Subtract
return - offsetTime->time().msecsSinceStartOfDay();
return - offsetTime->gentime().ms();
case 0: // Disabled
default:
return 0;
......
......@@ -116,13 +116,10 @@
</widget>
</item>
<item>
<widget class="QTimeEdit" name="offsetTime">
<widget class="TimecodeDisplay" name="offsetTime" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="displayFormat">
<string>h:mm:ss</string>
</property>
</widget>
</item>
</layout>
......@@ -135,6 +132,11 @@
<extends>QWidget</extends>
<header>kmessagewidget.h</header>
</customwidget>
<customwidget>
<class>TimecodeDisplay</class>
<extends>QAbstractSpinBox</extends>
<header>widgets/timecodedisplay.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
......
......@@ -60,6 +60,11 @@ TimecodeDisplay::TimecodeDisplay(const Timecode &t, QWidget *parent)
connect(lineEdit(), &QLineEdit::editingFinished, this, &TimecodeDisplay::slotEditingFinished, Qt::DirectConnection);
}
TimecodeDisplay::TimecodeDisplay(QWidget *parent)
: TimecodeDisplay(Timecode(), parent)
{
}
// virtual protected
QAbstractSpinBox::StepEnabled TimecodeDisplay::stepEnabled() const
{
......@@ -176,6 +181,11 @@ Timecode TimecodeDisplay::timecode() const
return m_timecode;
}
void TimecodeDisplay::setTimecode(const Timecode &t)
{
m_timecode = t;
}
void TimecodeDisplay::setRange(int min, int max)
{
m_minimum = min;
......
......@@ -39,6 +39,11 @@ public:
* @param t Timecode object used to setup correct input (frames or HH:MM:SS:FF)
* @param parent parent Widget */
explicit TimecodeDisplay(const Timecode &t, QWidget *parent = nullptr);
/** @brief Constructor for the widget, sets value to 0.
* This variant of ctor is mainly for the usage in QtDesigner,
* remember to set a correct timecode with setTimecode()
* @param parent parent Widget */
explicit TimecodeDisplay(QWidget *parent = nullptr);
/** @brief Returns the minimum value, which can be entered.
* default is 0 */
......@@ -62,6 +67,9 @@ public:
/** @brief Returns the widget's timecode object. */
Timecode timecode() const;
/** @brief Setup the timecode in case you are using this widget with QtDesigner. */
void setTimecode(const Timecode &t);
/** @brief Sets value's format to frames or HH:MM:SS:FF according to @param frametimecode.
* @param frametimecode true = frames, false = HH:MM:SS:FF
* @param init true = force the change, false = update only if the frametimecode param changed */
......
Supports Markdown
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