Fix: 选择文件时未对“未选择”的情况做处理 | #19

dev-wuyize
yang.yongquan 2023-03-21 13:57:16 +08:00
parent 2581624388
commit 93537954a9
1 changed files with 6 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <QInputDialog>
#include <QFileDialog>
#include <QDialogButtonBox>
#include <QMessagebox>
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent)
@ -125,7 +126,12 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
{
menu->addAction(QString::fromLocal8Bit("添加元素从svg导入"), this, [this]() {
QString filePath = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("打开文件"), "", "SVG Files (*.svg)");
filePath = filePath.trimmed();
QFileInfo fileInfo(filePath);
if (!fileInfo.exists() || !fileInfo.isFile()) {
QMessageBox::warning(this, tr("Error"), QString::fromLocal8Bit("请选择Svg文件"));
return;
}
QString fileName = fileInfo.fileName();
qDebug() << fileName << " " << filePath;
this->elementManager->createSimpleElement(fileName, filePath);