2727#include < QtConcurrent/QtConcurrent>
2828#include < QtWinExtras/QtWin>
2929#include < psapi.h>
30- ProcessMonitor::ProcessMonitor (QSettings* settings,
30+ ProcessMonitor::ProcessMonitor (QSettings* settings,
3131 QTreeWidget* treeWidget,
32- QLabel* treeStatusLabel,
33- QLabel* injector32StatusLabel,
34- QLabel* injector64StatusLabel,
35- QObject* parent)
36- : m_treeWidget(treeWidget)
37- , m_treeStatusLabel(treeStatusLabel)
38- , m_injector32StatusLabel(injector32StatusLabel)
39- , m_injector64StatusLabel(injector64StatusLabel)
40- , m_settings(settings)
32+ QLabel* treeStatusLabel,
33+ QLabel* injector32StatusLabel,
34+ QLabel* injector64StatusLabel,
35+ QObject* parent)
36+ : m_treeWidget(treeWidget)
37+ , m_treeStatusLabel(treeStatusLabel)
38+ , m_injector32StatusLabel(injector32StatusLabel)
39+ , m_injector64StatusLabel(injector64StatusLabel)
40+ , m_settings(settings)
4141{
4242 m_treeWidget->header ()->setMinimumHeight (40 );
4343 m_treeWidget->setColumnWidth (0 , 300 );
@@ -80,8 +80,8 @@ ProcessMonitor::refresh()
8080 {
8181 update (processList);
8282 m_treeStatusLabel->setText (QString (tr (" 搜索到%1个进程, 已过滤展示%2个" ))
83- .arg (processList.size ())
84- .arg (processList.size ()));
83+ .arg (processList.size ())
84+ .arg (processList.size ()));
8585 }
8686 else
8787 {
@@ -93,8 +93,8 @@ ProcessMonitor::refresh()
9393 }
9494 update (filtered);
9595 m_treeStatusLabel->setText (QString (tr (" 搜索到%1个进程, 已过滤展示%2个" ))
96- .arg (processList.size ())
97- .arg (filtered.size ()));
96+ .arg (processList.size ())
97+ .arg (filtered.size ()));
9898 }
9999}
100100
152152ProcessMonitor::init ()
153153{
154154 QStringList targetNames =
155- m_settings->value (CONFIG_TARGETNAMES_KEY).toStringList ();
155+ m_settings->value (CONFIG_TARGETNAMES_KEY).toStringList ();
156156 m_targetNames = QSet<QString>(targetNames.begin (), targetNames.end ());
157157}
158158
@@ -232,21 +232,21 @@ ProcessMonitor::update(const QList<ProcessInfo>& processList)
232232 QString priority;
233233 switch (info.priorityClass )
234234 {
235- case HIGH_PRIORITY_CLASS:
236- priority = tr (" 高" );
237- break ;
238- case NORMAL_PRIORITY_CLASS:
239- priority = tr (" 中" );
240- break ;
241- case IDLE_PRIORITY_CLASS:
242- priority = tr (" 低" );
243- break ;
244- case REALTIME_PRIORITY_CLASS:
245- priority = tr (" 实时" );
246- break ;
247- default :
248- priority = tr (" 未知" );
249- break ;
235+ case HIGH_PRIORITY_CLASS:
236+ priority = tr (" 高" );
237+ break ;
238+ case NORMAL_PRIORITY_CLASS:
239+ priority = tr (" 中" );
240+ break ;
241+ case IDLE_PRIORITY_CLASS:
242+ priority = tr (" 低" );
243+ break ;
244+ case REALTIME_PRIORITY_CLASS:
245+ priority = tr (" 实时" );
246+ break ;
247+ default :
248+ priority = tr (" 未知" );
249+ break ;
250250 }
251251 item->setText (4 , priority);
252252 if (m_targetNames.contains (info.name ))
@@ -270,6 +270,7 @@ ProcessMonitor::update(const QList<ProcessInfo>& processList)
270270 QTreeWidgetItem* item = new SortTreeWidgetItem ();
271271
272272 item->setText (0 , info.name );
273+ item->setData (0 , Qt::UserRole, info.name .toLower ());
273274 item->setText (1 , QString::number (info.pid ));
274275 item->setData (1 , Qt::UserRole, (long long )info.pid );
275276 item->setText (2 ,
@@ -285,21 +286,21 @@ ProcessMonitor::update(const QList<ProcessInfo>& processList)
285286 QString priority;
286287 switch (info.priorityClass )
287288 {
288- case HIGH_PRIORITY_CLASS:
289- priority = tr (" 高" );
290- break ;
291- case NORMAL_PRIORITY_CLASS:
292- priority = tr (" 中" );
293- break ;
294- case IDLE_PRIORITY_CLASS:
295- priority = tr (" 低" );
296- break ;
297- case REALTIME_PRIORITY_CLASS:
298- priority = tr (" 实时" );
299- break ;
300- default :
301- priority = tr (" 未知" );
302- break ;
289+ case HIGH_PRIORITY_CLASS:
290+ priority = tr (" 高" );
291+ break ;
292+ case NORMAL_PRIORITY_CLASS:
293+ priority = tr (" 中" );
294+ break ;
295+ case IDLE_PRIORITY_CLASS:
296+ priority = tr (" 低" );
297+ break ;
298+ case REALTIME_PRIORITY_CLASS:
299+ priority = tr (" 实时" );
300+ break ;
301+ default :
302+ priority = tr (" 未知" );
303+ break ;
303304 }
304305 item->setText (4 , priority);
305306 item->setCheckState (5 , Qt::Unchecked);
@@ -359,10 +360,10 @@ ProcessMonitor::startBridge32()
359360 connect (m_bridge32,
360361 &QProcess::readyReadStandardOutput,
361362 [&]()
362- {
363- QByteArray data = m_bridge32->readAllStandardOutput ();
364- qDebug () << " 收到输出:" << QString (data).trimmed ();
365- });
363+ {
364+ QByteArray data = m_bridge32->readAllStandardOutput ();
365+ qDebug () << " 收到输出:" << QString (data).trimmed ();
366+ });
366367}
367368
368369void
@@ -383,10 +384,10 @@ ProcessMonitor::startBridge64()
383384 connect (m_bridge64,
384385 &QProcess::readyReadStandardOutput,
385386 [&]()
386- {
387- QByteArray data = m_bridge64->readAllStandardOutput ();
388- qDebug () << " 收到输出:" << QString (data).trimmed ();
389- });
387+ {
388+ QByteArray data = m_bridge64->readAllStandardOutput ();
389+ qDebug () << " 收到输出:" << QString (data).trimmed ();
390+ });
390391}
391392
392393void
@@ -463,7 +464,7 @@ ProcessMonitor::getDefaultIcon(const QString& processName)
463464 &sfi,
464465 sizeof (SHFILEINFO),
465466 SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |
466- SHGFI_SMALLICON))
467+ SHGFI_SMALLICON))
467468 {
468469 // 将HICON转换为QIcon
469470 icon = QtWin::fromHICON (sfi.hIcon );
@@ -483,7 +484,7 @@ ProcessMonitor::getDefaultIcon(const QString& processName)
483484 &sfi,
484485 sizeof (SHFILEINFO),
485486 SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |
486- SHGFI_SMALLICON))
487+ SHGFI_SMALLICON))
487488 {
488489 // 将HICON转换为QIcon
489490 icon = QtWin::fromHICON (sfi.hIcon );
@@ -499,7 +500,7 @@ QIcon
499500ProcessMonitor::getProcessIcon (QString processPath)
500501{
501502 int lastSlashPos =
502- std::max (processPath.lastIndexOf (' /' ), processPath.lastIndexOf (' \\ ' ));
503+ std::max (processPath.lastIndexOf (' /' ), processPath.lastIndexOf (' \\ ' ));
503504 QString processName;
504505 if (lastSlashPos == -1 )
505506 {
@@ -533,7 +534,7 @@ ProcessMonitor::getProcessIcon(QString processPath)
533534 }
534535
535536 HICON hIcon =
536- ExtractIconW (nullptr , reinterpret_cast <LPCWSTR>(processPath.utf16 ()), 0 );
537+ ExtractIconW (nullptr , reinterpret_cast <LPCWSTR>(processPath.utf16 ()), 0 );
537538 if (hIcon)
538539 {
539540 QIcon icon = QtWin::fromHICON (hIcon);
0 commit comments