Port away from custom format* QML functions
This commit is contained in:
@@ -379,16 +379,6 @@ void Controller::joinRoom(const QString &alias)
|
|||||||
RoomManager::instance().joinRoom(m_connection, alias, QStringList{knownServer});
|
RoomManager::instance().joinRoom(m_connection, alias, QStringList{knownServer});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Controller::formatByteSize(double size, int precision) const
|
|
||||||
{
|
|
||||||
return QLocale().formattedDataSize(size, precision);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Controller::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const
|
|
||||||
{
|
|
||||||
return KFormat().formatDuration(msecs, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::forceRefreshTextDocument(QQuickTextDocument *textDocument, QQuickItem *item)
|
void Controller::forceRefreshTextDocument(QQuickTextDocument *textDocument, QQuickItem *item)
|
||||||
{
|
{
|
||||||
// HACK: Workaround bug QTBUG 93281
|
// HACK: Workaround bug QTBUG 93281
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
#include <KFormat>
|
|
||||||
|
|
||||||
#include "neochatconnection.h"
|
#include "neochatconnection.h"
|
||||||
#include <Quotient/accountregistry.h>
|
#include <Quotient/accountregistry.h>
|
||||||
#include <Quotient/jobs/basejob.h>
|
#include <Quotient/jobs/basejob.h>
|
||||||
@@ -134,20 +132,6 @@ public:
|
|||||||
|
|
||||||
bool isFlatpak() const;
|
bool isFlatpak() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return a string for the input timestamp.
|
|
||||||
*
|
|
||||||
* The output format depends on the KFormat::DurationFormatOptions chosen.
|
|
||||||
*
|
|
||||||
* @sa KFormat::DurationFormatOptions
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString formatDuration(quint64 msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return a human readable string for a given input number of bytes.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString formatByteSize(double size, int precision = 1) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force a QQuickTextDocument to refresh when images are loaded.
|
* @brief Force a QQuickTextDocument to refresh when images are loaded.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import QtQuick.Controls as QQC2
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtMultimedia
|
import QtMultimedia
|
||||||
|
|
||||||
|
import org.kde.coreaddons
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
import org.kde.neochat
|
import org.kde.neochat
|
||||||
@@ -127,7 +128,7 @@ MessageDelegate {
|
|||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
visible: root.contentMaxWidth > Kirigami.Units.gridUnit * 12
|
visible: root.contentMaxWidth > Kirigami.Units.gridUnit * 12
|
||||||
|
|
||||||
text: Controller.formatDuration(audio.position) + "/" + Controller.formatDuration(audio.duration)
|
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
@@ -135,7 +136,7 @@ MessageDelegate {
|
|||||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||||
visible: audio.hasAudio && root.contentMaxWidth < Kirigami.Units.gridUnit * 12
|
visible: audio.hasAudio && root.contentMaxWidth < Kirigami.Units.gridUnit * 12
|
||||||
|
|
||||||
text: Controller.formatDuration(audio.position) + "/" + Controller.formatDuration(audio.duration)
|
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import QtQuick.Controls as QQC2
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Qt.labs.platform
|
import Qt.labs.platform
|
||||||
|
|
||||||
|
import org.kde.coreaddons
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
import org.kde.neochat
|
import org.kde.neochat
|
||||||
@@ -104,7 +105,7 @@ MessageDelegate {
|
|||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: sizeLabel
|
target: sizeLabel
|
||||||
text: i18nc("file download progress", "%1 / %2", Controller.formatByteSize(root.progressInfo.progress), Controller.formatByteSize(root.progressInfo.total))
|
text: i18nc("file download progress", "%1 / %2", Format.formatByteSize(root.progressInfo.progress), Format.formatByteSize(root.progressInfo.total))
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: downloadButton
|
target: downloadButton
|
||||||
@@ -140,7 +141,7 @@ MessageDelegate {
|
|||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
id: sizeLabel
|
id: sizeLabel
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: Controller.formatByteSize(root.mediaInfo.size)
|
text: Format.formatByteSize(root.mediaInfo.size)
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import QtQuick
|
|||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.coreaddons
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ Item {
|
|||||||
MimeComponent {
|
MimeComponent {
|
||||||
mimeIconSource: root.mediaInfo.mimeIcon
|
mimeIconSource: root.mediaInfo.mimeIcon
|
||||||
label: root.display
|
label: root.display
|
||||||
subLabel: root.type === DelegateType.File ? Controller.formatByteSize(root.mediaInfo.size) : Controller.formatDuration(root.mediaInfo.duration)
|
subLabel: root.type === DelegateType.File ? Format.formatByteSize(root.mediaInfo.size) : Format.formatDuration(root.mediaInfo.duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import QtQuick.Layouts
|
|||||||
import QtMultimedia
|
import QtMultimedia
|
||||||
import Qt.labs.platform as Platform
|
import Qt.labs.platform as Platform
|
||||||
|
|
||||||
|
import org.kde.coreaddons
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
import org.kde.neochat
|
import org.kde.neochat
|
||||||
@@ -191,7 +192,7 @@ MessageDelegate {
|
|||||||
onMoved: vid.seek(value)
|
onMoved: vid.seek(value)
|
||||||
}
|
}
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
text: Controller.formatDuration(vid.position) + "/" + Controller.formatDuration(vid.duration)
|
text: Format.formatDuration(vid.position) + "/" + Format.formatDuration(vid.duration)
|
||||||
}
|
}
|
||||||
QQC2.ToolButton {
|
QQC2.ToolButton {
|
||||||
id: volumeButton
|
id: volumeButton
|
||||||
|
|||||||
Reference in New Issue
Block a user