Skip to content

Commit

Permalink
Various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Nov 6, 2019
1 parent acf49f8 commit a3790c9
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 46 deletions.
2 changes: 2 additions & 0 deletions MiniVideoInfos.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ios | android { CONFIG += qtquickcompiler }
# Use contribs (otherwise use system libs)
ios | android { DEFINES += USE_CONTRIBS }

win32 { DEFINES += _USE_MATH_DEFINES }

# StatusBar for mobile OS
include(src/thirdparty/StatusBar/statusbar.pri)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Get detailed informations about your audio, video and pictures files!
### Dependencies

You will need:
- a C++14 compiler
- Any C++11 compiler
- Android NDK 20
- Android SDK
- Qt 5.12 (with Qt Charts)
Expand All @@ -29,7 +29,7 @@ You will need:

> $ git clone https://github.com/emericg/MiniVideoInfos.git
> $ cd MiniVideoInfos/
> $ cd contribs/; python3 contribs.py; cd ..;
> $ cd contribs/ && python3 contribs.py && cd ..
> $ qmake
> $ make
Expand Down
2 changes: 1 addition & 1 deletion qml/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Item {
Column {
id: column1
anchors.left: imageLogo.right
anchors.leftMargin: 32
anchors.leftMargin: 24
anchors.verticalCenter: parent.verticalCenter

Text {
Expand Down
2 changes: 1 addition & 1 deletion qml/InfosAV.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ScrollView {

// track
info_id.text = trackItem.id
info_size.text = UtilsString.bytesToString_short(trackItem.size)
info_size.text = UtilsString.bytesToString_short(trackItem.size, settingsManager.unitSizes)
info_duration.text = UtilsString.durationToString_short(trackItem.duration)
item_delay.visible = (trackItem.delay !== 0)
info_delay.text = UtilsString.durationToString_short(trackItem.delay)
Expand Down
1 change: 0 additions & 1 deletion qml/InfosGeneric.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ ScrollView {
}

Column {
id: columnStuff
anchors.top: parent.top
anchors.topMargin: 16
anchors.right: parent.right
Expand Down
4 changes: 2 additions & 2 deletions qml/components/FileDialog_Native.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import QtQuick.Dialogs 1.3
FileDialog {

nameFilters: [qsTr("All files") + " (*)",
qsTr("Media files") + " (*.mp1 *.mp2 *.mp3 *.m4a *.mp4a *.aac *.mka *.wma *.wav *.wave *.ogg *.opus *.vorbis *.mov *.m4v *.mp4 *.mp4v *.3gp *.3gpp *.mkv *.webm *.avi *.divx *.asf *.wmv *.jpg *.jpeg *.webp *.png *.gpr *.gif *.heif *.heic *.avif *.bmp *.tga *.tif *.tiff *.svg)",
qsTr("Audio files") + " (*.mp1 *.mp2 *.mp3 *.m4a *.mp4a *.aac *.mka *.wma *.wav *.wave *.ogg *.opus *.vorbis)",
qsTr("Media files") + " (*.mp1 *.mp2 *.mp3 *.m4a *.mp4a *.m4r *.aac *.mka *.wma *.amb *.wav *.wave *.ogg *.opus *.vorbis *.mov *.m4v *.mp4 *.mp4v *.3gp *.3gpp *.mkv *.webm *.avi *.divx *.asf *.wmv *.jpg *.jpeg *.webp *.png *.gpr *.gif *.heif *.heic *.avif *.bmp *.tga *.tif *.tiff *.svg)",
qsTr("Audio files") + " (*.mp1 *.mp2 *.mp3 *.m4a *.mp4a *.m4r *.aac *.mka *.wma *.amb *.wav *.wave *.ogg *.opus *.vorbis)",
qsTr("Video files") + " (*.mov *.m4v *.mp4 *.mp4v *.3gp *.3gpp *.mkv *.webm *.avi *.divx *.asf *.wmv)",
qsTr("Image files") + " (*.jpg *.jpeg *.webp *.png *.gpr *.gif *.heif *.heic *.avif *.bmp *.tga *.tif *.tiff *.svg)"]

Expand Down
2 changes: 1 addition & 1 deletion qml/components/FileDialog_QML.qml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Rectangle {

if (onlyShowMedias)
folderListModel.nameFilters = ["*.mov", "*.m4v", "*.mp4", "*.mp4v", "*.3gp", "*.3gpp", "*.mkv", "*.webm", "*.avi", "*.divx", "*.asf", "*.wmv",
"*.mp1", "*.mp2", "*.mp3", "*.m4a", "*.mp4a", "*.aac", "*.mka", "*.wma", "*.wav", "*.wave", "*.ogg", "*.opus", "*.vorbis",
"*.mp1", "*.mp2", "*.mp3", "*.m4a", "*.mp4a", "*.m4r", "*.aac", "*.mka", "*.wma", "*.amb", "*.wav", "*.wave", "*.ogg", "*.opus", "*.vorbis",
"*.jpg", "*.jpeg", "*.webp", "*.png", "*.gpr", "*.gif", "*.heif", "*.heic", "*.avif", "*.bmp", "*.tga", "*.tif", "*.tiff", "*.svg"]
else
folderListModel.nameFilters = []
Expand Down
2 changes: 2 additions & 0 deletions qml/components_js/UtilsMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ function framerateToString(framerate) {

/*!
* orientationToString()
*
* Convert EXIF enumeration to a readable string
*/
function orientationToString(orientation) {
var text = '';
Expand Down
16 changes: 13 additions & 3 deletions qml/components_js/UtilsNumber.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// UtilsNumber.js
// Version 0.3
// Version 0.4
.pragma library

/*!
Expand Down Expand Up @@ -77,20 +77,30 @@ function isFloat(n) {
return Number(n) === n && n % 1 !== 0;
}

/*!
* Return true if n is an even number
*/
function isEven(n) {
return n % 2 === 0;
}

/*!
* Return true if n is an odd number
*/
function isOdd(n) {
return n % 2 !== 0;
}

// Fahrenheit to Celsius
/*!
* Fahrenheit to Celsius conversion
*/
function tempFahrenheitToCelsius(temp_f) {
return (temp_f - 32) / 1.8;
}

// Celsius to Fahrenheit
/*!
* Celsius to Fahrenheit conversion
*/
function tempCelsiusToFahrenheit(temp_c) {
return (temp_c * 1.8 + 32);
}
25 changes: 18 additions & 7 deletions qml/components_js/UtilsPath.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// UtilsPath.js
// Version 0.2
// Version 0.3
.pragma library

/*!
* Take an url or string, and make sure we output a clean string path.
*/
function cleanUrl(urlIn) {
var pathOut = '';

urlIn = Qt.resolvedUrl(urlIn)
if (!(typeof urlIn === 'string' || urlIn instanceof String)) {
urlIn = urlIn.toString();
}

var pathOut = '';
if (typeof urlIn === 'string' || urlIn instanceof String) {
if (urlIn.slice(0, 8) === "file:///") {
var k = urlIn.charAt(9) === ':' ? 8 : 7;
Expand All @@ -38,12 +37,11 @@ function makeUrl(urlIn) {
* Take an url or string from a file, return the absolute path of the folder containing that file.
*/
function fileToFolder(filePath) {
var folderPath = '';

if (!(typeof filePath === 'string' || filePath instanceof String)) {
filePath = filePath.toString();
}

var folderPath = '';
if (typeof filePath === 'string' || filePath instanceof String) {
folderPath = filePath.substring(0, filePath.lastIndexOf("/"));
} else {
Expand All @@ -60,6 +58,10 @@ function isMediaFile(filePath) {
}

function isVideoFile(filePath) {
if (!(typeof filePath === 'string' || filePath instanceof String)) {
filePath = filePath.toString();
}

var extension = filePath.split('.').pop().toLowerCase();
var valid = false;

Expand All @@ -77,6 +79,10 @@ function isVideoFile(filePath) {
}

function isPictureFile(filePath) {
if (!(typeof filePath === 'string' || filePath instanceof String)) {
filePath = filePath.toString();
}

var extension = filePath.split('.').pop().toLowerCase();
var valid = false;

Expand All @@ -96,14 +102,19 @@ function isPictureFile(filePath) {
}

function isAudioFile(filePath) {
if (!(typeof filePath === 'string' || filePath instanceof String)) {
filePath = filePath.toString();
}

var extension = filePath.split('.').pop().toLowerCase();
var valid = false;

if (extension.length !== 0) {
if (extension === "mp1" || extension === "mp2" || extension === "mp3" ||
extension === "m4a" || extension === "mp4a" || extension === "aac" ||
extension === "m4a" || extension === "mp4a" || extension === "m4r" || extension === "aac" ||
extension === "mka" ||
extension === "wma" || extension === "wav" || extension === "wave" ||
extension === "wma" ||
extension === "amb" || extension === "wav" || extension === "wave" ||
extension === "ogg" || extension === "opus" || extension === "vorbis" ) {
valid = true;
}
Expand Down
14 changes: 0 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@

int main(int argc, char *argv[])
{
// Arguments parsing ///////////////////////////////////////////////////////

bool test = false;
for (int i = 1; i < argc; i++)
{
if (argv[i])
{
//qDebug() << "> arg >" << argv[i];

if (QString::fromLocal8Bit(argv[i]) == "--test")
test = true;
}
}

// GUI application /////////////////////////////////////////////////////////

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Expand Down
22 changes: 10 additions & 12 deletions src/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
* \date 2019
*/

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <cmath>

#include "media.h"
#include "utils_media.h"
#include "minivideo_textexport.h"
Expand All @@ -47,6 +42,8 @@
#include <taglib/apetag.h>
#endif

#include <cmath>

#include <QDir>
#include <QUrl>
#include <QUuid>
Expand Down Expand Up @@ -98,7 +95,7 @@ Media::~Media()

/* ************************************************************************** */
/* ************************************************************************** */

/*
#ifdef ENABLE_LIBEXIF
static void show_tag(ExifData *d, ExifIfd ifd, ExifTag tag)
{
Expand All @@ -112,7 +109,7 @@ static void show_tag(ExifData *d, ExifIfd ifd, ExifTag tag)
}
}
#endif // ENABLE_LIBEXIF

*/
bool Media::getMetadatasFromPicture()
{
bool status = false;
Expand Down Expand Up @@ -386,7 +383,8 @@ bool Media::getMetadatasFromPicture()
*/
}

// MAKERNOTE ///////////////////////////////////////////////////////////////
// MAKERNOTE ///////////////////////////////////////////////////////////

ExifMnoteData *mn = exif_data_get_mnote_data(ed);
if (mn)
{
Expand Down Expand Up @@ -499,7 +497,7 @@ bool Media::getMetadatasFromAudio()
{
std::string a = (*j).to8Bit();
a = a.substr(a.rfind('/')+1);
tag_track_total = std::stoul(a);
tag_track_total = std::stoi(a);
}

//qDebug() << key << " - " << QString::fromStdWString((*j).toCWString());
Expand All @@ -515,8 +513,8 @@ bool Media::getMetadatasFromAudio()
{
TagLib::AudioProperties *properties = f.audioProperties();

int seconds = properties->length() % 60;
int minutes = (properties->length() - seconds) / 60;
//int seconds = properties->length() % 60;
//int minutes = (properties->length() - seconds) / 60;

if (m_duration <= 0)
m_duration = properties->lengthInMilliseconds();
Expand Down Expand Up @@ -570,7 +568,7 @@ bool Media::getMetadatasFromVideo()
m_creation_app = QString::fromLocal8Bit(m_media->creation_app);
m_creation_lib = QString::fromLocal8Bit(m_media->creation_lib);

m_duration = m_media->duration;
m_duration = static_cast<qint64>(m_media->duration);

m_date_metadatas = QDateTime::fromTime_t(m_media->creation_time);

Expand Down
1 change: 0 additions & 1 deletion src/utils_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "utils_android.h"
#include "utils_ios.h"

#define _USE_MATH_DEFINES
#include <cmath>

#include <QApplication>
Expand Down
2 changes: 1 addition & 1 deletion src/utils_media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ QString getTimestampSmtpeString(const uint64_t timestamp, const double framerate
uint64_t seconds = (timestamp - (hours * 3600000000) - (minutes * 60000000)) / 1000000;

double us = (timestamp - (hours * 3600000000) - (minutes * 60000000) - (seconds * 1000000));
uint64_t frames = std::floor(us / std::floor(1000000.0 / framerate));
uint64_t frames = static_cast<uint64_t>(std::floor(us / std::floor(1000000.0 / framerate)));

timestamp_qstr = QString::number(hours) + ":" + QString::number(minutes) + ":" + QString::number(seconds) + "-" + QString::number(frames);
timestamp_qstr = QString("%1:%2:%3-%4")\
Expand Down

0 comments on commit a3790c9

Please sign in to comment.