⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rampanel.cpp

📁 这是linux下读取pc主板温度传感器的源代码
💻 CPP
字号:
/***************************************************************************                          rampanel.cpp  -  description                             -------------------    begin                : Fri Jan 11 2002    copyright            : (C) 2002 by Miguel Novas    email                : michaell@teleline.es ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include "rampanel.h"#include "procinfo.h"RamPanel::RamPanel(QWidget *parent, const char *name, RamType type): Panel(parent,name){ ramType= type; memTotal= -1; memUsed = -1; arc = new QDialArc(this); arc->installEventFilter(this); arc->setAngles(180,-180); arc->setGeometry( 6 , 64/4+9, 64-10, 64/2-8); arc->setColorRanges(red,red,QColor(0,200,150)); // QColor(0,200,0)); lcd1= new QLCDString(this); lcd1->setGeometry(6, 8,54,11); lcd1->setShadow(true); lcd1->setForeColor(getColorValue()); lcd1->setAlign(QLCDString::alignCenter); lcd1->installEventFilter(this); lcd2= new QLCDString(this); lcd2->setGeometry(4, 52,58,8); lcd2->setForeColor(getColorTitle()); lcd2->setAlign(QLCDString::alignCenter); lcd2->installEventFilter(this); updateInfo();}RamPanel::~RamPanel(){}void RamPanel::updateInfo(){ int newMemTotal,newMemUsed,newSwapTotal,newSwapUsed; getMemInfo(&newMemTotal,&newMemUsed,&newSwapTotal,&newSwapUsed); if(ramType==memSWAP) {    newMemTotal= newSwapTotal;    newMemUsed = newSwapUsed; } newMemUsed /=1024; newMemTotal/=1024; if(memTotal!=newMemTotal) {    arc->setValueRanges(0,newMemTotal);    QString str;    str.sprintf ( ramType==memSWAP ? "SWP %dM" : "RAM %dM", newMemTotal);    lcd2->display(str);    memTotal= newMemTotal; } if(memUsed!=newMemUsed)  {    QString str;    str.sprintf ("%dM" , newMemUsed );    lcd1->display(str);    arc->setValue(newMemUsed);    arc->setValueLimitRanges(newMemUsed,newMemUsed);    memUsed = newMemUsed; }}void RamPanel::paletteChange(const QPalette &oldPalette){ lcd2->setForeColor(getColorTitle()); lcd1->setForeColor(getColorValue()); arc->setArrowColor(getColorValue());}void RamPanel::resizeEvent ( QResizeEvent *e ){ int w= width(); int h= height(); int i1= (h * 2) / 5; int i2= (h * 4) / 5; lcd1->setGeometry( 3 , h/8 , w -4  , h/4-h/16); arc ->setGeometry( 3 , i1  , w -6 , i2-i1-2  ); lcd2->setGeometry( 3 , i2+1, w -6 , h-i2-h/11);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -