Added support for XML formatted MediaInfo output.
This commit is contained in:
parent
018b111259
commit
2e6c6dfccf
@ -241,6 +241,7 @@
|
|||||||
<addaction name="actionShellExtension"/>
|
<addaction name="actionShellExtension"/>
|
||||||
<addaction name="actionLineWrapping"/>
|
<addaction name="actionLineWrapping"/>
|
||||||
<addaction name="actionVerboseOutput"/>
|
<addaction name="actionVerboseOutput"/>
|
||||||
|
<addaction name="actionXmlOutput"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@ -382,6 +383,14 @@
|
|||||||
<string>Enable Line Wrapping</string>
|
<string>Enable Line Wrapping</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionXmlOutput">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable XML-style Output</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>analyzeButton</tabstop>
|
<tabstop>analyzeButton</tabstop>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
//Version
|
//Version
|
||||||
MIXP_DEFINE_CONF(unsigned int, mixp_versionMajor, 2)
|
MIXP_DEFINE_CONF(unsigned int, mixp_versionMajor, 2)
|
||||||
MIXP_DEFINE_CONF(unsigned int, mixp_versionMinor, 27)
|
MIXP_DEFINE_CONF(unsigned int, mixp_versionMinor, 28)
|
||||||
|
|
||||||
//MediaInfo Version
|
//MediaInfo Version
|
||||||
MIXP_DEFINE_CONF(unsigned int, mixp_miVersionMajor, 0)
|
MIXP_DEFINE_CONF(unsigned int, mixp_miVersionMajor, 0)
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
//CRT
|
//CRT
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@ -68,16 +70,6 @@ const char *LINK_MULDER = "http://muldersoft.com/";
|
|||||||
const char *LINK_MEDIAINFO = "http://mediaarea.net/en/MediaInfo"; /*"http://mediainfo.sourceforge.net/en"*/
|
const char *LINK_MEDIAINFO = "http://mediaarea.net/en/MediaInfo"; /*"http://mediainfo.sourceforge.net/en"*/
|
||||||
const char *LINK_DISCUSS = "http://forum.doom9.org/showthread.php?t=96516";
|
const char *LINK_DISCUSS = "http://forum.doom9.org/showthread.php?t=96516";
|
||||||
|
|
||||||
//HTML characters
|
|
||||||
static QList<QPair<const QString, const QString>> HTML_ESCAPE(void)
|
|
||||||
{
|
|
||||||
QList<QPair<const QString, const QString>> htmlEscape;
|
|
||||||
htmlEscape << QPair<const QString, const QString>("<", "<");
|
|
||||||
htmlEscape << QPair<const QString, const QString>(">", ">");
|
|
||||||
htmlEscape << QPair<const QString, const QString>("&", "&");
|
|
||||||
return htmlEscape;
|
|
||||||
}
|
|
||||||
|
|
||||||
//MediaInfo
|
//MediaInfo
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
@ -106,7 +98,6 @@ CMainWindow::CMainWindow(const QString &tempFolder, MUtils::IPCChannel *const ip
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
m_tempFolder(tempFolder),
|
m_tempFolder(tempFolder),
|
||||||
m_ipcThread(new IPCReceiveThread(ipc)),
|
m_ipcThread(new IPCReceiveThread(ipc)),
|
||||||
m_htmlEscape(HTML_ESCAPE()),
|
|
||||||
m_status(APP_STATUS_STARTING),
|
m_status(APP_STATUS_STARTING),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
@ -138,6 +129,8 @@ CMainWindow::CMainWindow(const QString &tempFolder, MUtils::IPCChannel *const ip
|
|||||||
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutScreen()));
|
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutScreen()));
|
||||||
connect(ui->actionShellExtension, SIGNAL(toggled(bool)), this, SLOT(updateShellExtension(bool)));
|
connect(ui->actionShellExtension, SIGNAL(toggled(bool)), this, SLOT(updateShellExtension(bool)));
|
||||||
connect(ui->actionLineWrapping, SIGNAL(toggled(bool)), this, SLOT(updateLineWrapping(bool)));
|
connect(ui->actionLineWrapping, SIGNAL(toggled(bool)), this, SLOT(updateLineWrapping(bool)));
|
||||||
|
connect(ui->actionVerboseOutput, SIGNAL(toggled(bool)), this, SLOT(toggleOutputOption(bool)));
|
||||||
|
connect(ui->actionXmlOutput, SIGNAL(toggled(bool)), this, SLOT(toggleOutputOption(bool)));
|
||||||
connect(m_ipcThread.data(), SIGNAL(received(quint32, QString)), this, SLOT(received(quint32, QString)));
|
connect(m_ipcThread.data(), SIGNAL(received(quint32, QString)), this, SLOT(received(quint32, QString)));
|
||||||
ui->versionLabel->installEventFilter(this);
|
ui->versionLabel->installEventFilter(this);
|
||||||
|
|
||||||
@ -416,6 +409,7 @@ void CMainWindow::analyzeNextFile(void)
|
|||||||
//Generate the command line
|
//Generate the command line
|
||||||
QStringList commandLine;
|
QStringList commandLine;
|
||||||
if(ui->actionVerboseOutput->isChecked()) commandLine << "--Full";
|
if(ui->actionVerboseOutput->isChecked()) commandLine << "--Full";
|
||||||
|
if(ui->actionXmlOutput->isChecked()) commandLine << "--Output=XML";
|
||||||
commandLine << QDir::toNativeSeparators(filePath);
|
commandLine << QDir::toNativeSeparators(filePath);
|
||||||
|
|
||||||
//Start analyziation
|
//Start analyziation
|
||||||
@ -552,11 +546,11 @@ void CMainWindow::processFinished(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Remove leading "E:" lines
|
//Remove leading "E:" lines
|
||||||
while ((!m_outputLines.isEmpty()) && m_outputLines.first().trimmed().startsWith(QLatin1String("E: ")))
|
/*while ((!m_outputLines.isEmpty()) && m_outputLines.first().trimmed().startsWith(QLatin1String("E: ")))
|
||||||
{
|
//{
|
||||||
qWarning("E: line has been removed!");
|
// qWarning("E: line has been removed!");
|
||||||
m_outputLines.takeFirst();
|
// m_outputLines.takeFirst();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//Failed?
|
//Failed?
|
||||||
if(m_outputLines.empty())
|
if(m_outputLines.empty())
|
||||||
@ -589,17 +583,20 @@ void CMainWindow::processFinished(void)
|
|||||||
//Hide banner
|
//Hide banner
|
||||||
if(m_floatingLabel->isVisible()) m_floatingLabel->hide();
|
if(m_floatingLabel->isVisible()) m_floatingLabel->hide();
|
||||||
|
|
||||||
//Convert to HTML
|
|
||||||
QStringList htmlData(m_outputLines);
|
|
||||||
escapeHtmlChars(htmlData);
|
|
||||||
|
|
||||||
//Highlight headers
|
|
||||||
htmlData.replaceInStrings(QRegExp("^(-+)$"), "<font color=\"darkgray\">\\1</font>"); //Separator lines
|
|
||||||
htmlData.replaceInStrings(QRegExp("^([^:<>]+):(.+)$"), "<font color=\"darkblue\">\\1:</font>\\2"); //Info lines
|
|
||||||
htmlData.replaceInStrings(QRegExp("^([^:<>]+)$"), "<b><font color=\"darkred\">\\1</font></b>"); //Heading lines
|
|
||||||
|
|
||||||
//Update document
|
//Update document
|
||||||
|
if (!ui->actionXmlOutput->isChecked())
|
||||||
|
{
|
||||||
|
QStringList htmlData = escapeHtmlLines(m_outputLines);
|
||||||
|
htmlData.replaceInStrings(QRegExp("^(-+)$"), "<font color=\"darkgray\">\\1</font>");
|
||||||
|
htmlData.replaceInStrings(QRegExp("^([^:<>]+):(.+)$"), "<font color=\"darkblue\">\\1:</font>\\2");
|
||||||
|
htmlData.replaceInStrings(QRegExp("^([^:<>]+)$"), "<b><font color=\"darkred\">\\1</font></b>");
|
||||||
ui->textBrowser->setHtml(QString("<pre style=\"white-space:pre-wrap\">%1</pre>").arg(htmlData.join("<br>")));
|
ui->textBrowser->setHtml(QString("<pre style=\"white-space:pre-wrap\">%1</pre>").arg(htmlData.join("<br>")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString xmlData = Qt::escape(reformatXml(m_outputLines.join(QLatin1String("\n"))));
|
||||||
|
ui->textBrowser->setHtml(QString("<pre style=\"white-space:pre-wrap\">%1</pre>").arg(xmlData));
|
||||||
|
}
|
||||||
|
|
||||||
//Enable actions
|
//Enable actions
|
||||||
if(!m_outputLines.empty())
|
if(!m_outputLines.empty())
|
||||||
@ -641,6 +638,11 @@ void CMainWindow::updateLineWrapping(bool checked)
|
|||||||
ui->textBrowser->setLineWrapMode(checked ? QTextEdit::WidgetWidth : QTextEdit::NoWrap);
|
ui->textBrowser->setLineWrapMode(checked ? QTextEdit::WidgetWidth : QTextEdit::NoWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMainWindow::toggleOutputOption(bool checked)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, this->windowTitle(), tr("Changes will take effect the next time that you open a file!"));
|
||||||
|
}
|
||||||
|
|
||||||
void CMainWindow::linkTriggered(void)
|
void CMainWindow::linkTriggered(void)
|
||||||
{
|
{
|
||||||
QObject *obj = QObject::sender();
|
QObject *obj = QObject::sender();
|
||||||
@ -892,11 +894,29 @@ QString CMainWindow::getMediaInfoPath(void)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::escapeHtmlChars(QStringList &strings)
|
QStringList CMainWindow::escapeHtmlLines(const QStringList &strings)
|
||||||
{
|
{
|
||||||
QList<QPair<const QString, const QString>>::ConstIterator iter;
|
QStringList output;
|
||||||
for(iter = m_htmlEscape.constBegin(); iter != m_htmlEscape.constEnd(); iter++)
|
for (QStringList::const_iterator iter = strings.constBegin(); iter != strings.constEnd(); ++iter)
|
||||||
{
|
{
|
||||||
strings.replaceInStrings((*iter).first, (*iter).second);
|
output << Qt::escape(*iter);
|
||||||
}
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CMainWindow::reformatXml(const QString &input)
|
||||||
|
{
|
||||||
|
QString output;
|
||||||
|
QXmlStreamReader reader(input);
|
||||||
|
QXmlStreamWriter writer(&output);
|
||||||
|
writer.setAutoFormatting(true);
|
||||||
|
while (!reader.atEnd())
|
||||||
|
{
|
||||||
|
reader.readNext();
|
||||||
|
if (!reader.isWhitespace())
|
||||||
|
{
|
||||||
|
writer.writeCurrentToken(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ private slots:
|
|||||||
void initShellExtension(void);
|
void initShellExtension(void);
|
||||||
void updateShellExtension(bool checked);
|
void updateShellExtension(bool checked);
|
||||||
void updateLineWrapping(bool checked);
|
void updateLineWrapping(bool checked);
|
||||||
|
void toggleOutputOption(bool checked);
|
||||||
void received(const quint32 &command, const QString &message);
|
void received(const quint32 &command, const QString &message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -96,10 +97,10 @@ private:
|
|||||||
QStringList m_pendingFiles;
|
QStringList m_pendingFiles;
|
||||||
QStringList m_outputLines;
|
QStringList m_outputLines;
|
||||||
|
|
||||||
const QList<QPair<const QString, const QString>> m_htmlEscape;
|
|
||||||
|
|
||||||
QPair<QString, const char*> getMediaInfoArch(void);
|
QPair<QString, const char*> getMediaInfoArch(void);
|
||||||
void selfTest(void);
|
void selfTest(void);
|
||||||
QString getMediaInfoPath(void);
|
QString getMediaInfoPath(void);
|
||||||
void escapeHtmlChars(QStringList &strings);
|
|
||||||
|
static QStringList escapeHtmlLines(const QStringList &strings);
|
||||||
|
static QString reformatXml(const QString &input);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user