diff --git a/imports/NeoChat/Component/Timeline/AudioDelegate.qml b/imports/NeoChat/Component/Timeline/AudioDelegate.qml index 55901f24e..184763c7b 100644 --- a/imports/NeoChat/Component/Timeline/AudioDelegate.qml +++ b/imports/NeoChat/Component/Timeline/AudioDelegate.qml @@ -9,7 +9,6 @@ import Qt.labs.platform 1.1 as Platform import QtMultimedia 5.15 import org.kde.kirigami 2.15 as Kirigami -import org.kde.kcoreaddons 1.0 as KCA import org.kde.neochat 1.0 import NeoChat.Component 1.0 @@ -56,7 +55,7 @@ Control { } Label { - text: KCA.Format.formatDuration(audio.position) + "/" + KCA.Format.formatDuration(audio.duration) + text: Controller.formatDuration(audio.position) + "/" + Controller.formatDuration(audio.duration) } } } diff --git a/imports/NeoChat/Component/Timeline/FileDelegate.qml b/imports/NeoChat/Component/Timeline/FileDelegate.qml index b3ab37641..23d8f818a 100644 --- a/imports/NeoChat/Component/Timeline/FileDelegate.qml +++ b/imports/NeoChat/Component/Timeline/FileDelegate.qml @@ -8,7 +8,6 @@ import QtGraphicalEffects 1.15 import Qt.labs.platform 1.1 import org.kde.kirigami 2.15 as Kirigami -import org.kde.kcoreaddons 1.0 as KCA import org.kde.neochat 1.0 import NeoChat.Component 1.0 @@ -43,7 +42,7 @@ RowLayout { Label { Layout.fillWidth: true - text: !progressInfo.completed && progressInfo.active ? (KCA.Format.formatByteSize(progressInfo.progress) + "/" + KCA.Format.formatByteSize(progressInfo.total)) : KCA.Format.formatByteSize(content.info ? content.info.size : 0) + text: !progressInfo.completed && progressInfo.active ? (Controller.formatByteSize(progressInfo.progress) + "/" + Controller.formatByteSize(progressInfo.total)) : Controller.formatByteSize(content.info ? content.info.size : 0) color: Kirigami.Theme.disabledTextColor wrapMode: Label.Wrap } diff --git a/src/controller.cpp b/src/controller.cpp index baf8b5b77..51717d04d 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -591,3 +591,13 @@ void Controller::joinRoom(const QString &alias) Q_EMIT errorOccured(joinRoomJob->roomId()); }); } + +QString Controller::formatByteSize(double size, int precision) const +{ + return KFormat().formatByteSize(size, precision); +} + +QString Controller::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const +{ + return KFormat().formatDuration(msecs, options); +} diff --git a/src/controller.h b/src/controller.h index 55cd0ce25..877f1f1f2 100644 --- a/src/controller.h +++ b/src/controller.h @@ -9,6 +9,8 @@ #include #include +#include + class QKeySequences; class QNetworkConfigurationManager; @@ -81,6 +83,9 @@ public: Q_INVOKABLE void joinRoom(const QString &alias); bool isOnline() const; + + Q_INVOKABLE QString formatDuration(quint64 msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration) const; + Q_INVOKABLE QString formatByteSize(double size, int precision = 1) const; private: explicit Controller(QObject *parent = nullptr); ~Controller() override;