File indexing completed on 2024-12-22 04:17:38

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #include <config.h>
0014 
0015 #include "memorywidget.h"
0016 
0017 #include <psversion.h>
0018 #include <sysinfo.h>
0019 
0020 namespace Kst {
0021 
0022 MemoryWidget::MemoryWidget(QWidget *parent, int updateMilliSeconds)
0023 : QLabel(parent) {
0024   connect(&_timer, SIGNAL(timeout()), this, SLOT(updateFreeMemory()));
0025   _timer.start(updateMilliSeconds);
0026   updateFreeMemory();
0027 }
0028 
0029 
0030 MemoryWidget::~MemoryWidget() {
0031 }
0032 
0033 
0034 void MemoryWidget::updateFreeMemory() {
0035 #ifdef __linux__
0036   meminfo();
0037   unsigned long mi = S(kb_main_free + kb_main_cached);
0038   setText(tr("%1 MB available").arg(mi / (1024 * 1024)));
0039 #endif
0040 }
0041 
0042 }
0043 
0044 // vim: ts=2 sw=2 et