Commit 6e393336 authored by Jan Möbius's avatar Jan Möbius

Main memory info for Windows

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17838 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f2f0e2ca
......@@ -104,25 +104,23 @@ void MemInfoPlugin::pluginsInitialized() {
}
// Main Memory information
#ifdef WIN32 //Windows
#ifdef ARCH_DARWIN //Apple
#elif defined ARCH_DARWIN // Apple
#else // Linux and Windows
#else // Linux
//emit log(LOGINFO,"Linux Main Memory monitoring supported, installing main memory monitor into status bar");
//emit log(LOGINFO,"Linux Main Memory monitoring supported, installing main memory monitor into status bar");
mainMemBar_= new QProgressBar();
mainMemBar_->setFixedWidth(260);
mainMemBar_->setFormat( "Mem %p% %v/%m MB" );
mainMemBar_= new QProgressBar();
mainMemBar_->setFixedWidth(260);
mainMemBar_->setFormat( "Mem %p% %v/%m MB" );
emit addWidgetToStatusbar(mainMemBar_);
emit addWidgetToStatusbar(mainMemBar_);
connect(updateTimer_,SIGNAL(timeout()),this,SLOT(cpuMemoryInfoUpdate()));
connect(updateTimer_,SIGNAL(timeout()),this,SLOT(cpuMemoryInfoUpdate()));
updateTimer_->start(4000);
updateTimer_->start(4000);
cpuMemoryInfoUpdate();
cpuMemoryInfoUpdate();
#endif
......@@ -152,28 +150,35 @@ void MemInfoPlugin::cpuMemoryInfoUpdate() {
if (mainMemBar_) {
unsigned long totalRamMB = 0;
unsigned long freeRamMB = 0;
// Main Memory information
#ifdef WIN32 //Windows
// Define memory structure
MEMORYSTATUSEX ms;
// Set the size ( required according to spec ... why???? )
ms.dwLength = sizeof (ms);
// Get the info
GlobalMemoryStatusEx(&ms);
totalRamMB = ms.ullAvailPhys/1024/1024;
freeRamMB = ms.ullAvailPhys/1024/1024;
#elif defined ARCH_DARWIN // Apple
#else // Linux
struct sysinfo sys_info;
sysinfo(&sys_info);
// Unit in bytes ; /1024 -> KB ; /1024 MB
unsigned long totalRamMB = sys_info.totalram / 1024 /1024 * sys_info.mem_unit;
// Unit in bytes ; /1024 -> KB ; /1024 MB
unsigned long freeRamMB = sys_info.freeram / 1024 / 1024 * sys_info.mem_unit;
mainMemBar_->setRange( 0 , totalRamMB );
mainMemBar_->setValue( totalRamMB-freeRamMB);
totalRamMB = sys_info.totalram / 1024 / 1024 * sys_info.mem_unit;
freeRamMB = sys_info.freeram / 1024 / 1024 * sys_info.mem_unit;
#endif
mainMemBar_->setRange( 0 , totalRamMB );
mainMemBar_->setValue( totalRamMB-freeRamMB);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment