diff --git a/keil_development_assistant.pro b/keil_development_assistant.pro index 3115be0..1d1ebb3 100644 --- a/keil_development_assistant.pro +++ b/keil_development_assistant.pro @@ -1,8 +1,10 @@ -QT += core gui xml charts printsupport +QT += core gui xml charts greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -CONFIG += c++11 +#CONFIG += c++11 +win32:QMAKE_CXXFLAGS += -std=c++11 +CONFIG += console # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings @@ -64,3 +66,5 @@ DISTFILES += \ RESOURCES += \ R.qrc +TARGET = KDA + diff --git a/main.cpp b/main.cpp index 3fc40a2..b44db14 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,10 @@ #include #include + +#include +#include + MainWindow* main_window=nullptr; #include "only_run_by_file.h" @@ -15,44 +19,104 @@ void onAppExit() QString project_path; QString map_path; -bool only_printf=false; + + + + +QString gb2312ToQString(const char *gb2312Data) { + QTextCodec *gb2312Codec = QTextCodec::codecForName("GB2312"); + if (!gb2312Codec) { + qWarning("GB2312 codec not available. Cannot convert to QString."); + return QString(); + } + + QByteArray byteArray = QByteArray::fromRawData(gb2312Data, strlen(gb2312Data)); + return gb2312Codec->toUnicode(byteArray); +} + + + + +//QString executeCmdCommand(const QString& cmdCommand) { +// QProcess process; + +// // Set the command to be executed (cmd in this case) +// QString command = "cmd.exe"; + +// // Set the arguments to pass to the command +// QStringList arguments; +// arguments << "/c" << cmdCommand; + +// // Start the process +// process.start(command, arguments); + +// // Wait for the process to finish +// process.waitForFinished(); + +// // Read the output from the process +// QString output = process.readAllStandardOutput(); + +// return output; + +//} int main(int argc, char *argv[]) { -// for(int i=0;i3) - { - project_path=argv[1]; - map_path=argv[2]; - only_printf=argv[3]; - }else if(argc>2) + // Execute the cmd command and get the output +// QString result = executeCmdCommand("cd "); + + // Display the output +// qDebug() << "Output:" << result; + + + for(int i=0;i1) + + project_path=gb2312ToQString(argv[1]); + map_path=gb2312ToQString(argv[2]); + + project_path.replace("\"", ""); + map_path.replace("\"", ""); + + project_path.replace("“", ""); + project_path.replace("”", ""); + map_path.replace("“", ""); + map_path.replace("”", ""); + + }else if(argc==2) { - project_path="./"; - map_path="./"; - only_printf=argv[1]; + project_path=map_path=gb2312ToQString(argv[1]); + project_path.replace("\"", ""); + map_path.replace("\"", ""); + project_path.replace("“", ""); + project_path.replace("”", ""); + map_path.replace("“", ""); + map_path.replace("”", ""); + + }else + + { + project_path=map_path=""; } QApplication a(argc, argv); - only_run_by_file programController; - QObject::connect(&programController, &only_run_by_file::runFileDeleted, &a, &QCoreApplication::quit); +// only_run_by_file programController; +// QObject::connect(&programController, &only_run_by_file::runFileDeleted, &a, &QCoreApplication::quit); // 注册程序退出的处理函数 QObject::connect(&a, &QCoreApplication::aboutToQuit, onAppExit); - MainWindow w; + MainWindow w; - if(!only_printf) w.show(); + w.show(); return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index c2933d1..9af6d8c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,9 +8,15 @@ #include "flatui.h" #include #include -extern MainWindow* main_window; -#pragma execution_character_set("utf-8") +#pragma execution_character_set("utf-8") +void MainWindow::winow_on_top(bool is_top) +{ + if(is_top) + setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint); + else + setWindowFlags(windowFlags()&(~Qt::WindowStaysOnTopHint)); +} @@ -18,6 +24,8 @@ MainWindow::MainWindow(QWidget *parent) : FramelessMainWindow(parent), ui(new Ui { ui->setupUi(this); this->initForm(); + winow_on_top(true); +// winow_on_top(false); } MainWindow::~MainWindow() @@ -45,12 +53,10 @@ void MainWindow::initForm() list << "#titleBar{background:#BBBBBB;}"; list << "#titleBar{border-top-left-radius:8px;border-top-right-radius:8px;}"; list << "#widgetMain{border:2px solid #BBBBBB;background:#FFFFFF;}"; - //list << "#widgetMain{border-bottom-left-radius:8px;border-bottom-right-radius:8px;}"; + list << "#widgetMain{border-bottom-left-radius:8px;border-bottom-right-radius:8px;}"; this->setStyleSheet(list.join("")); - FlatUI::setScrollBarQss(ui->ram_scrollArea->verticalScrollBar(), 8, 120, 20, "##E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); - FlatUI::setScrollBarQss(ui->ram_scrollArea->horizontalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); + FlatUI::setScrollBarQss(ui->ram_scrollArea->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); FlatUI::setScrollBarQss(ui->flash_scrollArea->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); - FlatUI::setScrollBarQss(ui->flash_scrollArea->horizontalScrollBar(), 8, 120, 20, "#E5E5E5","#D0D0D0", "#1ABC9C", "#E74C3C"); FlatUI::setScrollBarQss(ui->ram_table->horizontalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); FlatUI::setScrollBarQss(ui->ram_table->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); @@ -63,28 +69,16 @@ void MainWindow::initForm() main_window=this; -map_path="P:/AT32_F403A_FreeRTOS/MDK_Project"; -project_path="P:/AT32_F403A_FreeRTOS/MDK_Project"; +//map_path="./"; +//project_path="./"; + ui->map_path->setText(map_path); ui->project_path->setText(project_path); ram_pieseries=new QPieSeries(); flash_pieseries=new QPieSeries(); - cpu= new parse_keil_project(ui->project_path->text()); - cpu->to_parse_keil_project(ui->project_path->text()); - if(cpu->getCpu_core_name()!="8051") - { - map= new parse_map_from_keil( ui->map_path->text(),cpu->IRAM.getBase_addr(),cpu->IRAM.getMax_size(),cpu->IROM.getBase_addr(),cpu->IROM.getMax_size()); - if(map->to_parse_map_from_keil(ui->map_path->text())) - map_calculate_size_by_address(map); - }else { - - m51 =new parse_m51_from_keil(ui->map_path->text(),cpu->IRAM.getMax_size(),cpu->XRAM.getMax_size(),cpu->IROM.getMax_size()); - - - } ram_chart=new QChart(); flash_chart=new QChart(); @@ -103,12 +97,14 @@ ram_chart->legend()->hide(); ram_chart->setTheme(QChart::ChartThemeQt); ram_chart->setBackgroundBrush(QBrush(Qt::gray)); +ram_chart->setTitleBrush(Qt::white);; // 数据集分类标题文字颜色 flash_chart->addSeries(flash_pieseries); flash_chart->setTitle("文件flash分布饼图"); flash_chart->legend()->hide(); // Set the theme to one of the predefined themes flash_chart->setTheme(QChart::ChartThemeQt); flash_chart->setBackgroundBrush(QBrush(Qt::gray)); +flash_chart->setTitleBrush(Qt::white); ui->ram_chart_view->setChart(ram_chart); ui->ram_chart_view->setRubberBand(QChartView::RectangleRubberBand); @@ -116,17 +112,46 @@ ui->ram_chart_view->setRubberBand(QChartView::RectangleRubberBand); ui->flash_chart_view->setChart(flash_chart); ui->flash_chart_view->setRubberBand(QChartView::RectangleRubberBand); - update_cpu_info(); + +if(map_path.length()>1&&project_path.length()>1) +{ + cpu= new parse_keil_project(ui->project_path->text()); + if(cpu->to_parse_keil_project(ui->project_path->text())) + { + update_cpu_info(); - if(cpu->getCpu_core_name()!="8051") - { - update_map_info(); - }else { - update_m51_info(); + + + + if(cpu->getCpu_core_name()!="8051") + { + + }else { + + } + } + if(cpu->getCpu_core_name()!="8051") + { + map= new parse_map_from_keil( ui->map_path->text(),cpu->IRAM.getBase_addr(),cpu->IRAM.getMax_size(),cpu->IROM.getBase_addr(),cpu->IROM.getMax_size()); + if(map->to_parse_map_from_keil(ui->map_path->text())) + { + map_calculate_size_by_address(map); + update_map_info(); + } + }else { + m51 =new parse_m51_from_keil(ui->map_path->text(),cpu->IRAM.getMax_size(),cpu->XRAM.getMax_size(),cpu->IROM.getMax_size()); + if(m51->to_parse_m51_from_keil(ui->map_path->text())) + { + update_m51_info(); + } + } +} + +fflush(stdout); } @@ -238,7 +263,6 @@ void MainWindow::on_update_info_clicked() cpu=nullptr; } cpu= new parse_keil_project(ui->project_path->text()); - if(cpu->to_parse_keil_project(ui->project_path->text())) update_cpu_info(); @@ -252,10 +276,11 @@ void MainWindow::on_update_info_clicked() } map= new parse_map_from_keil(ui->map_path->text(),cpu->IRAM.getBase_addr(),cpu->IRAM.getMax_size(),cpu->IROM.getBase_addr(),cpu->IROM.getMax_size()); if(map->to_parse_map_from_keil(ui->map_path->text())) + { map_calculate_size_by_address(map); update_map_info(); - + } }else { @@ -272,7 +297,7 @@ void MainWindow::on_update_info_clicked() } - +fflush(stdout); } @@ -295,7 +320,7 @@ void MainWindow::on_ram_table_itemSelectionChanged() QPieSlice *slice = ram_pieseries->slices().at(row); slice->setExploded();//突出这一块 slice->setLabelVisible();//设置这一块可见数据 - + slice->setLabelBrush(Qt::white); } @@ -319,6 +344,7 @@ void MainWindow::on_flash_table_itemSelectionChanged() QPieSlice *slice = flash_pieseries->slices().at(row); slice->setExploded();//突出这一块 slice->setLabelVisible();//设置这一块可见数据 + slice->setLabelBrush(Qt::white); } @@ -371,7 +397,21 @@ void MainWindow::update_m51_info(void) clearLayout(ui->flash_scrollAreaWidgetContents->layout()); // 移除并释放布局中的所有小部件 + for(uint64_t row_cnt=0;row_cntram_table->rowCount();row_cnt++) + { + ui->ram_table->removeRow(row_cnt); + } + ui->ram_table->clear(); + + ram_pieseries->clear(); + + for(uint64_t row_cnt=0;row_cntflash_table->rowCount();row_cnt++) + { + ui->flash_table->removeRow(row_cnt); + } + ui->flash_table->clear(); + flash_pieseries->clear(); for(i=0;iram_list.size();i++) { @@ -421,6 +461,12 @@ set_bar_style(ui->ram_used_bar,ram_all_used_size/1.0/ram_all_max_size/1.0); } set_bar_style(ui->flash_used_bar,ram_all_used_size/1.0/ram_all_max_size/1.0); +if(ui->ram_scrollArea->verticalScrollBar()!=nullptr) + FlatUI::setScrollBarQss(ui->ram_scrollArea->verticalScrollBar(), 8, 120, 20, "##E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); +if(ui->ram_scrollArea->verticalScrollBar()!=nullptr) +FlatUI::setScrollBarQss(ui->flash_scrollArea->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); + + } void MainWindow::setPieSliceStyle(QPieSlice* slice, qreal percentage, qreal maxPercentage) @@ -452,6 +498,10 @@ void MainWindow::setPieSliceStyle(QPieSlice* slice, qreal percentage, qreal maxP void MainWindow::update_map_info(void) { + if(map->ram_list.length()==0) + return; + if(map->flash_list.length()==0) + return; uint64_t ram_all_max_size=0; uint64_t ram_all_used_size=0; uint64_t ram_min_base_addr=map->ram_list.at(0)->getBase_addr(); @@ -471,14 +521,14 @@ for(uint64_t row_cnt=0;row_cntram_table->rowCount();row_cnt++) ui->ram_table->removeRow(row_cnt); } - + ui->ram_table->clear(); ram_pieseries->clear(); for(uint64_t row_cnt=0;row_cntflash_table->rowCount();row_cnt++) { ui->flash_table->removeRow(row_cnt); } - + ui->flash_table->clear(); flash_pieseries->clear(); @@ -531,7 +581,7 @@ set_bar_style(ui->ram_used_bar,ram_all_used_size/1.0/ram_all_max_size/1.0); ui->flash_used->setText(QString().sprintf("占用:%.4f MB / (%.4f MB)",flash_all_used_size/1024.0/1024.0,flash_all_max_size/1024.0/1024.0)); } - set_bar_style(ui->flash_used_bar,ram_all_used_size/1.0/ram_all_max_size/1.0); + set_bar_style(ui->flash_used_bar,flash_all_used_size/1.0/flash_all_max_size/1.0); @@ -617,7 +667,10 @@ set_bar_style(ui->ram_used_bar,ram_all_used_size/1.0/ram_all_max_size/1.0); } - + if(ui->ram_scrollArea->verticalScrollBar()!=nullptr) + FlatUI::setScrollBarQss(ui->ram_scrollArea->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); + if(ui->ram_scrollArea->verticalScrollBar()!=nullptr) + FlatUI::setScrollBarQss(ui->flash_scrollArea->verticalScrollBar(), 8, 120, 20, "#E5E5E5", "#D0D0D0", "#1ABC9C", "#E74C3C"); } diff --git a/mainwindow.h b/mainwindow.h index c9aca34..222efa8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -24,6 +24,7 @@ class MainWindow : public FramelessMainWindow public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void winow_on_top(bool is_top); void setPieSliceStyle(QPieSlice* slice, qreal percentage, qreal maxPercentage); void set_bar_style(QProgressBar *bar,float per); void update_cpu_info(void); @@ -64,5 +65,5 @@ private slots: void on_flash_table_itemSelectionChanged(); void on_gitee_index_clicked(); }; - +extern MainWindow* main_window; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 87dc562..d8e9b2d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -460,7 +460,7 @@ color: rgb(255, 255, 255); - 3 + 0 @@ -480,34 +480,34 @@ color: rgb(255, 255, 255); - mcu_name + 主控名称 - 最高主频: + 最高主频:未知 - 内部flash 大小: + 内部flash 大小:未知 - 内部ram 大小: + 内部ram 大小:未知 - 核心: + 核心:未知 @@ -549,13 +549,13 @@ color: rgb(255, 255, 255); - all_ram + 全部ram - 地址:0xxxxxx + 地址:0x00 Qt::AlignCenter @@ -565,21 +565,21 @@ color: rgb(255, 255, 255); - 24 + 0 - 占用: + 占用:0 - 还剩: + 还剩:0 @@ -614,13 +614,13 @@ color: rgb(255, 255, 255); - all_flash + 全部flash - 地址:0xxxxxx + 地址:0x00 Qt::AlignCenter @@ -630,21 +630,21 @@ color: rgb(255, 255, 255); - 24 + 0 - 占用: + 占用:0 - 还剩: + 还剩:0 @@ -672,7 +672,7 @@ color: rgb(255, 255, 255); - project::xxx cup:xxxx + map文件ram占比分析 @@ -838,6 +838,9 @@ color: rgb(255, 255, 255); 0 + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -850,11 +853,6 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">来反馈BUG或者提供优化代码来帮助维护这个项目,</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">或者给予建议或者告诉作者你想要的功能。</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">参与了代码的奉献,实现某些功能或优化了某些代码,</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">会更新到readme的奉献者名单。</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">或者能力赞助该项目开发的,</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">会更新到readme赞助者名单。</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">该软件将永久免费,开源不易,谢谢大家的支持,</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">你的支持是我更新维护项目的动力。</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> @@ -918,6 +916,9 @@ p, li { white-space: pre-wrap; } + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> diff --git a/parse_m51_from_keil.cpp b/parse_m51_from_keil.cpp index 4cbda55..971a7d9 100644 --- a/parse_m51_from_keil.cpp +++ b/parse_m51_from_keil.cpp @@ -3,9 +3,11 @@ #include #include #include "find_path.h" - +#include #include + + parse_m51_from_keil::parse_m51_from_keil(QString path,uint64_t iram_max_size,uint64_t xram_max_size, uint64_t irom_max_size) { @@ -14,7 +16,7 @@ iram_max=iram_max_size; xram_max=xram_max_size; irom_max=irom_max_size; -//to_parse_m51_from_keil(path); + } bool parse_m51_from_keil::to_parse_m51_from_keil(QString path) @@ -29,7 +31,11 @@ qDebug()<winow_on_top(false); + QMessageBox::critical(nullptr, "Error", "路径错误,请检测输入的工程路径!"); + return false; } } diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..3b07045 --- /dev/null +++ b/readme.md @@ -0,0 +1,109 @@ +# KDA v1.0 (keil_development_assistant) +keil开发助手项目 + +[简介](#1)
+ +[功能演示](#2)
+ +[开始使用](#3)
+ +[二次开发环境搭建](#4)
+ +[提供建议&&反馈bug](#5)
+ +

+ +## 简介 + +这个项目的原型是就是[Keil5_disp_size_bar](https://gitee.com/nikolan/keil5_disp_size_bar) + +C语言编写的一个解析map文件输出占用百分比进度条的命令行工具
+起初只是为了方便查看代码对芯片的内存ram和存储flash的占用
+项目推出不久收到不少网友的喜爱,提出了许多建议,使得项目得以完善。
+ +后来想更进一步开发更多功能,
+例如输出ram和flash的地址方便区分
+例如查看已使用的ram和flash里,每个文件的占比。
+ +到这里C语言和命令行也就不能很好的满足对这些功能的开发了
+于是用Qt重新开发了一下,于是推出升级版的KDA(keil_development_assistant)
+keil开发助手项目就这样诞生了。 + +

+ +## 功能演示 +1.对结构较简单stm32或者各种国产32工程解析。
+ + +3.对8051单片机的工程解析。
+ + +

+ +## 开始使用 + +1. 安装KDA +下载代码仓库右侧的发行版
+ +2. 选择安装路径 +3. 安装完成 + +- 普通用法 +4. 打开KDA选择工程目录,会递归查找子目录,选择工程目录后会自动选map目录为工程目录 +5. 如果map和工程不在一个命命令再选map所在目录 +6. 选择手动更新 + + +- 进阶用法 +软件打包时已经设置添加软件安装路径到系统环境变量Path +如果并没有添加成功则需要自己手动添加 + +在keil after bulid +KDA +

+ + +## 二次开发环境搭建 + +开发环境: +- 系统:window10 x64位 +- 框架:Qt5.12.9 +- IDE:Qt Creator 4.12.2 (Community) +- 编译链:mingw64 + +Qt项目库依赖: + +``` + QT += core gui xml charts + +``` + +克隆仓库代码: +``` shell + +git clone xxx + +``` + +使用Qt Creator打开项目即可开始二次开发 + + + + +

+ +## 提供建议&&反馈bug + +可以在代码仓库提Issues +或者发送到邮箱2503865771@qq.com + + +

+ +## 参与奉献&&赞助 + + + + + +