优化界面样式;修复符号文件路径不支持非ASCII字符的问题;增加对elf格式的支持;添加未选择符号文件的警告框;修复连接错误导致闪退的问题;版本号更新为1.0.1

This commit is contained in:
skythinker 2022-01-25 16:13:54 +08:00
parent 4797c462d6
commit 2ecda4e4db
16 changed files with 226 additions and 23 deletions

View File

@ -35,3 +35,6 @@ RC_ICONS = icon.ico
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2022-01-02T00:24:35. -->
<!-- Written by QtCreator 4.11.0, 2022-01-25T15:56:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -67,7 +67,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.9 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.9 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.599.win32_mingw53_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
@ -299,7 +299,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">F:/Sketches/Qt/LinkScope/build-LinkScope-Desktop_Qt_5_9_9_MinGW_32bit-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">F:/Sketches/Qt/LinkScope/build-LinkScope-Desktop_Qt_5_9_9_MinGW_32bit-Release</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@ -76,8 +76,6 @@
* 将采样频率提升至约1kHz
* 优化界面样式
---
## 运行过程简介

View File

@ -34,7 +34,7 @@ void GraphWindow::paintGraph(QWidget *canvas)
QPainter painter(canvas); //画笔
painter.setBrush(QBrush(QColor(Qt::white)));//填充背景
painter.drawRect(posx,posy,wid,hei);
painter.drawRect(posx,posy,wid-1,hei-1);
//绘制标记线
painter.setPen(QPen(QColor(184,184,184),2,Qt::DotLine));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -8,6 +8,8 @@ MainWindow::MainWindow(QWidget *parent)
ui->setupUi(this);
setWindowTitle("LinkScope");
setStylesheet();//设置全局样式表
graph=new GraphWindow();//创建并显示绘图窗口
graph->setVarList(&varList);
graph->show();
@ -163,7 +165,16 @@ void MainWindow::slotTableTimerTrig()
//连接按钮点击,触发连接状态切换
void MainWindow::on_bt_conn_clicked()
{
setConnState(!connected);
if(!connected && !axfChosen)//用户未选择axf文件就点击连接按钮
{
QMessageBox msgBox;
msgBox.setWindowTitle("警告");
msgBox.setText("还未选择符号文件,连接后仅能使用绝对地址查看变量,是否继续连接?");
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
if(msgBox.exec()!=QMessageBox::Ok)
return;
}
setConnState(!connected);//切换连接状态
}
//设置连接状态参数true表示进行连接false表示断开连接
@ -215,6 +226,8 @@ void MainWindow::setOCDState(bool connect)
}
else
{
if(ocdProcess->state()==QProcess::NotRunning)
return;
QProcess killProcess(0);//创建新进程用taskkill强行结束ocd进程
killProcess.setProgram("taskkill");
killProcess.setNativeArguments(QString("/F /PID %1").arg(ocdProcess->pid()->dwProcessId));
@ -229,6 +242,7 @@ void MainWindow::setGDBState(bool run)
if(run)
{
gdbProcess->setProgram(QCoreApplication::applicationDirPath()+"/gdb/gdb.exe");//设置程序路径
gdbProcess->setWorkingDirectory(QCoreApplication::applicationDirPath()+"/gdb");//设置工作路径
gdbProcess->setNativeArguments("-q");//设置gdb在安静模式下打开
gdbProcess->start();
}
@ -241,17 +255,23 @@ void MainWindow::setGDBState(bool run)
//参数truegdb连接到本机3333端口设置调试参数参数false断开gdb连接
void MainWindow::setGDBConnState(bool connect)
{
QString tmpFilePath=QCoreApplication::applicationDirPath()+"/gdb/tmp";//临时符号文件路径
if(connect)
{
gdbProcess->write("target remote localhost:3333\r\n");//连接到3333端口
gdbProcess->write(QString("symbol-file %1 \r\n").arg(ui->txt_axf_path->text()).toStdString().c_str());//设置符号文件为所选的axf文件
QFile::remove(tmpFilePath);//确保删除当前的临时文件
QFile::copy(ui->txt_axf_path->text(),tmpFilePath);//将所选符号文件复制为临时文件
gdbProcess->write(QString("symbol-file %1 \r\n").arg("tmp").toStdString().c_str());//设置符号文件
gdbProcess->write("set confirm off\r\n");//设置不要手动确认
gdbProcess->write("set print pretty on\r\n");//设置结构体规范打印
setGDBDispList();//向gdb发送当前的变量列表
}
else
{
gdbProcess->write("disconnect\r\n");
gdbProcess->write("symbol-file\r\n");//取消符号文件
gdbProcess->write("disconnect\r\n");//断开gdb连接
sleep(10);//确保对临时文件取消占用
QFile::remove(tmpFilePath);//删除复制过来的临时文件
}
}
@ -335,7 +355,7 @@ void MainWindow::on_bt_set_axf_clicked()
QFileDialog *fileDialog = new QFileDialog(this);//弹出文件选择框
fileDialog->setWindowTitle(QStringLiteral("选中文件"));
fileDialog->setDirectory(".");
fileDialog->setNameFilter(tr("AXF File (*.axf)"));//设置文件过滤器为axf
fileDialog->setNameFilter(tr("AXF/ELF File (*.axf *.elf)"));//设置文件过滤器为axf/elf
fileDialog->setFileMode(QFileDialog::ExistingFile);
fileDialog->setViewMode(QFileDialog::Detail);
if(fileDialog->exec())
@ -344,6 +364,7 @@ void MainWindow::on_bt_set_axf_clicked()
QString fileName=fileList.at(0);
QFileInfo info(fileName);
ui->txt_axf_path->setText(info.filePath());
axfChosen=true;
}
}
@ -414,6 +435,7 @@ void MainWindow::saveToFile(const QString &filename)
settings.beginGroup("Global");//写入全局配置
settings.setValue("Interface",ui->cb_interface->currentText());
settings.setValue("Target",ui->cb_target->currentText());
settings.setValue("AxfChosen",axfChosen);
settings.setValue("AxfPath",ui->txt_axf_path->text());
settings.setValue("VarNum",varList.size());
settings.endGroup();
@ -438,6 +460,7 @@ void MainWindow::loadFromFile(const QString &filename)
settings.beginGroup("Global");//读取全局配置
ui->cb_interface->setCurrentText(settings.value("Interface").toString());
ui->cb_target->setCurrentText(settings.value("Target").toString());
axfChosen=settings.value("AxfChosen",true).toBool();
ui->txt_axf_path->setText(settings.value("AxfPath").toString());
int varNum=settings.value("VarNum").toInt();
settings.endGroup();
@ -613,7 +636,7 @@ void MainWindow::on_action_export_triggered()
void MainWindow::on_action_about_triggered()
{
//弹出messagebox显示关于信息
QString str="LinkScope 版本号V1.0.0\n\n"
QString str="LinkScope 版本号V1.0.1\n\n"
"Developed by Skythinker";
QMessageBox box;
box.setWindowTitle("关于 LinkScope");
@ -665,3 +688,11 @@ void MainWindow::on_action_homepage_triggered()
{
QDesktopServices::openUrl(QUrl("https://gitee.com/skythinker/link-scope"));//打开仓库主页
}
//设置QSS全局样式
void MainWindow::setStylesheet()
{
QFile qss(":/qss/light-blue.qss");
if(qss.open(QIODevice::ReadOnly))
qApp->setStyleSheet(QLatin1String(qss.readAll()));
}

View File

@ -63,6 +63,8 @@ private:
QElapsedTimer *stampTimer;//时间戳定时器指针
GraphWindow *graph;//绘图窗口指针
bool isWatchProcessing=false;//标记当前是否正在处理变量值查看
bool axfChosen=false;//是否已经选择了axf文件
void setStylesheet();
void setConnState(bool connect);
void setOCDState(bool connect);
void setGDBState(bool run);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>918</width>
<height>727</height>
<width>893</width>
<height>680</height>
</rect>
</property>
<property name="windowTitle">
@ -87,14 +87,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Axf文件路径</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="txt_axf_path">
<property name="text">
<string>请选择axf文件</string>
<string>符号文件(AXF/ELF)</string>
</property>
</widget>
</item>
@ -111,10 +104,17 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="txt_axf_path">
<property name="text">
<string>请设置符号文件</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bt_set_axf">
<property name="text">
<string>设置Axf路径</string>
<string>设置符号文件</string>
</property>
</widget>
</item>
@ -128,7 +128,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>918</width>
<width>893</width>
<height>29</height>
</rect>
</property>
@ -192,6 +192,9 @@
<property name="text">
<string>刷新连接配置</string>
</property>
<property name="toolTip">
<string>刷新连接配置</string>
</property>
</action>
<action name="action_homepage">
<property name="text">

155
qss/light-blue.qss Normal file
View File

@ -0,0 +1,155 @@
QMainWindow,QDialog{
background: white;
}
*:disabled{
background: rgb(221, 221, 221);
}
QGroupBox{
border: 2px solid rgb(85, 170, 255);
border-radius: 10px;
padding: 15px 5px 3px 5px;
color: rgb(85, 170, 255);
font-size: 9pt;
font-family: "Microsoft YaHei UI";
font: bold;
}
QGroupBox::title{
subcontrol-origin: margin;
subcontrol-position: top left;
border-top: 2px solid rgb(85, 170, 255);
border-left: 2px solid rgb(85, 170, 255);
}
QLineEdit{
border: 2px solid rgb(85, 170, 255);
border-radius: 3px;
background-color: white;
}
QPushButton{
border: 2px solid rgb(85, 170, 255);
border-radius: 5px;
background-color: white;
padding: 3px 5px 3px 5px;
color: rgb(85, 170, 255);
font-size: 9pt;
font-family: "Microsoft YaHei UI";
font: bold;
}
QPushButton:hover{
border: 2px solid white;
background-color: rgb(85, 170, 255);
color: white;
}
QRadioButton:indicator{
width: 22px;
height: 22px;
}
QRadioButton:indicator:unchecked{
image: url(:/qss/qss-img/light-blue-radiobutton-unchecked.png)
}
QRadioButton:indicator:checked{
image: url(:/qss/qss-img/light-blue-radiobutton-checked.png)
}
QCheckBox:indicator{
width: 22px;
height: 22px;
}
QCheckBox:indicator:unchecked{
image: url(:/qss/qss-img/light-blue-checkbox-unchecked.png)
}
QCheckBox:indicator:checked{
image: url(:/qss/qss-img/light-blue-checkbox-checked.png)
}
QComboBox{
border: 2px solid rgb(85, 170, 255);
border-radius: 3px;
background-color: white;
min-width: 80px;
padding: 2px;
}
QComboBox:drop-down{
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;
margin: 2px;
padding-left: 2px;
border-left: 2px solid rgb(85, 170, 255);
image: url(:/qss/qss-img/light-blue-downarrow.png);
}
QComboBox:drop-down:on{
image: url(:/qss/qss-img/light-blue-uparrow.png)
}
QSpinBox,QDoubleSpinBox{
border: 2px solid rgb(85, 170, 255);
border-radius: 3px;
background-color: white;
}
QSpinBox:up-button,QSpinBox:down-button,QDoubleSpinBox:up-button,QDoubleSpinBox:down-button{
width: 0px;
}
QSlider:groove:horizontal{
height: 0px;
border: 3px solid rgba(85, 170, 255,150);
border-radius: 3px;
}
QSlider::handle:horizontal{
width: 15px;
margin: -10px 0px;
border: 2px solid rgb(85, 170, 255);
border-radius: 3px;
background-color: white;
}
QMenuBar{
background-color: white;
}
QMenuBar:item{
padding: 5px 20px;
}
QMenuBar:item:selected{
border-bottom: 3px solid rgb(85, 170, 255);
}
QMenu{
border-radius: 3px;
background-color: white;
}
QMenu:item{
background-color: white;
padding: 8px 15px;
}
QMenu::item:selected{
background-color: rgb(85, 170, 255);
}
QMenu::separator{
height: 0px;
border: 1px solid rgb(85, 170, 255);
background-color: white;
}
QTableView{
border: 2px solid rgb(85, 170, 255);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

11
res.qrc Normal file
View File

@ -0,0 +1,11 @@
<RCC>
<qresource prefix="/">
<file>qss/light-blue.qss</file>
<file>qss/qss-img/light-blue-checkbox-checked.png</file>
<file>qss/qss-img/light-blue-checkbox-unchecked.png</file>
<file>qss/qss-img/light-blue-downarrow.png</file>
<file>qss/qss-img/light-blue-radiobutton-checked.png</file>
<file>qss/qss-img/light-blue-radiobutton-unchecked.png</file>
<file>qss/qss-img/light-blue-uparrow.png</file>
</qresource>
</RCC>