diff --git a/LinkScope.pro b/LinkScope.pro index ad6076c..3f77b2d 100644 --- a/LinkScope.pro +++ b/LinkScope.pro @@ -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 diff --git a/LinkScope.pro.user b/LinkScope.pro.user index 1921fb4..da2022c 100644 --- a/LinkScope.pro.user +++ b/LinkScope.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -67,7 +67,7 @@ Desktop Qt 5.9.9 MinGW 32bit Desktop Qt 5.9.9 MinGW 32bit qt.qt5.599.win32_mingw53_kit - 0 + 1 0 0 @@ -299,7 +299,7 @@ false true - F:/Sketches/Qt/LinkScope/build-LinkScope-Desktop_Qt_5_9_9_MinGW_32bit-Debug + F:/Sketches/Qt/LinkScope/build-LinkScope-Desktop_Qt_5_9_9_MinGW_32bit-Release 1 diff --git a/README.md b/README.md index 17ae990..51c3676 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,6 @@ * 将采样频率提升至约1kHz -* 优化界面样式 - --- ## 运行过程简介 diff --git a/graphwindow.cpp b/graphwindow.cpp index e1eb713..197e99e 100644 --- a/graphwindow.cpp +++ b/graphwindow.cpp @@ -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)); diff --git a/imgs/run-demo.png b/imgs/run-demo.png index 95ea519..2e40c93 100644 Binary files a/imgs/run-demo.png and b/imgs/run-demo.png differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 5afafc0..48f66c0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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) //参数true:gdb连接到本机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())); +} diff --git a/mainwindow.h b/mainwindow.h index ae34c9d..01a3337 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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); diff --git a/mainwindow.ui b/mainwindow.ui index f7cf1da..09fc99e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 918 - 727 + 893 + 680 @@ -87,14 +87,7 @@ - Axf文件路径 - - - - - - - 请选择axf文件 + 符号文件(AXF/ELF) @@ -111,10 +104,17 @@ + + + + 请设置符号文件 + + + - 设置Axf路径 + 设置符号文件 @@ -128,7 +128,7 @@ 0 0 - 918 + 893 29 @@ -192,6 +192,9 @@ 刷新连接配置 + + 刷新连接配置 + diff --git a/qss/light-blue.qss b/qss/light-blue.qss new file mode 100644 index 0000000..f4b4cd3 --- /dev/null +++ b/qss/light-blue.qss @@ -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); +} diff --git a/qss/qss-img/light-blue-checkbox-checked.png b/qss/qss-img/light-blue-checkbox-checked.png new file mode 100644 index 0000000..da7f1b5 Binary files /dev/null and b/qss/qss-img/light-blue-checkbox-checked.png differ diff --git a/qss/qss-img/light-blue-checkbox-unchecked.png b/qss/qss-img/light-blue-checkbox-unchecked.png new file mode 100644 index 0000000..4d5f5b6 Binary files /dev/null and b/qss/qss-img/light-blue-checkbox-unchecked.png differ diff --git a/qss/qss-img/light-blue-downarrow.png b/qss/qss-img/light-blue-downarrow.png new file mode 100644 index 0000000..07c75c6 Binary files /dev/null and b/qss/qss-img/light-blue-downarrow.png differ diff --git a/qss/qss-img/light-blue-radiobutton-checked.png b/qss/qss-img/light-blue-radiobutton-checked.png new file mode 100644 index 0000000..b2961e3 Binary files /dev/null and b/qss/qss-img/light-blue-radiobutton-checked.png differ diff --git a/qss/qss-img/light-blue-radiobutton-unchecked.png b/qss/qss-img/light-blue-radiobutton-unchecked.png new file mode 100644 index 0000000..0121cc1 Binary files /dev/null and b/qss/qss-img/light-blue-radiobutton-unchecked.png differ diff --git a/qss/qss-img/light-blue-uparrow.png b/qss/qss-img/light-blue-uparrow.png new file mode 100644 index 0000000..634bc56 Binary files /dev/null and b/qss/qss-img/light-blue-uparrow.png differ diff --git a/res.qrc b/res.qrc new file mode 100644 index 0000000..c28f4f1 --- /dev/null +++ b/res.qrc @@ -0,0 +1,11 @@ + + + qss/light-blue.qss + qss/qss-img/light-blue-checkbox-checked.png + qss/qss-img/light-blue-checkbox-unchecked.png + qss/qss-img/light-blue-downarrow.png + qss/qss-img/light-blue-radiobutton-checked.png + qss/qss-img/light-blue-radiobutton-unchecked.png + qss/qss-img/light-blue-uparrow.png + +