diff --git a/gui/Dialog.ui b/gui/Dialog.ui index 7735452..52800cb 100644 --- a/gui/Dialog.ui +++ b/gui/Dialog.ui @@ -31,6 +31,68 @@ + + + + + + + + + 170 + 0 + 0 + + + + + + + + + 170 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + 75 + true + + + + QFrame::StyledPanel + + + (UPDATE_INFO) + + + Qt::AlignCenter + + + 2 + + + true + + + diff --git a/src/Config.h b/src/Config.h index 253f697..84bf3a7 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 = 1; +static unsigned int mixp_versionMinor = 3; //MediaInfo Version static unsigned int mixp_miVersionMajor = 0; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b9195fc..b4f171b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -133,8 +133,18 @@ void CMainWindow::showEvent(QShowEvent *event) { QMainWindow::showEvent(event); resize(this->minimumSize()); - ui->versionLabel->setText(QString("v%1 (%2)").arg(QString().sprintf("%u.%02u", mixp_versionMajor, mixp_versionMinor), getBuildDate().toString(Qt::ISODate))); + + //Init test + ui->versionLabel->setText(QString("v%1 (%2)").arg(QString().sprintf("%u.%02u", mixp_versionMajor, mixp_versionMinor), mixp_get_build_date().toString(Qt::ISODate))); + ui->updateLabel->setText(tr("This version is more than six month old and probably outdated. Please check %1 for updates!").arg(LINK_MULDER)); + + //Show update hint? + ui->updateLabel->setVisible(mixp_get_build_date().addMonths(6) < mixp_get_current_date()); + + //Force resize event resizeEvent(NULL); + + //Enable drag & drop support setAcceptDrops(true); if(m_firstShow) @@ -361,9 +371,12 @@ void CMainWindow::showAboutScreen(void) { QString text; + const QDate buildDate = mixp_get_build_date(); + const QDate curntDate = mixp_get_current_date(); + text += QString().sprintf("MediaInfoXP v%u.%02u - Simple GUI for MediaInfo
", mixp_versionMajor, mixp_versionMinor); - text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
", qMax(getBuildDate().year(),QDate::currentDate().year())); - text += QString().sprintf("Built on %s at %s, using Qt Framework v%s.

", getBuildDate().toString(Qt::ISODate).toLatin1().constData(), mixp_buildTime, qVersion()); + text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
", qMax(buildDate.year(),curntDate.year())); + text += QString().sprintf("Built on %s at %s, using Qt Framework v%s.

", buildDate.toString(Qt::ISODate).toLatin1().constData(), mixp_buildTime, qVersion()); text += QString().sprintf("This program is free software: you can redistribute it and/or modify
"); text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.
"); text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.

"); @@ -416,36 +429,6 @@ void CMainWindow::handleDroppedFile(void) // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////// -QDate CMainWindow::getBuildDate(void) -{ - QDate buildDate(2000, 1, 1); - - static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - int date[3] = {0, 0, 0}; char temp[12] = {'\0'}; - strncpy_s(temp, 12, mixp_buildDate, _TRUNCATE); - - if(strlen(temp) == 11) - { - temp[3] = temp[6] = '\0'; - date[2] = atoi(&temp[4]); - date[0] = atoi(&temp[7]); - - for(int j = 0; j < 12; j++) - { - if(!_strcmpi(&temp[0], months[j])) - { - date[1] = j+1; - break; - } - } - - buildDate = QDate(date[0], date[1], date[2]); - } - - return buildDate; -} - #define VALIDATE_MEDIAINFO(HANDLE) do \ { \ if(HANDLE != INVALID_HANDLE_VALUE) \ diff --git a/src/MainWindow.h b/src/MainWindow.h index 30c1f7d..d7843ef 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -72,7 +72,6 @@ private: QString m_droppedFile; QStringList m_outputLines; - QDate getBuildDate(void); QString getMediaInfoPath(void); bool analyzeFile(const QString &filePath); }; diff --git a/src/Utils.cpp b/src/Utils.cpp index 3419822..1f62db9 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -20,6 +20,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "Utils.h" +#include "Config.h" //StdLib #include @@ -34,6 +35,7 @@ #include #include #include +#include //Win32 #define WIN32_LEAN_AND_MEAN @@ -41,6 +43,7 @@ #include #include #include +#include /* * Try to lock folder @@ -202,3 +205,99 @@ void mixp_clean_folder(const QString &folderPath) tempFolder.rmdir("."); } + +/* + * Clean folder + */ +QDate mixp_get_build_date(void) +{ + QDate buildDate(2000, 1, 1); + + static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + int date[3] = {0, 0, 0}; char temp[12] = {'\0'}; + strncpy_s(temp, 12, mixp_buildDate, _TRUNCATE); + + if(strlen(temp) == 11) + { + temp[3] = temp[6] = '\0'; + date[2] = atoi(&temp[4]); + date[0] = atoi(&temp[7]); + + for(int j = 0; j < 12; j++) + { + if(!_strcmpi(&temp[0], months[j])) + { + date[1] = j+1; + break; + } + } + + buildDate = QDate(date[0], date[1], date[2]); + } + + return buildDate; +} + +/* + * Clean folder + */ +QDate mixp_get_current_date(void) +{ + const DWORD MAX_PROC = 1024; + DWORD *processes = new DWORD[MAX_PROC]; + DWORD bytesReturned = 0; + + if(!EnumProcesses(processes, sizeof(DWORD) * MAX_PROC, &bytesReturned)) + { + MIXP_DELETE_ARR(processes); + return QDate::currentDate(); + } + + const DWORD procCount = bytesReturned / sizeof(DWORD); + ULARGE_INTEGER lastStartTime; + memset(&lastStartTime, 0, sizeof(ULARGE_INTEGER)); + + for(DWORD i = 0; i < procCount; i++) + { + HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processes[i]); + if(hProc) + { + FILETIME processTime[4]; + if(GetProcessTimes(hProc, &processTime[0], &processTime[1], &processTime[2], &processTime[3])) + { + ULARGE_INTEGER timeCreation; + timeCreation.LowPart = processTime[0].dwLowDateTime; + timeCreation.HighPart = processTime[0].dwHighDateTime; + if(timeCreation.QuadPart > lastStartTime.QuadPart) + { + lastStartTime.QuadPart = timeCreation.QuadPart; + } + } + CloseHandle(hProc); + } + } + + MIXP_DELETE_ARR(processes); + + FILETIME lastStartTime_fileTime; + lastStartTime_fileTime.dwHighDateTime = lastStartTime.HighPart; + lastStartTime_fileTime.dwLowDateTime = lastStartTime.LowPart; + + FILETIME lastStartTime_localTime; + if(!FileTimeToLocalFileTime(&lastStartTime_fileTime, &lastStartTime_localTime)) + { + memcpy(&lastStartTime_localTime, &lastStartTime_fileTime, sizeof(FILETIME)); + } + + SYSTEMTIME lastStartTime_system; + if(!FileTimeToSystemTime(&lastStartTime_localTime, &lastStartTime_system)) + { + memset(&lastStartTime_system, 0, sizeof(SYSTEMTIME)); + lastStartTime_system.wYear = 1970; lastStartTime_system.wMonth = lastStartTime_system.wDay = 1; + } + + const QDate currentDate = QDate::currentDate(); + const QDate processDate = QDate(lastStartTime_system.wYear, lastStartTime_system.wMonth, lastStartTime_system.wDay); + return (currentDate >= processDate) ? currentDate : processDate; +} diff --git a/src/Utils.h b/src/Utils.h index cf6bb28..35ef68e 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -24,10 +24,15 @@ #include #include +class QDate; + //Helper macros #define MIXP_DELETE_OBJ(PTR) do { if((PTR)) { delete ((PTR)); (PTR) = NULL; } } while (0) +#define MIXP_DELETE_ARR(PTR) do { if((PTR)) { delete [] ((PTR)); (PTR) = NULL; } } while (0) #define QWCHAR(STR) reinterpret_cast(STR.utf16()) //Utils QString mixp_getTempFolder(QFile **lockfile); void mixp_clean_folder(const QString &folderPath); +QDate mixp_get_build_date(void); +QDate mixp_get_current_date(void);