From 57f8c1b6af3bb378938a75baea554788a4b7cd24 Mon Sep 17 00:00:00 2001 From: brige Date: Sun, 6 Jul 2025 00:10:59 +0800 Subject: [PATCH] modify chatplot menu ui --- src/translations/Dyt_zh_CN.ts | 109 +++++------------ src/ui/Layout/CodeEdtUI.cpp | 10 +- src/ui/MainWindow.cpp | 14 +-- src/ui/Menu/ChartPlotMenu.cpp | 88 ++++++------- src/ui/PropertyBrowser/qtpropertymanager.cpp | 122 +------------------ 5 files changed, 87 insertions(+), 256 deletions(-) diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts index 53106946..3c79bcc8 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -120,34 +120,6 @@ - - CodeEdtUI - - - matlab editor - - - - - &bat - - - - - &Control - - - - - &Run - - - - - &Save - - - CodeEdtUIClass @@ -959,48 +931,48 @@ QtConeWaveComponentManager - - + + ConeWaveComponent - + Height - + Radius - + waveCount - + waveSpeed - + baseColor - + waveColor - + ringBrightAlpha - + ringDarkAlpha @@ -1106,28 +1078,28 @@ QtDashedLineComponentManager - - + + DashedLineComponent - + Start - + End - + Radius - + Color @@ -1143,17 +1115,17 @@ QtEntityPropertyManager - + Name - + Visible - + Transform @@ -1235,13 +1207,13 @@ QtMeshComponetManager - - + + MeshComponent - + Mesh @@ -1290,13 +1262,13 @@ QtPathComponentManager - - + + PathComponent - + Path @@ -1546,45 +1518,20 @@ QtWorkspacePropertyManager - + Name - + Description - + Timestep - - - SimMatlab - - - - - MatlabParam - - - - - Wave - - - - - RD - - - - - Report - - SignalIndicatorLampUI diff --git a/src/ui/Layout/CodeEdtUI.cpp b/src/ui/Layout/CodeEdtUI.cpp index 18ca4965..e1225488 100644 --- a/src/ui/Layout/CodeEdtUI.cpp +++ b/src/ui/Layout/CodeEdtUI.cpp @@ -71,7 +71,7 @@ void CodeEdtUI::AttachDock(DockWidget* dockWidget) DockTitleBar* dockTitleBar = new DockTitleBar; - dockTitleBar->SetTitle(tr("matlab editor")); + dockTitleBar->SetTitle(u8"bat文件"); dockWidget->SetDockWidgetTitleBar(dockTitleBar); } @@ -79,7 +79,7 @@ void CodeEdtUI::AttachDock(DockWidget* dockWidget) void CodeEdtUI::InitBat() { { - QMenu* fileMenu = menuBar()->addMenu(tr("&bat")); + QMenu* fileMenu = menuBar()->addMenu(u8"文件"); QDir dir(RecourceHelper::Get().GetBasePath() + "/bat"); QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); @@ -99,12 +99,12 @@ void CodeEdtUI::InitBat() } { - QMenu* ctrlMenu = menuBar()->addMenu(tr("&Control")); + QMenu* ctrlMenu = menuBar()->addMenu(u8"控制"); - QAction* runAction = new QAction(tr("&Run"), this); + QAction* runAction = new QAction(tr(u8"执行"), this); ctrlMenu->addAction(runAction); - QAction* saveAction = new QAction(tr("&Save"), this); + QAction* saveAction = new QAction(u8"保存", this); ctrlMenu->addAction(saveAction); connect(runAction, &QAction::triggered, this, &CodeEdtUI::runFile); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 17a420b0..0554d49c 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -336,14 +336,14 @@ void MainWindow::AddDockArea(const QString& strArea) { } void MainWindow::OnTabifiedDockWidgetActivated(QDockWidget* dockWidget) { - if (dockWidget) { - QMainWindow* mainWindow = qobject_cast(dockWidget->parentWidget()); - if (mainWindow) { - mainWindow->removeDockWidget(dockWidget); - } + //if (dockWidget) { + // QMainWindow* mainWindow = qobject_cast(dockWidget->parentWidget()); + // if (mainWindow) { + // mainWindow->removeDockWidget(dockWidget); + // } - // tabWidget_->setCurrentWidget(dockWidget->parentWidget()); - } + // // tabWidget_->setCurrentWidget(dockWidget->parentWidget()); + //} } void MainWindow::slotShowUISetting() { diff --git a/src/ui/Menu/ChartPlotMenu.cpp b/src/ui/Menu/ChartPlotMenu.cpp index b6415578..225215b8 100644 --- a/src/ui/Menu/ChartPlotMenu.cpp +++ b/src/ui/Menu/ChartPlotMenu.cpp @@ -33,7 +33,7 @@ void ChartPlotMenu::InitMenu() } else { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查仿真文件路径是否存在!")); + QMessageBox::information(nullptr, QString::fromLocal8Bit("鎻愮ず"), QString::fromLocal8Bit("璇锋鏌ヤ豢鐪熸枃浠惰矾寰勬槸鍚﹀瓨鍦紒")); } } }); @@ -41,30 +41,30 @@ void ChartPlotMenu::InitMenu() connect(ui.toolButton_2, &QToolButton::clicked, this, [=] { auto current = WorkSpaceManager::Get().GetCurrent(); if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); + QMessageBox::information(nullptr, QString::fromLocal8Bit("鎻愮ず"), QString::fromLocal8Bit("璇峰厛鍒涘缓绌洪棿锛")); return; } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择仿真运行文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.m"); + QString strSel = QFileDialog::getOpenFileName(this, u8"閫夋嫨浠跨湡杩愯鏂囦欢", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.m"); if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); + LOG_WARN("閫夋嫨鏂囦欢涓虹┖"); return; } const QString old = current->GetSimMatlab(); if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); + LOG_INFO("閫夋嫨鏂囦欢涓庡綋鍓嶆枃浠剁浉鍚"); return; } else if (!old.isEmpty()) { if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前仿真文件!"), + QString::fromLocal8Bit("璇㈤棶"), + QString::fromLocal8Bit("鏇挎崲褰撳墠浠跨湡鏂囦欢锛"), QMessageBox::Yes | QMessageBox::No) ) { if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); + LOG_WARN("鍒犻櫎鏂囦欢澶辫触"); QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); + QString::fromLocal8Bit("鎻愮ず"), + QString::fromLocal8Bit("鍒犻櫎鏂囦欢澶辫触锛")); return; } } @@ -76,32 +76,34 @@ void ChartPlotMenu::InitMenu() connect(ui.toolButton_5, &QToolButton::clicked, this, [=] { auto current = WorkSpaceManager::Get().GetCurrent(); if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); + QMessageBox::information(nullptr, QString::fromLocal8Bit("鎻愮ず"), QString::fromLocal8Bit("璇峰厛鍒涘缓绌洪棿锛")); return; } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择Wave文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); + QString strSel = QFileDialog::getOpenFileName(this, u8"閫夋嫨Wave鏂囦欢", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); + LOG_WARN("閫夋嫨鏂囦欢涓虹┖"); return; } const QString old = current->GetWavePath(); if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); + LOG_INFO("閫夋嫨鏂囦欢涓庡綋鍓嶆枃浠剁浉鍚"); return; } else if (!old.isEmpty()) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前Wave文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; + if (QFileInfo(old).isFile() && QFile::exists(old)) { + if (QMessageBox::Yes == QMessageBox::question(nullptr, + QString::fromLocal8Bit("璇㈤棶"), + QString::fromLocal8Bit("鏇挎崲褰撳墠Wave鏂囦欢锛"), + QMessageBox::Yes | QMessageBox::No) + ) { + if (!QFile::remove(old)) { + LOG_WARN("鍒犻櫎鏂囦欢澶辫触"); + QMessageBox::information(nullptr, + QString::fromLocal8Bit("鎻愮ず"), + QString::fromLocal8Bit("鍒犻櫎鏂囦欢澶辫触锛")); + return; + } } } } @@ -112,32 +114,32 @@ void ChartPlotMenu::InitMenu() connect(ui.toolButton_3, &QToolButton::clicked, this, [=] { auto current = WorkSpaceManager::Get().GetCurrent(); if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); + QMessageBox::information(nullptr, QString::fromLocal8Bit("鎻愮ず"), QString::fromLocal8Bit("璇峰厛鍒涘缓绌洪棿锛")); return; } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择RD文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); + QString strSel = QFileDialog::getOpenFileName(this, u8"閫夋嫨RD鏂囦欢", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); + LOG_WARN("閫夋嫨鏂囦欢涓虹┖"); return; } const QString old = current->GetRDPath(); if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); + LOG_INFO("閫夋嫨鏂囦欢涓庡綋鍓嶆枃浠剁浉鍚"); return; } else if (!old.isEmpty()) { if (QFileInfo(old).isFile()) { if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前RD文件!"), + QString::fromLocal8Bit("璇㈤棶"), + QString::fromLocal8Bit("鏇挎崲褰撳墠RD鏂囦欢锛"), QMessageBox::Yes | QMessageBox::No) ) { if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); + LOG_WARN("鍒犻櫎鏂囦欢澶辫触"); QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); + QString::fromLocal8Bit("鎻愮ず"), + QString::fromLocal8Bit("鍒犻櫎鏂囦欢澶辫触锛")); return; } } @@ -150,31 +152,31 @@ void ChartPlotMenu::InitMenu() connect(ui.toolButton_4, &QToolButton::clicked, this, [=] { auto current = WorkSpaceManager::Get().GetCurrent(); if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); + QMessageBox::information(nullptr, QString::fromLocal8Bit("鎻愮ず"), QString::fromLocal8Bit("璇峰厛鍒涘缓绌洪棿锛")); return; } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择Report文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); + QString strSel = QFileDialog::getOpenFileName(this, u8"閫夋嫨Report鏂囦欢", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); + LOG_WARN("閫夋嫨鏂囦欢涓虹┖"); return; } const QString old = current->GetReportPath(); if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); + LOG_INFO("閫夋嫨鏂囦欢涓庡綋鍓嶆枃浠剁浉鍚"); return; } else if (!old.isEmpty()) { if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前Report文件!"), + QString::fromLocal8Bit("璇㈤棶"), + QString::fromLocal8Bit("鏇挎崲褰撳墠Report鏂囦欢锛"), QMessageBox::Yes | QMessageBox::No) ) { if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); + LOG_WARN("鍒犻櫎鏂囦欢澶辫触"); QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); + QString::fromLocal8Bit("鎻愮ず"), + QString::fromLocal8Bit("鍒犻櫎鏂囦欢澶辫触锛")); return; } } diff --git a/src/ui/PropertyBrowser/qtpropertymanager.cpp b/src/ui/PropertyBrowser/qtpropertymanager.cpp index 65ade017..7c6ca7cf 100644 --- a/src/ui/PropertyBrowser/qtpropertymanager.cpp +++ b/src/ui/PropertyBrowser/qtpropertymanager.cpp @@ -7911,22 +7911,10 @@ public: QMap m_properyToName; QMap m_properyToDescription; QMap m_properyToTimestep; - QMap m_properyToSimMatlab; - QMap m_properyToMatlabParam; - - QMap m_properyToWave; - QMap m_properyToReport; - QMap m_properyToRD; QMap m_nameToPropery; QMap m_descriptionToPropery; QMap m_timestepToPropery; - QMap m_simMatlabToPropery; - QMap m_matlabParamToPropery; - - QMap m_waveToPropery; - QMap m_reportToPropery; - QMap m_rdToPropery; }; void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property, QString value) { @@ -7942,11 +7930,7 @@ void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property, QWorkspaceAttribute c = m_values[prop]; c.SetTimeStep(value); q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_simMatlabToPropery.value(property, 0)) { - QWorkspaceAttribute c = m_values[prop]; - c.SetSimMatlab(value); - q_ptr->setValue(prop, c); - } + } } void QtWorkspacePropertyManagerPrivate::slotPropertyDestroyed(QtProperty* property) { @@ -7964,31 +7948,6 @@ void QtWorkspacePropertyManagerPrivate::slotPropertyDestroyed(QtProperty* proper m_timestepToPropery[subProp] = 0; m_timestepToPropery.remove(property); } - - if (QtProperty* subProp = m_simMatlabToPropery.value(property, nullptr)) { - m_simMatlabToPropery[subProp] = 0; - m_simMatlabToPropery.remove(property); - } - - if (QtProperty* subProp = m_matlabParamToPropery.value(property, nullptr)) { - m_matlabParamToPropery[subProp] = 0; - m_matlabParamToPropery.remove(property); - } - - if (QtProperty* subProp = m_waveToPropery.value(property, nullptr)) { - m_waveToPropery[subProp] = 0; - m_waveToPropery.remove(property); - } - - if (QtProperty* subProp = m_reportToPropery.value(property, nullptr)) { - m_reportToPropery[subProp] = 0; - m_reportToPropery.remove(property); - } - - if (QtProperty* subProp = m_rdToPropery.value(property, nullptr)) { - m_rdToPropery[subProp] = 0; - m_rdToPropery.remove(property); - } } QtWorkspacePropertyManager::QtWorkspacePropertyManager(QObject* parent) @@ -8073,12 +8032,6 @@ void QtWorkspacePropertyManager::setValue(QtProperty* property, const QWorkspace d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToName[property], value.GetName()); d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToDescription[property], value.GetDescription()); d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToTimestep[property], value.GetTimeStep()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToSimMatlab[property], value.GetSimMatlab()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToMatlabParam[property], value.GetMatlabParam()); - - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToWave[property], value.GetWavePath()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToReport[property], value.GetReportPath()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToRD[property], value.GetRDPath()); emit propertyChanged(property); emit valueChanged(property, value); @@ -8111,41 +8064,6 @@ void QtWorkspacePropertyManager::initializeProperty(QtProperty* property) { d_ptr->m_properyToTimestep[property] = prop; d_ptr->m_timestepToPropery[prop] = property; property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("SimMatlab")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetSimMatlab()); - d_ptr->m_properyToSimMatlab[property] = prop; - d_ptr->m_simMatlabToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("MatlabParam")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetMatlabParam()); - d_ptr->m_properyToMatlabParam[property] = prop; - d_ptr->m_matlabParamToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("Wave")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetWavePath()); - d_ptr->m_properyToWave[property] = prop; - d_ptr->m_waveToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("RD")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetRDPath()); - d_ptr->m_properyToRD[property] = prop; - d_ptr->m_rdToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("Report")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetReportPath()); - d_ptr->m_properyToReport[property] = prop; - d_ptr->m_reportToPropery[prop] = property; - property->addSubProperty(prop); } /*! @@ -8172,41 +8090,6 @@ void QtWorkspacePropertyManager::uninitializeProperty(QtProperty* property) { delete prop; } d_ptr->m_properyToTimestep.remove(property); - - prop = d_ptr->m_simMatlabToPropery[property]; - if (prop) { - d_ptr->m_simMatlabToPropery.remove(prop); - delete prop; - } - d_ptr->m_properyToSimMatlab.remove(property); - - prop = d_ptr->m_matlabParamToPropery[property]; - if (prop) { - d_ptr->m_matlabParamToPropery.remove(prop); - delete prop; - } - d_ptr->m_properyToMatlabParam.remove(property); - - prop = d_ptr->m_waveToPropery[property]; - if (prop) { - d_ptr->m_waveToPropery.remove(prop); - delete prop; - } - d_ptr->m_properyToWave.remove(property); - - prop = d_ptr->m_reportToPropery[property]; - if (prop) { - d_ptr->m_reportToPropery.remove(prop); - delete prop; - } - d_ptr->m_properyToReport.remove(property); - - prop = d_ptr->m_rdToPropery[property]; - if (prop) { - d_ptr->m_rdToPropery.remove(prop); - delete prop; - } - d_ptr->m_properyToRD.remove(property); } #pragma endregion @@ -8917,9 +8800,8 @@ QtConeWaveComponentManager::QtConeWaveComponentManager(QObject* parent) this, SLOT(slotPropertyDestroyed(QtProperty*))); d_ptr->m_intProperyManager = new QtIntPropertyManager(this); - bool intConnected = connect(d_ptr->m_intProperyManager, SIGNAL(valueChanged(QtProperty*, int)), + connect(d_ptr->m_intProperyManager, SIGNAL(valueChanged(QtProperty*, int)), this, SLOT(slotIntChanged(QtProperty*, int))); - qDebug() << "Int manager connection result:" << intConnected; connect(d_ptr->m_intProperyManager, SIGNAL(propertyDestroyed(QtProperty*)), this, SLOT(slotPropertyDestroyed(QtProperty*)));