Skip to content

Commit

Permalink
修改UI内容
Browse files Browse the repository at this point in the history
  • Loading branch information
MingYueRuYa committed Oct 11, 2024
1 parent 972410a commit 71b3ead
Show file tree
Hide file tree
Showing 44 changed files with 205 additions and 81 deletions.
95 changes: 60 additions & 35 deletions WindbgIFEO/WindbgIFEO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,21 @@ void WindbgIFEO::on_pushButtonPostmortemQuery_clicked() {
std::for_each(this->_arch_map.begin(), this->_arch_map.end(), func);
}

void WindbgIFEO::on_chinese_stateChanged(int state) {
if (state == Qt::Checked) {
((Application*)qApp)->switch_language(Application::Language::ch_ZN);
this->_settings.set_lang("zh_CN");
this->log_info(tr("set language chinese successful"), LOG_TYPE::INFO);
}
}

void WindbgIFEO::on_english_stateChanged(int state) {
if (state == Qt::Checked) {
((Application*)qApp)->switch_language(Application::Language::en_US);
this->_settings.set_lang("en_US");
this->log_info(tr("set language english successful"), LOG_TYPE::INFO);
}
}
// void WindbgIFEO::on_chinese_stateChanged(int state) {
// if (state == Qt::Checked) {
// ((Application*)qApp)->switch_language(Application::Language::zh_CN);
// this->_settings.set_lang("zh_CN");
// this->log_info(tr("set language chinese successful"), LOG_TYPE::INFO);
// }
//}
//
// void WindbgIFEO::on_english_stateChanged(int state) {
// if (state == Qt::Checked) {
// ((Application*)qApp)->switch_language(Application::Language::en_US);
// this->_settings.set_lang("en_US");
// this->log_info(tr("set language english successful"), LOG_TYPE::INFO);
// }
//}

void WindbgIFEO::on_auto_start_stateChanged(int state) {
const QString reg_path =
Expand Down Expand Up @@ -459,17 +459,18 @@ void WindbgIFEO::_init_ui() {
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
_frame_less_helper = new NcFramelessHelper();
_frame_less_helper->activeOnWithChildWidget(this, ui.widget_title);
_frame_less_helper->setWidgetResizable(false);
std::string lang = this->_settings.get_lang();
if (lang == "zh_CN") {
this->ui.chb_chinese->setChecked(true);
((Application*)qApp)->switch_language(Application::Language::ch_ZN);
} else {
this->ui.chb_english->setChecked(true);
((Application*)qApp)->switch_language(Application::Language::en_US);
}
ui.chb_auto_start->setChecked(_settings.get_auto_start());

this->_init_comobo();

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setOffset(0, 0);
effect->setColor(Qt::lightGray);
effect->setBlurRadius(10);
this->setGraphicsEffect(effect);
}

void WindbgIFEO::_init_comobo() {
std::vector<QComboBox*> vec_com = {ui.comboBox_proc_name,
ui.comboBox_attach_name};
for (auto& item : vec_com) {
Expand All @@ -478,13 +479,21 @@ void WindbgIFEO::_init_ui() {
item->setCompleter(com);
}

this->ui.comboBox_windbg_path->set_line_edit_enable(false);

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setOffset(0, 0);
effect->setColor(Qt::lightGray);
effect->setBlurRadius(10);
this->setGraphicsEffect(effect);
using data_pair = std::pair<QString, Application::Language>;
for (auto& item :
{data_pair(tr("chinese"), Application::Language::zh_CN),
data_pair(tr("english(US)"), Application::Language::en_US)}) {
this->ui.comboBox_language->addItem(item.first, (int)item.second);
}
// this->ui.comboBox_language->addItems({tr("chinese"), tr("english(US)")});
std::string lang = this->_settings.get_lang();
if (lang == "zh_CN") {
this->ui.comboBox_language->setCurrentText("zh_CN");
((Application*)qApp)->switch_language(Application::Language::zh_CN);
} else {
this->ui.comboBox_language->setCurrentText("en_US");
((Application*)qApp)->switch_language(Application::Language::en_US);
}
}

void WindbgIFEO::_init_signal() {
Expand All @@ -494,14 +503,16 @@ 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.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,
SLOT(on_auto_start_stateChanged(int)));
connect(ui.comboBox_language, SIGNAL(currentTextChanged(QString)), this,
SLOT(on_comboBoxLanguage(QString)));
}

void WindbgIFEO::on_update_windbg_path() {
Expand Down Expand Up @@ -551,6 +562,20 @@ void WindbgIFEO::on_comboBoxChanged(const QString& text) {
this->log_info(tr("selecte current Windbg:") + "\n" + text, LOG_TYPE::INFO);
}

void WindbgIFEO::on_comboBoxLanguage(const QString& text) {
int data = this->ui.comboBox_language->currentData(Qt::UserRole).toInt();
bool is_zh_CN = (Application::Language)data == Application::Language::zh_CN;
((Application*)qApp)
->switch_language(is_zh_CN ? Application::Language::zh_CN
: Application::Language::en_US);
this->_settings.set_lang(is_zh_CN ? "zh_CN" : "en_US");
this->log_info(is_zh_CN ? tr("set language chinese successful")
: tr("set language english successful"),
LOG_TYPE::INFO);

this->update();
}

void WindbgIFEO::on_btn_close_clicked() {
this->close();
}
Expand Down
6 changes: 4 additions & 2 deletions WindbgIFEO/WindbgIFEO.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ class WindbgIFEO : public QWidget {
void on_pushButtonPostmortemQuery_clicked();

// settings
void on_chinese_stateChanged(int state);
void on_english_stateChanged(int state);
// void on_chinese_stateChanged(int state);
// void on_english_stateChanged(int state);
void on_auto_start_stateChanged(int state);

void on_update_windbg_path();
void on_update_process_info();
void on_process_finished(int exitCode);

void on_comboBoxChanged(const QString& text);
void on_comboBoxLanguage(const QString& text);

void on_btn_close_clicked();
void on_btn_mini_clicked();
Expand All @@ -78,6 +79,7 @@ class WindbgIFEO : public QWidget {

private:
void _init_ui();
void _init_comobo();
void _init_signal();
QString _get_reg_path() const;
QString _get_process_name() const;
Expand Down
108 changes: 79 additions & 29 deletions WindbgIFEO/WindbgIFEO.ui
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ QPushButton:pressed{border-image: url(&quot;:/WindbgConfig/images/close_pressed.
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>25</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -457,13 +457,19 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_proc_name">
<widget class="ComboBox" name="comboBox_proc_name">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
Expand All @@ -481,13 +487,50 @@ background-color:#407ee1;
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_5">
<property name="styleSheet">
<string notr="true">QLineEdit{
border:1px solid #CCCCCC;
background:#eceff7;
color:
#5b5c60;
font-size:12px;
padding:0 0 0 8px;
border-radius:12px;
}</string>
</property>
<property name="text">
<string>Parameters:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_process_param">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLineEdit{
border:1px solid #eceff7;
background:#eceff7;
color:
#5b5c60;
font-size:12px;
padding-left:10px;
border-radius:12px;
}



QLineEdit:focus{
border:1px solid #0b57d0;
background:#fff;


}</string>
</property>
<property name="placeholderText">
<string>example:-g</string>
</property>
Expand Down Expand Up @@ -691,13 +734,19 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_attach_name">
<widget class="ComboBox" name="comboBox_attach_name">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
Expand All @@ -721,13 +770,19 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_attach_pid">
<widget class="ComboBox" name="comboBox_attach_pid">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="editable">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -1042,29 +1097,13 @@ background-color:#407ee1;
</widget>
</item>
<item>
<widget class="QCheckBox" name="chb_english">
<property name="styleSheet">
<string notr="true">border:0px;</string>
</property>
<property name="text">
<string>English</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupChb</string>
</attribute>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chb_chinese">
<property name="styleSheet">
<string notr="true">border:0px;</string>
</property>
<property name="text">
<string>Chinese</string>
<widget class="ComboBox" name="comboBox_language">
<property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupChb</string>
</attribute>
</widget>
</item>
<item>
Expand All @@ -1091,10 +1130,21 @@ background-color:#407ee1;
<enum>Qt::RightToLeft</enum>
</property>
<property name="styleSheet">
<string notr="true">border:0px;</string>
<string notr="true">

QCheckBox::indicator:unchecked {
border:0px;
image: url(:/WindbgConfig/images/def_100_precent/switch_off_middle.png);
}


QCheckBox::indicator:checked {
border:0px;
image: url(:/WindbgConfig/images/def_100_precent/switch_on_middle.png);
}</string>
</property>
<property name="text">
<string>Auto start</string>
<string>Auto start:</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion WindbgIFEO/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ QString Application::AppName() const {

bool Application::_install_lang(QTranslator& trans, Language lang) {
std::map<Language, QString> _map = {
{Language::ch_ZN, ":/WindbgConfig/language/zh_CN.qm"},
{Language::zh_CN, ":/WindbgConfig/language/zh_CN.qm"},
{Language::en_US, ":/WindbgConfig/language/en_US.qm"}};

if (!trans.load(_map[lang])) {
Expand Down
2 changes: 1 addition & 1 deletion WindbgIFEO/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Application : public QApplication {
Q_OBJECT

public:
enum class Language { ch_ZN = 0, en_US = 1 };
enum class Language { zh_CN = 0, en_US = 1 };

public:
Application(int& argc, char** arg);
Expand Down
Loading

0 comments on commit 71b3ead

Please sign in to comment.