Display "N/A" if CPU usage cannot be determined (as on Win2k).

This commit is contained in:
LoRd_MuldeR 2011-10-30 21:41:00 +01:00
parent a6ddde787e
commit a7126f42d2
6 changed files with 89 additions and 85 deletions

View File

@ -2653,94 +2653,94 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="320"/>
<location filename="../../src/Dialog_Processing.cpp" line="322"/>
<source>Encoding files, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="364"/>
<location filename="../../src/Dialog_Processing.cpp" line="366"/>
<source>Multi-threading enabled: Running %1 instances in parallel!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="378"/>
<location filename="../../src/Dialog_Processing.cpp" line="380"/>
<source>Aborted! Waiting for running jobs to terminate...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="393"/>
<location filename="../../src/Dialog_Processing.cpp" line="395"/>
<source>Encoding: %1 files of %2 completed so far, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="421"/>
<location filename="../../src/Dialog_Processing.cpp" line="423"/>
<source>Creating the playlist file, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="431"/>
<location filename="../../src/Dialog_Processing.cpp" line="433"/>
<source>Process was aborted by the user after %1 file(s)!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="431"/>
<location filename="../../src/Dialog_Processing.cpp" line="433"/>
<source>Process was aborted prematurely by the user!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="432"/>
<location filename="../../src/Dialog_Processing.cpp" line="434"/>
<source>LameXP - Aborted</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="432"/>
<location filename="../../src/Dialog_Processing.cpp" line="434"/>
<source>Process was aborted by the user.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="444"/>
<location filename="../../src/Dialog_Processing.cpp" line="446"/>
<source>Error: %1 of %2 files failed. Double-click failed items for detailed information!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="445"/>
<location filename="../../src/Dialog_Processing.cpp" line="447"/>
<source>LameXP - Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="445"/>
<location filename="../../src/Dialog_Processing.cpp" line="447"/>
<source>At least one file has failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="455"/>
<location filename="../../src/Dialog_Processing.cpp" line="456"/>
<location filename="../../src/Dialog_Processing.cpp" line="457"/>
<location filename="../../src/Dialog_Processing.cpp" line="458"/>
<source>All files completed successfully.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="456"/>
<location filename="../../src/Dialog_Processing.cpp" line="458"/>
<source>LameXP - Done</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="844"/>
<location filename="../../src/Dialog_Processing.cpp" line="846"/>
<source>Playlist creation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="844"/>
<location filename="../../src/Dialog_Processing.cpp" line="846"/>
<source>The playlist file could not be created:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="914"/>
<location filename="../../src/Dialog_Processing.cpp" line="916"/>
<source>Warning: Computer will shutdown in %1 seconds...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="918"/>
<location filename="../../src/Dialog_Processing.cpp" line="919"/>
<location filename="../../src/Dialog_Processing.cpp" line="920"/>
<location filename="../../src/Dialog_Processing.cpp" line="921"/>
<source>Cancel Shutdown</source>
<translation type="unfinished"></translation>
</message>

View File

@ -2653,94 +2653,94 @@
<translation type="unfinished">Twoje pliki właśnie kompresowane, prosze być cierpliwy...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="320"/>
<location filename="../../src/Dialog_Processing.cpp" line="322"/>
<source>Encoding files, please wait...</source>
<translation type="unfinished">Kompresowanie plików, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="364"/>
<location filename="../../src/Dialog_Processing.cpp" line="366"/>
<source>Multi-threading enabled: Running %1 instances in parallel!</source>
<translation type="unfinished">Wielowątkowosć włączona: Równolegle wykonywanych jest %1 kodowań!</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="378"/>
<location filename="../../src/Dialog_Processing.cpp" line="380"/>
<source>Aborted! Waiting for running jobs to terminate...</source>
<translation type="unfinished">Przerwano! Czekanie na wyłączenie procesu...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="393"/>
<location filename="../../src/Dialog_Processing.cpp" line="395"/>
<source>Encoding: %1 files of %2 completed so far, please wait...</source>
<translation type="unfinished">Kompresja: Prosze czekać, jak dotąd wykonano %1 z %2 plików...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="421"/>
<location filename="../../src/Dialog_Processing.cpp" line="423"/>
<source>Creating the playlist file, please wait...</source>
<translation type="unfinished">Tworzenie pliku playlisty, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="431"/>
<location filename="../../src/Dialog_Processing.cpp" line="433"/>
<source>Process was aborted by the user after %1 file(s)!</source>
<translation type="unfinished">Proces został przerwany przez użytkownika po wykonaniu %1 plików!</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="431"/>
<location filename="../../src/Dialog_Processing.cpp" line="433"/>
<source>Process was aborted prematurely by the user!</source>
<translation type="unfinished">Proces został przedwcześnie zakończony przez użytkownika!</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="432"/>
<location filename="../../src/Dialog_Processing.cpp" line="434"/>
<source>LameXP - Aborted</source>
<translation type="unfinished">LameXP - Przerwano</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="432"/>
<location filename="../../src/Dialog_Processing.cpp" line="434"/>
<source>Process was aborted by the user.</source>
<translation type="unfinished">Proces został przerwany przez użytkownika.</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="444"/>
<location filename="../../src/Dialog_Processing.cpp" line="446"/>
<source>Error: %1 of %2 files failed. Double-click failed items for detailed information!</source>
<translation type="unfinished">Błąd: %1 z %2 plików nie zostało skompresowanych. Kliknij dwukrotnie na plik aby zobaczyć szczegóły!</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="445"/>
<location filename="../../src/Dialog_Processing.cpp" line="447"/>
<source>LameXP - Error</source>
<translation type="unfinished">LameXP - Błąd</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="445"/>
<location filename="../../src/Dialog_Processing.cpp" line="447"/>
<source>At least one file has failed!</source>
<translation type="unfinished">Przynajmniej jeden plik nie został skompresowany!</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="455"/>
<location filename="../../src/Dialog_Processing.cpp" line="456"/>
<location filename="../../src/Dialog_Processing.cpp" line="457"/>
<location filename="../../src/Dialog_Processing.cpp" line="458"/>
<source>All files completed successfully.</source>
<translation type="unfinished">Kompresja wszystkich plików zakończona powodzeniem.</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="456"/>
<location filename="../../src/Dialog_Processing.cpp" line="458"/>
<source>LameXP - Done</source>
<translation type="unfinished">LameXP - Zrobione</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="844"/>
<location filename="../../src/Dialog_Processing.cpp" line="846"/>
<source>Playlist creation failed</source>
<translation type="unfinished">Tworzenie playlisty zakończone niepowodzeniem</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="844"/>
<location filename="../../src/Dialog_Processing.cpp" line="846"/>
<source>The playlist file could not be created:</source>
<translation type="unfinished">Playlista nie mogła zostać utworzona:</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="914"/>
<location filename="../../src/Dialog_Processing.cpp" line="916"/>
<source>Warning: Computer will shutdown in %1 seconds...</source>
<translation type="unfinished">Ostrzeżenie: Komputer zostanie zamknięty za %1 sekund/y...</translation>
</message>
<message>
<location filename="../../src/Dialog_Processing.cpp" line="918"/>
<location filename="../../src/Dialog_Processing.cpp" line="919"/>
<location filename="../../src/Dialog_Processing.cpp" line="920"/>
<location filename="../../src/Dialog_Processing.cpp" line="921"/>
<source>Cancel Shutdown</source>
<translation type="unfinished">Anuluj wyłączenie komputera</translation>
</message>

View File

@ -416,7 +416,7 @@
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
@ -495,7 +495,7 @@
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 3
#define VER_LAMEXP_TYPE RC
#define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 762
#define VER_LAMEXP_BUILD 763
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -244,6 +244,8 @@ ProcessingDialog::~ProcessingDialog(void)
void ProcessingDialog::showEvent(QShowEvent *event)
{
static const char *NA = " N/A";
setCloseButtonEnabled(false);
button_closeDialog->setEnabled(false);
button_AbortProcess->setEnabled(false);
@ -254,9 +256,9 @@ void ProcessingDialog::showEvent(QShowEvent *event)
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
ramUsageHasChanged(0.0);
cpuUsageHasChanged(0.0);
diskUsageHasChanged(0ui64);
label_cpu->setText(NA);
label_disk->setText(NA);
label_ram->setText(NA);
QTimer::singleShot(1000, this, SLOT(initEncoding()));
}

View File

@ -74,63 +74,65 @@ ULONGLONG CPUObserverThread::filetime2ulonglong(const void *ftime)
void CPUObserverThread::observe(void)
{
ULONGLONG sys[2], usr[2], idl[2];
FILETIME sysTime, usrTime, idlTime;
QLibrary kernel32("kernel32.dll");
GetSystemTimesPtr getSystemTimes = NULL;
bool first = true;
double previous = -1.0;
if(kernel32.load())
{
getSystemTimes = reinterpret_cast<GetSystemTimesPtr>(kernel32.resolve("GetSystemTimes"));
}
if(getSystemTimes == NULL)
if(getSystemTimes != NULL)
{
qWarning("GetSystemTimes() ist not available on this system!");
return;
}
for(size_t i = 0; i < 2; i++)
{
sys[i] = 0; usr[i] = 0; idl[i] = 0;
}
bool first = true;
double previous = -1.0;
FILETIME sysTime, usrTime, idlTime;
ULONGLONG sys[2], usr[2], idl[2];
while(!m_terminated)
{
if(getSystemTimes(&idlTime, &sysTime, &usrTime))
for(size_t i = 0; i < 2; i++)
{
sys[1] = sys[0]; sys[0] = filetime2ulonglong(&sysTime);
usr[1] = usr[0]; usr[0] = filetime2ulonglong(&usrTime);
idl[1] = idl[0]; idl[0] = filetime2ulonglong(&idlTime);
sys[i] = 0; usr[i] = 0; idl[i] = 0;
}
if(first)
while(!m_terminated)
{
if(getSystemTimes(&idlTime, &sysTime, &usrTime))
{
first = false;
emit currentUsageChanged(1.0);
msleep(250);
continue;
}
sys[1] = sys[0]; sys[0] = filetime2ulonglong(&sysTime);
usr[1] = usr[0]; usr[0] = filetime2ulonglong(&usrTime);
idl[1] = idl[0]; idl[0] = filetime2ulonglong(&idlTime);
ULONGLONG timeIdl = (idl[0] - idl[1]); //Idle time only
ULONGLONG timeSys = (sys[0] - sys[1]); //Kernel mode time (incl. Idle time!)
ULONGLONG timeUsr = (usr[0] - usr[1]); //User mode time only
ULONGLONG timeSum = timeUsr + timeSys; //Overall CPU time that has elapsed
ULONGLONG timeWrk = timeSum - timeIdl; //Time the CPU spent working
if((timeSum > 0) || (timeWrk > 0))
{
double current = static_cast<double>(timeWrk) / static_cast<double>(timeSum);
if(current != previous)
if(first)
{
emit currentUsageChanged(current);
previous = current;
first = false;
emit currentUsageChanged(1.0);
msleep(250);
continue;
}
ULONGLONG timeIdl = (idl[0] - idl[1]); //Idle time only
ULONGLONG timeSys = (sys[0] - sys[1]); //Kernel mode time (incl. Idle time!)
ULONGLONG timeUsr = (usr[0] - usr[1]); //User mode time only
ULONGLONG timeSum = timeUsr + timeSys; //Overall CPU time that has elapsed
ULONGLONG timeWrk = timeSum - timeIdl; //Time the CPU spent working
if(timeSum > 0)
{
double current = static_cast<double>(timeWrk) / static_cast<double>(timeSum);
if(current != previous)
{
emit currentUsageChanged(current);
previous = current;
}
}
}
msleep(1000);
}
msleep(1000);
}
else
{
qWarning("GetSystemTimes() ist not available on this system!");
}
}