diff --git a/MediaInfoXP.qrc b/MediaInfoXP.qrc index 5fc13ea..c3d1e16 100644 --- a/MediaInfoXP.qrc +++ b/MediaInfoXP.qrc @@ -5,9 +5,11 @@ MediaInfoXP.png res/ico_clear.png res/ico_discard.png + res/ico_disk.png res/ico_folder.png res/ico_info.png res/ico_link.png + res/ico_paste.png res/ico_qt.png res/ico_quit.png res/logo.png diff --git a/gui/Dialog.ui b/gui/Dialog.ui index 5c39022..7735452 100644 --- a/gui/Dialog.ui +++ b/gui/Dialog.ui @@ -6,7 +6,7 @@ 0 0 - 720 + 800 384 @@ -160,7 +160,7 @@ 0 0 - 720 + 800 21 @@ -169,6 +169,9 @@ Application + + + @@ -232,6 +235,9 @@ + + false + :/res/ico_clear.png:/res/ico_clear.png @@ -249,6 +255,30 @@ MediaInfo Discussion (Doom9) + + + false + + + + :/res/ico_paste.png:/res/ico_paste.png + + + Copy to Clipboard + + + + + false + + + + :/res/ico_disk.png:/res/ico_disk.png + + + Save to File... + + analyzeButton diff --git a/res/ico_disk.png b/res/ico_disk.png new file mode 100644 index 0000000..99d532e Binary files /dev/null and b/res/ico_disk.png differ diff --git a/res/ico_paste.png b/res/ico_paste.png new file mode 100644 index 0000000..c0490eb Binary files /dev/null and b/res/ico_paste.png differ diff --git a/src/Config.h b/src/Config.h index 797e1ba..712e529 100644 --- a/src/Config.h +++ b/src/Config.h @@ -21,7 +21,7 @@ //Version static unsigned int mixp_versionMajor = 2; -static unsigned int mixp_versionMinor = 0; +static unsigned int mixp_versionMinor = 1; //MediaInfo Version static unsigned int mixp_miVersionMajor = 0; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 825d5fa..6dd8fb4 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -34,6 +34,7 @@ #include #include #include +#include //Win32 #define WIN32_LEAN_AND_MEAN @@ -79,6 +80,8 @@ CMainWindow::CMainWindow(const QString &tempFolder, QWidget *parent) //Setup connections connect(ui->analyzeButton, SIGNAL(clicked()), this, SLOT(analyzeButtonClicked())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(analyzeButtonClicked())); + connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveButtonClicked())); + connect(ui->actionCopyToClipboard, SIGNAL(triggered()), this, SLOT(copyToClipboardButtonClicked())); connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(clearButtonClicked())); connect(ui->actionLink_MuldeR, SIGNAL(triggered()), this, SLOT(linkTriggered())); connect(ui->actionLink_MediaInfo, SIGNAL(triggered()), this, SLOT(linkTriggered())); @@ -86,6 +89,10 @@ CMainWindow::CMainWindow(const QString &tempFolder, QWidget *parent) connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutScreen())); ui->versionLabel->installEventFilter(this); + //Context menu + ui->textBrowser->setContextMenuPolicy(Qt::ActionsContextMenu); + ui->textBrowser->insertActions(0, ui->menuFile->actions()); + //Create label m_floatingLabel = new QLabel(ui->textBrowser); m_floatingLabel->setText(QString::fromLatin1(STATUS_BLNK)); @@ -93,12 +100,9 @@ CMainWindow::CMainWindow(const QString &tempFolder, QWidget *parent) m_floatingLabel->show(); SET_TEXT_COLOR(m_floatingLabel, Qt::darkGray); SET_FONT_BOLD(m_floatingLabel, true); - - //Update font - QFont font("Lucida Console"); - font.setStyleHint(QFont::TypeWriter); - ui->textBrowser->setFont(font); - + m_floatingLabel->setContextMenuPolicy(Qt::ActionsContextMenu); + m_floatingLabel->insertActions(0, ui->textBrowser->actions()); + //Clear m_mediaInfoPath.clear(); m_mediaInfoHandle = INVALID_HANDLE_VALUE; @@ -237,6 +241,34 @@ void CMainWindow::analyzeButtonClicked(void) } } +void CMainWindow::saveButtonClicked(void) +{ + const QString selectedFile = QFileDialog::getSaveFileName(this, tr("Select file to save..."), QString(), tr("Plain Text (*.txt)")); + if(!selectedFile.isEmpty()) + { + QFile file(selectedFile); + if(file.open(QIODevice::WriteOnly | QIODevice::WriteOnly)) + { + file.write(m_outputLines.join("\r\n").toUtf8()); + file.close(); + MessageBeep(MB_ICONINFORMATION); + } + else + { + QMessageBox::critical(this, tr("Failure"), tr("Error: Failed to open the file writing!"), QMessageBox::Ok); + } + } +} + +void CMainWindow::copyToClipboardButtonClicked(void) +{ + if(QClipboard *clipboard = QApplication::clipboard()) + { + clipboard->setText(m_outputLines.join("\n")); + MessageBeep(MB_ICONINFORMATION); + } +} + void CMainWindow::clearButtonClicked(void) { if(m_process) @@ -247,30 +279,70 @@ void CMainWindow::clearButtonClicked(void) } } + //Clear data and re-show banner ui->textBrowser->clear(); m_floatingLabel->setText(STATUS_BLNK); m_floatingLabel->show(); + + //Disable actions + ui->actionClear->setEnabled(false); + ui->actionCopyToClipboard->setEnabled(false); + ui->actionSave->setEnabled(false); } void CMainWindow::outputAvailable(void) { if(m_process) { + bool bDataChanged = false; + + //Update lines while(m_process->canReadLine()) { + bDataChanged = true; + QString line = QString::fromUtf8(m_process->readLine()).trimmed(); + m_outputLines << line; + } + + if(bDataChanged) + { + //Hide banner if(m_floatingLabel->isVisible()) m_floatingLabel->hide(); - QString line = Qt::escape(QString::fromUtf8(m_process->readLine()).trimmed()).replace(' ', " "); - if(!(line.isEmpty() || line.contains(':'))) line = QString("%1").arg(line); - ui->textBrowser->setHtml(m_output.append(line).append("
")); + + //Convert to HTML + QStringList htmlData(m_outputLines); + htmlData.replaceInStrings("<", "<", Qt::CaseInsensitive); + htmlData.replaceInStrings(">", ">", Qt::CaseInsensitive); + htmlData.replaceInStrings("\"", """, Qt::CaseInsensitive); + htmlData.replaceInStrings("&", "&", Qt::CaseInsensitive); + + //Highlight headers + htmlData.replaceInStrings(QRegExp("^([^:]+):(.+)$"), "\\1:\\2"); + htmlData.replaceInStrings(QRegExp("^([^:]+)$"), "\\1"); + + //Update document + ui->textBrowser->setHtml(QString("
%1
").arg(htmlData.join("
"))); } } } void CMainWindow::processFinished(void) { + //Fetch any remaining data outputAvailable(); + + //Enable actions + if(!m_outputLines.empty()) + { + ui->actionClear->setEnabled(true); + ui->actionCopyToClipboard->setEnabled(true); + ui->actionSave->setEnabled(true); + } + ui->actionOpen->setEnabled(true); ui->analyzeButton->setEnabled(true); ui->exitButton->setEnabled(true); + + //Scroll up ui->textBrowser->verticalScrollBar()->setValue(0); ui->textBrowser->horizontalScrollBar()->setValue(0); } @@ -298,7 +370,7 @@ void CMainWindow::showAboutScreen(void) text += QString().sprintf("

"); text += QString().sprintf("This application is powered by MediaInfo v%u.%u.%02u
", mixp_miVersionMajor, mixp_miVersionMinor, mixp_miVersionPatch); text += QString().sprintf("Free and OpenSource tool for displaying technical information about media files.
"); - text += QString().sprintf("Copyright (c) 2002-2013 MediaArea.net SARL. All rights reserved.

"); + text += QString().sprintf("Copyright (c) 2002-%s MediaArea.net SARL. All rights reserved.

", &mixp_buildDate[7]); text += QString().sprintf("Redistribution and use is permitted according to the (2-Clause) BSD License.
"); text += QString().sprintf("Please see %s for more information.
", LINK_MEDIAINFO, LINK_MEDIAINFO); @@ -485,11 +557,15 @@ bool CMainWindow::analyzeFile(const QString &filePath) //Clear data ui->textBrowser->clear(); - m_output.clear(); + m_outputLines.clear(); //Disable buttons ui->analyzeButton->setEnabled(false); ui->exitButton->setEnabled(false); + ui->actionClear->setEnabled(false); + ui->actionCopyToClipboard->setEnabled(false); + ui->actionSave->setEnabled(false); + ui->actionOpen->setEnabled(false); //Show banner m_floatingLabel->show(); @@ -515,6 +591,7 @@ bool CMainWindow::analyzeFile(const QString &filePath) { QMessageBox::critical(this, tr("Failure"), tr("Error: Failed to create MediaInfo process!"), QMessageBox::Ok); m_floatingLabel->hide(); + ui->actionOpen->setEnabled(true); ui->analyzeButton->setEnabled(true); ui->exitButton->setEnabled(true); return false; diff --git a/src/MainWindow.h b/src/MainWindow.h index 8ab97d5..30c1f7d 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -43,6 +43,8 @@ public: private slots: void analyzeButtonClicked(void); + void saveButtonClicked(void); + void copyToClipboardButtonClicked(void); void clearButtonClicked(void); void outputAvailable(void); void processFinished(void); @@ -68,7 +70,7 @@ private: QProcess *m_process; QLabel *m_floatingLabel; QString m_droppedFile; - QString m_output; + QStringList m_outputLines; QDate getBuildDate(void); QString getMediaInfoPath(void);