+ClipDurationDialog::~ClipDurationDialog()
+{
+}
+
+void ClipDurationDialog::setMargins(GenTime min, GenTime max)
+{
+ m_min = min;
+ m_max = max;
+ connect(m_view.clip_position, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckStart()));
+ connect(m_view.clip_duration, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckDuration()));
+}
+
+void ClipDurationDialog::slotCheckStart()
+{
+ int pos = m_tc.getFrameCount(m_view.clip_position->text());
+ int dur = m_tc.getFrameCount(m_view.clip_duration->text());
+ GenTime start(pos, m_fps);
+ GenTime duration(dur, m_fps);
+ if (m_min != GenTime() && start < m_min) {
+ m_view.clip_position->setText(m_tc.getTimecode(m_min));
+ } else if (m_max != GenTime() && start + duration > m_max) {
+ m_view.clip_position->setText(m_tc.getTimecode(m_max - duration));
+ }
+}
+
+void ClipDurationDialog::slotCheckDuration()
+{
+ int pos = m_tc.getFrameCount(m_view.clip_position->text());
+ int dur = m_tc.getFrameCount(m_view.clip_duration->text());
+ GenTime start(pos, m_fps);
+ GenTime duration(dur, m_fps);
+ GenTime maxDuration;
+ if (m_clip->maxDuration() == GenTime()) maxDuration = m_max;
+ else maxDuration = m_max == GenTime() ? start + m_clip->maxDuration() : qMin(m_max, start + m_clip->maxDuration());
+ if (maxDuration != GenTime() && start + duration > maxDuration) {
+ m_view.clip_duration->setText(m_tc.getTimecode(maxDuration - start));
+ }
+}
+
+void ClipDurationDialog::slotCheckCrop()
+{
+ int dur = m_tc.getFrameCount(m_view.clip_duration->text());
+ int crop = m_tc.getFrameCount(m_view.crop_position->text());
+ GenTime duration(dur, m_fps);
+ GenTime cropStart(crop, m_fps);
+ GenTime maxDuration = m_clip->maxDuration();
+ if (maxDuration != GenTime() && cropStart + duration > maxDuration) {
+ m_view.crop_position->setText(m_tc.getTimecode(maxDuration - duration));
+ }