支持批量导入svg

main
wuyize 2023-04-10 19:29:30 +08:00
parent ee0bc1094e
commit 9f90622c6b
1 changed files with 11 additions and 8 deletions

View File

@ -170,16 +170,19 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
else else
{ {
menu->addAction(QString::fromLocal8Bit("Ìí¼ÓÔªËØ£¨´Ósvgµ¼È룩"), this, [this]() { menu->addAction(QString::fromLocal8Bit("Ìí¼ÓÔªËØ£¨´Ósvgµ¼È룩"), this, [this]() {
QString filePath = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("打开文件"), "", "SVG Files (*.svg)"); auto filePaths = QFileDialog::getOpenFileNames(this, QString::fromLocal8Bit("打开文件"), "", "SVG Files (*.svg)");
filePath = filePath.trimmed(); if (filePaths.empty())
QFileInfo fileInfo(filePath); {
if (!fileInfo.exists() || !fileInfo.isFile()) { //QMessageBox::warning(this, tr("Error"), QString::fromLocal8Bit("请选择Svg文件"));
QMessageBox::warning(this, tr("Error"), QString::fromLocal8Bit("请选择Svg文件"));
return; return;
} }
QString fileName = fileInfo.fileName();
qDebug() << fileName << " " << filePath; for (auto& filePath : filePaths)
this->elementManager->createSimpleElement(fileName, filePath); {
QFileInfo fileInfo(filePath);
QString fileName = fileInfo.fileName();
this->elementManager->createSimpleElement(fileName, filePath);
}
this->refresh(); this->refresh();
emit triggerCentralRefresh(); emit triggerCentralRefresh();
}); });