[Backend] Reimplement createTimestamp in C++.
This commit is contained in:
parent
8fc36d20b7
commit
8d68ab2a46
|
@ -8,7 +8,7 @@
|
|||
#include <QOpenGLContext>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include <math.h>
|
||||
namespace {
|
||||
|
||||
void
|
||||
|
@ -282,6 +282,22 @@ MpvPlayerBackend::getTracks() const
|
|||
return mpv::qt::get_property_variant(mpv, "track-list");
|
||||
}
|
||||
|
||||
QVariant
|
||||
MpvPlayerBackend::createTimestamp(const QVariant& seconds) const
|
||||
{
|
||||
int d = seconds.toInt();
|
||||
double h = floor(d / 3600);
|
||||
double m = floor(d % 3600 / 60);
|
||||
double s = floor(d % 3600 % 60);
|
||||
|
||||
QString hour = h > 0 ? QString::number(h) + ":" : "";
|
||||
QString minute = h < 1 ? QString::number(m) + ":"
|
||||
: (m < 10 ? "0" + QString::number(m) + ":"
|
||||
: QString::number(m) + ":");
|
||||
QString second = s < 10 ? "0" + QString::number(s) : QString::number(s);
|
||||
return hour + minute + second;
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::on_mpv_events()
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@ public slots:
|
|||
void setProperty(const QString& name, const QVariant& value);
|
||||
void setOption(const QString& name, const QVariant& value);
|
||||
QVariant getProperty(const QString& name) const;
|
||||
QVariant createTimestamp(const QVariant& seconds) const;
|
||||
|
||||
signals:
|
||||
void onUpdate();
|
||||
|
|
|
@ -145,24 +145,12 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
function createTimestamp(d) {
|
||||
d = Number(d)
|
||||
var h = Math.floor(d / 3600)
|
||||
var m = Math.floor(d % 3600 / 60)
|
||||
var s = Math.floor(d % 3600 % 60)
|
||||
|
||||
var hour = h > 0 ? h + ":" : ""
|
||||
var minute = h < 1 ? m + ":" : (m < 10 ? "0" + m + ":" : m + ":")
|
||||
var second = s < 10 ? "0" + s : s
|
||||
return hour + minute + second
|
||||
}
|
||||
|
||||
function setProgressBarEnd(val) {
|
||||
progressBar.to = val
|
||||
}
|
||||
|
||||
function setProgressBarValue(val) {
|
||||
timeLabel.text = createTimestamp(val) + " / " + createTimestamp(
|
||||
timeLabel.text = player.createTimestamp(val) + " / " + player.createTimestamp(
|
||||
progressBar.to) + " (" + parseFloat(
|
||||
player.getProperty("speed").toFixed(2)) + "x)"
|
||||
progressBar.value = val
|
||||
|
|
Loading…
Reference in a new issue