diff --git a/plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp b/plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp index 6fc04e16e6..3222afd02b 100644 --- a/plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp +++ b/plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp @@ -716,41 +716,47 @@ void TwoDModelScene::addEllipse() void TwoDModelScene::addImage() { // Loads world and robot models simultaneously. - const QString loadFileName = utils::QRealFileDialog::getOpenFileName("2DSelectImage", views().first() - , tr("Select image") + const auto loadImages = utils::QRealFileDialog::getOpenFileNames("2DSelectImage", views().first() + , tr("Select images") , qReal::PlatformInfo::invariantSettingsPath("pathToImages") + "/../fields" , tr("Graphics (*.*)")); - if (loadFileName.isEmpty()) { - return; - } - QFile imageFile(loadFileName); - if (imageFile.size() > 5 * 1024 * 1024) { - if (utils::QRealMessageBox::question(QApplication::focusWidget(), tr("Warning") - , tr("You are trying to load to big image, it may freeze execution for some time. Continue?")) - != QMessageBox::Yes) { - return; + + const auto gridSize = SettingsManager::value("2dGridCellSize").toInt(); + const QPoint step(gridSize, gridSize); + QPoint topLeft = mainView()->mapToScene(0,0).toPoint() + step; + + for (auto &&loadFileName : loadImages) { + if (loadFileName.isEmpty()) { + continue; } - } - auto newImage = QSharedPointer::create(loadFileName, false); - auto size = newImage->preferedSize(); - if (size.width() == 0 || size.height() == 0) { - if (utils::QRealMessageBox::question(QApplication::focusWidget(), tr("Error") - , tr("Cannot load file. Try another one.") - , QMessageBox::StandardButtons(QMessageBox::Retry | QMessageBox::Close)) - == QMessageBox::Retry) { - addImage(); + QFile imageFile(loadFileName); + if (imageFile.size() > 5 * 1024 * 1024) { + if (utils::QRealMessageBox::question(QApplication::focusWidget(), tr("Warning") + , tr("You are trying to load to big image, it may freeze execution for some time. Continue?")) + != QMessageBox::Yes) { + continue; + } } - return; + + auto newImage = QSharedPointer::create(loadFileName, false); + auto size = newImage->preferedSize(); + if (size.width() == 0 || size.height() == 0) { + utils::QRealMessageBox::question(QApplication::focusWidget(), tr("Error") + , tr("Cannot load %1. Try another file.").arg(loadFileName) + , QMessageBox::StandardButtons(QMessageBox::Close)); + continue; + } + mDrawingAction = image; + const QRect rect(topLeft, size); + QSharedPointer result(new twoDModel::items::ImageItem(newImage, rect)); + result->setMemorize(true); + mModel.worldModel().addImageItem(result); + registerInUndoStack(result.data()); + setNoneStatus(); + topLeft += step; } - mDrawingAction = image; - const QRect rect(QPoint(-size.width() / 2, -size.height() / 2), size); - QSharedPointer result(new twoDModel::items::ImageItem(newImage, rect)); - result->setMemorize(true); - mModel.worldModel().addImageItem(result); - registerInUndoStack(result.data()); - setNoneStatus(); } void TwoDModelScene::setNoneStatus() diff --git a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts index 3c479f8543..21bbe71f27 100644 --- a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts +++ b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts @@ -657,7 +657,7 @@ twoDModel::view::TwoDModelScene - Select image + Select images @@ -666,7 +666,7 @@ - + Warning Attention @@ -682,7 +682,7 @@ - Cannot load file. Try another one. + Cannot load %1. Try another file. diff --git a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts index c09c3fab1f..9a16aa8064 100644 --- a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts +++ b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts @@ -995,9 +995,13 @@ twoDModel::view::TwoDModelScene - Select image - Выберите картинку + Выберите картинку + + + + Select images + Выберите картинки @@ -1005,7 +1009,7 @@ Графика (*.*) - + Warning Предупреждение @@ -1021,8 +1025,8 @@ - Cannot load file. Try another one. - Невозможно загрузить выбранный файл. Попробуйте другой. + Cannot load %1. Try another file. + Невозможно загрузить %1. Попробуйте другой файл.