diff --git a/app/common/qtversionabstraction.cpp b/app/common/qtversionabstraction.cpp
index ed61b6122..44365cefd 100644
--- a/app/common/qtversionabstraction.cpp
+++ b/app/common/qtversionabstraction.cpp
@@ -1,3 +1,23 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2019 Olive Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#include "qtversionabstraction.h"
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s) {
diff --git a/app/common/qtversionabstraction.h b/app/common/qtversionabstraction.h
index 006c7d041..641850ff6 100644
--- a/app/common/qtversionabstraction.h
+++ b/app/common/qtversionabstraction.h
@@ -1,8 +1,40 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2019 Olive Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#ifndef QTVERSIONABSTRACTION_H
#define QTVERSIONABSTRACTION_H
+/**
+ *
+ * A fairly simple header for reducing the amount of Qt version checks necessary throughout the code
+ *
+ */
+
#include
+/**
+ * @brief Retrieves the width of a string according to certain QFontMetrics
+ *
+ * QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the latter was only
+ * introduced in 5.11+. This function wraps the latter for 5.11+ and the former for earlier.
+ */
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s);
#endif // QTVERSIONABSTRACTION_H
diff --git a/app/common/timecodefunctions.cpp b/app/common/timecodefunctions.cpp
index 6a549d95d..cf304a3cc 100644
--- a/app/common/timecodefunctions.cpp
+++ b/app/common/timecodefunctions.cpp
@@ -1,3 +1,23 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2019 Olive Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#include "timecodefunctions.h"
#include
@@ -6,13 +26,11 @@ QString padded(int arg, int padding) {
return QString("%1").arg(arg, padding, 10, QChar('0'));
}
-QString olive::timestamp_to_timecode(const rational& timestamp,
+QString olive::timestamp_to_timecode(const int64_t ×tamp,
const rational& timebase,
const TimecodeDisplay& display)
{
- double timestamp_dbl = timestamp.ToDouble();
-
-
+ double timestamp_dbl = (rational(timestamp) * timebase).ToDouble();
switch (display) {
case kTimecodeFrames:
@@ -43,9 +61,9 @@ QString olive::timestamp_to_timecode(const rational& timestamp,
}
}
case kFrames:
- return QString::number(timestamp.numerator() / timebase.numerator());
+ return QString::number(timestamp);
case kMilliseconds:
- return QString::number(qFloor(timestamp_dbl * 1000));
+ return QString::number(qRound(timestamp_dbl * 1000));
}
return QString();
diff --git a/app/common/timecodefunctions.h b/app/common/timecodefunctions.h
index feb882950..d731631f2 100644
--- a/app/common/timecodefunctions.h
+++ b/app/common/timecodefunctions.h
@@ -1,3 +1,23 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2019 Olive Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#ifndef TIMECODEFUNCTIONS_H
#define TIMECODEFUNCTIONS_H
@@ -14,7 +34,10 @@ enum TimecodeDisplay {
kMilliseconds
};
-QString timestamp_to_timecode(const rational& timestamp, const rational& timebase, const TimecodeDisplay& display);
+/**
+ * @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation
+ */
+QString timestamp_to_timecode(const int64_t ×tamp, const rational& timebase, const TimecodeDisplay& display);
}
diff --git a/app/widget/playbackcontrols/playbackcontrols.cpp b/app/widget/playbackcontrols/playbackcontrols.cpp
index 6c2928448..a2390730c 100644
--- a/app/widget/playbackcontrols/playbackcontrols.cpp
+++ b/app/widget/playbackcontrols/playbackcontrols.cpp
@@ -120,9 +120,9 @@ void PlaybackControls::SetTimebase(const rational &r)
time_base_ = r;
}
-void PlaybackControls::SetTime(const rational &r)
+void PlaybackControls::SetTime(const int64_t &r)
{
Q_ASSERT(time_base_.denominator() != 0);
- cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, olive::kTimecodeFrames));
+ cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, olive::kMilliseconds));
}
diff --git a/app/widget/playbackcontrols/playbackcontrols.h b/app/widget/playbackcontrols/playbackcontrols.h
index f212ee57c..5a089d231 100644
--- a/app/widget/playbackcontrols/playbackcontrols.h
+++ b/app/widget/playbackcontrols/playbackcontrols.h
@@ -45,7 +45,7 @@ public:
void SetTimebase(const rational& r);
public slots:
- void SetTime(const rational& r);
+ void SetTime(const int64_t &r);
signals:
/**
diff --git a/app/widget/viewer/viewer.cpp b/app/widget/viewer/viewer.cpp
index 956b3b34f..791f21144 100644
--- a/app/widget/viewer/viewer.cpp
+++ b/app/widget/viewer/viewer.cpp
@@ -73,9 +73,9 @@ void ViewerWidget::SetTexture(GLuint tex)
void ViewerWidget::RulerTimeChange(int64_t i)
{
- rational time_set = rational(i, 1) * time_base_;
+ rational time_set = rational(i) * time_base_;
- controls_->SetTime(time_set);
+ controls_->SetTime(i);
emit TimeChanged(time_set);
}