Expose new CppUtils class with formattedBytes()
This commit is contained in:
parent
69aea0e37f
commit
fe087ba724
5
TODO.md
5
TODO.md
@ -1,11 +1,14 @@
|
|||||||
- Media
|
- Media
|
||||||
- Caching
|
- Caching
|
||||||
- Downloading
|
- Downloading
|
||||||
|
- Bottom/top bar
|
||||||
- Uploading (+local echo)
|
- Uploading (+local echo)
|
||||||
- GIF thumbnails: load the real animated image
|
- Deduplicate uploads
|
||||||
- Files, links, video, audio
|
- Files, links, video, audio
|
||||||
|
- File thumbnails, ask matrix API?
|
||||||
- Encrypted media
|
- Encrypted media
|
||||||
- Loading animation
|
- Loading animation
|
||||||
|
- GIF thumbnails: load the real animated image
|
||||||
- Copy thumbnail URL in context menu?
|
- Copy thumbnail URL in context menu?
|
||||||
|
|
||||||
- RoomMessageNotice
|
- RoomMessageNotice
|
||||||
|
@ -12,7 +12,8 @@ RCC_DIR = $$BUILD_DIR/rcc
|
|||||||
QRC_FILE = $$BUILD_DIR/resources.qrc
|
QRC_FILE = $$BUILD_DIR/resources.qrc
|
||||||
|
|
||||||
RESOURCES += $$QRC_FILE
|
RESOURCES += $$QRC_FILE
|
||||||
SOURCES += src/main.cpp
|
HEADERS += src/utils.h
|
||||||
|
SOURCES += src/main.cpp src/utils.cpp
|
||||||
TARGET = harmonyqml
|
TARGET = harmonyqml
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@ -23,6 +26,8 @@ int main(int argc, char *argv[]) {
|
|||||||
objectContext->setContextProperty("debugMode", false);
|
objectContext->setContextProperty("debugMode", false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
objectContext->setContextProperty("CppUtils", new Utils());
|
||||||
|
|
||||||
QFileInfo qrcPath(":src/qml/Window.qml");
|
QFileInfo qrcPath(":src/qml/Window.qml");
|
||||||
|
|
||||||
QQmlComponent component(
|
QQmlComponent component(
|
||||||
|
16
src/utils.cpp
Normal file
16
src/utils.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <QLocale>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
Utils::Utils() {
|
||||||
|
// Initialization
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QString Utils::formattedBytes(qint64 bytes, int precision) {
|
||||||
|
return m_locale.formattedDataSize(
|
||||||
|
bytes, precision, QLocale::DataSizeTraditionalFormat
|
||||||
|
);
|
||||||
|
};
|
23
src/utils.h
Normal file
23
src/utils.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef UTILS_H
|
||||||
|
#define UTILS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
|
|
||||||
|
class Utils : public QObject {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Utils();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QString formattedBytes(qint64 bytes, int precision = 2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLocale m_locale;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user