forked from openkylin/quarkai
Add resourcescategory, resourcesindicator and networkindicator
This commit is contained in:
parent
fa9410e234
commit
667bb23aa6
|
@ -26,11 +26,17 @@
|
|||
|
||||
CpuOccupancyRate::CpuOccupancyRate(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->setFixedSize(302, 140);
|
||||
// this->setFixedSize(302, 140);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
/*QVBoxLayout **/mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QWidget *w = new QWidget;
|
||||
w->setFixedSize(302, 140);
|
||||
m_titleLeftLayout = new QHBoxLayout(w);
|
||||
m_titleLeftLayout->setContentsMargins(6, 0, 0, 0);
|
||||
m_titleLeftLayout->setSpacing(0);
|
||||
|
||||
m_title = new QLabel(tr("CPU"));
|
||||
m_title->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
m_title->setStyleSheet("font-size: 22px; color:#303030");
|
||||
|
@ -43,8 +49,14 @@ CpuOccupancyRate::CpuOccupancyRate(QWidget *parent) : QWidget(parent)
|
|||
m_cpuBall = new CpuBallWidget;
|
||||
m_cpuBall->setFixedSize(100, 100);
|
||||
|
||||
mainLayout->addWidget(m_title, 0, Qt::AlignLeft);
|
||||
mainLayout->addWidget(m_cpuBall, 0, Qt::AlignCenter);
|
||||
m_titleLeftLayout->addWidget(m_title, 0, Qt::AlignLeft);
|
||||
m_titleLeftLayout->addWidget(m_cpuBall, 0, Qt::AlignCenter);
|
||||
|
||||
mainLayout->addWidget(w, 1, Qt::AlignCenter);
|
||||
|
||||
|
||||
// mainLayout->addWidget(m_title, 0, Qt::AlignLeft);
|
||||
// mainLayout->addWidget(m_cpuBall, 0, Qt::AlignCenter);
|
||||
|
||||
m_cpuBall->startTimer();
|
||||
}
|
||||
|
@ -53,6 +65,13 @@ CpuOccupancyRate::~CpuOccupancyRate()
|
|||
{
|
||||
delete m_title;
|
||||
delete m_cpuBall;
|
||||
QLayoutItem *child;
|
||||
while ((child = m_titleLeftLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
delete mainLayout;
|
||||
}
|
||||
|
||||
void CpuOccupancyRate::onUpdateCpuPercent(double value)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class CpuBallWidget;
|
||||
|
||||
|
@ -42,6 +44,8 @@ public slots:
|
|||
private:
|
||||
QLabel *m_title = nullptr;
|
||||
CpuBallWidget *m_cpuBall = nullptr;
|
||||
QHBoxLayout *m_titleLeftLayout = nullptr;
|
||||
QVBoxLayout *mainLayout = nullptr;
|
||||
};
|
||||
|
||||
#endif // CPUOCCUPANCYRATE_H
|
||||
|
|
|
@ -204,6 +204,9 @@ void MemoryWidget::drawText(QPainter *painter)
|
|||
painter->drawText(swapstatusRect, Qt::AlignVCenter | Qt::AlignHCenter, swapstatusStr);
|
||||
|
||||
painter->restore();
|
||||
|
||||
const QString info = QString("%1/%2(%3%)").arg(formatMemory(mi.user)).arg(formatMemory(mi.total)).arg(QString::number(mi.percent, 'f', 1));
|
||||
emit rebackMemoryInfo(info, mi.percent);
|
||||
}
|
||||
|
||||
void MemoryWidget::onUpdateMemoryStatus()
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
public slots:
|
||||
void onUpdateMemoryStatus();
|
||||
|
||||
signals:
|
||||
void rebackMemoryInfo(const QString &info, double percent);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent * event);
|
||||
|
||||
|
|
|
@ -36,15 +36,20 @@ MonitorTitleWidget::MonitorTitleWidget(QSettings *settings, QWidget *parent)
|
|||
:QFrame(parent)
|
||||
,proSettings(settings)
|
||||
{
|
||||
this->setWindowFlags(Qt::FramelessWindowHint);//this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
installEventFilter(this);
|
||||
setMouseTracking(true);
|
||||
setFixedHeight(MONITOR_TITLE_WIDGET_HEIGHT);
|
||||
|
||||
m_topBorderColor = QColor(255, 255, 255, 153);
|
||||
this->setAutoFillBackground(true);
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor("#0d87ca"));
|
||||
this->setPalette(palette);
|
||||
// this->setStyleSheet("QFrame{background:transparent;background-color:#0d87ca;border-radius:5px;border:1px solid red;}");
|
||||
// this->setStyleSheet("QFrame {padding: 5px 0;} QFrame:hover {background-color: rgba(255, 245, 250, 0.1);border-radius: 5px;}");
|
||||
|
||||
m_searchTimer = new QTimer(this);
|
||||
m_searchTimer->setSingleShot(true);
|
||||
|
@ -176,21 +181,38 @@ void MonitorTitleWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
|||
QFrame::mouseDoubleClickEvent(e);
|
||||
}
|
||||
|
||||
void MonitorTitleWidget::paintEvent(QPaintEvent *e)
|
||||
/*void MonitorTitleWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QFrame::paintEvent(e);
|
||||
// QFrame::paintEvent(event);
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
const QColor tc(m_topBorderColor);
|
||||
int borderHeight = 1;
|
||||
QPainterPath tPath;
|
||||
tPath.moveTo(QPointF(x(), y() + borderHeight - 0.5));
|
||||
tPath.lineTo(QPointF(x() + width(), y() + borderHeight - 0.5));
|
||||
p.setPen(QPen(tc));
|
||||
p.drawPath(tPath);
|
||||
}
|
||||
//draw background
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(0, 0, width(), height()));
|
||||
painter.setOpacity(1);
|
||||
painter.fillPath(path, QColor("#0d87ca"));
|
||||
|
||||
|
||||
//draw line
|
||||
// const QColor color(QColor(255, 255, 255, 127));
|
||||
// int borderHeight = 1;
|
||||
// QPainterPath path;
|
||||
// path.moveTo(QPointF(x(), y() + borderHeight - 0.5));
|
||||
// path.lineTo(QPointF(x() + width(), y() + borderHeight - 0.5));
|
||||
// painter.setPen(QPen(color));
|
||||
// painter.drawPath(path);
|
||||
|
||||
//绘制圆角矩形
|
||||
// painter.setPen(QPen(QColor("#e9eef0"), 0));//边框颜色
|
||||
// painter.setBrush(QColor("#0d87ca"));//背景色
|
||||
// painter.setOpacity(1);
|
||||
// QRectF r(1, 1, width() - 2, height() - 2);//左边 上边 右边 下边
|
||||
// painter.drawRoundedRect(r, 5, 5);
|
||||
|
||||
QFrame::paintEvent(event);
|
||||
}*/
|
||||
|
||||
void MonitorTitleWidget::initTitlebarLeftContent()
|
||||
{
|
||||
|
|
|
@ -56,13 +56,12 @@ signals:
|
|||
void canelSearchEditFocus();
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
// void paintEvent(QPaintEvent *event) override;
|
||||
bool eventFilter(QObject *, QEvent *event) override;
|
||||
|
||||
private:
|
||||
QSettings *proSettings;
|
||||
QColor m_topBorderColor;
|
||||
MySearchEdit *m_searchEdit = nullptr;
|
||||
QPushButton *m_cancelSearchBtn = nullptr;
|
||||
QString searchTextCache;
|
||||
|
|
|
@ -229,6 +229,8 @@ void NetworkFlow::onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes
|
|||
}
|
||||
m_uploadPath = SmoothCurveGenerator::generateSmoothCurve(uploadPoints);
|
||||
|
||||
// emit rebackNetworkPainterPath(m_downloadPath, m_uploadPath);
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ public slots:
|
|||
void onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateKbs, long sentRateKbs);
|
||||
void setRadioButtonRowStatus();
|
||||
|
||||
signals:
|
||||
// void rebackNetworkPainterPath(QPainterPath downloadPath, QPainterPath uploadPath);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
#include "networkindicator.h"
|
||||
#include "smoothcurvegenerator.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
NetworkIndicator::NetworkIndicator(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
,m_state(Normal)
|
||||
,m_isChecked(false)
|
||||
,m_rectTopPadding(9)
|
||||
,m_rectTotalHeight(38)
|
||||
,m_rectTotalWidth(58)
|
||||
,m_outsideBorderColor(Qt::transparent)
|
||||
,m_bgColor(QColor("#ffffff"))
|
||||
{
|
||||
this->setFixedSize(188, 56);
|
||||
m_netMaxHeight = 30;
|
||||
m_pointSpace = 5;
|
||||
|
||||
m_pointsCount = int((this->width() -2) / m_pointSpace);
|
||||
m_downloadSpeedList = new QList<long>();
|
||||
for (int i = 0; i < m_pointsCount; i++) {
|
||||
m_downloadSpeedList->append(0);
|
||||
}
|
||||
|
||||
m_uploadSpeedList = new QList<long>();
|
||||
for (int i = 0; i < m_pointsCount; i++) {
|
||||
m_uploadSpeedList->append(0);
|
||||
}
|
||||
|
||||
m_gridY = new QList<int>();
|
||||
}
|
||||
|
||||
NetworkIndicator::~NetworkIndicator()
|
||||
{
|
||||
delete m_downloadSpeedList;
|
||||
delete m_uploadSpeedList;
|
||||
delete m_gridY;
|
||||
}
|
||||
|
||||
void NetworkIndicator::enterEvent(QEvent *event)
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
|
||||
if (!m_isChecked) {
|
||||
setNetworkState(Hover);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::enterEvent(event);
|
||||
}
|
||||
|
||||
void NetworkIndicator::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (!m_isChecked) {
|
||||
setNetworkState(Normal);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::leaveEvent(event);
|
||||
}
|
||||
|
||||
void NetworkIndicator::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
setNetworkState(Press);
|
||||
|
||||
event->accept();
|
||||
//QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void NetworkIndicator::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!rect().contains(event->pos()))
|
||||
return;
|
||||
|
||||
m_isChecked = !m_isChecked;
|
||||
if (m_isChecked) {
|
||||
setNetworkState(Checked);
|
||||
} else {
|
||||
setNetworkState(Normal);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::mouseReleaseEvent(event);
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
void NetworkIndicator::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!rect().contains(event->pos())) {
|
||||
setNetworkState(Normal);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkIndicator::updateBgColor()
|
||||
{
|
||||
switch (m_state) {
|
||||
case Hover:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#f6fcfe");
|
||||
break;
|
||||
case Press:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#f6fcfe");
|
||||
break;
|
||||
case Checked:
|
||||
this->m_outsideBorderColor = QColor("#0973b4");
|
||||
this->m_bgColor = QColor("#e9f8fd");
|
||||
break;
|
||||
default:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#ffffff");
|
||||
break;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
void NetworkIndicator::setNetworkState(NetworkIndicator::NetworkState state)
|
||||
{
|
||||
if (m_state == state)
|
||||
return;
|
||||
|
||||
m_state = state;
|
||||
updateBgColor();
|
||||
}
|
||||
|
||||
void NetworkIndicator::setChecked(bool flag)
|
||||
{
|
||||
m_isChecked = flag;
|
||||
if (m_isChecked){
|
||||
setNetworkState(Checked);
|
||||
} else {
|
||||
setNetworkState(Normal);
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkIndicator::isChecked()
|
||||
{
|
||||
return m_isChecked;
|
||||
}
|
||||
|
||||
void NetworkIndicator::setTitle(const QString &title)
|
||||
{
|
||||
this->m_title = title;
|
||||
}
|
||||
|
||||
//void NetworkIndicator::updateNetworkPainterPath(QPainterPath downloadPath, QPainterPath uploadPath)
|
||||
//{
|
||||
// this->m_downloadPath = downloadPath;
|
||||
// this->m_uploadPath = uploadPath;
|
||||
// repaint();
|
||||
//}
|
||||
|
||||
NetworkIndicator::NetworkState NetworkIndicator::getNetworkState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void NetworkIndicator::onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateBytes, long sentRateBytes)
|
||||
{
|
||||
m_recvTotalBytes = recvTotalBytes;
|
||||
m_sentTotalBytes = sentTotalBytes;
|
||||
m_recvRateBytes = recvRateBytes;
|
||||
m_sentRateBytes = sentRateBytes;
|
||||
|
||||
//download
|
||||
QList<QPointF> downloadPoints;
|
||||
m_downloadSpeedList->append(m_recvRateBytes);
|
||||
if (m_downloadSpeedList->size() > m_pointsCount) {
|
||||
m_downloadSpeedList->pop_front();
|
||||
}
|
||||
//计算出下载速度中最大的值
|
||||
long downloadMaxHeight = 0;
|
||||
for (int i = 0; i < m_downloadSpeedList->size(); i++) {
|
||||
if (m_downloadSpeedList->at(i) > downloadMaxHeight) {
|
||||
downloadMaxHeight = m_downloadSpeedList->at(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_downloadSpeedList->size(); i++) {
|
||||
if (downloadMaxHeight < m_netMaxHeight) {
|
||||
downloadPoints.append(QPointF(i * m_pointSpace, m_downloadSpeedList->at(i)));
|
||||
}
|
||||
else {
|
||||
downloadPoints.append(QPointF(i * m_pointSpace, m_downloadSpeedList->at(i) * m_netMaxHeight / downloadMaxHeight));
|
||||
}
|
||||
}
|
||||
m_downloadPath = SmoothCurveGenerator::generateSmoothCurve(downloadPoints);
|
||||
|
||||
//upload
|
||||
QList<QPointF> uploadPoints;
|
||||
m_uploadSpeedList->append(m_sentRateBytes);
|
||||
if (m_uploadSpeedList->size() > m_pointsCount) {
|
||||
m_uploadSpeedList->pop_front();
|
||||
}
|
||||
//计算出上传速度中最大的值
|
||||
long uploadMaxHeight = 0;
|
||||
for (int i = 0; i < m_uploadSpeedList->size(); i++) {
|
||||
if (m_uploadSpeedList->at(i) > uploadMaxHeight) {
|
||||
uploadMaxHeight = m_uploadSpeedList->at(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_uploadSpeedList->size(); i++) {
|
||||
if (uploadMaxHeight < m_netMaxHeight) {
|
||||
uploadPoints.append(QPointF(i * m_pointSpace, m_uploadSpeedList->at(i)));
|
||||
}
|
||||
else {
|
||||
uploadPoints.append(QPointF(i * m_pointSpace, m_uploadSpeedList->at(i) * m_netMaxHeight / uploadMaxHeight));
|
||||
}
|
||||
}
|
||||
m_uploadPath = SmoothCurveGenerator::generateSmoothCurve(uploadPoints);
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void NetworkIndicator::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
//border of rect
|
||||
QPainterPath borderPath;
|
||||
borderPath.addRoundedRect(this->rect(), 0, 0);
|
||||
QPen pen(this->m_outsideBorderColor, 1);
|
||||
painter.setPen(pen);
|
||||
painter.drawPath(borderPath);
|
||||
|
||||
//background of rect
|
||||
painter.setOpacity(1);
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(1, 1, width()-2, height()-2));
|
||||
painter.fillPath(path, this->m_bgColor);
|
||||
|
||||
|
||||
painter.translate((rect().width() - m_pointsCount * m_pointSpace) / 2 + 2, 40);//将坐标第原点移动到该点
|
||||
painter.scale(1, -1);//将横坐标扩大1倍,将纵坐标缩小1倍
|
||||
//使用QPainterPath画贝塞尔曲线
|
||||
painter.setPen(QPen(QColor("#1E90FF"), 1));
|
||||
painter.setBrush(QBrush());
|
||||
painter.drawPath(m_downloadPath);//绘制前面创建的path:m_downloadPath
|
||||
painter.translate(0, -8);//将点(0,-8)设为原点
|
||||
painter.setPen(QPen(QColor("#FF0000"), 1));
|
||||
painter.setBrush(QBrush());
|
||||
painter.drawPath(m_uploadPath);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#ifndef NETWORKINDICATOR_H
|
||||
#define NETWORKINDICATOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
|
||||
class NetworkIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum NetworkState {Normal, Hover, Press, Checked};
|
||||
|
||||
public:
|
||||
NetworkIndicator(QWidget * parent=0);
|
||||
~NetworkIndicator();
|
||||
|
||||
void setChecked(bool flag);
|
||||
bool isChecked();
|
||||
void setTitle(const QString &title);
|
||||
// void updateNetworkPainterPath(QPainterPath downloadPath, QPainterPath uploadPath);
|
||||
|
||||
NetworkState getNetworkState() const;
|
||||
|
||||
public slots:
|
||||
void onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateKbs, long sentRateKbs);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateBgColor();
|
||||
void setNetworkState(NetworkState state);
|
||||
|
||||
private:
|
||||
NetworkState m_state;
|
||||
bool m_isChecked;
|
||||
QString m_title;
|
||||
int m_rectTopPadding;
|
||||
int m_rectTotalHeight;
|
||||
int m_rectTotalWidth;
|
||||
QColor m_outsideBorderColor;
|
||||
QColor m_bgColor;
|
||||
|
||||
|
||||
QList<long> *m_downloadSpeedList;
|
||||
QList<long> *m_uploadSpeedList;
|
||||
QPainterPath m_downloadPath;
|
||||
QPainterPath m_uploadPath;
|
||||
|
||||
int m_netMaxHeight;
|
||||
int m_pointsCount;
|
||||
QList<int> *m_gridY;
|
||||
int m_pointSpace;
|
||||
|
||||
long m_recvTotalBytes;
|
||||
long m_sentTotalBytes;
|
||||
long m_recvRateBytes;
|
||||
long m_sentRateBytes;
|
||||
};
|
||||
|
||||
#endif // NETWORKINDICATOR_H
|
|
@ -143,12 +143,6 @@ ProcessDialog::ProcessDialog(QList<bool> toBeDisplayedColumns, int currentSortIn
|
|||
m_layout->addWidget(w);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QList<SortFunction> *sortFuncList = new QList<SortFunction>();
|
||||
sortFuncList->append(&ProcessListItem::sortByName);
|
||||
sortFuncList->append(&ProcessListItem::sortByUser);
|
||||
|
@ -339,7 +333,6 @@ void ProcessDialog::changeProcPriority(int nice)
|
|||
pid_t cur_pid = -1;
|
||||
for (pid_t pid : *actionPids) {
|
||||
cur_pid = pid;
|
||||
qDebug() << "******************"<<cur_pid;
|
||||
break;
|
||||
}
|
||||
if (cur_pid > -1) {
|
||||
|
@ -541,8 +534,6 @@ void ProcessDialog::refreshProcessList()
|
|||
// FIXME: not sure if glibtop always returns a sorted list of pid
|
||||
// but it is important otherwise refresh_list won't find the parent
|
||||
std::sort(pid_list, pid_list + proclist.number);
|
||||
// qDebug() << "proclist.number="<<proclist.number;
|
||||
|
||||
|
||||
//---------------start----------------------
|
||||
typedef std::list<ProcessWorker*> ProcList;
|
||||
|
@ -599,7 +590,6 @@ void ProcessDialog::refreshProcessList()
|
|||
++next;
|
||||
|
||||
if (pids.find(info->pid) == pids.end()) {
|
||||
// qDebug() << "ripping ====" << info->pid;
|
||||
addition.remove(info);
|
||||
ProcessWorker::all.erase(it);
|
||||
delete info;
|
||||
|
@ -609,32 +599,19 @@ void ProcessDialog::refreshProcessList()
|
|||
|
||||
QList<ProcessListItem*> items;
|
||||
for (ProcessWorker::Iterator it(ProcessWorker::begin()); it != ProcessWorker::end(); ++it) {
|
||||
//qDebug() <<"it->second->pid="<< it->second->pid;
|
||||
QString username = QString::fromStdString(it->second->user);
|
||||
//qDebug() << "username=" << username;
|
||||
long nice = it->second->nice;
|
||||
// QString session = "c2";
|
||||
QString name = QString::fromStdString(it->second->name);
|
||||
// qDebug() << "pcpu="<<it->second->pcpu;
|
||||
// qDebug() << "mem="<<it->second->mem;
|
||||
QString session;
|
||||
if (it->second->session) {
|
||||
session = QString(it->second->session);
|
||||
}
|
||||
QString status = formatProcessState(it->second->status);
|
||||
// qDebug() <<"status="<<it->second->status;
|
||||
// qDebug() <<"name================"<<name;
|
||||
|
||||
uint cpu = it->second->pcpu;
|
||||
long memory = it->second->mem;
|
||||
pid_t pid = it->second->pid;
|
||||
|
||||
// if (pid == 16280) {
|
||||
// qDebug() << "--------------------------"<<name << it->second->pid << "===" << it->second->uid;
|
||||
// }
|
||||
// if (pid == 6924) {
|
||||
// qDebug() << "--------------------------"<<name << it->second->mem;
|
||||
// }
|
||||
|
||||
/*---------------------kobe test string---------------------
|
||||
//QString to std:string
|
||||
QString test_QString = "lixiang";
|
||||
|
@ -646,7 +623,6 @@ void ProcessDialog::refreshProcessList()
|
|||
|
||||
std::string desktopFile;
|
||||
desktopFile = getDesktopFileFromName(pid, name, "");
|
||||
|
||||
// qDebug() << "****************"<< QString::fromStdString(desktopFile);
|
||||
|
||||
QPixmap icon_pixmap;
|
||||
|
@ -906,3 +882,26 @@ void ProcessDialog::updateStatus(QList<ProcessListItem*> items)
|
|||
{
|
||||
m_processListWidget->refreshItems(items);
|
||||
}
|
||||
|
||||
/*void ProcessDialog::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
//绘制背景色
|
||||
// QPainterPath path;
|
||||
// path.addRect(QRectF(rect()));
|
||||
// painter.setOpacity(1);
|
||||
// painter.fillPath(path, QColor("#FFFFFF"));
|
||||
|
||||
//绘制圆角矩形
|
||||
// painter.setPen(QPen(QColor("#0d87ca"), 0));//边框颜色 QColor(255, 255, 255, 153)
|
||||
// painter.setBrush(QColor("#e9eef0"));//背景色 #0d87ca
|
||||
painter.setPen(QPen(QColor("#0000FF"), 0));//边框颜色 QColor(255, 255, 255, 153)
|
||||
painter.setBrush(QColor("#B22222"));//背景色 #0d87ca
|
||||
painter.setOpacity(1);
|
||||
// QRectF r(0 / 2.0, 0 / 2.0, width() - 0, height() - 0);//左边 上边 右边 下边
|
||||
QRectF r(2, 2, width() - 0, height() - 0);//左边 上边 右边 下边
|
||||
painter.drawRoundedRect(r, 10, 10);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}*/
|
||||
|
|
|
@ -83,6 +83,9 @@ public slots:
|
|||
void changeProcPriority(int nice);
|
||||
void refreshProcessList();
|
||||
|
||||
protected:
|
||||
// void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QTimer *timer = nullptr;
|
||||
QSettings *proSettings = nullptr;
|
||||
|
|
|
@ -36,13 +36,29 @@ bool ProcessListItem::isSameItem(ProcessListItem *item)
|
|||
return m_data.pid == ((static_cast<ProcessListItem*>(item)))->m_data.pid;
|
||||
}
|
||||
|
||||
void ProcessListItem::drawCellBackground(QRect rect, QPainter *painter, int level)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(rect.x(), rect.y(), rect.width(), rect.height()));
|
||||
painter->setOpacity(0.5);//0.1
|
||||
if (level == 0) {
|
||||
painter->fillPath(path, QColor("#fff4c4"));
|
||||
}
|
||||
else if (level == 1) {
|
||||
painter->fillPath(path, QColor("#f9eca8"));
|
||||
}
|
||||
else {
|
||||
painter->fillPath(path, QColor("#fca71d"));
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessListItem::drawBackground(QRect rect, QPainter *painter, int index, bool isSelect)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(rect));
|
||||
|
||||
if (isSelect) {
|
||||
painter->setOpacity(0.5);//0.1
|
||||
painter->setOpacity(0.1);
|
||||
painter->fillPath(path, QColor("#2bb6ea"));
|
||||
}
|
||||
else {
|
||||
|
@ -64,15 +80,15 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
|
|||
painter->drawPixmap(QRect(rect.x() + padding, rect.y() + (rect.height() - iconSize) / 2, iconSize, iconSize), m_data.iconPixmap);
|
||||
QString name = m_data.processName;
|
||||
if (m_data.m_status == tr("Stopped")) {//已停止
|
||||
painter->setPen(QPen(QColor("#fff4c4")));
|
||||
painter->setPen(QPen(QColor("#fca71d")));
|
||||
name = QString("(%1) %2").arg(tr("Suspend")).arg(m_data.processName);
|
||||
}
|
||||
else if (m_data.m_status == tr("Zombie")) {//僵死
|
||||
painter->setPen(QPen(QColor("#fca71d")));
|
||||
painter->setPen(QPen(QColor("#808080")));
|
||||
name = QString("(%1) %2").arg(tr("No response")).arg(m_data.processName);
|
||||
}
|
||||
else if (m_data.m_status == tr("Uninterruptible")) {//不可中断
|
||||
painter->setPen(QPen(QColor("#f9eca8")));
|
||||
painter->setPen(QPen(QColor("#ff6a6a")));
|
||||
name = QString("(%1) %2").arg(tr("Uninterruptible")).arg(m_data.processName);
|
||||
}
|
||||
else {//Sleeping 睡眠中 Running 运行中
|
||||
|
@ -91,7 +107,7 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
|
|||
}
|
||||
else if (column == 1) {
|
||||
if (!m_data.user.isEmpty()) {
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, m_data.user);
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignRight | Qt::AlignVCenter, m_data.user);
|
||||
}
|
||||
if (isSeparator) {
|
||||
painter->setOpacity(0.8);
|
||||
|
@ -102,7 +118,7 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
|
|||
}
|
||||
else if (column == 2) {
|
||||
if (!m_data.m_status.isEmpty()) {
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, m_data.m_status);
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignRight | Qt::AlignVCenter, m_data.m_status);
|
||||
}
|
||||
if (isSeparator) {
|
||||
painter->setOpacity(0.8);
|
||||
|
@ -113,24 +129,18 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
|
|||
}
|
||||
else if (column == 3) {
|
||||
if (m_data.cpu < 10) {
|
||||
painter->setPen(QPen(QColor("#fff4c4")));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 0);
|
||||
}
|
||||
else if (m_data.cpu < 33) {
|
||||
painter->setPen(QPen(QColor("#f9eca8")));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 1);
|
||||
}
|
||||
else {
|
||||
painter->setPen(QPen(QColor("#fca71d")));
|
||||
}
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, QString("%1%").arg(m_data.cpu));
|
||||
if (isSeparator) {
|
||||
painter->setOpacity(0.8);
|
||||
QPainterPath separatorPath;
|
||||
separatorPath.addRect(QRectF(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()));
|
||||
painter->fillPath(separatorPath, QColor("#e0e0e0"));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 2);
|
||||
}
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignRight | Qt::AlignVCenter, QString("%1%").arg(m_data.cpu));
|
||||
}
|
||||
else if (column == 4) {
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - padding, rect.height()), Qt::AlignCenter, QString("%1").arg(m_data.pid));
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - padding, rect.height()), Qt::AlignRight | Qt::AlignVCenter, QString("%1").arg(m_data.pid));
|
||||
if (isSeparator) {
|
||||
painter->setOpacity(0.8);
|
||||
QPainterPath separatorPath;
|
||||
|
@ -156,15 +166,15 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
|
|||
painter->setOpacity(1);
|
||||
QString memory = QString(g_format_size_full(m_data.m_memory, G_FORMAT_SIZE_IEC_UNITS));
|
||||
if (m_data.m_memory < 102400000) {//<100M
|
||||
painter->setPen(QPen(QColor("#fff4c4")));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 0);
|
||||
}
|
||||
else if (m_data.m_memory < 1024000000) {//1G
|
||||
painter->setPen(QPen(QColor("#f9eca8")));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 1);
|
||||
}
|
||||
else {
|
||||
painter->setPen(QPen(QColor("#fca71d")));
|
||||
this->drawCellBackground(QRect(rect.x(), rect.y(), rect.width(), rect.height()), painter, 2);
|
||||
}
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, memory);
|
||||
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignRight | Qt::AlignVCenter, memory);
|
||||
}
|
||||
if (isSeparator) {
|
||||
painter->setOpacity(0.8);
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
ProcessListItem(ProcData info);
|
||||
|
||||
bool isSameItem(ProcessListItem *item);
|
||||
void drawCellBackground(QRect rect, QPainter *painter, int level);
|
||||
void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect);
|
||||
void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isSeparator);
|
||||
static bool doSearch(const ProcessListItem *item, QString text);
|
||||
|
|
|
@ -704,7 +704,7 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|||
|
||||
int penWidth = 1;
|
||||
QPainterPath framePath;
|
||||
framePath.addRoundedRect(QRect(rect().x() + penWidth, rect().y() + penWidth, rect().width() - penWidth * 2, rect().height() - penWidth * 2), 4, 4);//背景弧度
|
||||
framePath.addRoundedRect(QRect(rect().x() + penWidth, rect().y() + penWidth, rect().width() - penWidth * 2, rect().height() - penWidth * 2), 5, 5);//背景弧度
|
||||
painter.setClipPath(framePath);
|
||||
|
||||
//标题的背景
|
||||
|
@ -725,8 +725,6 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|||
//标题文字左上方的排序箭头图标
|
||||
if (this->m_currentSortIndex == counter) {
|
||||
painter.setOpacity(1);
|
||||
// int arrowX = rect().x() + posX - 2 - m_upArrowPixmap.width() / m_upArrowPixmap.devicePixelRatio();
|
||||
// int arrowY = rect().y() + (this->m_titleHeight / m_upArrowPixmap.devicePixelRatio()) - m_downArrowPixmap.height() - 5;
|
||||
if (this->m_isSort) {
|
||||
painter.drawPixmap(QPoint(rect().x() + posX + 5, rect().y() + 10), m_downArrowPixmap);
|
||||
} else {
|
||||
|
@ -741,15 +739,25 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|||
font.setPixelSize(12);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(QColor("#999999")));
|
||||
painter.drawText(QRect(posX + this->m_titlePadding, 0, itemWidth, this->m_titleHeight), Qt::AlignBottom | Qt::AlignLeft, this->columnTitles[counter]);
|
||||
posX += itemWidth;
|
||||
|
||||
if (counter < titleItemsWidths.size() - 1) {//垂直分割线
|
||||
if (this->columnTitles[counter] == tr("Process Name") || this->columnTitles[counter] == tr("Command Line") || this->columnTitles[counter] == tr("Priority"))
|
||||
painter.drawText(QRect(posX + this->m_titlePadding, 0, itemWidth, this->m_titleHeight), Qt::AlignBottom | Qt::AlignLeft, this->columnTitles[counter]);
|
||||
else
|
||||
painter.drawText(QRect(posX, 0, itemWidth - this->m_titlePadding, this->m_titleHeight), Qt::AlignBottom | Qt::AlignRight, this->columnTitles[counter]);
|
||||
|
||||
//水平下划线
|
||||
painter.setOpacity(0.8);
|
||||
QPainterPath separatorPath;
|
||||
separatorPath.addRect(QRectF(rect().x() + posX - 1, rect().y() + 5, 1, this->m_titleHeight - 5));
|
||||
painter.fillPath(separatorPath, QColor("#e0e0e0"));
|
||||
QPainterPath h_separatorPath;
|
||||
h_separatorPath.addRect(QRectF(posX, rect().y() + this->m_titleHeight - 1, itemWidth, 1));
|
||||
painter.fillPath(h_separatorPath, QColor("#e0e0e0"));
|
||||
|
||||
if (counter < titleItemsWidths.size()) {//垂直分割线
|
||||
QPainterPath v_separatorPath;
|
||||
v_separatorPath.addRect(QRectF(rect().x() + posX - 1, rect().y() + 5, 1, this->m_titleHeight - 5));
|
||||
painter.fillPath(v_separatorPath, QColor("#e0e0e0"));
|
||||
}
|
||||
|
||||
posX += itemWidth;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
@ -849,10 +857,7 @@ void ProcessListWidget::paintScrollbar(QPainter *painter)
|
|||
painter->setOpacity(opacitry);
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(
|
||||
QRectF(rect().x() + rect().width() - barWidth - 4,
|
||||
barY + 2,
|
||||
barWidth,
|
||||
barHeight - 2 * 2), 2, 2);
|
||||
QRectF(rect().x() + rect().width() - barWidth - 4, barY + 2, barWidth, barHeight - 2 * 2), 2, 2);//2 is radius
|
||||
painter->fillPath(path, QColor("#0B95D7"));
|
||||
|
||||
QPen pen;
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* 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; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "resourcescategory.h"
|
||||
#include "resourcesindicator.h"
|
||||
#include "networkindicator.h"
|
||||
|
||||
ResourcesCategory::ResourcesCategory(int tabIndex, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
,activeIndex(tabIndex)
|
||||
{
|
||||
this->setFixedWidth(196);
|
||||
|
||||
layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
cpuButton = new ResourcesIndicator(0, this);
|
||||
cpuButton->setTitle(tr("CPU"));
|
||||
memoryButton = new ResourcesIndicator(1, this);
|
||||
memoryButton->setTitle(tr("Memory"));
|
||||
networkButton = new NetworkIndicator(this);
|
||||
networkButton->setTitle(tr("Network"));
|
||||
|
||||
if (activeIndex == 0) {
|
||||
cpuButton->setChecked(true);
|
||||
memoryButton->setChecked(false);
|
||||
networkButton->setChecked(false);
|
||||
}
|
||||
else if (activeIndex == 1) {
|
||||
cpuButton->setChecked(false);
|
||||
memoryButton->setChecked(true);
|
||||
networkButton->setChecked(false);
|
||||
}
|
||||
else {
|
||||
cpuButton->setChecked(false);
|
||||
memoryButton->setChecked(false);
|
||||
networkButton->setChecked(true);
|
||||
}
|
||||
|
||||
connect(cpuButton, &ResourcesIndicator::clicked, this, [=] {
|
||||
activeIndex = 0;
|
||||
emit this->switchResoucesPage(activeIndex);
|
||||
cpuButton->setChecked(true);
|
||||
memoryButton->setChecked(false);
|
||||
networkButton->setChecked(false);
|
||||
});
|
||||
connect(memoryButton, &ResourcesIndicator::clicked, this, [=] {
|
||||
activeIndex = 1;
|
||||
emit this->switchResoucesPage(activeIndex);
|
||||
cpuButton->setChecked(false);
|
||||
memoryButton->setChecked(true);
|
||||
networkButton->setChecked(false);
|
||||
});
|
||||
connect(networkButton, &NetworkIndicator::clicked, this, [=] {
|
||||
activeIndex = 2;
|
||||
emit this->switchResoucesPage(activeIndex);
|
||||
cpuButton->setChecked(false);
|
||||
memoryButton->setChecked(false);
|
||||
networkButton->setChecked(true);
|
||||
});
|
||||
|
||||
layout->addWidget(cpuButton, 0, Qt::AlignHCenter);
|
||||
layout->addWidget(memoryButton, 0, Qt::AlignHCenter);
|
||||
layout->addWidget(networkButton, 0, Qt::AlignHCenter);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
ResourcesCategory::~ResourcesCategory()
|
||||
{
|
||||
delete cpuButton;
|
||||
delete memoryButton;
|
||||
delete networkButton;
|
||||
delete layout;
|
||||
}
|
||||
|
||||
void ResourcesCategory::onUpdateCpuPercent(double value)
|
||||
{
|
||||
cpuButton->updatePercentAndInfo(value, QString::number(value, 'f', 1) + "%");
|
||||
}
|
||||
|
||||
void ResourcesCategory::onUpdateMemoryPercent(const QString &info, double value)
|
||||
{
|
||||
memoryButton->updatePercentAndInfo(value, info);
|
||||
}
|
||||
|
||||
//void ResourcesCategory::onUpdateNetworkPainterPath(QPainterPath downloadPath, QPainterPath uploadPath)
|
||||
//{
|
||||
//// networkButton->updateNetworkPainterPath(downloadPath, uploadPath);
|
||||
//}
|
||||
|
||||
void ResourcesCategory::onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateKbs, long sentRateKbs)
|
||||
{
|
||||
networkButton->onUpdateNetworkStatus(recvTotalBytes, sentTotalBytes, recvRateKbs, sentRateKbs);
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* 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; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RESOURCESCATEGORY_H
|
||||
#define RESOURCESCATEGORY_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class NetworkIndicator;
|
||||
class ResourcesIndicator;
|
||||
|
||||
class ResourcesCategory : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ResourcesCategory(int tabIndex, QWidget *parent = 0);
|
||||
~ResourcesCategory();
|
||||
|
||||
public slots:
|
||||
void onUpdateCpuPercent(double value);
|
||||
void onUpdateMemoryPercent(const QString &info, double value);
|
||||
// void onUpdateNetworkPainterPath(QPainterPath downloadPath, QPainterPath uploadPath);
|
||||
void onUpdateNetworkStatus(long recvTotalBytes, long sentTotalBytes, long recvRateKbs, long sentRateKbs);
|
||||
|
||||
signals:
|
||||
void switchResoucesPage(int index);
|
||||
|
||||
private:
|
||||
int activeIndex;
|
||||
QVBoxLayout *layout = nullptr;
|
||||
ResourcesIndicator *cpuButton = nullptr;
|
||||
ResourcesIndicator *memoryButton = nullptr;
|
||||
NetworkIndicator *networkButton = nullptr;
|
||||
};
|
||||
|
||||
#endif // RESOURCESCATEGORY_H
|
|
@ -21,6 +21,7 @@
|
|||
#include "cpuoccupancyrate.h"
|
||||
#include "memorywidget.h"
|
||||
#include "networkflow.h"
|
||||
#include "resourcescategory.h"
|
||||
|
||||
#include <glibtop/netload.h>
|
||||
#include <glibtop/netlist.h>
|
||||
|
@ -129,7 +130,6 @@ ResouresDialog::ResouresDialog(QWidget *parent)
|
|||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
setAcceptDrops(true);
|
||||
setAttribute(Qt::WA_NoMousePropagation);
|
||||
|
||||
this->setObjectName("ResouresDialog");
|
||||
|
||||
//cpu
|
||||
|
@ -138,20 +138,55 @@ ResouresDialog::ResouresDialog(QWidget *parent)
|
|||
m_prevCpuTotalTime = 0;
|
||||
m_prevCpuWorkTime = 0;
|
||||
|
||||
m_vlayout = new QVBoxLayout(this);
|
||||
m_vlayout->setSpacing(2);
|
||||
m_hlayout = new QHBoxLayout(this);
|
||||
m_hlayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
// splitter = new QSplitter(this);
|
||||
// splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// splitter->setOrientation(Qt::Horizontal);
|
||||
// splitter->setHandleWidth(1);
|
||||
|
||||
m_stack = new QStackedWidget(this);
|
||||
m_stack->setStyleSheet("QStackedWidget{background: rgb(255, 255, 255);}");
|
||||
// m_stack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
m_resourcesCategory = new ResourcesCategory(0);
|
||||
connect(m_resourcesCategory, SIGNAL(switchResoucesPage(int)), this, SLOT(onSwitchResoucesPage(int)));
|
||||
|
||||
// m_vlayout = new QVBoxLayout;
|
||||
m_cpuWidget = new CpuOccupancyRate();
|
||||
m_memoryWidget = new MemoryWidget();
|
||||
m_networkWidget = new NetworkFlow();
|
||||
m_vlayout->addWidget(m_cpuWidget, 0, Qt::AlignHCenter);
|
||||
m_vlayout->addWidget(m_memoryWidget, 0, Qt::AlignHCenter);
|
||||
m_vlayout->addWidget(m_networkWidget, 0, Qt::AlignHCenter);
|
||||
// m_vlayout->addWidget(m_cpuWidget, 0, Qt::AlignHCenter);
|
||||
// m_vlayout->addWidget(m_memoryWidget, 0, Qt::AlignHCenter);
|
||||
// m_vlayout->addWidget(m_networkWidget, 0, Qt::AlignHCenter);
|
||||
m_stack->addWidget(m_cpuWidget);
|
||||
m_stack->addWidget(m_memoryWidget);
|
||||
m_stack->addWidget(m_networkWidget);
|
||||
m_stack->setCurrentWidget(m_cpuWidget);
|
||||
|
||||
m_hlayout->addWidget(m_resourcesCategory);
|
||||
// m_hlayout->addLayout(m_vlayout);
|
||||
m_hlayout->addWidget(m_stack);
|
||||
// splitter->addWidget(m_resourcesCategory);
|
||||
// splitter->addWidget(m_stack);
|
||||
|
||||
// m_hlayout->addWidget(splitter);
|
||||
|
||||
connect(this, SIGNAL(updateNetworkStatus(long,long,long,long)), m_networkWidget, SLOT(onUpdateNetworkStatus(long,long,long,long)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(updateMemoryStatus()), m_memoryWidget, SLOT(onUpdateMemoryStatus()));
|
||||
connect(this, SIGNAL(updateCpuStatus(double)), m_cpuWidget, SLOT(onUpdateCpuPercent(double)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_memoryWidget, &MemoryWidget::rebackMemoryInfo, this, [=] (const QString &info, double percent) {
|
||||
m_resourcesCategory->onUpdateMemoryPercent(info, percent);
|
||||
});
|
||||
|
||||
connect(this, SIGNAL(updateCpuStatus(double)), m_resourcesCategory, SLOT(onUpdateCpuPercent(double)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(updateNetworkStatus(long,long,long,long)), m_resourcesCategory, SLOT(onUpdateNetworkStatus(long,long,long,long)), Qt::QueuedConnection);
|
||||
// connect(m_networkWidget, &NetworkFlow::rebackNetworkPainterPath, this, [=] (QPainterPath downloadPath, QPainterPath uploadPath) {
|
||||
// m_resourcesCategory->onUpdateNetworkPainterPath(downloadPath, uploadPath);
|
||||
// });
|
||||
|
||||
updateStatusTimer = new QTimer(this);
|
||||
connect(updateStatusTimer, SIGNAL(timeout()), this, SLOT(updateResourceStatus()));
|
||||
updateStatusTimer->start(2000);
|
||||
|
@ -159,18 +194,36 @@ ResouresDialog::ResouresDialog(QWidget *parent)
|
|||
|
||||
ResouresDialog::~ResouresDialog()
|
||||
{
|
||||
if (m_vlayout) {
|
||||
foreach (QObject *child, m_vlayout->children()) {
|
||||
delete m_resourcesCategory;
|
||||
if (m_stack) {
|
||||
foreach (QObject *child, m_stack->children()) {
|
||||
QWidget *widget = static_cast<QWidget *>(child);
|
||||
widget->deleteLater();
|
||||
}
|
||||
delete m_stack;
|
||||
}
|
||||
/*QLayoutItem *child;
|
||||
/*
|
||||
// if (m_vlayout) {
|
||||
// foreach (QObject *child, m_vlayout->children()) {
|
||||
// QWidget *widget = static_cast<QWidget *>(child);
|
||||
// widget->deleteLater();
|
||||
// }
|
||||
// }
|
||||
|
||||
QLayoutItem *child;
|
||||
while ((child = m_vlayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}*/
|
||||
|
||||
delete m_hlayout;
|
||||
}
|
||||
|
||||
void ResouresDialog::onSwitchResoucesPage(int index)
|
||||
{
|
||||
if (index < 3 && index >= 0)
|
||||
m_stack->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void ResouresDialog::startCpuTimer()
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QStackedWidget>
|
||||
#include <QSplitter>
|
||||
|
||||
class ResourcesCategory;
|
||||
class CpuOccupancyRate;
|
||||
class MemoryWidget;
|
||||
class NetworkFlow;
|
||||
|
@ -38,6 +41,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void updateResourceStatus();
|
||||
void onSwitchResoucesPage(int index);
|
||||
|
||||
signals:
|
||||
void updateCpuStatus(double percent);
|
||||
|
@ -58,8 +62,13 @@ private:
|
|||
unsigned long long int m_rateSentBytes;
|
||||
|
||||
QTimer *updateStatusTimer = nullptr;
|
||||
QVBoxLayout *m_vlayout = nullptr;
|
||||
QHBoxLayout *m_hlayout = nullptr;
|
||||
// QVBoxLayout *m_vlayout = nullptr;
|
||||
ResourcesCategory * m_resourcesCategory = nullptr;
|
||||
CpuOccupancyRate *m_cpuWidget = nullptr;
|
||||
MemoryWidget *m_memoryWidget = nullptr;
|
||||
NetworkFlow *m_networkWidget = nullptr;
|
||||
|
||||
// QSplitter *splitter = nullptr;
|
||||
QStackedWidget *m_stack = nullptr;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,280 @@
|
|||
#include "resourcesindicator.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
ResourcesIndicator::ResourcesIndicator(int flag, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
,m_state(Normal)
|
||||
,m_isChecked(false)
|
||||
,m_currentPercent(0)
|
||||
,m_posX(5)
|
||||
,m_rectTopPadding(9)
|
||||
,m_rectTotalHeight(38)
|
||||
,m_rectTotalWidth(58)
|
||||
,m_outsideBorderColor(Qt::transparent)
|
||||
,m_bgColor(QColor("#ffffff"))
|
||||
{
|
||||
this->setFixedSize(188, 56);
|
||||
|
||||
if (flag == 0) {
|
||||
m_borderColor = QColor("#0973b4");
|
||||
}
|
||||
else if (flag == 1) {
|
||||
m_borderColor = QColor("#9528b4");
|
||||
}
|
||||
else {
|
||||
m_borderColor = Qt::transparent;
|
||||
}
|
||||
|
||||
/*m_layout = new QHBoxLayout(this);
|
||||
m_layout->setContentsMargins(5,5,5,5);
|
||||
|
||||
QWidget *w = new QWidget;
|
||||
m_rLayout = new QVBoxLayout(w);
|
||||
m_rLayout->setContentsMargins(0, 0, 5, 0);
|
||||
m_rLayout->setSpacing(5);
|
||||
|
||||
m_titleLabel = new QLabel;
|
||||
m_titleLabel->setText("CPU");
|
||||
m_titleLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:16px;text-align:left;}");
|
||||
|
||||
m_textLabel = new QLabel;
|
||||
m_textLabel->setText("40% 1.8GHz");
|
||||
m_textLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:12px;text-align:left;}");
|
||||
|
||||
m_rLayout->addWidget(m_titleLabel);
|
||||
m_rLayout->addWidget(m_textLabel);
|
||||
|
||||
m_layout->addWidget(w, 1, Qt::AlignRight);*/
|
||||
}
|
||||
|
||||
ResourcesIndicator::~ResourcesIndicator()
|
||||
{
|
||||
// delete m_titleLabel;
|
||||
// delete m_textLabel;
|
||||
// QLayoutItem *child;
|
||||
// while ((child = m_rLayout->takeAt(0)) != 0) {
|
||||
// if (child->widget())
|
||||
// child->widget()->deleteLater();
|
||||
// delete child;
|
||||
// }
|
||||
// delete m_layout;
|
||||
}
|
||||
|
||||
void ResourcesIndicator::enterEvent(QEvent *event)
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
|
||||
if (!m_isChecked) {
|
||||
setResourcesState(Hover);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::enterEvent(event);
|
||||
}
|
||||
|
||||
void ResourcesIndicator::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (!m_isChecked) {
|
||||
setResourcesState(Normal);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::leaveEvent(event);
|
||||
}
|
||||
|
||||
void ResourcesIndicator::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
setResourcesState(Press);
|
||||
|
||||
event->accept();
|
||||
//QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ResourcesIndicator::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!rect().contains(event->pos()))
|
||||
return;
|
||||
|
||||
m_isChecked = !m_isChecked;
|
||||
if (m_isChecked) {
|
||||
setResourcesState(Checked);
|
||||
} else {
|
||||
setResourcesState(Normal);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
//QWidget::mouseReleaseEvent(event);
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
void ResourcesIndicator::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!rect().contains(event->pos())) {
|
||||
setResourcesState(Normal);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourcesIndicator::updateBgColor()
|
||||
{
|
||||
switch (m_state) {
|
||||
case Hover:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#f6fcfe");
|
||||
break;
|
||||
case Press:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#f6fcfe");
|
||||
break;
|
||||
case Checked:
|
||||
this->m_outsideBorderColor = QColor("#0973b4");
|
||||
this->m_bgColor = QColor("#e9f8fd");
|
||||
break;
|
||||
default:
|
||||
this->m_outsideBorderColor = Qt::transparent;
|
||||
this->m_bgColor = QColor("#ffffff");
|
||||
break;
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
void ResourcesIndicator::setResourcesState(ResourcesIndicator::ResourcesState state)
|
||||
{
|
||||
if (m_state == state)
|
||||
return;
|
||||
|
||||
m_state = state;
|
||||
updateBgColor();
|
||||
}
|
||||
|
||||
void ResourcesIndicator::setChecked(bool flag)
|
||||
{
|
||||
m_isChecked = flag;
|
||||
if (m_isChecked){
|
||||
setResourcesState(Checked);
|
||||
} else {
|
||||
setResourcesState(Normal);
|
||||
}
|
||||
}
|
||||
|
||||
bool ResourcesIndicator::isChecked()
|
||||
{
|
||||
return m_isChecked;
|
||||
}
|
||||
|
||||
void ResourcesIndicator::setTitle(const QString &title)
|
||||
{
|
||||
this->m_title = title;
|
||||
}
|
||||
|
||||
void ResourcesIndicator::updatePercentAndInfo(double percent, const QString &info)
|
||||
{
|
||||
this->m_currentPercent = static_cast<int>(percent);
|
||||
this->m_info = info;
|
||||
repaint();
|
||||
}
|
||||
|
||||
ResourcesIndicator::ResourcesState ResourcesIndicator::getResourcesState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void ResourcesIndicator::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
//渐变填充
|
||||
/*QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||
gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
|
||||
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
|
||||
QBrush brush(gradient);*/
|
||||
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
//border of rect
|
||||
QPainterPath borderPath;
|
||||
borderPath.addRoundedRect(this->rect(), 0, 0);
|
||||
QPen pen(this->m_outsideBorderColor, 1);
|
||||
// QPen pen(QColor("#B22222"), 1);
|
||||
painter.setPen(pen);
|
||||
painter.drawPath(borderPath);
|
||||
|
||||
//background of rect
|
||||
painter.setOpacity(1);
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(1, 1, width()-2, height()-2));
|
||||
painter.fillPath(path, this->m_bgColor);
|
||||
// painter.fillPath(path, QColor("#f6fcfe"));
|
||||
|
||||
int convertPercent = static_cast<int>(m_rectTotalHeight*this->m_currentPercent/100);
|
||||
|
||||
//percent rect
|
||||
painter.setPen(QPen(this->m_borderColor, 0.5));//设置画笔颜色、宽度
|
||||
painter.setBrush(QColor("#ffffff"));//设置画刷颜色
|
||||
painter.drawRect(this->m_posX, this->m_rectTopPadding, this->m_rectTotalWidth, this->m_rectTotalHeight - convertPercent);
|
||||
painter.setBrush(QColor("#f4f2f4"));
|
||||
painter.drawRect(this->m_posX, this->m_rectTopPadding + this->m_rectTotalHeight - convertPercent, this->m_rectTotalWidth, convertPercent);
|
||||
|
||||
//draw title
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
QFont font = painter.font() ;
|
||||
font.setPixelSize(16);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(QColor("#000000")));
|
||||
painter.drawText(QRect(68, 1, 118, 28), Qt::AlignLeft | Qt::AlignVCenter, this->m_title);
|
||||
|
||||
//draw content
|
||||
font.setPixelSize(12);
|
||||
painter.setFont(font);
|
||||
QFontMetrics fm(font);
|
||||
QString text = fm.elidedText(this->m_info, Qt::ElideRight, 120);
|
||||
painter.drawText(QRect(68, 30, 120, 20), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*QFrame::paintEvent(e);
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
//border
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(this->rect(), m_borderRadius, m_borderRadius);
|
||||
QPen pen(m_outsideBorderColor, m_borderWidth);
|
||||
p.setPen(pen);
|
||||
p.drawPath(path);
|
||||
|
||||
QRect insideRect;
|
||||
insideRect.setRect(this->rect().x() + m_borderWidth,
|
||||
this->rect().y() + m_borderWidth,
|
||||
this->rect().width() - m_borderWidth * 2,
|
||||
this->rect().height() - m_borderWidth * 2);
|
||||
QPainterPath lastpath;
|
||||
lastpath.addRoundedRect(insideRect, m_borderRadius, m_borderRadius);
|
||||
p.setClipPath(lastpath);
|
||||
|
||||
p.fillRect(0, 0, width(), height(), m_coverBrush);
|
||||
|
||||
p.end();*/
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef RESOURCESINDICATOR_H
|
||||
#define RESOURCESINDICATOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
//#include <QLabel>
|
||||
#include <QPixmap>
|
||||
|
||||
//class QVBoxLayout;
|
||||
//class QHBoxLayout;
|
||||
|
||||
class ResourcesIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum ResourcesState {Normal, Hover, Press, Checked};
|
||||
|
||||
public:
|
||||
ResourcesIndicator(int flag, QWidget * parent=0);
|
||||
~ResourcesIndicator();
|
||||
|
||||
void setChecked(bool flag);
|
||||
bool isChecked();
|
||||
void setTitle(const QString &title);
|
||||
void updatePercentAndInfo(double percent, const QString &info);
|
||||
ResourcesState getResourcesState() const;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateBgColor();
|
||||
void setResourcesState(ResourcesState state);
|
||||
|
||||
private:
|
||||
ResourcesState m_state;
|
||||
bool m_isChecked;
|
||||
int m_currentPercent;
|
||||
QString m_title;
|
||||
QString m_info;
|
||||
int m_posX;
|
||||
int m_rectTopPadding;
|
||||
int m_rectTotalHeight;
|
||||
int m_rectTotalWidth;
|
||||
QColor m_outsideBorderColor;
|
||||
QColor m_bgColor;
|
||||
QColor m_borderColor;
|
||||
// QLabel *m_titleLabel = nullptr;
|
||||
// QLabel *m_textLabel = nullptr;
|
||||
// QVBoxLayout *m_rLayout = nullptr;
|
||||
// QHBoxLayout *m_layout = nullptr;
|
||||
};
|
||||
|
||||
#endif // RESOURCESINDICATOR_H
|
|
@ -34,19 +34,12 @@ SystemMonitor::SystemMonitor(QWidget *parent)
|
|||
: QFrame(parent)
|
||||
, mousePressed(false)
|
||||
{
|
||||
/*this->setAutoFillBackground(true);
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor("#0d87ca"));
|
||||
this->setPalette(palette);*/
|
||||
|
||||
// this->setStyleSheet("QFrame{border: 1px solid #121212;border-radius:1px;background-color:#1f1f1f;}");
|
||||
// this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);//去掉边框
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
|
||||
|
||||
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);//去掉边框
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
|
||||
// this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setMouseTracking(true);
|
||||
// installEventFilter(this);
|
||||
|
@ -292,14 +285,24 @@ void SystemMonitor::closeEvent(QCloseEvent *event)
|
|||
event->accept();
|
||||
}
|
||||
|
||||
void SystemMonitor::paintEvent(QPaintEvent *)
|
||||
void SystemMonitor::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
//绘制背景色
|
||||
// QPainterPath path;
|
||||
// path.addRect(QRectF(rect()));
|
||||
// painter.setOpacity(1);
|
||||
// painter.fillPath(path, QColor("#FFFFFF"));
|
||||
|
||||
QPainterPath path;
|
||||
path.addRect(QRectF(rect()));
|
||||
//绘制圆角矩形
|
||||
painter.setPen(QPen(QColor("#e9eef0"), 0));//边框颜色 QColor(255, 255, 255, 153)
|
||||
painter.setBrush(QColor("#ffffff"));//背景色 #0d87ca
|
||||
painter.setOpacity(1);
|
||||
painter.fillPath(path, QColor("#FFFFFF"));
|
||||
QRectF r(1, 1, width() - 2, height() - 2);//左边 上边 右边 下边
|
||||
painter.drawRoundedRect(r, 5, 5);
|
||||
|
||||
QFrame::paintEvent(event);
|
||||
}
|
||||
|
||||
void SystemMonitor::mousePressEvent(QMouseEvent *event)
|
||||
|
|
|
@ -58,7 +58,10 @@ HEADERS += \
|
|||
cpuoccupancyrate.h \
|
||||
cpuballwidget.h \
|
||||
smoothcurvegenerator.h \
|
||||
memorywidget.h
|
||||
memorywidget.h \
|
||||
networkindicator.h \
|
||||
resourcesindicator.h \
|
||||
resourcescategory.h
|
||||
|
||||
SOURCES += \
|
||||
systemmonitor.cpp \
|
||||
|
@ -90,7 +93,10 @@ SOURCES += \
|
|||
cpuoccupancyrate.cpp \
|
||||
cpuballwidget.cpp \
|
||||
smoothcurvegenerator.cpp \
|
||||
memorywidget.cpp
|
||||
memorywidget.cpp \
|
||||
networkindicator.cpp \
|
||||
resourcesindicator.cpp \
|
||||
resourcescategory.cpp
|
||||
|
||||
OTHER_FILES += \
|
||||
systemmonitor.json
|
||||
|
|
|
@ -24,7 +24,7 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|||
m_clearBtn->hide();
|
||||
|
||||
m_edit = new QLineEdit;
|
||||
m_edit->setStyleSheet("QLineEdit{background-color:transparent;border-radius:0px;color:#303030;padding-right:15px;padding-bottom: 3px;}");
|
||||
m_edit->setStyleSheet("QLineEdit{background-color:transparent;border-radius:0px;color:#ffffff;padding-right:12px;padding-bottom: 2px;}");
|
||||
//m_edit->setPlaceholderText("enter process info");
|
||||
|
||||
m_placeHolder = new QLabel;
|
||||
|
|
Loading…
Reference in New Issue