From ed4f2945da180fca4cb0942dbeeffab498c017bb Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 22 Apr 2024 12:26:12 +0300 Subject: [PATCH] Show a piece position status in Property tab. --- src/app/puzzle/vpmainwindow.cpp | 18 +++++++ src/app/puzzle/vpmainwindow.ui | 63 ++++++++++++++++++++--- src/libs/vtools/dialogs/dialogtoolbox.cpp | 2 +- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 2cb6b7777..4b53aa594 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -883,6 +883,17 @@ void VPMainWindow::InitPropertyTabCurrentPiece() connect(ui->checkBoxCurrentPieceHorizontallyFlipped, &QCheckBox::toggled, this, &VPMainWindow::CurrentPieceHorizontallyFlippedToggled); + const QIcon warningIcon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + auto WarningIcon = [warningIcon](QLabel *label) + { + const int size = qRound(16 * label->devicePixelRatio()); + label->setPixmap(warningIcon.pixmap(size, size)); + }; + + WarningIcon(ui->labelWarningOutOfBound); + WarningIcon(ui->labelWarningSuperpositionOfPieces); + WarningIcon(ui->labelWarningPieceGape); + // Translate ui->comboBoxTranslateUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); ui->comboBoxTranslateUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); @@ -1356,12 +1367,14 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui->labelCurrentPieceNoPieceSelected->setVisible(true); ui->groupBoxCurrentPieceInfo->setVisible(false); + ui->groupBoxCurrentPieceStatus->setVisible(false); ui->groupBoxPieceTransformation->setVisible(false); ui->groupBoxCurrentPieceGeometry->setVisible(false); } else if (selectedPieces.count() == 1) { ui->groupBoxCurrentPieceInfo->setVisible(true); + ui->groupBoxCurrentPieceStatus->setVisible(true); ui->groupBoxPieceTransformation->setVisible(true); ui->groupBoxCurrentPieceGeometry->setVisible(true); @@ -1373,6 +1386,10 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() SetLineEditValue(ui->lineEditCurrentPieceGradationId, selectedPiece->GetGradationId()); SetLineEditValue(ui->lineEditCopyNumber, QString::number(selectedPiece->CopyNumber())); + ui->labelWarningOutOfBound->setEnabled(selectedPiece->OutOfBound()); + ui->labelWarningSuperpositionOfPieces->setEnabled(selectedPiece->HasSuperpositionWithPieces()); + ui->labelWarningPieceGape->setEnabled(selectedPiece->HasInvalidPieceGapPosition()); + SetCheckBoxValue(ui->checkBoxCurrentPieceShowSeamline, not selectedPiece->IsHideMainPath()); SetCheckBoxValue(ui->checkBoxCurrentPieceVerticallyFlipped, selectedPiece->IsVerticallyFlipped()); SetCheckBoxValue(ui->checkBoxCurrentPieceHorizontallyFlipped, selectedPiece->IsHorizontallyFlipped()); @@ -1401,6 +1418,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() { // show the content "multiple pieces selected" ui->groupBoxCurrentPieceInfo->setVisible(false); + ui->groupBoxCurrentPieceStatus->setVisible(false); ui->groupBoxPieceTransformation->setVisible(true); ui->groupBoxCurrentPieceGeometry->setVisible(false); diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 84d16c6bc..3e66d253c 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -279,8 +279,8 @@ 0 0 - 378 - 752 + 385 + 865 @@ -395,6 +395,57 @@ + + + + Status + + + + + + Warning! + + + + + + + Out of bound + + + + + + + Warning! + + + + + + + Superposition of pieces + + + + + + + Warning! + + + + + + + Piece gape + + + + + + @@ -752,7 +803,7 @@ 0 0 - 378 + 385 829 @@ -1276,7 +1327,7 @@ 0 0 - 392 + 399 700 @@ -1659,7 +1710,7 @@ 0 0 - 378 + 385 710 @@ -2455,8 +2506,8 @@ + - diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index 5b4f89821..95a7ca30f 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -615,7 +615,7 @@ auto DialogWarningIcon() -> QString QByteArray byteArray; QBuffer buffer(&byteArray); pixmap.save(&buffer, "PNG"); - return QStringLiteral(" "); + return QStringLiteral(" "_L1; } //---------------------------------------------------------------------------------------------------------------------