performwidget.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef PERFORMWIDGET_H
  2. #define PERFORMWIDGET_H
  3. #include <QWidget>
  4. #include <QTimer>
  5. #include<QDesktopWidget>
  6. #include<QProcess>
  7. #include<QRegularExpression>
  8. #include<QDebug>
  9. #include<QTableWidgetItem>
  10. #include<QMouseEvent>
  11. #define CPU_SORT "ps ax -o \"%u %p %C\" -o pmem -o \"%c %a\" --sort=-%cpu|head -21"
  12. #define MEM_SORT "ps ax -o \"%u %p %C\" -o pmem -o \"%c %a\" --sort=-pmem|head -21"
  13. #define BG_color "#monitorwindow{ background-color:%1; }\
  14. #pushButton{ color:%2; }"
  15. #define FD_CALCU_SPRINT_STR "lsof -p %1 | wc -l"
  16. #define LOW "rgb(50, 162, 106)"
  17. #define MID "rgb(233, 119, 57)"
  18. #define HIGH "rgb(179, 10, 13)"
  19. QT_BEGIN_NAMESPACE
  20. namespace Ui { class PerformWidget; }
  21. QT_END_NAMESPACE
  22. class PerformWidget : public QWidget
  23. {
  24. Q_OBJECT
  25. public:
  26. PerformWidget(QWidget *parent = nullptr);
  27. ~PerformWidget();
  28. static int GetProcessFds(int processID);
  29. signals:
  30. void opencpu();
  31. private:
  32. static int GetProcessFdsImpl(QProcess* pro, int processID);
  33. public slots:
  34. bool GetPerformInfo();
  35. void UpdateMemUsed();
  36. void sortByColumn(int selColumn);
  37. private:
  38. Ui::PerformWidget *ui;
  39. QPoint oldpos;
  40. void makelist();
  41. bool pidselected(const QString&);
  42. QTimer *timer;
  43. QProcess *process;
  44. QProcess *pro;
  45. QStringList selectedpid;
  46. QString cmd;
  47. QString pressed;
  48. QStringList selected;
  49. QStringList listupdate2freshselected;
  50. int memused;
  51. QRegularExpression reg;
  52. };
  53. #endif // PERFORMWIDGET_H