diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d8dd55..6241693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ set(CMAKE_AUTOMOC ON) include(ExternalProject) - find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) find_package(Qt5Concurrent REQUIRED) @@ -93,6 +92,8 @@ add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") endif(DEFINED ENV{TRAVIS}) add_executable(KittehPlayer ${SOURCES} ${qml_QRC}) +set_property(TARGET KittehPlayer PROPERTY CXX_STANDARD 14) + # Use the Qml/Quick modules from Qt 5. target_link_libraries(KittehPlayer ${MPV_LIBRARIES} ${X11_LIBRARIES} ${Xext_LIBRARIES} Qt5::X11Extras) diff --git a/src/Backends/MPVCommon/MPVCommon.cpp b/src/Backends/MPVCommon/MPVCommon.cpp index 695b018..36bcb9a 100644 --- a/src/Backends/MPVCommon/MPVCommon.cpp +++ b/src/Backends/MPVCommon/MPVCommon.cpp @@ -20,6 +20,24 @@ auto mpvLogger = initLogger("mpv"); +QString humanSize(uint64_t bytes) +{ + char *suffix[] = {"B", "KB", "MB", "GB", "TB"}; + char length = sizeof(suffix) / sizeof(suffix[0]); + + int i = 0; + double dblBytes = bytes; + + if (bytes > 1024) { + for (i = 0; (bytes / 1024) > 0 && igetProperty("file-format").toString(); stats += "Format/Protocol: " + fileFormat + "
"; - QLocale a; - // a.formattedDataSize( double cacheUsed = b->getProperty("cache-used").toDouble(); - // Utils::createTimestamp( int demuxerSecs = b->getProperty("demuxer-cache-duration").toInt(); QVariantMap demuxerState = b->getProperty("demuxer-cache-state").toMap(); int demuxerCache = demuxerState.value("fw-bytes", QVariant(0)).toInt(); @@ -86,23 +101,23 @@ QString getStats(BackendInterface *b) { if (demuxerSecs + demuxerCache + cacheUsed > 0) { QString cacheStats; cacheStats += "Total Cache: "; - cacheStats += a.formattedDataSize(demuxerCache + cacheUsed); + cacheStats += humanSize(demuxerCache + cacheUsed); cacheStats += " (Demuxer: "; - cacheStats += a.formattedDataSize(demuxerCache); + cacheStats += humanSize(demuxerCache); cacheStats += ", "; cacheStats += QString::number(demuxerSecs) + "s) "; double cacheSpeed = b->getProperty("cache-speed").toDouble(); if (cacheSpeed > 0) { cacheStats += "Speed: "; - cacheStats += a.formattedDataSize(demuxerSecs); + cacheStats += humanSize(demuxerSecs); cacheStats += "/s"; } cacheStats += "
"; stats += cacheStats; } QString fileSize = - a.formattedDataSize(b->getProperty("file-size").toInt()).remove("-"); + humanSize(b->getProperty("file-size").toInt()).remove("-"); stats += "Size: " + fileSize + "
"; stats += ""; @@ -197,7 +212,7 @@ QString getStats(BackendInterface *b) { int pVB = b->getProperty("packet-video-bitrate").toInt(); if (pVB > 0) { stats += "Bitrate: "; - stats += a.formattedDataSize(pVB) + "/s"; + stats += humanSize(pVB) + "/s"; stats += "
"; } @@ -227,7 +242,7 @@ QString getStats(BackendInterface *b) { int pAB = b->getProperty("packet-audio-bitrate").toInt(); if (pAB > 0) { stats += "Bitrate: "; - stats += a.formattedDataSize(pAB) + "/s"; + stats += humanSize(pAB) + "/s"; stats += "
"; } diff --git a/src/Process.h b/src/Process.h index 81b226d..b09f0c5 100644 --- a/src/Process.h +++ b/src/Process.h @@ -5,7 +5,6 @@ #include #include #include -class QObject; class Process : public QProcess {