add icon resource

This commit is contained in:
李 翔 2018-01-22 16:37:35 +08:00
parent 19ae131dbc
commit 891f6b29d5
28 changed files with 615 additions and 702 deletions

View File

@ -101,10 +101,14 @@ void CpuBallWidget::loadWaveImage()
void CpuBallWidget::onRepaintWaveImage()
{
m_xFrontOffset -= 1;
// m_xFrontOffset -= 1;
m_xFrontOffset += 1;
m_xBackOffset += 2;
if (m_xFrontOffset < - (m_frontImage.width() - this->width())) {//保留整个显示直径的大小不做处理,避免出现断层
m_xFrontOffset = 0;
// if (m_xFrontOffset < - (m_frontImage.width() - this->width())) {//保留整个显示直径的大小不做处理,避免出现断层
// m_xFrontOffset = 0;
// }
if (m_xFrontOffset > m_frontImage.width()) {//保留整个显示直径的大小不做处理,避免出现断层
m_xFrontOffset = this->width();
}
if (m_xBackOffset > m_backImage.width()) {//保留整个显示直径的大小不做处理,避免出现断层
m_xBackOffset = this->width();
@ -167,7 +171,8 @@ void CpuBallWidget::paintEvent(QPaintEvent *)
//CompositionMode_SourceOver保证波浪出现的时候其背景为通明的
wavePainter.setCompositionMode(QPainter::CompositionMode_SourceOver);//混和模式QImage::CompositionMode_SourceOver 即原象素正在绘制的象素和目标象素已经存在的象素混和原象素的alpha分量定义为最终的透明度
wavePainter.drawImage(static_cast<int>(m_xBackOffset) - m_backImage.width(), 100 - currentPercent, m_backImage);
wavePainter.drawImage(static_cast<int>(m_xFrontOffset), 100 - currentPercent, m_frontImage);
// wavePainter.drawImage(static_cast<int>(m_xFrontOffset), 100 - currentPercent, m_frontImage);
wavePainter.drawImage(static_cast<int>(m_xFrontOffset) - m_frontImage.width(), 100 - currentPercent, m_frontImage);
//Step3:矩形区域中圆球的外径和内径
QRectF outRect = QRectF(0, 0, waveSize.width(), waveSize.height());

View File

@ -1,6 +1,51 @@
#include "memorywidget.h"
#include "util.h"
#include <QDebug>
#include <QObject>
inline QString formatMemory(guint64 size)
{
enum {
K_INDEX,
M_INDEX,
G_INDEX,
T_INDEX
};
QList<guint64> factorList;
factorList.append(G_GUINT64_CONSTANT(1) << 10);//KiB
factorList.append(G_GUINT64_CONSTANT(1) << 20);//MiB
factorList.append(G_GUINT64_CONSTANT(1) << 30);//GiB
factorList.append(G_GUINT64_CONSTANT(1) << 40);//TiB
if (size < factorList.at(K_INDEX)) {
if ((guint) size > 1) {
return QString("%1 %2").arg((guint) size).arg(QObject::tr("byte"));
}
else {
return QString("%1 %2").arg((guint) size).arg(QObject::tr("bytes"));
}
} else {
guint64 factor;
QString format;
if (size < factorList.at(M_INDEX)) {
factor = factorList.at(K_INDEX);
format = QObject::tr("KiB");
}else if (size < factorList.at(G_INDEX)) {
factor = factorList.at(M_INDEX);
format = QObject::tr("MiB");
} else if (size < factorList.at(T_INDEX)) {
factor = factorList.at(G_INDEX);
format = QObject::tr("GiB");
} else {
factor = factorList.at(T_INDEX);
format = QObject::tr("TiB");
}
std::string formatted_result(make_string(g_strdup_printf("%.1f", size / (double)factor)));
return QString::fromStdString(formatted_result) + format;
}
}
MemoryWidget::MemoryWidget(QWidget *parent)
: QWidget(parent)
@ -129,9 +174,9 @@ void MemoryWidget::drawText(QPainter *painter)
QRectF swapstatusRect(swapstatustopLeft, swapstatusbottomRight);
//内存状态内容
QString statusStr = tr("Used %1(%2), Total %3").arg(mi.user).arg(mi.percent).arg(mi.total);
QString statusStr = tr("Used %1(%2%), Total %3").arg(formatMemory(mi.user)).arg(QString::number(mi.percent, 'f', 1)).arg(formatMemory(mi.total));
//SWAP状态内容
QString swapstatusStr = tr("Used %1(%2), Total %3").arg(mi.swapused).arg(mi.swappercent).arg(mi.swaptotal);
QString swapstatusStr = tr("Used %1(%2%), Total %3").arg(formatMemory(mi.swapused)).arg(QString::number(mi.swappercent, 'f', 1)).arg(formatMemory(mi.swaptotal));
painter->save();
@ -176,11 +221,11 @@ void MemoryWidget::onUpdateMemoryStatus()
mi.swappercent = swappercent * 100;
//初始单位为字节,需要修正
mi.user = mem.user / 1024 / 1024 /1024;
mi.total = mem.total / 1024 / 1024 / 1024;
mi.user = mem.user;
mi.total = mem.total;
mi.swapused = swap.used / 1024 / 1024 /1024;
mi.swaptotal = swap.total / 1024 /1024 / 1024;
mi.swapused = swap.used;
mi.swaptotal = swap.total;
repaint();
}

View File

@ -34,7 +34,7 @@ MonitorTitleWidget::MonitorTitleWidget(QWidget *parent)
{
installEventFilter(this);
setMouseTracking(true);
setFixedHeight(TOP_TITLE_WIDGET_HEIGHT);
setFixedHeight(TITLE_WIDGET_HEIGHT);
m_topBorderColor = QColor(255, 255, 255, 153);
this->setAutoFillBackground(true);

View File

@ -22,8 +22,8 @@
ProcessCategory::ProcessCategory(int tabIndex, QWidget *parent)
: QWidget(parent)
,width(26)
,height(26)
,width(16)
,height(16)
,activeIndex(tabIndex)
{
setFixedSize(width * 3, height);
@ -60,7 +60,6 @@ ProcessCategory::ProcessCategory(int tabIndex, QWidget *parent)
allProcessButton->setChecked(false);
}
connect(activeProcessButton, &MyImageButton::clicked, this, [=] {
activeIndex = 0;
emit this->activeWhoseProcessList(activeIndex);

View File

@ -41,10 +41,10 @@ private:
int width;
int height;
int activeIndex;
QHBoxLayout *layout;
MyImageButton *activeProcessButton;
MyImageButton *userProcessButton;
MyImageButton *allProcessButton;
QHBoxLayout *layout = nullptr;
MyImageButton *activeProcessButton = nullptr;
MyImageButton *userProcessButton = nullptr;
MyImageButton *allProcessButton = nullptr;
};
#endif // PROCESSCATEGORY_H

View File

@ -87,29 +87,29 @@ QDataStream &operator>>(QDataStream &dataStream, ProcDataPtr &object)
return dataStream;
}
ProcessDialog::ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, bool sortOrder, QSettings *settings, QWidget *parent)
ProcessDialog::ProcessDialog(QList<bool> toBeDisplayedColumns, int currentSortIndex, bool isSort, QSettings *settings, QWidget *parent)
:QWidget(parent)
,num_cpus(0)
,frequency(0U)
,proSettings(settings)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
// setAcceptDrops(true);
setAttribute(Qt::WA_NoMousePropagation);
this->setObjectName("ProcessDialog");
qRegisterMetaType<ProcDataPtr>();
qRegisterMetaTypeStreamOperators<ProcDataPtr>();
qRegisterMetaType<ProcDataPtrList>();
qRegisterMetaType<QList<ProcData>>();
actionPids = new QList<pid_t>();
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
m_processListWidget = new ProcessListWidget(columnShowOrHideFlags);
m_processListWidget = new ProcessListWidget(toBeDisplayedColumns);
connect(m_processListWidget, SIGNAL(changeColumnVisible(int,bool,QList<bool>)), this, SIGNAL(changeColumnVisible(int,bool,QList<bool>)));
connect(m_processListWidget, SIGNAL(changeSortStatus(int,bool)), this, SIGNAL(changeSortStatus(int,bool)));
connect(m_processListWidget, &ProcessListWidget::rightMouseClickedItems, this, &ProcessDialog::popupMenu, Qt::QueuedConnection);
layout->addWidget(m_processListWidget);
whose_processes = "user";
@ -137,7 +137,7 @@ ProcessDialog::ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, b
sortFuncList->append(&ProcessListItem::sortByCommand);
sortFuncList->append(&ProcessListItem::sortByMemory);
sortFuncList->append(&ProcessListItem::sortByPriority);
m_processListWidget->setColumnSortingAlgorithms(sortFuncList, sortIndex, sortOrder);
m_processListWidget->setProcessSortFunctions(sortFuncList, currentSortIndex, isSort);
m_processListWidget->setSearchFunction(&ProcessListItem::doSearch);
endProcessDialog = new MyDialog(QString(tr("End process")), QString(tr("Ending a process may destroy data, break the session or introduce a security risk. Only unresponsive processes should be ended.\nAre you sure to continue?")));
@ -152,8 +152,6 @@ ProcessDialog::ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, b
killProcessDialog->addButton(QString(tr("Kill process")), true);
connect(killProcessDialog, &MyDialog::buttonClicked, this, &ProcessDialog::killDialogButtonClicked);
actionPids = new QList<pid_t>();
m_menu = new QMenu();
m_stopAction = new QAction(tr("Stop process"), this);
connect(m_stopAction, &QAction::triggered, this, &ProcessDialog::stopProcesses);
@ -198,8 +196,6 @@ ProcessDialog::ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, b
m_menu->addSeparator();
m_menu->addAction(m_propertiyAction);
connect(m_processListWidget, &ProcessListWidget::rightBtnClickedItems, this, &ProcessDialog::popupMenu, Qt::QueuedConnection);
glibtop_init();
this->num_cpus = glibtop_get_sysinfo()->ncpu;
@ -305,7 +301,6 @@ void startRenice(QString command, int value, pid_t pid)
QProcess::startDetached(rootCommand(command, value, pid));
}
void ProcessDialog::changeProcPriority(int nice)
{
if (nice == 32) {
@ -348,8 +343,8 @@ void ProcessDialog::changeProcPriority(int nice)
QString command = QString("renice %1 %1").arg(nice).arg(cur_pid);
QFile file("/usr/bin/pkexec");
if(file.exists()) {
gint *exit_status = NULL;
GError *error = NULL;
// gint *exit_status = NULL;
// GError *error = NULL;
QString cmd = QString("pkexec --disable-internal-agent /usr/lib/gnome-system-monitor/gnome-system-monitor/gsm-%1").arg(command);//gsm-renice
qDebug() << "cmd="<<cmd;
// if (!g_spawn_command_line_sync(command_line, NULL, NULL, exit_status, &error)) {

View File

@ -17,14 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "processworker.h"
#include "../../component/utils.h"
#include "../widgets/mydialog.h"
#include "processlistitem.h"
#include "../widgets/myactiongroup.h"
#include "../widgets/myactiongroupitem.h"
#include "../widgets/myaction.h"
#include "processworker.h"
#include "processlistitem.h"
#include "processlistwidget.h"
#include <QLabel>
@ -51,7 +50,7 @@ class ProcessDialog : public QWidget
Q_OBJECT
public:
explicit ProcessDialog(QList<bool> columnShowOrHideFlags, int sortIndex, bool sortOrder, QSettings *settings, QWidget* parent = 0);
explicit ProcessDialog(QList<bool> toBeDisplayedColumns, int currentSortIndex, bool isSort, QSettings *settings, QWidget* parent = 0);
~ProcessDialog();
ProcessListWidget* getProcessView();
@ -62,7 +61,7 @@ public:
signals:
void changeColumnVisible(int index, bool visible, QList<bool> columnVisible);
void changeSortStatus(int index, bool sortOrder);
void changeSortStatus(int index, bool isSort);
public slots:
void focusProcessView();
@ -83,18 +82,18 @@ public slots:
void refreshProcessList();
private:
QTimer *timer;
QSettings *proSettings;
QTimer *timer = nullptr;
QSettings *proSettings = nullptr;
guint64 cpu_total_time;
guint64 cpu_total_time_last;
MyDialog *killProcessDialog;
MyDialog *endProcessDialog;
ProcessListWidget *m_processListWidget;
QAction *m_propertiyAction;
QAction *m_stopAction;//停止
QAction *m_continueAction;//继续进程
QAction *m_endAction;//结束
QAction *m_killAction;//杀死
MyDialog *killProcessDialog = nullptr;
MyDialog *endProcessDialog = nullptr;
ProcessListWidget *m_processListWidget = nullptr;
QAction *m_propertiyAction = nullptr;
QAction *m_stopAction = nullptr;//停止
QAction *m_continueAction = nullptr;//继续进程
QAction *m_endAction = nullptr;//结束
QAction *m_killAction = nullptr;//杀死
// QMenu *m_priorityMenu;
// MyActionGroup * priorityGroup;
// MyAction *veryHighAction;
@ -104,7 +103,7 @@ private:
// MyAction *veryLowAction;
// MyAction *customAction;
QList<pid_t> *actionPids;
QMenu *m_menu;
QMenu *m_menu = nullptr;
QString whose_processes;
gint num_cpus;
unsigned frequency;

View File

@ -60,13 +60,10 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
setFontSize(*painter, 9);
painter->setOpacity(1);
if (isSelect) {
// //this->setToolTip();//kobe neet to draw tooltip
painter->setPen(QPen(QColor("#ffffff")));
} else {
painter->setPen(QPen(QColor("#000000")));
}
// Draw icon and process's name
if (column == 0) {
painter->drawPixmap(QRect(rect.x() + padding, rect.y() + (rect.height() - iconSize) / 2, iconSize, iconSize), m_data.iconPixmap);
QString name = m_data.processName;
@ -84,7 +81,6 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
name = QString("(%1) %2").arg(tr("Uninterruptible")).arg(m_data.processName);
}
else {//Sleeping 睡眠中 Running 运行中
}
int nameMaxWidth = rect.width() - iconSize - padding * 3;
QFont font = painter->font();
@ -92,27 +88,22 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
QString procName = fm.elidedText(name, Qt::ElideRight, nameMaxWidth);
painter->drawText(QRect(rect.x() + iconSize + padding * 2, rect.y(), nameMaxWidth, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, procName);
}
// Draw User.
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);
}
}
// Draw Status.
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);
}
}
// Draw CPU.
else if (column == 3) {
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, QString("%1%").arg(m_data.cpu));
}
// Draw pid.
else if (column == 4) {
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - padding, rect.height()), Qt::AlignCenter, QString("%1").arg(m_data.pid));
}
// Draw Command.
else if (column == 5) {
int commandMaxWidth = rect.width();
QFont font = painter->font();
@ -120,14 +111,12 @@ void ProcessListItem::drawForeground(QRect rect, QPainter *painter, int column,
QString command = fm.elidedText(m_data.commandLine, Qt::ElideRight, commandMaxWidth);
painter->drawText(QRect(rect.x(), rect.y(), commandMaxWidth, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, command);
}
// Draw memory.
else if (column == 6) {
if (m_data.m_memory > 0) {
QString memory = QString(g_format_size_full(m_data.m_memory, G_FORMAT_SIZE_IEC_UNITS));
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignCenter, memory);
}
}
// Draw Priority.
else if (column == 7) {
painter->drawText(QRect(rect.x(), rect.y(), rect.width() - textPadding, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, getNiceLevel(m_data.m_nice));
}
@ -144,72 +133,58 @@ bool ProcessListItem::sortByName(const ProcessListItem *item1, const ProcessList
{
QString name1 = (static_cast<const ProcessListItem*>(item1))->getDisplayName();
QString name2 = (static_cast<const ProcessListItem*>(item2))->getDisplayName();
bool sortOrder;
bool isSort;
// Sort item with cpu if name is same.
if (name1 == name2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by name.
else {
QCollator qco(QLocale::system());
int result = qco.compare(name1, name2);
sortOrder = result < 0;
isSort = result < 0;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByUser(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
QString user1 = (static_cast<const ProcessListItem*>(item1))->getUser();
QString user2 = (static_cast<const ProcessListItem*>(item2))->getUser();
bool sortOrder;
// Sort item with cpu if user is same.
bool isSort;
if (user1 == user2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by user.
else {
QCollator qco(QLocale::system());
int result = qco.compare(user1, user2);
sortOrder = result < 0;
isSort = result < 0;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByStatus(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
QString status1 = (static_cast<const ProcessListItem*>(item1))->getStatus();
QString status2 = (static_cast<const ProcessListItem*>(item2))->getStatus();
bool sortOrder;
// Sort item with cpu if status is same.
bool isSort;
if (status1 == status2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by status.
else {
QCollator qco(QLocale::system());
int result = qco.compare(status1, status2);
sortOrder = result < 0;
isSort = result < 0;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
@ -217,94 +192,77 @@ bool ProcessListItem::sortByCPU(const ProcessListItem *item1, const ProcessListI
{
double cpu1 = (static_cast<const ProcessListItem*>(item1))->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
bool sortOrder;
// Sort item with memory if cpu is same.
bool isSort;
if (cpu1 == cpu2) {
long memory1 = static_cast<const ProcessListItem*>(item1)->getMemory();
long memory2 = (static_cast<const ProcessListItem*>(item2))->getMemory();
sortOrder = memory1 > memory2;
isSort = memory1 > memory2;
}
// Otherwise sort by cpu.
else {
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByPid(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
bool sortOrder = (static_cast<const ProcessListItem*>(item1))->getPid() > (static_cast<const ProcessListItem*>(item2))->getPid();
bool isSort = (static_cast<const ProcessListItem*>(item1))->getPid() > (static_cast<const ProcessListItem*>(item2))->getPid();
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByCommand(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
QString command1 = (static_cast<const ProcessListItem*>(item1))->getCommandLine();
QString command2 = (static_cast<const ProcessListItem*>(item2))->getCommandLine();
bool sortOrder;
// Sort item with cpu if command is same.
bool isSort;
if (command1 == command2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by command.
else {
QCollator qco(QLocale::system());
int result = qco.compare(command1, command2);
sortOrder = result < 0;
isSort = result < 0;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByMemory(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
long memory1 = (static_cast<const ProcessListItem*>(item1))->getMemory();
long memory2 = (static_cast<const ProcessListItem*>(item2))->getMemory();
bool sortOrder;
// Sort item with cpu if memory is same.
bool isSort;
if (memory1 == memory2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by memory.
else {
sortOrder = memory1 > memory2;
isSort = memory1 > memory2;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
bool ProcessListItem::sortByPriority(const ProcessListItem *item1, const ProcessListItem *item2, bool descendingSort)
{
long nice1 = (static_cast<const ProcessListItem*>(item1))->getNice();
long nice2 = (static_cast<const ProcessListItem*>(item2))->getNice();
bool sortOrder;
// Sort item with cpu if nice is same.
bool isSort;
if (nice1 == nice2) {
double cpu1 = static_cast<const ProcessListItem*>(item1)->getCPU();
double cpu2 = (static_cast<const ProcessListItem*>(item2))->getCPU();
sortOrder = cpu1 > cpu2;
isSort = cpu1 > cpu2;
}
// Otherwise sort by nice.
else {
sortOrder = nice1 > nice2;
isSort = nice1 > nice2;
}
return descendingSort ? sortOrder : !sortOrder;
return descendingSort ? isSort : !isSort;
}
QString ProcessListItem::getProcessName() const

File diff suppressed because it is too large Load Diff

View File

@ -38,48 +38,48 @@ class ProcessListWidget : public QWidget
public:
~ProcessListWidget();
ProcessListWidget(QList<bool> columnShowOrHideFlags, QWidget *parent = 0);
ProcessListWidget(QList<bool> toBeDisplayedColumns, QWidget *parent = 0);
void setColumnSortingAlgorithms(QList<SortFunction> *list, int sortColumn=-1, bool sortOrder=false);
void setProcessSortFunctions(QList<SortFunction> *list, int sortColumn=-1, bool isSort=false);
void setSearchFunction(SearchFunction func);
void addItems(QList<ProcessListItem*> items);
void clearItems();
void addSelectedItems(QList<ProcessListItem*> items, bool recordLastSelection=true);
void clearSelectedItems(bool clearTheLast=true);
void addSelectedItems(QList<ProcessListItem*> items, bool recordLastItem=true);
void clearSelectedItems(bool clearLast=true);
void refreshItems(QList<ProcessListItem*> items);
void doSearch(QString text);
void selectAllItems();
void selectFirstItem();
void selectLastItem();
void shiftSelectToEnd();
void shiftSelectToHome();
void selectTheFirstItem();
void selectTheLastItem();
void selectThePrevItem(int offset);
void selectTheNextItem(int offset);
void shiftToHomeItem();
void shiftToEndItem();
void shiftToPrevItem(int offset);
void shiftToNextItem(int offset);
void shiftToSelectedItems(int start, int end);
int getItemsTotalHeight();
QList<ProcessListItem*> getSearchedItems(QList<ProcessListItem*> items);
void sortItemsByColumn(int column, bool sortOrder);
void selectPrevItem(int offset);
void selectNextItem(int offset);
void shiftSelectNextItem(int offset);
void shiftSelectPrevItem(int offset);
void sortItemsByColumn(int column, bool isSort);
int getTopOffset();
int getBottomOffset();
int getScrollbarY();
int getScrollbarH();
int getScrollAreaH();
int getScrollbarHeight();
int getTheScrollAreaHeight();
QList<int> getTitleItemsWidths();
void shiftSelectItemsWithBound(int startIndex, int endIndex);
int setOffset(int offset);
void startScrollbarHideTimer();
bool mouseAtScrollArea(int x);
bool mouseAtTitleArea(int y);
signals:
void rightBtnClickedItems(QPoint pos, QList<ProcessListItem*> items);
void rightMouseClickedItems(QPoint pos, QList<ProcessListItem*> items);
void changeColumnVisible(int index, bool visible, QList<bool> columnVisible);
void changeSortStatus(int index, bool sortOrder);
void changeSortStatus(int index, bool isSort);
public slots:
void hideScrollbar();
@ -95,38 +95,39 @@ protected:
void paintScrollbar(QPainter *painter);
private:
ProcessListItem *lastSelectItem;
QTimer *m_hideScrollbarTimer = nullptr;
SearchFunction m_searchFunc;
ProcessListItem *m_lastItem = nullptr;
QList<ProcessListItem*> *m_listItems;
QList<ProcessListItem*> *m_searchedItems;
QList<ProcessListItem*> *m_selectedItems;
QList<QString> columnTitles;
QList<SortFunction> *m_sortFuncList;
QList<bool> *m_sortOrderes;
QList<bool> *m_isSortList;
QList<int> m_columnWidths;
QList<bool> m_columnVisibles;
QString m_searchText;
QTimer *m_hideScrollbarTimer = nullptr;
SearchFunction m_searchFunc;
bool m_defaultSortOrder;
bool m_isSort;
bool m_mouseAtScrollArea;
bool m_mouseDragScrollbar;
int m_defaultSortColumn;
int m_currentSortIndex;
int m_origOffset;
int m_offSet;
int m_rowHeight;
int m_scrollbarDragW;
int m_scrollbarMinH;
int m_arrowPadding;
int m_scrollbarWidth;
int m_titleHeight;
int m_titleHoverColumn;
int m_titlePadding;
int m_titlePressColumn;
QPixmap downArrowHoverPixmap;
QPixmap downArrowNormalPixmap;
QPixmap downArrowPressPixmap;
QPixmap upArrowHoverPixmap;
QPixmap upArrowNormalPixmap;
QPixmap upArrowPressPixmap;
QPixmap m_downArrowHoverPixmap;
QPixmap m_downArrowNormalPixmap;
QPixmap m_downArrowPressPixmap;
QPixmap m_upArrowHoverPixmap;
QPixmap m_upArrowNormalPixmap;
QPixmap m_upArrowPressPixmap;
};
#endif // PROCESSLISTWIDGET_H

View File

@ -335,38 +335,6 @@ void ProcessWorker::setProcData()
info->unit = info->session = info->seat = NULL;
get_process_systemd_info(info);
/*
// glibtop_proc_state procstate;
glibtop_proc_uid procuid;
// glibtop_proc_time proctime;
// glibtop_get_proc_state (&procstate, pid);
// info->status = procstate.state;
glibtop_get_proc_uid (&procuid, pid);
// glibtop_get_proc_time (&proctime, pid);
glibtop_proc_mem procmem;
glibtop_get_proc_mem(&procmem, pid);
info->mem = procmem.resident - procmem.share;
glibtop_get_proc_state (&procstate, pid);
info->status = procstate.state;
this->set_user(procstate.uid);
guint64 difference = proctime.rtime - info->cpu_time;
if (difference > 0)
info->status = GLIBTOP_PROCESS_RUNNING;
info->pcpu = difference * 100 / this->cpu_total_time;
info->pcpu = MIN(info->pcpu, 100);
//CPU 百分比使用 Solaris 模式工作在“Solaris 模式”,其中任务的 CPU 使用量将被除以总的 CPU 数目。否则它将工作在“Irix 模式”。
info->pcpu *= this->num_cpus;
ProcessWorker::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
info->nice = procuid.nice;*/
}

View File

@ -39,12 +39,10 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, pid_t processId) : QDialog(p
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
this->setAttribute(Qt::WA_TranslucentBackground);
// this->setAttribute(Qt::WA_DeleteOnClose, false);
this->setAttribute(Qt::WA_Resized, false);
this->setMaximumSize(480, 600);
this->setMinimumWidth(320);
// this->resize(380, 120);
pid = processId;
@ -320,11 +318,3 @@ void PropertiesDialog::paintEvent(QPaintEvent *event)
QDialog::paintEvent(event);
}
/*void PropertiesDialog::resizeEvent(QResizeEvent *event)
{
if (event->size().width() >= maximumWidth()) {
setFixedWidth(maximumWidth());
}
QDialog::resizeEvent(event);
}*/

View File

@ -116,10 +116,10 @@ unsigned long long getCpuTimeData(unsigned long long &workTime)
}
fclose(file);
sscanf(buffer,
"cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
&user, &nice, &system, &idle, &iowait, &irq, &softirq, &steal, &guest, &guestnice);
workTime = user + nice + system;
return user + nice + system + idle + iowait + irq + softirq + steal;
}

View File

@ -103,18 +103,18 @@ SystemMonitor::~SystemMonitor()
void SystemMonitor::resizeEvent(QResizeEvent *e)
{
if (m_titleWidget) {
m_titleWidget->resize(width(), TOP_TITLE_WIDGET_HEIGHT);
m_titleWidget->resize(width(), TITLE_WIDGET_HEIGHT);
if (e->oldSize() != e->size()) {
emit m_titleWidget->updateMaxBtn();
}
}
if (m_toolBar) {
m_toolBar->resize(width(), TOP_TITLE_WIDGET_HEIGHT);
m_toolBar->move(0, TOP_TITLE_WIDGET_HEIGHT);
m_toolBar->resize(width(), TITLE_WIDGET_HEIGHT);
m_toolBar->move(0, TITLE_WIDGET_HEIGHT);
}
if (m_sysMonitorStack) {
m_sysMonitorStack->resize(width(), this->height() - TOP_TITLE_WIDGET_HEIGHT*2);
m_sysMonitorStack->move(0, TOP_TITLE_WIDGET_HEIGHT*2);
m_sysMonitorStack->resize(width(), this->height() - TITLE_WIDGET_HEIGHT*2);
m_sysMonitorStack->move(0, TITLE_WIDGET_HEIGHT*2);
}
}
@ -151,28 +151,28 @@ void SystemMonitor::recordVisibleColumn(int, bool, QList<bool> columnVisible)
m_visibleColumns << "priority";
}
QString processColumns = "";
QString displayedColumns = "";
for (int i = 0; i < m_visibleColumns.length(); i++) {
if (i != m_visibleColumns.length() - 1) {
processColumns += QString("%1,").arg(m_visibleColumns[i]);
displayedColumns += QString("%1,").arg(m_visibleColumns[i]);
} else {
processColumns += m_visibleColumns[i];
displayedColumns += m_visibleColumns[i];
}
}
proSettings->beginGroup("PROCESS");
proSettings->setValue("ProcessDisplayColumns", processColumns);
proSettings->setValue("DisplayedColumns", displayedColumns);
proSettings->endGroup();
proSettings->sync();
}
void SystemMonitor::recordSortStatus(int index, bool sortOrder)
void SystemMonitor::recordSortStatus(int index, bool isSort)
{
QList<QString> columnNames = { "name", "user", "status", "cpu", "pid", "command", "memory", "priority"};
proSettings->beginGroup("PROCESS");
proSettings->setValue("ProcessCurrentSortColumn", columnNames[index]);
proSettings->setValue("ProcessSortOrder", sortOrder);
proSettings->setValue("CurrentSortColumn", columnNames[index]);
proSettings->setValue("IsSort", isSort);
proSettings->endGroup();
proSettings->sync();
}
@ -182,13 +182,13 @@ void SystemMonitor::initPanelStack()
m_sysMonitorStack = new QStackedWidget(this);
m_sysMonitorStack->setStyleSheet("QStackedWidget{background: rgb(255, 255, 255);}");
m_sysMonitorStack->setObjectName("SystemMonitorStack");
m_sysMonitorStack->resize(width(), this->height() - TOP_TITLE_WIDGET_HEIGHT);
m_sysMonitorStack->move(0, TOP_TITLE_WIDGET_HEIGHT);
m_sysMonitorStack->resize(width(), this->height() - TITLE_WIDGET_HEIGHT);
m_sysMonitorStack->move(0, TITLE_WIDGET_HEIGHT);
m_sysMonitorStack->setMouseTracking(false);
m_sysMonitorStack->installEventFilter(this);
process_dialog = new ProcessDialog(getColumnHideFlags(), getSortIndex(), getSortOrder(), proSettings);
process_dialog = new ProcessDialog(getReadyDisplayColumns(), getCurrentSortColumnIndex(), isSortOrNot(), proSettings);
process_dialog->getProcessView()->installEventFilter(this);
connect(process_dialog, &ProcessDialog::changeColumnVisible, this, &SystemMonitor::recordVisibleColumn);
connect(process_dialog, &ProcessDialog::changeSortStatus, this, &SystemMonitor::recordSortStatus);
@ -206,15 +206,15 @@ void SystemMonitor::initPanelStack()
void SystemMonitor::initTitleWidget()
{
m_titleWidget = new MonitorTitleWidget(this);
m_titleWidget->resize(width(), TOP_TITLE_WIDGET_HEIGHT);
m_titleWidget->resize(width(), TITLE_WIDGET_HEIGHT);
m_titleWidget->move(0, 0);
}
void SystemMonitor::initToolBar()
{
m_toolBar = new ToolBar(proSettings, this);
m_toolBar->resize(width(), TOP_TITLE_WIDGET_HEIGHT);
m_toolBar->move(0, TOP_TITLE_WIDGET_HEIGHT);
m_toolBar->resize(width(), TITLE_WIDGET_HEIGHT);
m_toolBar->move(0, TITLE_WIDGET_HEIGHT);
}
void SystemMonitor::initConnections()
@ -239,53 +239,51 @@ void SystemMonitor::onChangePage(int index)
}
}
int SystemMonitor::getSortIndex()
int SystemMonitor::getCurrentSortColumnIndex()
{
proSettings->beginGroup("PROCESS");
QString sortingName = proSettings->value("ProcessCurrentSortColumn").toString();
QString currentSortColumn = proSettings->value("CurrentSortColumn").toString();
proSettings->endGroup();
QList<QString> columnNames = {
"name", "user", "status", "cpu", "pid", "command", "memory", "priority"
};
QList<QString> columnNames = {"name", "user", "status", "cpu", "pid", "command", "memory", "priority"};
return columnNames.indexOf(sortingName);
return columnNames.indexOf(currentSortColumn);
}
bool SystemMonitor::getSortOrder()
bool SystemMonitor::isSortOrNot()
{
proSettings->beginGroup("PROCESS");
bool value = proSettings->value("ProcessSortOrder", true).toBool();
bool value = proSettings->value("IsSort", true).toBool();
proSettings->endGroup();
return value;
}
QList<bool> SystemMonitor::getColumnHideFlags()
QList<bool> SystemMonitor::getReadyDisplayColumns()
{
proSettings->beginGroup("PROCESS");
QString processColumns = proSettings->value("ProcessDisplayColumns", "name,user,status,cpu,pid,command,memory,priority").toString();
QString displayedColumns = proSettings->value("DisplayedColumns", "name,user,status,cpu,pid,command,memory,priority").toString();
proSettings->endGroup();
if (processColumns.isEmpty()) {
if (displayedColumns.isEmpty()) {
proSettings->beginGroup("PROCESS");
processColumns = "name,user,status,cpu,pid,command,memory,priority";
proSettings->setValue("ProcessDisplayColumns", processColumns);
displayedColumns = "name,user,status,cpu,pid,command,memory,priority";
proSettings->setValue("DisplayedColumns", displayedColumns);
proSettings->endGroup();
proSettings->sync();
}
QList<bool> toggleHideFlags;
toggleHideFlags << processColumns.contains("name");
toggleHideFlags << processColumns.contains("user");
toggleHideFlags << processColumns.contains("status");
toggleHideFlags << processColumns.contains("cpu");
toggleHideFlags << processColumns.contains("pid");
toggleHideFlags << processColumns.contains("command");
toggleHideFlags << processColumns.contains("memory");
toggleHideFlags << processColumns.contains("priority");
QList<bool> m_shows;
m_shows << displayedColumns.contains("name");
m_shows << displayedColumns.contains("user");
m_shows << displayedColumns.contains("status");
m_shows << displayedColumns.contains("cpu");
m_shows << displayedColumns.contains("pid");
m_shows << displayedColumns.contains("command");
m_shows << displayedColumns.contains("memory");
m_shows << displayedColumns.contains("priority");
return toggleHideFlags;
return m_shows;
}
void SystemMonitor::moveCenter()

View File

@ -44,14 +44,14 @@ public:
void initPanelStack();
void initConnections();
QList<bool> getColumnHideFlags();
bool getSortOrder();
int getSortIndex();
QList<bool> getReadyDisplayColumns();
bool isSortOrNot();
int getCurrentSortColumnIndex();
void moveCenter();
public slots:
void recordVisibleColumn(int, bool, QList<bool> columnVisible);
void recordSortStatus(int index, bool sortOrder);
void recordSortStatus(int index, bool isSort);
void onChangePage(int index);
protected:

View File

@ -38,7 +38,7 @@ ToolBar::ToolBar(QSettings *settings, QWidget *parent)
{
installEventFilter(this);
setMouseTracking(true);
setFixedHeight(TOP_TITLE_WIDGET_HEIGHT);
setFixedHeight(TITLE_WIDGET_HEIGHT);
m_topBorderColor = QColor(255, 255, 255, 153);
// this->setAutoFillBackground(true);

View File

@ -24,7 +24,7 @@
#include <QObject>
#include <QPainter>
#define TOP_TITLE_WIDGET_HEIGHT 39
#define TITLE_WIDGET_HEIGHT 39
using std::string;

View File

@ -172,6 +172,7 @@ void SoundWidget::initSettingData()
void SoundWidget::onSendSoundList(const QString &currentSound, const QStringList &soundList)
{
if (!soundList.isEmpty()) {
m_soundlist.clear();
m_soundlist = soundList;
theme_combo->clear();
@ -186,6 +187,7 @@ void SoundWidget::onSendSoundList(const QString &currentSound, const QStringList
break;
}
theme_combo->setCurrentIndex(initIndex);
}
}
void SoundWidget::onSendEnableSoundValue(bool login_music, bool sound_event, bool input_sound)

View File

@ -222,6 +222,11 @@
<file>res/upload.svg</file>
<file>res/wave-back.png</file>
<file>res/wave-front.png</file>
<file>res/disk.png</file>
<file>res/sub_logo.png</file>
<file>res/user_proc.png</file>
<file>res/active_proc.png</file>
<file>res/all_proc.png</file>
</qresource>
<qresource prefix="/sys">
<file>res/sysBtn/close_button.png</file>

BIN
src/res/active_proc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/res/all_proc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/res/disk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -812,22 +812,22 @@ MyTipImageButton#DisksBtn {
}
MyImageButton#ActiveProcessBtn {
qproperty-normalPic: url(:/res/browser_logo_gray.png);
qproperty-hoverPic: url(:/res/browser_logo.png);
qproperty-pressPic: url(:/res/browser_logo.png);
qproperty-checkedPic: url(:/res/browser_logo.png);
qproperty-normalPic: url(:/res/active_proc.png);
qproperty-hoverPic: url(:/res/active_proc.png);
qproperty-pressPic: url(:/res/active_proc.png);
qproperty-checkedPic: url(:/res/active_proc.png);
}
MyImageButton#UserProcessBtn {
qproperty-normalPic: url(:/res/cache_logo_gray.png);
qproperty-hoverPic: url(:/res/cache_logo.png);
qproperty-pressPic: url(:/res/cache_logo.png);
qproperty-checkedPic: url(:/res/cache_logo.png);
qproperty-normalPic: url(:/res/user_proc.png);
qproperty-hoverPic: url(:/res/user_proc.png);
qproperty-pressPic: url(:/res/user_proc.png);
qproperty-checkedPic: url(:/res/user_proc.png);
}
MyImageButton#AllProcessBtn {
qproperty-normalPic: url(:/res/cookie_logo_gray.png);
qproperty-hoverPic: url(:/res/cookie_logo.png);
qproperty-pressPic: url(:/res/cookie_logo.png);
qproperty-checkedPic: url(:/res/cookie_logo.png);
qproperty-normalPic: url(:/res/all_proc.png);
qproperty-hoverPic: url(:/res/all_proc.png);
qproperty-pressPic: url(:/res/all_proc.png);
qproperty-checkedPic: url(:/res/all_proc.png);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/res/sub_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
src/res/user_proc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -131,7 +131,7 @@ void SettingWidget::initUI(/*QString skin*/)
theme_widget = new ThemeWidget(this);
icon_widget = new IconWidget(this, desktop);
mouse_widget = new MouseWidget(this, desktop);
voice_widget = new SoundWidget(this, desktop);
sound_widget = new SoundWidget(this, desktop);
// animation_widget = new AnimationWidget(this, systemProxy, p_mainwindow);
launcher_widget = new MenuWidget(this, desktop);
panel_widget = new PanelWidget(this, desktop, battery);
@ -145,7 +145,7 @@ void SettingWidget::initUI(/*QString skin*/)
stacked_widget->addWidget(theme_widget);
stacked_widget->addWidget(icon_widget);
stacked_widget->addWidget(mouse_widget);
stacked_widget->addWidget(voice_widget);
stacked_widget->addWidget(sound_widget);
// stacked_widget->addWidget(animation_widget);
stacked_widget->addWidget(launcher_widget);
stacked_widget->addWidget(panel_widget);
@ -184,15 +184,15 @@ void SettingWidget::initUI(/*QString skin*/)
//voice
// connect(this, SIGNAL(string_value_notify(QString,QString)), voice_widget, SLOT(voicewidget_notify_string(QString,QString)));
// connect(this, SIGNAL(bool_value_notify(QString,bool)), voice_widget, SLOT(voicewidget_notify_bool(QString,bool)));
connect(voice_widget, SIGNAL(requestSoundData()), this, SIGNAL(requestSoundData()));
connect(this, SIGNAL(sendSoundList(QString,QStringList)), voice_widget, SLOT(onSendSoundList(QString,QStringList)));
connect(this, SIGNAL(sendEnableSoundValue(bool,bool,bool)), voice_widget, SLOT(onSendEnableSoundValue(bool,bool,bool)));
connect(voice_widget, SIGNAL(resetVoiceTheme(QString)), this, SIGNAL(resetVoiceTheme(QString)));
connect(voice_widget, SIGNAL(resetLoginTipVoice(bool)), this, SIGNAL(resetLoginTipVoice(bool)));
connect(voice_widget, SIGNAL(resetEventVoice(bool)), this, SIGNAL(resetEventVoice(bool)));
connect(voice_widget, SIGNAL(resetInputFeedbackVoice(bool)), this, SIGNAL(resetInputFeedbackVoice(bool)));
// connect(this, SIGNAL(string_value_notify(QString,QString)), sound_widget, SLOT(voicewidget_notify_string(QString,QString)));
// connect(this, SIGNAL(bool_value_notify(QString,bool)), sound_widget, SLOT(voicewidget_notify_bool(QString,bool)));
connect(sound_widget, SIGNAL(requestSoundData()), this, SIGNAL(requestSoundData()));
connect(this, SIGNAL(sendSoundList(QString,QStringList)), sound_widget, SLOT(onSendSoundList(QString,QStringList)));
connect(this, SIGNAL(sendEnableSoundValue(bool,bool,bool)), sound_widget, SLOT(onSendEnableSoundValue(bool,bool,bool)));
connect(sound_widget, SIGNAL(resetVoiceTheme(QString)), this, SIGNAL(resetVoiceTheme(QString)));
connect(sound_widget, SIGNAL(resetLoginTipVoice(bool)), this, SIGNAL(resetLoginTipVoice(bool)));
connect(sound_widget, SIGNAL(resetEventVoice(bool)), this, SIGNAL(resetEventVoice(bool)));
connect(sound_widget, SIGNAL(resetInputFeedbackVoice(bool)), this, SIGNAL(resetInputFeedbackVoice(bool)));
//panel

View File

@ -236,7 +236,7 @@ private:
ThemeWidget *theme_widget;
IconWidget *icon_widget;
MouseWidget *mouse_widget;
SoundWidget *voice_widget;
SoundWidget *sound_widget;
// AnimationWidget *animation_widget;
MenuWidget *launcher_widget;
PanelWidget *panel_widget;