Skip to content

Commit

Permalink
1、线程池使用 2、修改UI
Browse files Browse the repository at this point in the history
  • Loading branch information
MingYueRuYa committed Oct 12, 2024
1 parent 693e740 commit 673bd74
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 34 deletions.
34 changes: 13 additions & 21 deletions WindbgIFEO/WindbgIFEO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "everything/Everything.h"

WindbgIFEO::WindbgIFEO(QWidget* parent)
: QWidget(parent), _map_windbg_path(), _stop_enum_process(false) {
: QWidget(parent), _map_windbg_path() {
ui.setupUi(this);
_workbranch_ptr = std::make_unique<wsp::workbranch>(2);
this->_init_ui();
Expand All @@ -29,16 +29,6 @@ WindbgIFEO::WindbgIFEO(QWidget* parent)
}

WindbgIFEO::~WindbgIFEO() {
_stop_enum_process = true;
std::vector<std::unique_ptr<std::thread>*> thr_ptr = { &_query_windbg_ptr
};
for (auto& item : thr_ptr) {
if ((*item)->joinable()) {
this->log_info(tr("wait thread exit..."));
(*item)->join();
}
}

_workbranch_ptr->wait_tasks();
}

Expand Down Expand Up @@ -332,7 +322,7 @@ void WindbgIFEO::log_info(const QString& info, LOG_TYPE type) {
}

void WindbgIFEO::_query_windbg_path() {
// std::thread thr();
this->log_info(tr("Start serach windbg path"));
auto func = [this]() {
Everything_SetMatchCase(true);
Everything_SetMatchWholeWord(true);
Expand All @@ -350,12 +340,11 @@ void WindbgIFEO::_query_windbg_path() {
QString("\\") +
QString::fromStdWString(Everything_GetResultFileName(i));
map_path[path] = path;
qDebug() << path;
}
this->_add_windbg_path(map_path);
};

_query_windbg_ptr = std::make_unique<std::thread>(func);
_workbranch_ptr->submit(func);
}

void WindbgIFEO::_enum_process_name() {
Expand Down Expand Up @@ -494,10 +483,6 @@ void WindbgIFEO::_init_signal() {
connect(this, SIGNAL(finished_windbg_exes()), this,
SLOT(on_update_windbg_path()), Qt::QueuedConnection);

// connect(ui.chb_chinese, SIGNAL(stateChanged(int)), this,
// SLOT(on_chinese_stateChanged(int)));
// connect(ui.chb_english, SIGNAL(stateChanged(int)), this,
// SLOT(on_english_stateChanged(int)));
connect(ui.comboBox_attach_name, SIGNAL(currentTextChanged(QString)), this,
SLOT(on_attach_name_changed(QString)));
connect(ui.chb_auto_start, SIGNAL(stateChanged(int)), this,
Expand All @@ -507,9 +492,12 @@ void WindbgIFEO::_init_signal() {
}

void WindbgIFEO::on_update_windbg_path() {
this->log_info(tr("finished search windbg path"));
disconnect(this, SLOT(on_comboBoxChanged(QString)));
std::for_each(
this->_map_windbg_path.begin(), this->_map_windbg_path.end(),
[this](const std::pair<QString, QString>& value) {
this->ui.comboBox_windbg_path->clear();
QString windbg_path = value.second;
if (windbg_path.contains("arm")) {
this->log_info(QString(tr("filter arm version windbg path:%1"))
Expand Down Expand Up @@ -539,7 +527,6 @@ void WindbgIFEO::on_update_process_info() {
}
for (auto& item : vec_com) {
item->blockSignals(true);
// item->clear();
this->_remove_combo_item(item);
item->addItems(process_list);
item->blockSignals(false);
Expand Down Expand Up @@ -569,16 +556,21 @@ void WindbgIFEO::on_comboBoxLanguage(const QString& text) {
this->update();
}

void WindbgIFEO::on_btn_refresh_clicked()
void WindbgIFEO::on_btn_refresh_process_clicked()
{
this->_enum_process_name();
}

void WindbgIFEO::on_btn_refresh_2_clicked()
void WindbgIFEO::on_btn_refresh_process_2_clicked()
{
this->_enum_process_name();
}

void WindbgIFEO::on_btn_refresh_path_clicked()
{
this->_query_windbg_path();
}

void WindbgIFEO::on_btn_close_clicked() {
this->close();
}
Expand Down
8 changes: 3 additions & 5 deletions WindbgIFEO/WindbgIFEO.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ protected slots:
void on_comboBoxChanged(const QString& text);
void on_comboBoxLanguage(const QString& text);

void on_btn_refresh_clicked();
void on_btn_refresh_2_clicked();
void on_btn_refresh_process_clicked();
void on_btn_refresh_process_2_clicked();
void on_btn_refresh_path_clicked();

void on_btn_close_clicked();
void on_btn_mini_clicked();
Expand Down Expand Up @@ -102,11 +103,8 @@ protected slots:

private:
Ui::WindbgIFEOClass ui;
bool _stop_enum_process;
map_qstring _map_windbg_path;
ProcessHelper::process_map _proces_info;
std::unique_ptr<std::thread> _query_windbg_ptr;
std::unique_ptr<std::thread> _enum_process_ptr;
RegEditorHelper _reg_editor_helper;

const QString _ifeo_reg_path =
Expand Down
59 changes: 53 additions & 6 deletions WindbgIFEO/WindbgIFEO.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
<width>1167</width>
<height>644</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1167</width>
<height>644</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -298,6 +304,47 @@ QPushButton:pressed{border-image: url(&quot;:/WindbgConfig/images/close_pressed.
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_refresh_path">
<property name="minimumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border:None;
background-color:#FFFFFF;
qproperty-icon: url(:/WindbgConfig/images/def_100_precent/refresh.png) center;
border-radius:12px;
}

QPushButton:hover {
border:None;
qproperty-icon: url(:/WindbgConfig/images/def_100_precent/refresh.png) center;
background-color:#d2d4d9;
border-radius:12px;
}

QPushButton:pressed {
border:None;
qproperty-icon: url(:/WindbgConfig/images/def_100_precent/refresh.png) center;
background-color:#d8dbdf;
border-radius:12px;
}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -473,7 +520,7 @@ background-color:#407ee1;
</property>
<property name="minimumSize">
<size>
<width>170</width>
<width>210</width>
<height>25</height>
</size>
</property>
Expand All @@ -495,7 +542,7 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_refresh">
<widget class="QPushButton" name="btn_refresh_precoess">
<property name="minimumSize">
<size>
<width>25</width>
Expand Down Expand Up @@ -816,7 +863,7 @@ background-color:#407ee1;
</property>
<property name="minimumSize">
<size>
<width>170</width>
<width>210</width>
<height>25</height>
</size>
</property>
Expand All @@ -838,7 +885,7 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_refresh_2">
<widget class="QPushButton" name="btn_refresh_precoess_2">
<property name="minimumSize">
<size>
<width>25</width>
Expand Down
2 changes: 1 addition & 1 deletion WindbgIFEO/WindbgIFEO.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<DebugInformationFormat />
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<AdditionalIncludeDirectories>$(Qt_INCLUDEPATH_);%(AdditionalIncludeDirectories);./3rdparty;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(Qt_INCLUDEPATH_);%(AdditionalIncludeDirectories);./3rdparty;./3rdparty/workspace/include</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
Expand Down
2 changes: 1 addition & 1 deletion WindbgIFEO/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QtWidgets/QApplication>

int main(int argc, char* argv[]) {
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Application app(argc, argv);
WindbgIFEO w;
w.show();
Expand Down

0 comments on commit 673bd74

Please sign in to comment.