Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<model::Image>::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<model::Image>::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<twoDModel::items::ImageItem> 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<twoDModel::items::ImageItem> result(new twoDModel::items::ImageItem(newImage, rect));
result->setMemorize(true);
mModel.worldModel().addImageItem(result);
registerInUndoStack(result.data());
setNoneStatus();
}

void TwoDModelScene::setNoneStatus()
Expand Down
6 changes: 3 additions & 3 deletions qrtranslations/fr/plugins/robots/twoDModel_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
<name>twoDModel::view::TwoDModelScene</name>
<message>
<location filename="../../../../plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp" line="+720"/>
<source>Select image</source>
<source>Select images</source>
<translation type="unfinished"></translation>
</message>
<message>
Expand All @@ -666,7 +666,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+14"/>
<source>Warning</source>
<translation type="unfinished">Attention</translation>
</message>
Expand All @@ -682,7 +682,7 @@
</message>
<message>
<location line="+1"/>
<source>Cannot load file. Try another one.</source>
<source>Cannot load %1. Try another file.</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
14 changes: 9 additions & 5 deletions qrtranslations/ru/plugins/robots/twoDModel_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,17 +995,21 @@
<context>
<name>twoDModel::view::TwoDModelScene</name>
<message>
<location filename="../../../../plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp" line="+720"/>
<source>Select image</source>
<translation>Выберите картинку</translation>
<translation type="vanished">Выберите картинку</translation>
</message>
<message>
<location filename="../../../../plugins/robots/common/twoDModel/src/engine/view/scene/twoDModelScene.cpp" line="+720"/>
<source>Select images</source>
<translation type="unfinished">Выберите картинки</translation>
</message>
<message>
<location line="+2"/>
<source>Graphics (*.*)</source>
<translation>Графика (*.*)</translation>
</message>
<message>
<location line="+7"/>
<location line="+14"/>
<source>Warning</source>
<translation>Предупреждение</translation>
</message>
Expand All @@ -1021,8 +1025,8 @@
</message>
<message>
<location line="+1"/>
<source>Cannot load file. Try another one.</source>
<translation>Невозможно загрузить выбранный файл. Попробуйте другой.</translation>
<source>Cannot load %1. Try another file.</source>
<translation type="unfinished">Невозможно загрузить %1. Попробуйте другой файл.</translation>
</message>
</context>
<context>
Expand Down