From 891f6b29d5bd13997ba26488f3a9b021979df09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=20=E7=BF=94?= Date: Mon, 22 Jan 2018 16:37:35 +0800 Subject: [PATCH] add icon resource --- plugins/systemmonitor/cpuballwidget.cpp | 13 +- plugins/systemmonitor/memorywidget.cpp | 57 +- plugins/systemmonitor/monitortitlewidget.cpp | 2 +- plugins/systemmonitor/processcategory.cpp | 5 +- plugins/systemmonitor/processcategory.h | 8 +- plugins/systemmonitor/processdialog.cpp | 21 +- plugins/systemmonitor/processdialog.h | 31 +- plugins/systemmonitor/processlistitem.cpp | 102 +-- plugins/systemmonitor/processlistwidget.cpp | 790 +++++++++---------- plugins/systemmonitor/processlistwidget.h | 71 +- plugins/systemmonitor/processworker.cpp | 32 - plugins/systemmonitor/propertiesdialog.cpp | 10 - plugins/systemmonitor/resourcesdialog.cpp | 4 +- plugins/systemmonitor/systemmonitor.cpp | 80 +- plugins/systemmonitor/systemmonitor.h | 8 +- plugins/systemmonitor/toolbar.cpp | 2 +- plugins/systemmonitor/util.h | 2 +- setting/soundwidget.cpp | 26 +- src/img.qrc | 5 + src/res/active_proc.png | Bin 0 -> 1381 bytes src/res/all_proc.png | Bin 0 -> 1336 bytes src/res/disk.png | Bin 0 -> 1135 bytes src/res/qss/kylin-assistant.qss | 24 +- src/res/search.png | Bin 1163 -> 1365 bytes src/res/sub_logo.png | Bin 0 -> 5525 bytes src/res/user_proc.png | Bin 0 -> 1463 bytes src/settingwidget.cpp | 22 +- src/settingwidget.h | 2 +- 28 files changed, 615 insertions(+), 702 deletions(-) create mode 100644 src/res/active_proc.png create mode 100644 src/res/all_proc.png create mode 100644 src/res/disk.png create mode 100644 src/res/sub_logo.png create mode 100644 src/res/user_proc.png diff --git a/plugins/systemmonitor/cpuballwidget.cpp b/plugins/systemmonitor/cpuballwidget.cpp index 97e6dce..901f63b 100644 --- a/plugins/systemmonitor/cpuballwidget.cpp +++ b/plugins/systemmonitor/cpuballwidget.cpp @@ -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(m_xBackOffset) - m_backImage.width(), 100 - currentPercent, m_backImage); - wavePainter.drawImage(static_cast(m_xFrontOffset), 100 - currentPercent, m_frontImage); +// wavePainter.drawImage(static_cast(m_xFrontOffset), 100 - currentPercent, m_frontImage); + wavePainter.drawImage(static_cast(m_xFrontOffset) - m_frontImage.width(), 100 - currentPercent, m_frontImage); //Step3:矩形区域中圆球的外径和内径 QRectF outRect = QRectF(0, 0, waveSize.width(), waveSize.height()); diff --git a/plugins/systemmonitor/memorywidget.cpp b/plugins/systemmonitor/memorywidget.cpp index 1d2bf71..f822b7b 100644 --- a/plugins/systemmonitor/memorywidget.cpp +++ b/plugins/systemmonitor/memorywidget.cpp @@ -1,6 +1,51 @@ #include "memorywidget.h" +#include "util.h" #include +#include + +inline QString formatMemory(guint64 size) +{ + enum { + K_INDEX, + M_INDEX, + G_INDEX, + T_INDEX + }; + + QList 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(); } diff --git a/plugins/systemmonitor/monitortitlewidget.cpp b/plugins/systemmonitor/monitortitlewidget.cpp index 96ce4b5..db1637b 100644 --- a/plugins/systemmonitor/monitortitlewidget.cpp +++ b/plugins/systemmonitor/monitortitlewidget.cpp @@ -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); diff --git a/plugins/systemmonitor/processcategory.cpp b/plugins/systemmonitor/processcategory.cpp index b396504..9fdfe9f 100644 --- a/plugins/systemmonitor/processcategory.cpp +++ b/plugins/systemmonitor/processcategory.cpp @@ -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); diff --git a/plugins/systemmonitor/processcategory.h b/plugins/systemmonitor/processcategory.h index 05d1277..b97996a 100644 --- a/plugins/systemmonitor/processcategory.h +++ b/plugins/systemmonitor/processcategory.h @@ -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 diff --git a/plugins/systemmonitor/processdialog.cpp b/plugins/systemmonitor/processdialog.cpp index 7c4423a..c00c09c 100644 --- a/plugins/systemmonitor/processdialog.cpp +++ b/plugins/systemmonitor/processdialog.cpp @@ -87,29 +87,29 @@ QDataStream &operator>>(QDataStream &dataStream, ProcDataPtr &object) return dataStream; } -ProcessDialog::ProcessDialog(QList columnShowOrHideFlags, int sortIndex, bool sortOrder, QSettings *settings, QWidget *parent) +ProcessDialog::ProcessDialog(QList 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(); qRegisterMetaTypeStreamOperators(); qRegisterMetaType(); qRegisterMetaType>(); + actionPids = new QList(); + 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)), this, SIGNAL(changeColumnVisible(int,bool,QList))); 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 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 columnShowOrHideFlags, int sortIndex, b killProcessDialog->addButton(QString(tr("Kill process")), true); connect(killProcessDialog, &MyDialog::buttonClicked, this, &ProcessDialog::killDialogButtonClicked); - actionPids = new QList(); - 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 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="<. */ - -#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 @@ -51,7 +50,7 @@ class ProcessDialog : public QWidget Q_OBJECT public: - explicit ProcessDialog(QList columnShowOrHideFlags, int sortIndex, bool sortOrder, QSettings *settings, QWidget* parent = 0); + explicit ProcessDialog(QList 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 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 *actionPids; - QMenu *m_menu; + QMenu *m_menu = nullptr; QString whose_processes; gint num_cpus; unsigned frequency; diff --git a/plugins/systemmonitor/processlistitem.cpp b/plugins/systemmonitor/processlistitem.cpp index b87ec66..522098e 100644 --- a/plugins/systemmonitor/processlistitem.cpp +++ b/plugins/systemmonitor/processlistitem.cpp @@ -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(item1))->getDisplayName(); QString name2 = (static_cast(item2))->getDisplayName(); - bool sortOrder; + bool isSort; - // Sort item with cpu if name is same. if (name1 == name2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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(item1))->getUser(); QString user2 = (static_cast(item2))->getUser(); - bool sortOrder; - - // Sort item with cpu if user is same. + bool isSort; if (user1 == user2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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(item1))->getStatus(); QString status2 = (static_cast(item2))->getStatus(); - bool sortOrder; - - // Sort item with cpu if status is same. + bool isSort; if (status1 == status2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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(item1))->getCPU(); double cpu2 = (static_cast(item2))->getCPU(); - bool sortOrder; - - // Sort item with memory if cpu is same. + bool isSort; if (cpu1 == cpu2) { long memory1 = static_cast(item1)->getMemory(); long memory2 = (static_cast(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(item1))->getPid() > (static_cast(item2))->getPid(); + bool isSort = (static_cast(item1))->getPid() > (static_cast(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(item1))->getCommandLine(); QString command2 = (static_cast(item2))->getCommandLine(); - bool sortOrder; - - // Sort item with cpu if command is same. + bool isSort; if (command1 == command2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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(item1))->getMemory(); long memory2 = (static_cast(item2))->getMemory(); - bool sortOrder; - - // Sort item with cpu if memory is same. + bool isSort; if (memory1 == memory2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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(item1))->getNice(); long nice2 = (static_cast(item2))->getNice(); - bool sortOrder; - - // Sort item with cpu if nice is same. + bool isSort; if (nice1 == nice2) { double cpu1 = static_cast(item1)->getCPU(); double cpu2 = (static_cast(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 diff --git a/plugins/systemmonitor/processlistwidget.cpp b/plugins/systemmonitor/processlistwidget.cpp index a441ae9..6cec67e 100644 --- a/plugins/systemmonitor/processlistwidget.cpp +++ b/plugins/systemmonitor/processlistwidget.cpp @@ -29,38 +29,34 @@ #include #include -ProcessListWidget::ProcessListWidget(QList columnShowOrHideFlags, QWidget *parent) : QWidget(parent) +ProcessListWidget::ProcessListWidget(QList toBeDisplayedColumns, QWidget *parent) : QWidget(parent) ,m_titlePadding(10) - ,m_arrowPadding(2) ,m_titleHeight(36) ,m_rowHeight(36) ,m_offSet(0) + ,m_origOffset(0) + ,m_scrollbarWidth(10) + ,m_titleHoverColumn(-1) + ,m_titlePressColumn(-1) + ,m_mouseAtScrollArea(false) + ,m_mouseDragScrollbar(false) { this->m_searchFunc = NULL; this->m_searchText = ""; - this->m_titleHoverColumn = -1; - this->m_titlePressColumn = -1; - - this->upArrowNormalPixmap = QPixmap(":/res/arrow_up_normal.png"); - this->upArrowHoverPixmap = QPixmap(":/res/arrow_up_hover.png"); - this->upArrowPressPixmap = QPixmap(":/res/arrow_up_press.png"); - this->downArrowNormalPixmap = QPixmap(":/res/arrow_down_normal.png"); - this->downArrowHoverPixmap = QPixmap(":/res/arrow_down_hover.png"); - this->downArrowPressPixmap = QPixmap(":/res/arrow_down_press.png"); - + this->m_lastItem = NULL; this->m_listItems = new QList(); this->m_searchedItems = new QList(); this->m_selectedItems = new QList(); - this->lastSelectItem = NULL; - - this->m_mouseAtScrollArea = false; - this->m_mouseDragScrollbar = false; - this->m_scrollbarDragW = 10; - this->m_scrollbarMinH = 30; - this->m_origOffset = 0; this->m_sortFuncList = new QList(); - this->m_sortOrderes = new QList(); + this->m_isSortList = new QList(); + + this->m_upArrowNormalPixmap = QPixmap(":/res/arrow_up_normal.png"); + this->m_upArrowHoverPixmap = QPixmap(":/res/arrow_up_hover.png"); + this->m_upArrowPressPixmap = QPixmap(":/res/arrow_up_press.png"); + this->m_downArrowNormalPixmap = QPixmap(":/res/arrow_down_normal.png"); + this->m_downArrowHoverPixmap = QPixmap(":/res/arrow_down_hover.png"); + this->m_downArrowPressPixmap = QPixmap(":/res/arrow_down_press.png"); this->columnTitles << tr("Process Name") << tr("User") << tr("Status") << tr("CPU") << tr("ID") << tr("Command Line") << tr("Memory") << tr("Priority"); QList widths; @@ -75,39 +71,39 @@ ProcessListWidget::ProcessListWidget(QList columnShowOrHideFlags, QWidget if (widths[i] == -1) { this->m_columnWidths << widths[i]; } else {//-1时让改行填充所有剩余空间 - int maxWidth = fm.width(this->columnTitles[i]) + this->m_titlePadding + upArrowNormalPixmap.width() / upArrowNormalPixmap.devicePixelRatio() + this->m_arrowPadding * 2; + int maxWidth = fm.width(this->columnTitles[i]) + this->m_titlePadding + m_upArrowNormalPixmap.width() / m_upArrowNormalPixmap.devicePixelRatio() + 2 * 2; this->m_columnWidths << std::max(widths[i], maxWidth); } } this->m_columnVisibles.clear(); - for (int i = 0; i < columnShowOrHideFlags.count(); i++) { - this->m_columnVisibles.append(columnShowOrHideFlags[i]); + for (int i = 0; i < toBeDisplayedColumns.count(); i++) { + this->m_columnVisibles.append(toBeDisplayedColumns[i]); } - QTimer::singleShot(0, this, SLOT(setFocus())); + this->setFocus(); } ProcessListWidget::~ProcessListWidget() { - delete this->lastSelectItem; + delete this->m_lastItem; delete this->m_listItems; delete this->m_searchedItems; delete this->m_selectedItems; delete this->m_sortFuncList; - delete this->m_sortOrderes; + delete this->m_isSortList; delete this->m_hideScrollbarTimer; } -void ProcessListWidget::setColumnSortingAlgorithms(QList *list, int sortColumn, bool sortOrder) +void ProcessListWidget::setProcessSortFunctions(QList *list, int currentSortIndex, bool isSort) { this->m_sortFuncList = list; for (int i = 0; i < this->m_sortFuncList->count(); i++) { - this->m_sortOrderes->append(false); + this->m_isSortList->append(false); } - this->m_defaultSortColumn = sortColumn; - this->m_defaultSortOrder = sortOrder; + this->m_currentSortIndex = currentSortIndex; + this->m_isSort = isSort; } void ProcessListWidget::setSearchFunction(SearchFunction func) @@ -120,8 +116,8 @@ void ProcessListWidget::addItems(QList items) this->m_listItems->append(items); QList s_items = this->getSearchedItems(items); this->m_searchedItems->append(s_items); - if (this->m_defaultSortColumn != -1) { - this->sortItemsByColumn(this->m_defaultSortColumn, this->m_defaultSortOrder); + if (this->m_currentSortIndex != -1) { + this->sortItemsByColumn(this->m_currentSortIndex, this->m_isSort); } } @@ -132,40 +128,40 @@ void ProcessListWidget::clearItems() this->m_searchedItems->clear(); } -void ProcessListWidget::addSelectedItems(QList items, bool recordLastSelection) +void ProcessListWidget::addSelectedItems(QList items, bool recordLastItem) { this->m_selectedItems->append(items); - if (recordLastSelection && this->m_selectedItems->count() > 0) { - this->lastSelectItem = this->m_selectedItems->last(); + if (recordLastItem && this->m_selectedItems->count() > 0) { + this->m_lastItem = this->m_selectedItems->last(); } } -void ProcessListWidget::clearSelectedItems(bool clearTheLast) +void ProcessListWidget::clearSelectedItems(bool clearLast) { this->m_selectedItems->clear(); - if (clearTheLast) { - this->lastSelectItem = NULL; + if (clearLast) { + this->m_lastItem = NULL; } } void ProcessListWidget::refreshItems(QList items) { - QList *newSelection = new QList(); - ProcessListItem *newLastSelectionItem = NULL; + QList *allItems = new QList(); + ProcessListItem *newLastItem = NULL; for (ProcessListItem *item:items) { for (ProcessListItem *selectionItem:*this->m_selectedItems) { if (item->isSameItem(selectionItem)) { - newSelection->append(item); + allItems->append(item); break; } } } - if (this->lastSelectItem != NULL) { + if (this->m_lastItem != NULL) { for (ProcessListItem *item:items) { - if (item->isSameItem(this->lastSelectItem)) { - newLastSelectionItem = item; + if (item->isSameItem(this->m_lastItem)) { + newLastItem = item; break; } } @@ -176,14 +172,16 @@ void ProcessListWidget::refreshItems(QList items) QList s_items = this->getSearchedItems(items); this->m_searchedItems->append(s_items); - if (this->m_defaultSortColumn != -1) { - this->sortItemsByColumn(this->m_defaultSortColumn, this->m_defaultSortOrder); + if (this->m_currentSortIndex != -1) { + this->sortItemsByColumn(this->m_currentSortIndex, this->m_isSort); } clearSelectedItems(); - addSelectedItems(*newSelection, false); - this->lastSelectItem = newLastSelectionItem; + addSelectedItems(*allItems, false); + + this->m_lastItem = newLastItem; this->m_offSet = setOffset(this->m_offSet); + repaint(); } @@ -191,7 +189,6 @@ void ProcessListWidget::doSearch(QString text) { if (text == "" && this->m_searchText != text) { this->m_searchText = text; - this->m_searchedItems->clear(); this->m_searchedItems->append(*this->m_listItems); } else { @@ -204,19 +201,7 @@ void ProcessListWidget::doSearch(QString text) repaint(); } -void ProcessListWidget::selectAllItems() -{ - this->m_origOffset = this->m_offSet; - - clearSelectedItems(); - addSelectedItems(*this->m_searchedItems); - - this->m_offSet = this->getTopOffset(); - - repaint(); -} - -void ProcessListWidget::selectFirstItem() +void ProcessListWidget::selectTheFirstItem() { this->m_origOffset = this->m_offSet; @@ -226,12 +211,12 @@ void ProcessListWidget::selectFirstItem() items << this->m_searchedItems->first(); addSelectedItems(items); - this->m_offSet = this->getTopOffset(); + this->m_offSet = 0; repaint(); } -void ProcessListWidget::selectLastItem() +void ProcessListWidget::selectTheLastItem() { this->m_origOffset = this->m_offSet; @@ -246,35 +231,199 @@ void ProcessListWidget::selectLastItem() repaint(); } -void ProcessListWidget::shiftSelectToEnd() +void ProcessListWidget::selectThePrevItem(int offset) +{ + this->m_origOffset = this->m_offSet; + + if (this->m_selectedItems->empty()) { + selectTheFirstItem(); + } else { + int firstIndex = this->m_searchedItems->count(); + for (ProcessListItem *item:*this->m_selectedItems) { + int index = this->m_searchedItems->indexOf(item); + if (index < firstIndex) { + firstIndex = index; + } + } + + if (firstIndex != -1) { + firstIndex = std::max(0, firstIndex - offset); + clearSelectedItems(); + QList items = QList(); + items << (*this->m_searchedItems)[firstIndex]; + addSelectedItems(items); + int itemIndex = firstIndex - 1; + int itemOffset = setOffset(itemIndex * this->m_rowHeight + this->m_titleHeight); + if ((this->m_offSet / this->m_rowHeight) > itemIndex) { + this->m_offSet = itemOffset; + } + repaint(); + } + } +} + +void ProcessListWidget::selectTheNextItem(int offset) +{ + this->m_origOffset = this->m_offSet; + + if (this->m_selectedItems->empty()) { + selectTheFirstItem(); + } else { + int lastIndex = 0; + for (ProcessListItem *item:*this->m_selectedItems) { + int index = this->m_searchedItems->indexOf(item); + if (index > lastIndex) { + lastIndex = index; + } + } + + if (lastIndex != -1) { + lastIndex = std::min(this->m_searchedItems->count() - 1, lastIndex + offset); + + clearSelectedItems(false); + + QList items = QList(); + items << (*this->m_searchedItems)[lastIndex]; + + addSelectedItems(items); + + int itemIndex = lastIndex + 1; + int itemOffset = setOffset(itemIndex * this->m_rowHeight - rect().height() + this->m_titleHeight); + if (((this->m_offSet + getTheScrollAreaHeight()) / this->m_rowHeight) < itemIndex) { + this->m_offSet = itemOffset; + } + + repaint(); + } + } +} + +void ProcessListWidget::shiftToHomeItem() { if (this->m_selectedItems->empty()) { - selectLastItem(); + selectTheFirstItem(); } else { - int lastSelectionIndex = this->m_searchedItems->indexOf(this->lastSelectItem); - shiftSelectItemsWithBound(lastSelectionIndex, this->m_searchedItems->count() - 1); + int lastSelectionIndex = this->m_searchedItems->indexOf(this->m_lastItem); + shiftToSelectedItems(0, lastSelectionIndex); + this->m_offSet = 0; + repaint(); + } +} + +void ProcessListWidget::shiftToEndItem() +{ + if (this->m_selectedItems->empty()) { + selectTheLastItem(); + } + else { + shiftToSelectedItems(this->m_searchedItems->indexOf(this->m_lastItem), this->m_searchedItems->count() - 1); this->m_offSet = getBottomOffset(); repaint(); } } -void ProcessListWidget::shiftSelectToHome() +void ProcessListWidget::shiftToPrevItem(int offset) { + this->m_origOffset = this->m_offSet; if (this->m_selectedItems->empty()) { - selectFirstItem(); + selectTheFirstItem(); } else { - int lastSelectionIndex = this->m_searchedItems->indexOf(this->lastSelectItem); - shiftSelectItemsWithBound(0, lastSelectionIndex); - this->m_offSet = this->getTopOffset(); - repaint(); + int firstIndex = this->m_searchedItems->count(); + int lastIndex = 0; + for (ProcessListItem *item : *this->m_selectedItems) { + int index = this->m_searchedItems->indexOf(item); + if (index < firstIndex) { + firstIndex = index; + } + if (index > lastIndex) { + lastIndex = index; + } + } + + if (firstIndex != -1) { + int lastSelectionIndex = this->m_searchedItems->indexOf(this->m_lastItem); + int selectionStartIndex, selectionEndIndex; + if (lastIndex == lastSelectionIndex) { + selectionStartIndex = std::max(0, firstIndex - offset); + selectionEndIndex = lastSelectionIndex; + } else { + selectionStartIndex = firstIndex; + selectionEndIndex = std::max(0, lastIndex - offset); + } + shiftToSelectedItems(selectionStartIndex, selectionEndIndex); + if (this->m_offSet / this->m_rowHeight >= selectionStartIndex) { + this->m_offSet = setOffset((selectionStartIndex - 1) * this->m_rowHeight + this->m_titleHeight); + } + repaint(); + } } } -void ProcessListWidget::leaveEvent(QEvent * event){ - hideScrollbar(); +void ProcessListWidget::shiftToNextItem(int offset) +{ + this->m_origOffset = this->m_offSet; + if (this->m_selectedItems->empty()) { + selectTheFirstItem(); + } else { + int firstIndex = this->m_searchedItems->count(); + int lastIndex = 0; + for (ProcessListItem *item:*this->m_selectedItems) { + int index = this->m_searchedItems->indexOf(item); + + if (index < firstIndex) { + firstIndex = index; + } + + if (index > lastIndex) { + lastIndex = index; + } + } + + if (firstIndex != -1) { + int lastSelectionIndex = this->m_searchedItems->indexOf(this->m_lastItem); + int selectionStartIndex, selectionEndIndex; + + if (firstIndex == lastSelectionIndex) { + selectionStartIndex = firstIndex; + selectionEndIndex = std::min(this->m_searchedItems->count() - 1, lastIndex + offset); + } else { + selectionStartIndex = std::min(this->m_searchedItems->count() - 1, firstIndex + offset); + selectionEndIndex = lastIndex; + } + + shiftToSelectedItems(selectionStartIndex, selectionEndIndex); + + if ((this->m_offSet + rect().height()) / this->m_rowHeight <= selectionEndIndex + 1) { + this->m_offSet = setOffset((selectionEndIndex + 1) * this->m_rowHeight + this->m_titleHeight - rect().height()); + } + + + repaint(); + } + } +} + +void ProcessListWidget::shiftToSelectedItems(int start, int end) +{ + clearSelectedItems(false); + QList items = QList(); + int index = 0; + for (ProcessListItem *item:*this->m_searchedItems) { + if (index >= start && index <= end) { + items << item; + } + + index++; + } + addSelectedItems(items, false); +} + +void ProcessListWidget::leaveEvent(QEvent * event) +{ + hideScrollbar(); QWidget::leaveEvent(event); } @@ -288,57 +437,63 @@ void ProcessListWidget::hideScrollbar() void ProcessListWidget::keyPressEvent(QKeyEvent *keyEvent) { - if (keyEvent->key() == Qt::Key_Home) { + if (keyEvent->key() == Qt::Key_Up) { + if (keyEvent->modifiers() == Qt::ShiftModifier) + shiftToPrevItem(1); + else + selectThePrevItem(1); + } + else if (keyEvent->key() == Qt::Key_Down) { + if (keyEvent->modifiers() == Qt::ShiftModifier) + shiftToNextItem(1); + else + selectTheNextItem(1); + } + else if (keyEvent->key() == Qt::Key_Home) { if (keyEvent->modifiers() == Qt::ControlModifier) { - this->m_offSet = this->getTopOffset(); + this->m_offSet = 0; repaint(); - } else if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectToHome(); - }else { - selectFirstItem(); + } + else if (keyEvent->modifiers() == Qt::ShiftModifier) { + shiftToHomeItem(); + } + else { + selectTheFirstItem(); } } else if (keyEvent->key() == Qt::Key_End) { if (keyEvent->modifiers() == Qt::ControlModifier) { this->m_offSet = getBottomOffset(); repaint(); - } else if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectToEnd(); - } else { - selectLastItem(); } - } else if (keyEvent->key() == Qt::Key_Up) { - if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectPrevItem(1); - } else { - selectPrevItem(1); + else if (keyEvent->modifiers() == Qt::ShiftModifier) { + shiftToEndItem(); } - } else if (keyEvent->key() == Qt::Key_Down) { - if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectNextItem(1); - } else { - selectNextItem(1); + else { + selectTheLastItem(); } - } else if (keyEvent->key() == Qt::Key_PageUp) { + } + else if (keyEvent->key() == Qt::Key_PageUp) { if (keyEvent->modifiers() == Qt::ControlModifier) { - this->m_offSet = setOffset(this->m_offSet - getScrollAreaH()); + this->m_offSet = setOffset(this->m_offSet - getTheScrollAreaHeight()); repaint(); - } else if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectPrevItem(getScrollAreaH() / this->m_rowHeight); - } else { - selectPrevItem(getScrollAreaH() / this->m_rowHeight); } - } else if (keyEvent->key() == Qt::Key_PageDown) { + else if (keyEvent->modifiers() == Qt::ShiftModifier) { + shiftToPrevItem(getTheScrollAreaHeight() / this->m_rowHeight); + } + else { + selectThePrevItem(getTheScrollAreaHeight() / this->m_rowHeight); + } + } + else if (keyEvent->key() == Qt::Key_PageDown) { if (keyEvent->modifiers() == Qt::ControlModifier) { - this->m_offSet = setOffset(this->m_offSet + getScrollAreaH()); + this->m_offSet = setOffset(this->m_offSet + getTheScrollAreaHeight()); repaint(); - } else if (keyEvent->modifiers() == Qt::ShiftModifier) { - shiftSelectNextItem(getScrollAreaH() / this->m_rowHeight); - } else { - selectNextItem(getScrollAreaH() / this->m_rowHeight); } - } else if (keyEvent->key() == Qt::Key_A) { - if (keyEvent->modifiers() == Qt::ControlModifier) { - selectAllItems(); + else if (keyEvent->modifiers() == Qt::ShiftModifier) { + shiftToNextItem(getTheScrollAreaHeight() / this->m_rowHeight); + } + else { + selectTheNextItem(getTheScrollAreaHeight() / this->m_rowHeight); } } } @@ -346,8 +501,7 @@ void ProcessListWidget::keyPressEvent(QKeyEvent *keyEvent) void ProcessListWidget::mouseMoveEvent(QMouseEvent *mouseEvent) { if (this->m_mouseDragScrollbar) { - int barHeight = getScrollbarH(); - this->m_offSet = setOffset((mouseEvent->y() - barHeight / 2 - this->m_titleHeight) / (getScrollAreaH() * 1.0) * this->getItemsTotalHeight()); + this->m_offSet = setOffset((mouseEvent->y() - getScrollbarHeight() / 2 - this->m_titleHeight) / (getTheScrollAreaHeight()) * this->getItemsTotalHeight()); repaint(); } else if (mouseAtScrollArea(mouseEvent->x()) != this->m_mouseAtScrollArea) { @@ -357,25 +511,24 @@ void ProcessListWidget::mouseMoveEvent(QMouseEvent *mouseEvent) else { bool isTitleArea = mouseAtTitleArea(mouseEvent->y()); if (isTitleArea) { - int hoverColumn = -1; - if (this->m_sortFuncList->count() != 0 && this->m_sortFuncList->count() == this->columnTitles.count() && this->m_sortOrderes->count() == this->columnTitles.count()) { + int currentHoverIndex = -1; + if (this->m_sortFuncList->count() != 0 && this->m_sortFuncList->count() == this->columnTitles.count() && this->m_isSortList->count() == this->columnTitles.count()) { QList titleItemsWidths = getTitleItemsWidths(); - - int columnCounter = 0; - int columnX = 0; - for (int titleItemWidth:titleItemsWidths) { - if (titleItemWidth > 0) { - if (mouseEvent->x() > columnX && mouseEvent->x() < columnX + titleItemWidth) { - hoverColumn = columnCounter; + int counter = 0; + int pos_X = 0; + for (int t_width : titleItemsWidths) { + if (t_width > 0) { + if (mouseEvent->x() > pos_X && mouseEvent->x() < pos_X + t_width) { + currentHoverIndex = counter; break; } - columnX += titleItemWidth; + pos_X += t_width; } - columnCounter++; + counter++; } } - if (hoverColumn != this->m_titleHoverColumn) { - this->m_titleHoverColumn = hoverColumn; + if (currentHoverIndex != this->m_titleHoverColumn) { + this->m_titleHoverColumn = currentHoverIndex; repaint(); } } @@ -391,39 +544,36 @@ void ProcessListWidget::mousePressEvent(QMouseEvent *mouseEvent) if (isTitleArea) {//点击列表的标题栏区域 if (mouseEvent->button() == Qt::LeftButton) { - if (this->m_sortFuncList->count() != 0 && this->m_sortFuncList->count() == this->columnTitles.count() && this->m_sortOrderes->count() == this->columnTitles.count()) { + if (this->m_sortFuncList->count() != 0 && this->m_sortFuncList->count() == this->columnTitles.count() && this->m_isSortList->count() == this->columnTitles.count()) { QList titleItemsWidths = getTitleItemsWidths(); - int columnCounter = 0; - int columnX = 0; - for (int titleItemWidth : titleItemsWidths) { - if (titleItemWidth > 0) { - if (mouseEvent->x() > columnX && mouseEvent->x() < columnX + titleItemWidth) { - if (columnCounter != this->m_defaultSortColumn) { - (*this->m_sortOrderes)[columnCounter] = true; + int counter = 0; + int posX = 0; + for (int t_width : titleItemsWidths) { + if (t_width > 0) { + if (mouseEvent->x() > posX && mouseEvent->x() < posX + t_width) { + if (counter != this->m_currentSortIndex) { + (*this->m_isSortList)[counter] = true; } else { - (*this->m_sortOrderes)[columnCounter] = !(*this->m_sortOrderes)[columnCounter]; + (*this->m_isSortList)[counter] = !(*this->m_isSortList)[counter]; } - - this->m_defaultSortColumn = columnCounter; - this->m_defaultSortOrder = (*this->m_sortOrderes)[columnCounter]; - - emit this->changeSortStatus(this->m_defaultSortColumn, this->m_defaultSortOrder); - - this->sortItemsByColumn(columnCounter, (*this->m_sortOrderes)[columnCounter]); - - if (columnCounter != this->m_titlePressColumn) { - this->m_titlePressColumn = columnCounter; + this->m_currentSortIndex = counter; + this->m_isSort = (*this->m_isSortList)[counter]; + emit this->changeSortStatus(this->m_currentSortIndex, this->m_isSort); + this->sortItemsByColumn(counter, (*this->m_isSortList)[counter]); + if (counter != this->m_titlePressColumn) { + this->m_titlePressColumn = counter; } repaint(); break; } - columnX += titleItemWidth; + posX += t_width; } - columnCounter++; + counter++; } } - } else if (mouseEvent->button() == Qt::RightButton) { + } + else if (mouseEvent->button() == Qt::RightButton) { if (m_columnVisibles.count() == this->columnTitles.count()) { QMenu *menu = new QMenu(); menu->setObjectName("MonitorMenu"); @@ -431,7 +581,6 @@ void ProcessListWidget::mousePressEvent(QMouseEvent *mouseEvent) if (i != 0) {//让第一行总是显示,不可以设置显示或者不显示,其他行可以设置 QAction *action = new QAction(menu); action->setText(this->columnTitles[i]); - action->setCheckable(true); action->setChecked(m_columnVisibles[i]); connect(action, &QAction::triggered, this, [this, action, i] { @@ -442,36 +591,33 @@ void ProcessListWidget::mousePressEvent(QMouseEvent *mouseEvent) menu->addAction(action); } } - menu->exec(this->mapToGlobal(mouseEvent->pos())); delete menu; } } } else if (isScrollArea) {//点击滚动条区域 - int barHeight = getScrollbarH(); + int barHeight = getScrollbarHeight(); int barY = getScrollbarY(); - if (mouseEvent->y() > barY && mouseEvent->y() < barY + barHeight) { this->m_mouseDragScrollbar = true; } else { - this->m_offSet = setOffset((mouseEvent->y() - barHeight / 2 - this->m_titleHeight) / (getScrollAreaH() * 1.0) * this->getItemsTotalHeight()); + this->m_offSet = setOffset((mouseEvent->y() - barHeight / 2 - this->m_titleHeight) / (getTheScrollAreaHeight()) * this->getItemsTotalHeight()); repaint(); } } else { - int pressItemIndex = (this->m_offSet + mouseEvent->y() - this->m_titleHeight) / this->m_rowHeight; - if (pressItemIndex >= this->m_searchedItems->count()) { + int pressedItemIndex = (this->m_offSet + mouseEvent->y() - this->m_titleHeight) / this->m_rowHeight; + if (pressedItemIndex >= this->m_searchedItems->count()) { clearSelectedItems(); repaint(); } else { if (mouseEvent->button() == Qt::LeftButton) { - if (pressItemIndex < this->m_searchedItems->count()) { + if (pressedItemIndex < this->m_searchedItems->count()) { if (mouseEvent->modifiers() == Qt::ControlModifier) { - ProcessListItem *item = (*this->m_searchedItems)[pressItemIndex]; - + ProcessListItem *item = (*this->m_searchedItems)[pressedItemIndex]; if (this->m_selectedItems->contains(item)) { this->m_selectedItems->removeOne(item); } else { @@ -481,23 +627,22 @@ void ProcessListWidget::mousePressEvent(QMouseEvent *mouseEvent) } } else if ((mouseEvent->modifiers() == Qt::ShiftModifier) && !this->m_selectedItems->empty()) { - int lastSelectionIndex = this->m_searchedItems->indexOf(this->lastSelectItem); - int selectionStartIndex = std::min(pressItemIndex, lastSelectionIndex); - int selectionEndIndex = std::max(pressItemIndex, lastSelectionIndex); - - shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); + int lastSelectionIndex = this->m_searchedItems->indexOf(this->m_lastItem); + int selectionStartIndex = std::min(pressedItemIndex, lastSelectionIndex); + int selectionEndIndex = std::max(pressedItemIndex, lastSelectionIndex); + shiftToSelectedItems(selectionStartIndex, selectionEndIndex); } else { clearSelectedItems(); QList items = QList(); - items << (*this->m_searchedItems)[pressItemIndex]; + items << (*this->m_searchedItems)[pressedItemIndex]; addSelectedItems(items); } repaint(); } } else if (mouseEvent->button() == Qt::RightButton) { - ProcessListItem *pressItem = (*this->m_searchedItems)[pressItemIndex]; + ProcessListItem *pressItem = (*this->m_searchedItems)[pressedItemIndex]; bool pressInSelectionArea = false; for (ProcessListItem *item : *this->m_selectedItems) { if (item == pressItem) { @@ -505,15 +650,15 @@ void ProcessListWidget::mousePressEvent(QMouseEvent *mouseEvent) break; } } - if (!pressInSelectionArea && pressItemIndex < this->m_searchedItems->length()) { + if (!pressInSelectionArea && pressedItemIndex < this->m_searchedItems->length()) { clearSelectedItems(); QList items = QList(); - items << (*this->m_searchedItems)[pressItemIndex]; + items << (*this->m_searchedItems)[pressedItemIndex]; addSelectedItems(items); repaint(); } if (this->m_selectedItems->length() > 0) { - emit this->rightBtnClickedItems(this->mapToGlobal(mouseEvent->pos()), *this->m_selectedItems); + emit this->rightMouseClickedItems(this->mapToGlobal(mouseEvent->pos()), *this->m_selectedItems); } } } @@ -525,7 +670,8 @@ void ProcessListWidget::mouseReleaseEvent(QMouseEvent *) if (this->m_mouseDragScrollbar) { this->m_mouseDragScrollbar = false; repaint(); - } else { + } + else { if (this->m_titlePressColumn != -1) { this->m_titlePressColumn = -1; repaint(); @@ -537,11 +683,10 @@ void ProcessListWidget::wheelEvent(QWheelEvent *event) { if (event->orientation() == Qt::Vertical) { this->m_origOffset = this->m_offSet; - qreal scrollStep = event->angleDelta().y() / 120.0; + qreal scrollStep = event->angleDelta().y() / 100.0; this->m_offSet = setOffset(this->m_offSet - scrollStep * this->m_rowHeight); repaint(); } - event->accept(); } @@ -552,7 +697,6 @@ void ProcessListWidget::paintEvent(QPaintEvent *) QList titleItemsWidths = getTitleItemsWidths(); - painter.setRenderHint(QPainter::Antialiasing, true); painter.setOpacity(0.05); int penWidth = 1; @@ -571,8 +715,8 @@ void ProcessListWidget::paintEvent(QPaintEvent *) int title_Y = 0; int title_Height = 0; if (this->m_titleHeight > 0) { - int columnCounter = 0; - int columnX = 0; + int counter = 0; + int posX = 0; for (int itemWidth:titleItemsWidths) { if (itemWidth > 0) { painter.setOpacity(1); @@ -581,48 +725,47 @@ void ProcessListWidget::paintEvent(QPaintEvent *) painter.setFont(font); //标题文字 painter.setPen(QPen(QColor("#000000"))); - painter.drawText(QRect(columnX + this->m_titlePadding, 0, itemWidth, this->m_titleHeight), Qt::AlignVCenter | Qt::AlignLeft, this->columnTitles[columnCounter]); - columnX += itemWidth; - if (columnCounter < titleItemsWidths.size() - 1) {//垂直分割线 + painter.drawText(QRect(posX + this->m_titlePadding, 0, itemWidth, this->m_titleHeight), Qt::AlignVCenter | Qt::AlignLeft, this->columnTitles[counter]); + posX += itemWidth; + if (counter < titleItemsWidths.size() - 1) {//垂直分割线 painter.setOpacity(0.1); QPainterPath separatorPath; - separatorPath.addRect(QRectF(rect().x() + columnX - 1, rect().y() + 5, 1, this->m_titleHeight - 5*2)); + separatorPath.addRect(QRectF(rect().x() + posX - 1, rect().y() + 5, 1, this->m_titleHeight - 5*2)); painter.fillPath(separatorPath, QColor("#000000")); } //标题文字右侧的排序箭头图标 - if (this->m_defaultSortColumn == columnCounter) { + if (this->m_currentSortIndex == counter) { painter.setOpacity(1); - int arrowX = rect().x() + columnX - this->m_arrowPadding - upArrowNormalPixmap.width() / upArrowNormalPixmap.devicePixelRatio(); - int arrowY = rect().y() + (this->m_titleHeight - downArrowNormalPixmap.height() / upArrowNormalPixmap.devicePixelRatio()) / 2; + int arrowX = rect().x() + posX - 2 - m_upArrowNormalPixmap.width() / m_upArrowNormalPixmap.devicePixelRatio(); + int arrowY = rect().y() + (this->m_titleHeight - m_downArrowNormalPixmap.height() / m_upArrowNormalPixmap.devicePixelRatio()) / 2; - if (this->m_defaultSortOrder) { - if (this->m_titlePressColumn == this->m_defaultSortColumn) { - painter.drawPixmap(QPoint(arrowX, arrowY), downArrowPressPixmap); - } else if (this->m_titleHoverColumn == this->m_defaultSortColumn) { - painter.drawPixmap(QPoint(arrowX, arrowY), downArrowHoverPixmap); + if (this->m_isSort) { + if (this->m_titlePressColumn == this->m_currentSortIndex) { + painter.drawPixmap(QPoint(arrowX, arrowY), m_downArrowPressPixmap); + } else if (this->m_titleHoverColumn == this->m_currentSortIndex) { + painter.drawPixmap(QPoint(arrowX, arrowY), m_downArrowHoverPixmap); } else { - painter.drawPixmap(QPoint(arrowX, arrowY), downArrowNormalPixmap); + painter.drawPixmap(QPoint(arrowX, arrowY), m_downArrowNormalPixmap); } } else { - if (this->m_titlePressColumn == this->m_defaultSortColumn) { - painter.drawPixmap(QPoint(arrowX, arrowY), upArrowPressPixmap); - } else if (this->m_titleHoverColumn == this->m_defaultSortColumn) { - painter.drawPixmap(QPoint(arrowX, arrowY), upArrowHoverPixmap); + if (this->m_titlePressColumn == this->m_currentSortIndex) { + painter.drawPixmap(QPoint(arrowX, arrowY), m_upArrowPressPixmap); + } else if (this->m_titleHoverColumn == this->m_currentSortIndex) { + painter.drawPixmap(QPoint(arrowX, arrowY), m_upArrowHoverPixmap); } else { - painter.drawPixmap(QPoint(arrowX, arrowY), upArrowNormalPixmap); + painter.drawPixmap(QPoint(arrowX, arrowY), m_upArrowNormalPixmap); } } } } - columnCounter++; + counter++; } title_Y += this->m_titleHeight; title_Height += this->m_titleHeight; } - //去掉列表标题栏后的列表显示区域的背景 painter.setOpacity(0.05); QPainterPath backgroundPath; @@ -631,7 +774,7 @@ void ProcessListWidget::paintEvent(QPaintEvent *) //进程信息 QPainterPath scrollAreaPath; - scrollAreaPath.addRect(QRectF(rect().x(), rect().y() + this->m_titleHeight, rect().width(), getScrollAreaH())); + scrollAreaPath.addRect(QRectF(rect().x(), rect().y() + this->m_titleHeight, rect().width(), getTheScrollAreaHeight())); int rowCounter = 0; for (ProcessListItem *item:*this->m_searchedItems) { @@ -669,11 +812,9 @@ void ProcessListWidget::paintEvent(QPaintEvent *) if (this->m_searchText != "" && this->m_searchedItems->size() == 0) { painter.setOpacity(1); painter.setPen(QPen(QColor("#666666"))); - QFont font = painter.font() ; font.setPointSize(22); painter.setFont(font); - painter.drawText(QRect(rect().x(), rect().y() + this->m_titleHeight, rect().width(), rect().height() - this->m_titleHeight), Qt::AlignCenter, tr("No search result")); } @@ -695,226 +836,39 @@ void ProcessListWidget::paintEvent(QPaintEvent *) void ProcessListWidget::paintScrollbar(QPainter *painter) { - if (this->getItemsTotalHeight() > getScrollAreaH()) { - qreal barOpacitry = 0; - qreal barFrameOpacitry = 0; - - // Press. + if (this->getItemsTotalHeight() > getTheScrollAreaHeight()) { + qreal opacitry = 0; if (this->m_mouseDragScrollbar) { - barOpacitry = 0.8; - barFrameOpacitry = 0; - } else { - // Hover. - if (this->m_mouseAtScrollArea) { - barOpacitry = 0.7; - barFrameOpacitry = 0; - } - // Normal. - else { - barOpacitry = 0.5; - barFrameOpacitry = 0; - } + opacitry = 0.8; + } + else { + if (this->m_mouseAtScrollArea) + opacitry = 0.7; + else + opacitry = 0.5; } - int barWidth = (this->m_mouseAtScrollArea || this->m_mouseDragScrollbar) ? this->m_scrollbarDragW : 6; - int barRadius = 3; - + int barWidth = (this->m_mouseAtScrollArea || this->m_mouseDragScrollbar) ? this->m_scrollbarWidth : 6; int barY = getScrollbarY(); - int barHeight = getScrollbarH(); - - painter->setOpacity(barOpacitry); + int barHeight = getScrollbarHeight(); + painter->setOpacity(opacitry); QPainterPath path; path.addRoundedRect( QRectF(rect().x() + rect().width() - barWidth - 4, - barY + barRadius, + barY + 2, barWidth, - barHeight - barRadius * 2), barRadius, barRadius); + barHeight - 2 * 2), 2, 2); painter->fillPath(path, QColor("#0B95D7")); QPen pen; pen.setColor(QColor("#0B95D7")); pen.setWidth(1); - painter->setOpacity(barFrameOpacitry); + painter->setOpacity(0); painter->setPen(pen); painter->drawPath(path); } } -void ProcessListWidget::selectNextItem(int offset) -{ - this->m_origOffset = this->m_offSet; - - if (this->m_selectedItems->empty()) { - selectFirstItem(); - } else { - int lastIndex = 0; - for (ProcessListItem *item:*this->m_selectedItems) { - int index = this->m_searchedItems->indexOf(item); - if (index > lastIndex) { - lastIndex = index; - } - } - - if (lastIndex != -1) { - lastIndex = std::min(this->m_searchedItems->count() - 1, lastIndex + offset); - - clearSelectedItems(false); - - QList items = QList(); - items << (*this->m_searchedItems)[lastIndex]; - - addSelectedItems(items); - - int itemIndex = lastIndex + 1; - int itemOffset = setOffset(itemIndex * this->m_rowHeight - rect().height() + this->m_titleHeight); - if (((this->m_offSet + getScrollAreaH()) / this->m_rowHeight) < itemIndex) { - this->m_offSet = itemOffset; - } - - repaint(); - } - } -} - -void ProcessListWidget::selectPrevItem(int offset) -{ - this->m_origOffset = this->m_offSet; - - if (this->m_selectedItems->empty()) { - selectFirstItem(); - } else { - int firstIndex = this->m_searchedItems->count(); - for (ProcessListItem *item:*this->m_selectedItems) { - int index = this->m_searchedItems->indexOf(item); - if (index < firstIndex) { - firstIndex = index; - } - } - - if (firstIndex != -1) { - firstIndex = std::max(0, firstIndex - offset); - - clearSelectedItems(); - - QList items = QList(); - items << (*this->m_searchedItems)[firstIndex]; - - addSelectedItems(items); - - int itemIndex = firstIndex - 1; - int itemOffset = setOffset(itemIndex * this->m_rowHeight + this->m_titleHeight); - if ((this->m_offSet / this->m_rowHeight) > itemIndex) { - this->m_offSet = itemOffset; - } - repaint(); - } - } -} - -void ProcessListWidget::shiftSelectItemsWithBound(int startIndex, int endIndex) -{ - clearSelectedItems(false); - QList items = QList(); - int index = 0; - for (ProcessListItem *item:*this->m_searchedItems) { - if (index >= startIndex && index <= endIndex) { - items << item; - } - - index++; - } - addSelectedItems(items, false); -} - -void ProcessListWidget::shiftSelectPrevItem(int offset) -{ - this->m_origOffset = this->m_offSet; - - if (this->m_selectedItems->empty()) { - selectFirstItem(); - } else { - int firstIndex = this->m_searchedItems->count(); - int lastIndex = 0; - for (ProcessListItem *item:*this->m_selectedItems) { - int index = this->m_searchedItems->indexOf(item); - - if (index < firstIndex) { - firstIndex = index; - } - - if (index > lastIndex) { - lastIndex = index; - } - } - - if (firstIndex != -1) { - int lastSelectionIndex = this->m_searchedItems->indexOf(this->lastSelectItem); - int selectionStartIndex, selectionEndIndex; - - if (lastIndex == lastSelectionIndex) { - selectionStartIndex = std::max(0, firstIndex - offset); - selectionEndIndex = lastSelectionIndex; - } else { - selectionStartIndex = firstIndex; - selectionEndIndex = std::max(0, lastIndex - offset); - } - - shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); - - if (this->m_offSet / this->m_rowHeight >= selectionStartIndex) { - this->m_offSet = setOffset((selectionStartIndex - 1) * this->m_rowHeight + this->m_titleHeight); - } - - repaint(); - } - } -} - -void ProcessListWidget::shiftSelectNextItem(int offset) -{ - this->m_origOffset = this->m_offSet; - - if (this->m_selectedItems->empty()) { - selectFirstItem(); - } else { - int firstIndex = this->m_searchedItems->count(); - int lastIndex = 0; - for (ProcessListItem *item:*this->m_selectedItems) { - int index = this->m_searchedItems->indexOf(item); - - if (index < firstIndex) { - firstIndex = index; - } - - if (index > lastIndex) { - lastIndex = index; - } - } - - if (firstIndex != -1) { - int lastSelectionIndex = this->m_searchedItems->indexOf(this->lastSelectItem); - int selectionStartIndex, selectionEndIndex; - - if (firstIndex == lastSelectionIndex) { - selectionStartIndex = firstIndex; - selectionEndIndex = std::min(this->m_searchedItems->count() - 1, lastIndex + offset); - } else { - selectionStartIndex = std::min(this->m_searchedItems->count() - 1, firstIndex + offset); - selectionEndIndex = lastIndex; - } - - shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); - - if ((this->m_offSet + rect().height()) / this->m_rowHeight <= selectionEndIndex + 1) { - this->m_offSet = setOffset((selectionEndIndex + 1) * this->m_rowHeight + this->m_titleHeight - rect().height()); - } - - - repaint(); - } - } -} - QList ProcessListWidget::getTitleItemsWidths() { QList titleItemsWidths; @@ -929,16 +883,15 @@ QList ProcessListWidget::getTitleItemsWidths() } } else { if (m_columnVisibles[i]) { - int totalWidthOfOtherColumns = 0; - + int totalWidth = 0; for (int j = 0; j < this->m_columnWidths.count(); j++) { if (this->m_columnWidths[j] != -1 && m_columnVisibles[j]) { - totalWidthOfOtherColumns += this->m_columnWidths[j]; + totalWidth += this->m_columnWidths[j]; } } - - titleItemsWidths << rect().width() - totalWidthOfOtherColumns; - } else { + titleItemsWidths << rect().width() - totalWidth; + } + else { titleItemsWidths << 0; } } @@ -947,7 +900,8 @@ QList ProcessListWidget::getTitleItemsWidths() for (int i = 0; i < this->m_columnWidths.count(); i++) { if (m_columnVisibles[i]) { titleItemsWidths << this->m_columnWidths[i]; - } else { + } + else { titleItemsWidths << 0; } } @@ -962,7 +916,7 @@ QList ProcessListWidget::getTitleItemsWidths() bool ProcessListWidget::mouseAtScrollArea(int x) { - return (x > rect().x() + rect().width() - this->m_scrollbarDragW) && (x < rect().x() + rect().width()); + return (x > rect().x() + rect().width() - this->m_scrollbarWidth) && (x < rect().x() + rect().width()); } bool ProcessListWidget::mouseAtTitleArea(int y) @@ -980,24 +934,19 @@ int ProcessListWidget::getItemsTotalHeight() return m_searchedItems->count() * m_rowHeight; } -int ProcessListWidget::getScrollAreaH() +int ProcessListWidget::getTheScrollAreaHeight() { - return rect().height() - this->m_titleHeight; + return this->rect().height() - this->m_titleHeight; } int ProcessListWidget::getScrollbarY() { - return static_cast((this->m_offSet / (this->getItemsTotalHeight() * 1.0)) * getScrollAreaH() + this->m_titleHeight); + return static_cast((this->m_offSet / (this->getItemsTotalHeight())) * getTheScrollAreaHeight() + this->m_titleHeight); } -int ProcessListWidget::getScrollbarH() +int ProcessListWidget::getScrollbarHeight() { - return std::max(static_cast(getScrollAreaH() / (this->getItemsTotalHeight() * 1.0) * rect().height()), this->m_scrollbarMinH); -} - -int ProcessListWidget::getTopOffset() -{ - return 0; + return std::max(static_cast(getTheScrollAreaHeight() / (this->getItemsTotalHeight()) * rect().height()), this->m_rowHeight); } QList ProcessListWidget::getSearchedItems(QList items) @@ -1026,11 +975,11 @@ int ProcessListWidget::getBottomOffset() } } -void ProcessListWidget::sortItemsByColumn(int column, bool sortOrder) +void ProcessListWidget::sortItemsByColumn(int column, bool isSort) { - if (m_sortFuncList->count() != 0 && m_sortFuncList->count() == columnTitles.count() && m_sortOrderes->count() == columnTitles.count()) { + if (m_sortFuncList->count() != 0 && m_sortFuncList->count() == columnTitles.count() && m_isSortList->count() == columnTitles.count()) { qSort(m_searchedItems->begin(), m_searchedItems->end(), [&](const ProcessListItem *item1, const ProcessListItem *item2) { - return (*m_sortFuncList)[column](item1, item2, sortOrder); + return (*m_sortFuncList)[column](item1, item2, isSort); }); } } @@ -1040,7 +989,6 @@ void ProcessListWidget::startScrollbarHideTimer() if (this->m_hideScrollbarTimer) { this->m_hideScrollbarTimer->stop(); } - this->m_hideScrollbarTimer = new QTimer(); connect(this->m_hideScrollbarTimer, SIGNAL(timeout()), this, SLOT(hideScrollbar())); this->m_hideScrollbarTimer->start(2000); diff --git a/plugins/systemmonitor/processlistwidget.h b/plugins/systemmonitor/processlistwidget.h index 744d700..707c5fe 100644 --- a/plugins/systemmonitor/processlistwidget.h +++ b/plugins/systemmonitor/processlistwidget.h @@ -38,48 +38,48 @@ class ProcessListWidget : public QWidget public: ~ProcessListWidget(); - ProcessListWidget(QList columnShowOrHideFlags, QWidget *parent = 0); + ProcessListWidget(QList toBeDisplayedColumns, QWidget *parent = 0); - void setColumnSortingAlgorithms(QList *list, int sortColumn=-1, bool sortOrder=false); + void setProcessSortFunctions(QList *list, int sortColumn=-1, bool isSort=false); void setSearchFunction(SearchFunction func); void addItems(QList items); void clearItems(); - void addSelectedItems(QList items, bool recordLastSelection=true); - void clearSelectedItems(bool clearTheLast=true); + void addSelectedItems(QList items, bool recordLastItem=true); + void clearSelectedItems(bool clearLast=true); void refreshItems(QList 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 getSearchedItems(QList 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 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 items); + void rightMouseClickedItems(QPoint pos, QList items); void changeColumnVisible(int index, bool visible, QList 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 *m_listItems; QList *m_searchedItems; QList *m_selectedItems; QList columnTitles; QList *m_sortFuncList; - QList *m_sortOrderes; + QList *m_isSortList; QList m_columnWidths; QList 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 diff --git a/plugins/systemmonitor/processworker.cpp b/plugins/systemmonitor/processworker.cpp index e6362e6..a888ad3 100644 --- a/plugins/systemmonitor/processworker.cpp +++ b/plugins/systemmonitor/processworker.cpp @@ -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;*/ } diff --git a/plugins/systemmonitor/propertiesdialog.cpp b/plugins/systemmonitor/propertiesdialog.cpp index d00b85b..92b78d6 100644 --- a/plugins/systemmonitor/propertiesdialog.cpp +++ b/plugins/systemmonitor/propertiesdialog.cpp @@ -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); -}*/ diff --git a/plugins/systemmonitor/resourcesdialog.cpp b/plugins/systemmonitor/resourcesdialog.cpp index b6c213d..6d5deb0 100644 --- a/plugins/systemmonitor/resourcesdialog.cpp +++ b/plugins/systemmonitor/resourcesdialog.cpp @@ -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; } diff --git a/plugins/systemmonitor/systemmonitor.cpp b/plugins/systemmonitor/systemmonitor.cpp index 9113f4a..2347d6e 100644 --- a/plugins/systemmonitor/systemmonitor.cpp +++ b/plugins/systemmonitor/systemmonitor.cpp @@ -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 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 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 columnNames = { - "name", "user", "status", "cpu", "pid", "command", "memory", "priority" - }; + QList 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 SystemMonitor::getColumnHideFlags() +QList 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 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 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() diff --git a/plugins/systemmonitor/systemmonitor.h b/plugins/systemmonitor/systemmonitor.h index 0604888..57437be 100644 --- a/plugins/systemmonitor/systemmonitor.h +++ b/plugins/systemmonitor/systemmonitor.h @@ -44,14 +44,14 @@ public: void initPanelStack(); void initConnections(); - QList getColumnHideFlags(); - bool getSortOrder(); - int getSortIndex(); + QList getReadyDisplayColumns(); + bool isSortOrNot(); + int getCurrentSortColumnIndex(); void moveCenter(); public slots: void recordVisibleColumn(int, bool, QList columnVisible); - void recordSortStatus(int index, bool sortOrder); + void recordSortStatus(int index, bool isSort); void onChangePage(int index); protected: diff --git a/plugins/systemmonitor/toolbar.cpp b/plugins/systemmonitor/toolbar.cpp index 2e5f357..c5254a5 100644 --- a/plugins/systemmonitor/toolbar.cpp +++ b/plugins/systemmonitor/toolbar.cpp @@ -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); diff --git a/plugins/systemmonitor/util.h b/plugins/systemmonitor/util.h index e3b9101..3325198 100644 --- a/plugins/systemmonitor/util.h +++ b/plugins/systemmonitor/util.h @@ -24,7 +24,7 @@ #include #include -#define TOP_TITLE_WIDGET_HEIGHT 39 +#define TITLE_WIDGET_HEIGHT 39 using std::string; diff --git a/setting/soundwidget.cpp b/setting/soundwidget.cpp index f815ae2..7447c09 100644 --- a/setting/soundwidget.cpp +++ b/setting/soundwidget.cpp @@ -172,20 +172,22 @@ void SoundWidget::initSettingData() void SoundWidget::onSendSoundList(const QString ¤tSound, const QStringList &soundList) { - m_soundlist.clear(); - m_soundlist = soundList; - theme_combo->clear(); - theme_combo->clearEditText(); - theme_combo->addItems(m_soundlist); + if (!soundList.isEmpty()) { + m_soundlist.clear(); + m_soundlist = soundList; + theme_combo->clear(); + theme_combo->clearEditText(); + theme_combo->addItems(m_soundlist); - QList::Iterator it = m_soundlist.begin(), itend = m_soundlist.end(); - int initIndex = 0; - for(;it != itend; it++,initIndex++) - { - if(*it == currentSound) - break; + QList::Iterator it = m_soundlist.begin(), itend = m_soundlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == currentSound) + break; + } + theme_combo->setCurrentIndex(initIndex); } - theme_combo->setCurrentIndex(initIndex); } void SoundWidget::onSendEnableSoundValue(bool login_music, bool sound_event, bool input_sound) diff --git a/src/img.qrc b/src/img.qrc index e20c9ea..d543e8f 100644 --- a/src/img.qrc +++ b/src/img.qrc @@ -222,6 +222,11 @@ res/upload.svg res/wave-back.png res/wave-front.png + res/disk.png + res/sub_logo.png + res/user_proc.png + res/active_proc.png + res/all_proc.png res/sysBtn/close_button.png diff --git a/src/res/active_proc.png b/src/res/active_proc.png new file mode 100644 index 0000000000000000000000000000000000000000..c2ad1dccb6df9d30983879e6e5b52f36881028fa GIT binary patch literal 1381 zcmaJ>ZA=?w96u<+9Am|VU>TXY9cG(`>)mto?ap-wcfGAjfiVJ2jBeN7({h3KZr8&W zG|DhpMuaURgE?F>W5&b;b;OT+z`}-87l<#+m-+T((Zod-F%mbRJ_U;VK=ve;d;b6X z{r>O&>#46jP_T8!Rt&=mya$B_^e#+4TXHchtL5+6MI@9M9=~x|4Hz66I1M4%zziAY;C#wFaus$CA<(`t&q zS0P5Ln^+6V@2kgoRfo9U>L7!l!i76oE3mUJ##W9qG;mNfO92~61CC}n8sO`PK;CpY z#5D-wx-TTTi5A1qIEsqLQb zFs8QaLDY{>S%!>i_i#sPAc}^o(-qVdsZCIW?GYF?yn>rRU#zksb56E`ciF@$r@+#J z2takU&E|0mE*sCg1ee2;v9TGKb%@mr@1aEz2mpATRW!?s!0EB`jw%P^6f<0JG-gQA zAk6qxkl!_~AU>4K@j8?YRc}<)w#)?7x2T31Yf&|v=hGc`;(MEwsI10gPo-P5mazbJ zJbLV^0u}h~loa%6;d_ZT`Z+fq~^c#m~+$M{_E!KTnHI zO*daCEiK(uc>nsDviZxtw|Dnm+Wv%gcWG*R`b40iwsyN|?=!EiER|dh34?so7v1HS zojaFPi}Sx&Ui*1G{tsrh$|`O54~|MZ%i9y7(bviNVaTf2(YO+4nAzju6OToZSPJxXzyC7p~$+%VT=jaySMa4+bh?D z7D%+i1g9a{2ZLE6A6OO>BVj?J$s8dBAu@DsGk!s{=yaN)BOu8lGePk!P}~QyOD^|5 z&pp5A`91&McUoIsJXm_96vMEC{w67izK3&fi50^Nq7QFvAfd|iwwb5(h?$lRh`Cig z3~_&4?tnoktG!)|upYyTvRbIkYzs6CiXOMgIU8FhoLSkA19TuM!l>5NXTZ~aEg_|^Q{h#j;Ur$45s-s8G-W&!k0nw<#zk!V70@}S zrU-o7#O!ntJEYnIt+=Qg5VzYLqyp+V+{xR3o#z<#1kTXFLD4(~Sds<;%?mWZcOL>p zGt`I>lzh9fkmMqwrkNBdDxFT-(sef7=%4`4^Aycc3_~IdGS!p7SV&^={KeAf`Jh#FK%*p5sJnw@|2LR7Orxz(!N?crLGP>y#OU|I^slIu+_o zLMjMTdbgpVene{WU{t#&2g(^DHp0t>hMFSBBwgu_!-VOVTm<@KQ#Dm^@^vD|`rJ;5 zrzIZ%9uLcUof5~2A}4VUZ{Ej#SdO;?yXY2uJ|F?$b#kH`aIEC^w&XJJ_8bAP`lav*XCL^@0Dh#JOK!hPEM3Ksk&0}MfSE1R=9ru<3343b= z6KIzVv@{FvUV0PlZHr%WhcZ8eH@CJLib`nESkQ=p@OjK~xY;7n1JR2IYKE*O_|@mH zzCSYZ?8Nn77vKA2to@IbmCZw6&;?nna4gx?_4lp0xw$`o`?_M#)&Cc5wOF#{v89P~ zWwEirLF?Sc+E24=$>zWR9366Ji=~go#_Empc=g_3*^UOG|CO z_R6jMckg2Tywh2+YUNg!mmghdzWjDkP2WY#a%_0$6lOh#XFQ)iv-!b?7bYGSpIn%E zs%K!Nx^|(w`ZaY*Y5yJ`iZnj`RhS)xDnFUFP?; KNLM`V1OEXyWYI$a literal 0 HcmV?d00001 diff --git a/src/res/disk.png b/src/res/disk.png new file mode 100644 index 0000000000000000000000000000000000000000..0e3117805319659e7de3c1382542602c2834d95e GIT binary patch literal 1135 zcmaJ>&uipV9Dn01!%%mju!?RGd1O6UG?TncCdmsO+i5c64!hGGrvp2JhrT2)ozNyP zCaIJ5Vi6V;dg$4M`WMLd>_HETKMv|aP{hN6C@3s~Ea*kMFP%JW!sN))HU_((~hKh_dNyZXVMH!hgHf01)AAv_pJl`DHozqxcY6{~l zi%m(IOeVESy~dJF31N&SS&29Tg+g*0G`MZLOuM2(@HeS7z95lx8Gy=`3zg#GPWT$6`$@p(JC;kg@IA z1oX!&W9gX1(6Wk->+r=}LFBPXx>&Smnz2oj;4SKP5*EUf8k@m698|}56-=n;xV|Pj zhT0IFx}%85@indP)D0aw!YST+q;}I8(v?^42-=EKUpU--h^?%J(k{$i7T=@Ol>&LHM*Z?n-=2zmT{MqOGl{<6Q|HU8O3*->2 z0P@r7_tigN0#$hNZCF0E{#umAu6 literal 0 HcmV?d00001 diff --git a/src/res/qss/kylin-assistant.qss b/src/res/qss/kylin-assistant.qss index 69403d5..e5c64d7 100644 --- a/src/res/qss/kylin-assistant.qss +++ b/src/res/qss/kylin-assistant.qss @@ -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); } diff --git a/src/res/search.png b/src/res/search.png index eafb953e27c429df4ad01d51d223b0d5d8aaa3b4..ecbf4c7b67ac6838b00ae3f94d5a80d6ee4dd819 100644 GIT binary patch delta 755 zcmeC?yvj8}hLthn%lYpU6*U+eCVKU$n&~DR8e1rsTk08_T3Q&H=qMN&7@FxDSn3;^ z=o%PW8CY5w7*70KGI#2lCWUU^m6(#Blxmfd zpA7U*K}LQ_esM;Aft8`Dk&&gjsfBJ@8Zc}O4O7i^6O%0rbkhtHQ<9A=Qp^m~j3(8Mh1U@+ru1*6BoD4C+w30#jFEx3J+ zxV8Ag3dB3o89u5h{Nr4j?r>C+fr&?qk0;>$x+bkzOhKk8uW~qE= ze?psQ38R_9Kb}uQCw^KtSTwmXH#Jnq>+tMZn0SD>R8EnBtGOgYqJddp$}69R3+vcs zwK?cbYO)IDI%Ur^^*%rEoB9_QJ@|g`GboltJ}zhp+seSe#lYa{>gTe~DWM4fvf%o% delta 544 zcmcc0)y+9UhLu77^Z&$&iW-cH6TSLWO?8tE3{4cwE%gjd4NWWzbrg&Y42|^-jP(tT zbq$TI3@oh-O(*^>nS6&)X>t~0_T*hmN}L+unRzMs<;9wltC(aIOw3#jUChm$oJ<|f z4Gmq~EX+(?+{|1ojGde;UCbRVCfgwtIpb9Hipek+HA)J_B|)iaRw?<(rManj zC7v#}N)@>UdMTMHR!~Pc;?g_0huNuqlI7nO3=E76o-U3d6}OW9{QqyytlH4o=yae- z(crJ1^n_Ckk31BvHFCu>K6>h4^VomcC;d5k3|Z6Ig47#th<2=Qh!E;py&y?_Vb+5N zK{2*~*^aZWGv{U=dUfYzd3Hkxhrn#+tAAX|9jyfHk1myDX(-ZlcqJ&XJn^%Wh`@KD zdcnNE0b3>5Bp5$RD)BI^G+d%0<=FU5dN$+ph8ry$%svY*b|o@s%;WAfSRk-U>~O8N~Sf+9wF?3kN zDY}pEh<8JUl|VGpM=1q9HpxRCet9fWN&KcNaxD|@yx}osQ8>V0vnph=*c)>N1|aZs L^>bP0l+XkKx(cyQ diff --git a/src/res/sub_logo.png b/src/res/sub_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..bb116014f8c50ecab1bc498e9ee0edeae724ada0 GIT binary patch literal 5525 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 literal 0 HcmV?d00001 diff --git a/src/res/user_proc.png b/src/res/user_proc.png new file mode 100644 index 0000000000000000000000000000000000000000..97745a754b5e8903dd111a05ec0409ab2b28c97e GIT binary patch literal 1463 zcmaJ>ZA{c=94{a*BZp|F0=i&VvV^_#+NbpH+R6=%>)j*~m6srnWZJtvciiCG(ktG9 zQ32g$63v$E!(yC^%3>y)M59KgqD+jLk!=LNY$O{ab8ItlxVb38273-T<_F@FG<}|@ z|KIQb`@i+z*3EBZq_0iKFf5~Vqga97D`HPt3Wg=r{r&A@bjUGWHAbcCGs2P%F^8;r zAYK}j{ICK_a&zNtScqXst%0fLD`B0$RX{s<&SDWA3=_we zDj`EsyfE%Jfc!3CozKJyP8~{ys#mFML%ajF)~SXXs#7)G>5Ns}hUae!D6$$3y&Nmi ze8eKu1G}K?*3}?Bmt!HYga*b#TUeQ8NQPl#68cz3a?nbX63g&_1|GlyE3tr=pUT~Q zkD?nChZdJ301LzLHVa4ke5e5dfHqR{ay03qCE3exvK9Ckf9e#=s3RyQ8CHrj^4IZkh;D z6lXr`>N<6dYdo2GYMDs4XJZKm29uI^4v!BUdAQ!ydi3bJ6U#pR<<7n|>|73(n5IN~ zd-r5zW^VcGLu$v(<++8ES*O~PZ#{VQ$h>;>YB)GNydmT6+7tQtX7jbXV`B+xXsgxw z=G6%J4y_uu$$#Uc#D_vLHdfKs>Pa4K8z@e_mMCcE!8VwkZZes2f4_Gx{olzyJ6C;0 z_NN``>FLQD7#J{(Ufa`uHu3Z0-Q9{MH8r)rclYC&ldobM^q+4Xp8cYyCp)(=(uZA$ zCVY}D{yIL+Fva^7pLsIAF(ST3bz*I-|riG@A73~|Di*ho_qh`FlJEPj^380>F>|`w>w_Q%j+CP z%pVtzztx^H`Q%A+(g!1JDl02fs;kfLjZQzFD3JaBf|S(M*{l^STI;7Cj3xDtT&&M2 zzk2-4nci}TqiyVmD`D-O^+kIRyi^|T>UyOoQd_&umwn;VrSm`Oy1LAlLVE_OC literal 0 HcmV?d00001 diff --git a/src/settingwidget.cpp b/src/settingwidget.cpp index 05b0514..d4e6c3f 100644 --- a/src/settingwidget.cpp +++ b/src/settingwidget.cpp @@ -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 diff --git a/src/settingwidget.h b/src/settingwidget.h index eed28ed..5d1bb64 100644 --- a/src/settingwidget.h +++ b/src/settingwidget.h @@ -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;