Added update hint label + some refactoring.
This commit is contained in:
parent
1cbd28bdff
commit
80c4388441
@ -31,6 +31,68 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="updateLabel">
|
||||||
|
<property name="palette">
|
||||||
|
<palette>
|
||||||
|
<active>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>170</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</active>
|
||||||
|
<inactive>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>170</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</inactive>
|
||||||
|
<disabled>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>120</red>
|
||||||
|
<green>120</green>
|
||||||
|
<blue>120</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</disabled>
|
||||||
|
</palette>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>(UPDATE_INFO)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
//Version
|
//Version
|
||||||
static unsigned int mixp_versionMajor = 2;
|
static unsigned int mixp_versionMajor = 2;
|
||||||
static unsigned int mixp_versionMinor = 1;
|
static unsigned int mixp_versionMinor = 3;
|
||||||
|
|
||||||
//MediaInfo Version
|
//MediaInfo Version
|
||||||
static unsigned int mixp_miVersionMajor = 0;
|
static unsigned int mixp_miVersionMajor = 0;
|
||||||
|
@ -133,8 +133,18 @@ void CMainWindow::showEvent(QShowEvent *event)
|
|||||||
{
|
{
|
||||||
QMainWindow::showEvent(event);
|
QMainWindow::showEvent(event);
|
||||||
resize(this->minimumSize());
|
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 <a href=\"%1\">%1</a> 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);
|
resizeEvent(NULL);
|
||||||
|
|
||||||
|
//Enable drag & drop support
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
if(m_firstShow)
|
if(m_firstShow)
|
||||||
@ -361,9 +371,12 @@ void CMainWindow::showAboutScreen(void)
|
|||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
|
const QDate buildDate = mixp_get_build_date();
|
||||||
|
const QDate curntDate = mixp_get_current_date();
|
||||||
|
|
||||||
text += QString().sprintf("<nobr><tt><b>MediaInfoXP v%u.%02u - Simple GUI for MediaInfo</b><br>", mixp_versionMajor, mixp_versionMinor);
|
text += QString().sprintf("<nobr><tt><b>MediaInfoXP v%u.%02u - Simple GUI for MediaInfo</b><br>", mixp_versionMajor, mixp_versionMinor);
|
||||||
text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.<br>", qMax(getBuildDate().year(),QDate::currentDate().year()));
|
text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.<br>", qMax(buildDate.year(),curntDate.year()));
|
||||||
text += QString().sprintf("Built on %s at %s, using Qt Framework v%s.<br><br>", getBuildDate().toString(Qt::ISODate).toLatin1().constData(), mixp_buildTime, qVersion());
|
text += QString().sprintf("Built on %s at %s, using Qt Framework v%s.<br><br>", buildDate.toString(Qt::ISODate).toLatin1().constData(), mixp_buildTime, qVersion());
|
||||||
text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
|
text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
|
||||||
text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.<br>");
|
text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.<br>");
|
||||||
text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
|
text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
|
||||||
@ -416,36 +429,6 @@ void CMainWindow::handleDroppedFile(void)
|
|||||||
// PRIVATE FUNCTIONS
|
// 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 \
|
#define VALIDATE_MEDIAINFO(HANDLE) do \
|
||||||
{ \
|
{ \
|
||||||
if(HANDLE != INVALID_HANDLE_VALUE) \
|
if(HANDLE != INVALID_HANDLE_VALUE) \
|
||||||
|
@ -72,7 +72,6 @@ private:
|
|||||||
QString m_droppedFile;
|
QString m_droppedFile;
|
||||||
QStringList m_outputLines;
|
QStringList m_outputLines;
|
||||||
|
|
||||||
QDate getBuildDate(void);
|
|
||||||
QString getMediaInfoPath(void);
|
QString getMediaInfoPath(void);
|
||||||
bool analyzeFile(const QString &filePath);
|
bool analyzeFile(const QString &filePath);
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
//StdLib
|
//StdLib
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
//Win32
|
//Win32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@ -41,6 +43,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <Objbase.h>
|
#include <Objbase.h>
|
||||||
|
#include <Psapi.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to lock folder
|
* Try to lock folder
|
||||||
@ -202,3 +205,99 @@ void mixp_clean_folder(const QString &folderPath)
|
|||||||
|
|
||||||
tempFolder.rmdir(".");
|
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;
|
||||||
|
}
|
||||||
|
@ -24,10 +24,15 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
class QDate;
|
||||||
|
|
||||||
//Helper macros
|
//Helper macros
|
||||||
#define MIXP_DELETE_OBJ(PTR) do { if((PTR)) { delete ((PTR)); (PTR) = NULL; } } while (0)
|
#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<const wchar_t*>(STR.utf16())
|
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
|
||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
QString mixp_getTempFolder(QFile **lockfile);
|
QString mixp_getTempFolder(QFile **lockfile);
|
||||||
void mixp_clean_folder(const QString &folderPath);
|
void mixp_clean_folder(const QString &folderPath);
|
||||||
|
QDate mixp_get_build_date(void);
|
||||||
|
QDate mixp_get_current_date(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user