Register mediainfo with QML. Display HDR type
This commit is contained in:
parent
411e6e3b55
commit
eeaec187cb
@ -31,18 +31,31 @@ Window {
|
|||||||
anchors.rightMargin: 25
|
anchors.rightMargin: 25
|
||||||
color: "lightgrey"
|
color: "lightgrey"
|
||||||
height: txtVideoFile.font.pixelSize + 10
|
height: txtVideoFile.font.pixelSize + 10
|
||||||
|
id: txtBackground
|
||||||
|
|
||||||
TextEdit {
|
TextEdit {
|
||||||
id: txtVideoFile
|
id: txtVideoFile
|
||||||
text: ""
|
text: ""
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: 15
|
|
||||||
verticalAlignment: TextEdit.AlignVCenter
|
verticalAlignment: TextEdit.AlignVCenter
|
||||||
|
anchors.fill: parent
|
||||||
readOnly: false
|
readOnly: false
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
|
anchors.leftMargin: 15
|
||||||
|
anchors.rightMargin: 15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
//TODO Need to scroll and clip long text
|
||||||
|
id: hdrType
|
||||||
|
anchors.left: btnVideoFile.left
|
||||||
|
anchors.top: txtBackground.bottom
|
||||||
|
width: 200
|
||||||
|
text: "None"
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
@ -50,6 +63,22 @@ Window {
|
|||||||
fileMode: FileDialog.OpenFile
|
fileMode: FileDialog.OpenFile
|
||||||
nameFilters: ["Video files (*.mkv *.mp4)", "All files (*)"]
|
nameFilters: ["Video files (*.mkv *.mp4)", "All files (*)"]
|
||||||
onAccepted: { const reg = /^file:\/\/\// //Remove "file:/// at start of URL
|
onAccepted: { const reg = /^file:\/\/\// //Remove "file:/// at start of URL
|
||||||
txtVideoFile.text = videoFileDialog.selectedFile.toString().replace(reg, "") }
|
var fileName = videoFileDialog.selectedFile.toString().replace(reg, "")
|
||||||
|
txtVideoFile.text = fileName
|
||||||
|
|
||||||
|
switch (mediaInfo.getHDRType(fileName)) {
|
||||||
|
case 0:
|
||||||
|
hdrType.text = "SDR"
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
hdrType.text = "HDR"
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
hdrType.text = "Dolby Vision"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
hdrType.text = "Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,17 @@
|
|||||||
#include <myMediaInfo.h>
|
#include <myMediaInfo.h>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
myMediaInfo mInfo;
|
myMediaInfo mInfo(&app);
|
||||||
|
|
||||||
//Check if HDR/DolbyVision
|
//Check if HDR/DolbyVision
|
||||||
enum myMediaInfo::HDR hdrType = mInfo.getHDR(__T("Cosmos.mkv"));
|
enum myMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv"));
|
||||||
if (hdrType >= 0) {
|
if (hdrType >= 0) {
|
||||||
qInfo() << hdrType;
|
qInfo() << hdrType;
|
||||||
} else {
|
} else {
|
||||||
@ -21,6 +22,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
engine.rootContext()->setContextProperty("mediaInfo", &mInfo);
|
||||||
|
|
||||||
const QUrl url(u"qrc:/DoViGUI/Main.qml"_qs);
|
const QUrl url(u"qrc:/DoViGUI/Main.qml"_qs);
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||||
&app, []() { QCoreApplication::exit(-1); },
|
&app, []() { QCoreApplication::exit(-1); },
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#include "myMediaInfo.h"
|
#include "myMediaInfo.h"
|
||||||
#include "MediaInfoDLL.h"
|
#include "MediaInfoDLL.h"
|
||||||
|
#include "qvariant.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
myMediaInfo::myMediaInfo() {
|
|
||||||
|
|
||||||
}
|
myMediaInfo::myMediaInfo(QObject *parent){}
|
||||||
|
|
||||||
enum myMediaInfo::HDR myMediaInfo::getHDR(const MediaInfoDLL::String fileName) {
|
enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const MediaInfoDLL::String fileName) {
|
||||||
if (Open(fileName)) {
|
if (Open(fileName)) {
|
||||||
MediaInfoDLL::String HDRtext = Get(MediaInfoDLL::Stream_Video, 0, __T("HDR_Format"), MediaInfoDLL::Info_Text, MediaInfoDLL::Info_Name);
|
MediaInfoDLL::String HDRtext = Get(MediaInfoDLL::Stream_Video, 0, __T("HDR_Format"), MediaInfoDLL::Info_Text, MediaInfoDLL::Info_Name);
|
||||||
Close();
|
Close();
|
||||||
@ -23,3 +23,7 @@ enum myMediaInfo::HDR myMediaInfo::getHDR(const MediaInfoDLL::String fileName) {
|
|||||||
}
|
}
|
||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const QString fileName) {
|
||||||
|
return getHDRType(fileName.toStdWString());
|
||||||
|
}
|
||||||
|
@ -2,16 +2,19 @@
|
|||||||
#define MYMEDIAINFO_H
|
#define MYMEDIAINFO_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
//#include "qvariant.h"
|
||||||
#include <MediaInfoDLL.h>
|
#include <MediaInfoDLL.h>
|
||||||
|
|
||||||
class myMediaInfo : public MediaInfoDLL::MediaInfo{
|
class myMediaInfo : public QObject, public MediaInfoDLL::MediaInfo {
|
||||||
// Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
myMediaInfo();
|
myMediaInfo(QObject* parent = nullptr);
|
||||||
enum HDR{ERR = -1, SDR = 0, HDR = 1, DOVI = 2};
|
enum HDR_Type{ERR = -1, SDR = 0, HDR = 1, DOVI = 2};
|
||||||
|
Q_ENUM(HDR_Type)
|
||||||
|
|
||||||
enum HDR getHDR(const MediaInfoDLL::String fileName);
|
enum HDR_Type getHDRType(const MediaInfoDLL::String fileName);
|
||||||
|
Q_INVOKABLE enum HDR_Type getHDRType(QString fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user