Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2b4c2df2 authored by Nicolas Carion's avatar Nicolas Carion

Make equality check of GenTime dependent of FPS

parent 37f99311
......@@ -90,6 +90,7 @@ void Core::build(const QString &MltPath)
m_self->m_profile = ProjectManager::getDefaultProjectFormat();
KdenliveSettings::setDefault_profile(m_self->m_profile);
}
m_self->profileChanged();
// Init producer shown for unavailable media
// TODO make it a more proper image, it currently causes a crash on exit
......@@ -105,6 +106,7 @@ void Core::initGUI(const QUrl &Url)
m_profile = KdenliveSettings::default_profile();
if (m_profile.isEmpty()) {
m_profile = ProjectManager::getDefaultProjectFormat();
profileChanged();
KdenliveSettings::setDefault_profile(m_profile);
}
......@@ -138,6 +140,7 @@ void Core::initGUI(const QUrl &Url)
m_profile = "dv_pal";
}
KdenliveSettings::setDefault_profile(m_profile);
profileChanged();
}
m_projectManager = new ProjectManager(this);
......@@ -290,3 +293,8 @@ KdenliveDoc *Core::currentDoc()
{
return m_projectManager->current();
}
void Core::profileChanged()
{
GenTime::setFps(getCurrentFps());
}
......@@ -110,6 +110,9 @@ public:
/** @brief Request project monitor refresh */
void requestMonitorRefresh();
/** @brief This function must be called whenever the profile used changes */
void profileChanged();
private:
explicit Core();
static std::unique_ptr<Core> m_self;
......
......@@ -4,7 +4,7 @@
begin : Sat Sep 14 2002
copyright : (C) 2002 by Jason Wood
email : jasonwood@blueyonder.co.uk
***************************************************************************/
***************************************************************************/
/***************************************************************************
* *
......@@ -53,3 +53,76 @@ QString GenTime::toString() const
{
return QStringLiteral("%1 s").arg(m_time, 0, 'f', 2);
}
GenTime GenTime::operator-()
{
return GenTime(-m_time);
}
GenTime &GenTime::operator+=(GenTime op)
{
m_time += op.m_time;
return *this;
}
GenTime &GenTime::operator-=(GenTime op)
{
m_time -= op.m_time;
return *this;
}
GenTime GenTime::operator+(GenTime op) const
{
return GenTime(m_time + op.m_time);
}
GenTime GenTime::operator-(GenTime op) const
{
return GenTime(m_time - op.m_time);
}
GenTime GenTime::operator*(double op) const
{
return GenTime(m_time * op);
}
GenTime GenTime::operator/(double op) const
{
return GenTime(m_time / op);
}
bool GenTime::operator<(GenTime op) const
{
return m_time + s_delta < op.m_time;
}
bool GenTime::operator>(GenTime op) const
{
return m_time > op.m_time + s_delta;
}
bool GenTime::operator>=(GenTime op) const
{
return m_time + s_delta >= op.m_time;
}
bool GenTime::operator<=(GenTime op) const
{
return m_time <= op.m_time + s_delta;
}
bool GenTime::operator==(GenTime op) const
{
return fabs(m_time - op.m_time) < s_delta;
}
bool GenTime::operator!=(GenTime op) const
{
return fabs(m_time - op.m_time) >= s_delta;
}
// static
void GenTime::setFps(double fps)
{
s_delta = 1.0 / fps;
}
......@@ -56,45 +56,44 @@ public:
*/
/// Unary minus
GenTime operator-() { return GenTime(-m_time); }
GenTime operator-();
/// Addition
GenTime &operator+=(GenTime op)
{
m_time += op.m_time;
return *this;
}
GenTime &operator+=(GenTime op);
/// Subtraction
GenTime &operator-=(GenTime op)
{
m_time -= op.m_time;
return *this;
}
GenTime &operator-=(GenTime op);
/** @brief Adds two GenTimes. */
GenTime operator+(GenTime op) const { return GenTime(m_time + op.m_time); }
GenTime operator+(GenTime op) const;
/** @brief Subtracts one genTime from another. */
GenTime operator-(GenTime op) const { return GenTime(m_time - op.m_time); }
GenTime operator-(GenTime op) const;
/** @brief Multiplies one GenTime by a double value, returning a GenTime. */
GenTime operator*(double op) const { return GenTime(m_time * op); }
GenTime operator*(double op) const;
/** @brief Divides one GenTime by a double value, returning a GenTime. */
GenTime operator/(double op) const { return GenTime(m_time / op); }
GenTime operator/(double op) const;
bool operator<(GenTime op) const { return m_time + s_delta < op.m_time; }
/* All the comparison operators considers that two GenTime that differs by less
than one frame are equal.
The fps used to carry this computation must be set using the static function setFps
*/
bool operator<(GenTime op) const;
bool operator>(GenTime op) const { return m_time > op.m_time + s_delta; }
bool operator>(GenTime op) const;
bool operator>=(GenTime op) const { return m_time + s_delta >= op.m_time; }
bool operator>=(GenTime op) const;
bool operator<=(GenTime op) const { return m_time <= op.m_time + s_delta; }
bool operator<=(GenTime op) const;
bool operator==(GenTime op) const { return fabs(m_time - op.m_time) < s_delta; }
bool operator==(GenTime op) const;
bool operator!=(GenTime op) const { return fabs(m_time - op.m_time) >= s_delta; }
bool operator!=(GenTime op) const;
/** @brief Sets the fps used to determine if two GenTimes are equal */
static void setFps(double fps);
private:
/** Holds the time in seconds for this object. */
......
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