When user wants to display timecode in frames, use frames for all timecode...

When user wants to display timecode in frames, use frames for all timecode display (keyframes, markers, ...):
http://www.kdenlive.org/mantis/view.php?id=1421

svn path=/trunk/kdenlive/; revision=4303
parent 2feaf66f
......@@ -187,16 +187,20 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event)
if (event->y() <= 10) setCursor(Qt::ArrowCursor);
else if (qAbs(pos - m_zoneStart * m_factor) < 4) {
setCursor(KCursor("left_side", Qt::SizeHorCursor));
setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart)));
if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone start: %1", m_zoneStart));
else setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart)));
} else if (qAbs(pos - m_zoneEnd * m_factor) < 4) {
setCursor(KCursor("right_side", Qt::SizeHorCursor));
setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd)));
if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone end: %1", m_zoneEnd));
else setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd)));
} else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * m_factor) < 4) {
setCursor(Qt::SizeHorCursor);
setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone duration: %1", m_zoneEnd - m_zoneStart));
else setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
} else {
setCursor(Qt::ArrowCursor);
setToolTip(i18n("Position: %1", m_timecode.getTimecodeFromFrames(pos / m_factor)));
if (KdenliveSettings::frametimecode()) setToolTip(i18n("Position: %1", (int)(pos / m_factor)));
else setToolTip(i18n("Position: %1", m_timecode.getTimecodeFromFrames(pos / m_factor)));
}
}
}
......
......@@ -5772,3 +5772,12 @@ void CustomTrackView::insertZoneOverwrite(QStringList data, int in)
new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), info, EffectsList(), true, false, true, false, addCommand);
m_commandStack->push(addCommand);
}
void CustomTrackView::clearSelection()
{
resetSelectionGroup();
scene()->clearSelection();
m_dragItem = NULL;
emit clipItemSelected(NULL);
}
......@@ -130,6 +130,7 @@ public:
QStringList extractTransitionsLumas();
void setEditMode(EDITMODE mode);
void insertClipCut(DocClipBase *clip, int in, int out);
void clearSelection();
public slots:
void setCursorPos(int pos, bool seek = true);
......
......@@ -482,9 +482,9 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
sceneList.setContent(scene, true);
QDomElement mlt = sceneList.firstChildElement("mlt");
if (mlt.isNull() || !mlt.hasChildNodes()) {
//Make sure we don't save if scenelist is corrupted
KMessageBox::error(kapp->activeWindow(), i18n("Cannot write to file %1", path));
return false;
//Make sure we don't save if scenelist is corrupted
KMessageBox::error(kapp->activeWindow(), i18n("Cannot write to file %1", path));
return false;
}
QDomElement addedXml = sceneList.createElement("kdenlivedoc");
mlt.appendChild(addedXml);
......
......@@ -96,7 +96,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent) :
QWidget *p6 = new QWidget;
m_configSdl.setupUi(p6);
// Disable drop B frames, see Kdenlive issue #1330
m_configSdl.groupBox->setHidden(true);
......
......@@ -100,7 +100,9 @@ void KeyframeEdit::addParameter(QDomElement e)
bool found = false;
int j;
for (j = 0; j < keyframe_list->rowCount(); j++) {
int currentPos = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(j)->text());
int currentPos;
if (KdenliveSettings::frametimecode()) currentPos = keyframe_list->verticalHeaderItem(j)->text().toInt();
else currentPos = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(j)->text());
if (frame == currentPos) {
keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
found = true;
......@@ -111,7 +113,10 @@ void KeyframeEdit::addParameter(QDomElement e)
}
if (!found) {
keyframe_list->insertRow(j);
keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(frame)));
QString currentPos;
if (KdenliveSettings::frametimecode()) currentPos = QString::number(frame);
else currentPos = m_timecode.getTimecodeFromFrames(frame);
keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(currentPos));
keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
keyframe_list->resizeRowToContents(j);
}
......@@ -145,7 +150,9 @@ void KeyframeEdit::setupParam()
for (int i = 0; i < frames.count(); i++) {
keyframe_list->insertRow(i);
int currentpos = frames.at(i).section(':', 0, 0).toInt();
QString framePos = m_timecode.getTimecodeFromFrames(currentpos);
QString framePos;
if (KdenliveSettings::frametimecode()) framePos = QString::number(currentpos);
else framePos = m_timecode.getTimecodeFromFrames(currentpos);
keyframe_list->setVerticalHeaderItem(i, new QTableWidgetItem(framePos));
keyframe_list->setItem(i, col, new QTableWidgetItem(frames.at(i).section(':', 1, 1)));
if ((m_active_keyframe > -1) && (m_active_keyframe == currentpos)) {
......@@ -182,11 +189,16 @@ void KeyframeEdit::slotAddKeyframe()
int row = keyframe_list->currentRow();
int col = keyframe_list->currentColumn();
int newrow = row;
int pos1 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row)->text());
int pos1;
if (KdenliveSettings::frametimecode()) pos1 = keyframe_list->verticalHeaderItem(row)->text().toInt();
else pos1 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row)->text());
int result;
kDebug() << "// ADD KF: " << row << ", MAX: " << keyframe_list->rowCount() << ", POS: " << pos1;
if (row < (keyframe_list->rowCount() - 1)) {
int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
int pos2;
if (KdenliveSettings::frametimecode()) pos2 = keyframe_list->verticalHeaderItem(row + 1)->text().toInt();
else pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row + 1)->text());
result = pos1 + (pos2 - pos1) / 2;
newrow++;
} else if (row == 0) {
......@@ -197,12 +209,17 @@ void KeyframeEdit::slotAddKeyframe()
result = m_min;
}
} else {
int pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
int pos2;
if (KdenliveSettings::frametimecode()) pos2 = keyframe_list->verticalHeaderItem(row - 1)->text().toInt();
else pos2 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(row - 1)->text());
result = pos2 + (pos1 - pos2) / 2;
}
keyframe_list->insertRow(newrow);
keyframe_list->setVerticalHeaderItem(newrow, new QTableWidgetItem(m_timecode.getTimecodeFromFrames(result)));
QString currentPos;
if (KdenliveSettings::frametimecode()) currentPos = QString::number(result);
else currentPos = m_timecode.getTimecodeFromFrames(result);
keyframe_list->setVerticalHeaderItem(newrow, new QTableWidgetItem(currentPos));
for (int i = 0; i < keyframe_list->columnCount(); i++) {
keyframe_list->setItem(newrow, i, new QTableWidgetItem(keyframe_list->item(item->row(), i)->text()));
}
......@@ -224,14 +241,19 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
QTableWidgetItem *item = keyframe_list->item(row, 0);
if (item == NULL) return;
QString val = keyframe_list->verticalHeaderItem(row)->text();
int pos = m_timecode.getFrameCount(val);
int pos;
if (KdenliveSettings::frametimecode()) pos = val.toInt();
else pos = m_timecode.getFrameCount(val);
if (pos <= m_min) {
pos = m_min;
val = m_timecode.getTimecodeFromFrames(pos);
if (KdenliveSettings::frametimecode()) val = QString::number(pos);
else val = m_timecode.getTimecodeFromFrames(pos);
}
if (pos > m_max) {
pos = m_max;
val = m_timecode.getTimecodeFromFrames(pos);
if (KdenliveSettings::frametimecode()) val = QString::number(pos);
else val = m_timecode.getTimecodeFromFrames(pos);
}
if (val != keyframe_list->verticalHeaderItem(row)->text()) keyframe_list->verticalHeaderItem(row)->setText(val);
......@@ -242,7 +264,12 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
if (v <= m_params.at(col).attribute("min").toInt()) item->setText(m_params.at(col).attribute("min"));
QString keyframes;
for (int i = 0; i < keyframe_list->rowCount(); i++) {
if (keyframe_list->item(i, col)) keyframes.append(QString::number(m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text())) + ':' + keyframe_list->item(i, col)->text() + ';');
if (keyframe_list->item(i, col)) {
int pos3;
if (KdenliveSettings::frametimecode()) pos3 = keyframe_list->verticalHeaderItem(i)->text().toInt();
else pos3 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text());
keyframes.append(QString::number(pos3) + ':' + keyframe_list->item(i, col)->text() + ';');
}
}
m_params[col].setAttribute("keyframes", keyframes);
}
......@@ -254,14 +281,20 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
QTableWidgetItem *item = keyframe_list->item(row, column);
if (item == NULL) return;
QString val = keyframe_list->verticalHeaderItem(row)->text();
int pos = m_timecode.getFrameCount(val);
;
int pos;
if (KdenliveSettings::frametimecode()) pos = val.toInt();
else pos = m_timecode.getFrameCount(val);
if (pos <= m_min) {
pos = m_min;
val = m_timecode.getTimecodeFromFrames(pos);
if (KdenliveSettings::frametimecode()) val = QString::number(pos);
else val = m_timecode.getTimecodeFromFrames(pos);
}
if (pos > m_max) {
pos = m_max;
val = m_timecode.getTimecodeFromFrames(pos);
if (KdenliveSettings::frametimecode()) val = QString::number(pos);
else val = m_timecode.getTimecodeFromFrames(pos);
}
/*QList<QTreeWidgetItem *> duplicates = keyframe_list->findItems(val, Qt::MatchExactly, 0);
duplicates.removeAll(item);
......@@ -278,7 +311,12 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
QString keyframes;
for (int i = 0; i < keyframe_list->rowCount(); i++) {
if (keyframe_list->item(i, column)) keyframes.append(QString::number(m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text())) + ':' + keyframe_list->item(i, column)->text() + ';');
if (keyframe_list->item(i, column)) {
int pos3;
if (KdenliveSettings::frametimecode()) pos3 = keyframe_list->verticalHeaderItem(i)->text().toInt();
else pos3 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text());
keyframes.append(QString::number(pos3) + ':' + keyframe_list->item(i, column)->text() + ';');
}
}
m_params[column].setAttribute("keyframes", keyframes);
emit parameterChanged();
......@@ -289,7 +327,12 @@ void KeyframeEdit::generateAllParams()
for (int col = 0; col < keyframe_list->columnCount(); col++) {
QString keyframes;
for (int i = 0; i < keyframe_list->rowCount(); i++) {
if (keyframe_list->item(i, col)) keyframes.append(QString::number(m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text())) + ':' + keyframe_list->item(i, col)->text() + ';');
if (keyframe_list->item(i, col)) {
int pos3;
if (KdenliveSettings::frametimecode()) pos3 = keyframe_list->verticalHeaderItem(i)->text().toInt();
else pos3 = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(i)->text());
keyframes.append(QString::number(pos3) + ':' + keyframe_list->item(i, col)->text() + ';');
}
}
m_params[col].setAttribute("keyframes", keyframes);
}
......@@ -315,11 +358,23 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
int max = m_max;
QTableWidgetItem *above = keyframe_list->item(item->row() - 1, item->column());
QTableWidgetItem *below = keyframe_list->item(item->row() + 1, item->column());
if (above) min = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(above->row())->text()) + 1;
if (below) max = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(below->row())->text()) - 1;
if (above) {
if (KdenliveSettings::frametimecode()) min = keyframe_list->verticalHeaderItem(above->row())->text().toInt();
else min = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(above->row())->text());
min++;
}
if (below) {
if (KdenliveSettings::frametimecode()) max = keyframe_list->verticalHeaderItem(below->row())->text().toInt();
else max = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(below->row())->text());
max--;
}
keyframe_pos->blockSignals(true);
keyframe_pos->setRange(min, max);
keyframe_pos->setValue(m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(item->row())->text()));
int pos;
if (KdenliveSettings::frametimecode()) pos = keyframe_list->verticalHeaderItem(item->row())->text().toInt();
else pos = m_timecode.getFrameCount(keyframe_list->verticalHeaderItem(item->row())->text());
keyframe_pos->setValue(pos);
keyframe_pos->blockSignals(false);
for (int col = 0; col < keyframe_list->columnCount(); col++) {
QSlider *sl = static_cast <QSlider*>(m_slidersLayout->itemAtPosition(col, 1)->widget());
......@@ -334,7 +389,10 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
void KeyframeEdit::slotAdjustKeyframePos(int value)
{
QTableWidgetItem *item = keyframe_list->currentItem();
keyframe_list->verticalHeaderItem(item->row())->setText(m_timecode.getTimecodeFromFrames(value));
QString val;
if (KdenliveSettings::frametimecode()) val = QString::number(value);
else val = m_timecode.getTimecodeFromFrames(value);
keyframe_list->verticalHeaderItem(item->row())->setText(val);
slotGenerateParams(item->row(), -1);
if (KdenliveSettings::keyframeseek()) emit seekToPos(value);
}
......
......@@ -426,7 +426,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
slotConnectMonitors();
// Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
KdenliveSettings::setDropbframes(false);
......@@ -3164,6 +3164,7 @@ void MainWindow::slotUpdateTimecodeFormat(int ix)
KdenliveSettings::setFrametimecode(ix == 1);
m_clipMonitor->updateTimecodeFormat();
m_projectMonitor->updateTimecodeFormat();
m_activeTimeline->projectView()->clearSelection();
}
void MainWindow::slotRemoveFocus()
......
......@@ -82,7 +82,10 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
connect(marker_position, SIGNAL(textChanged(const QString &)), this, SIGNAL(updateThumb()));
} else clip_thumb->setHidden(true);
marker_position->setText(tc.getTimecode(t.time()));
if (KdenliveSettings::frametimecode()) {
marker_position->setInputMask("000000000000");
marker_position->setText(QString::number((int) t.time().frames(m_fps)));
} else marker_position->setText(tc.getTimecode(t.time()));
marker_comment->setText(t.comment());
marker_comment->selectAll();
......@@ -104,7 +107,9 @@ MarkerDialog::~MarkerDialog()
void MarkerDialog::slotUpdateThumb()
{
m_previewTimer->stop();
int pos = m_tc.getFrameCount(marker_position->text());
int pos;
if (KdenliveSettings::frametimecode()) pos = marker_position->text().toInt();
else pos = m_tc.getFrameCount(marker_position->text());
int width = 100.0 * m_dar;
if (width % 2 == 1) width++;
QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100));
......@@ -114,22 +119,29 @@ void MarkerDialog::slotUpdateThumb()
void MarkerDialog::slotTimeUp()
{
int duration = m_tc.getFrameCount(marker_position->text());
int duration;
if (KdenliveSettings::frametimecode()) duration = marker_position->text().toInt();
else duration = m_tc.getFrameCount(marker_position->text());
if (m_clip && duration >= m_clip->duration().frames(m_fps)) return;
duration ++;
marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
if (KdenliveSettings::frametimecode()) marker_position->setText(QString::number(duration));
else marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
}
void MarkerDialog::slotTimeDown()
{
int duration = m_tc.getFrameCount(marker_position->text());
int duration;
if (KdenliveSettings::frametimecode()) duration = marker_position->text().toInt();
else duration = m_tc.getFrameCount(marker_position->text());
if (duration <= 0) return;
duration --;
marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
if (KdenliveSettings::frametimecode()) marker_position->setText(QString::number(duration));
else marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
}
CommentedTime MarkerDialog::newMarker()
{
if (KdenliveSettings::frametimecode()) return CommentedTime(GenTime(marker_position->text().toInt(), m_fps), marker_comment->text());
return CommentedTime(GenTime(m_tc.getFrameCount(marker_position->text()), m_fps), marker_comment->text());
}
......
......@@ -30,7 +30,10 @@ PositionEdit::PositionEdit(const QString name, int pos, int min, int max, const
connect(m_ui.horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateTimecode()));
connect(m_ui.krestrictedline, SIGNAL(editingFinished()), this, SLOT(slotUpdatePosition()));
m_ui.horizontalSlider->setValue(pos);
m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
if (KdenliveSettings::frametimecode()) {
m_ui.krestrictedline->setInputMask("000000000000");
m_ui.krestrictedline->setText(QString::number(pos));
} else m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
}
int PositionEdit::getPosition() const
......@@ -41,23 +44,28 @@ int PositionEdit::getPosition() const
void PositionEdit::setPosition(int pos)
{
m_ui.horizontalSlider->setValue(pos);
m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
if (KdenliveSettings::frametimecode()) m_ui.krestrictedline->setText(QString::number(pos));
else m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(pos));
}
void PositionEdit::slotUpdateTimecode()
{
m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
if (KdenliveSettings::frametimecode()) m_ui.krestrictedline->setText(QString::number(m_ui.horizontalSlider->value()));
else m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
emit parameterChanged();
}
void PositionEdit::slotUpdatePosition()
{
m_ui.horizontalSlider->blockSignals(true);
int pos = m_tc.getFrameCount(m_ui.krestrictedline->text());
int pos;
if (KdenliveSettings::frametimecode()) pos = m_ui.krestrictedline->text().toInt();
else pos = m_tc.getFrameCount(m_ui.krestrictedline->text());
m_ui.horizontalSlider->setValue(pos);
if (pos != m_ui.horizontalSlider->value()) {
// Value out of range
m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
if (KdenliveSettings::frametimecode()) m_ui.krestrictedline->setText(QString::number(m_ui.horizontalSlider->value()));
else m_ui.krestrictedline->setText(m_tc.getTimecodeFromFrames(m_ui.horizontalSlider->value()));
}
m_ui.horizontalSlider->blockSignals(false);
emit parameterChanged();
......
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