From 0123517f62831bb6f1d55f83674a0cd8a12b6b4e Mon Sep 17 00:00:00 2001 From: Silversupplier Date: Thu, 30 Apr 2026 15:00:10 +0900 Subject: [PATCH] [Application] polish layout review approval controls --- src/application/LayoutReviewWidget.cpp | 26 ++++++++++++++++++++++++-- src/application/LayoutReviewWidget.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/application/LayoutReviewWidget.cpp b/src/application/LayoutReviewWidget.cpp index fea327b..812b0b9 100644 --- a/src/application/LayoutReviewWidget.cpp +++ b/src/application/LayoutReviewWidget.cpp @@ -337,6 +337,7 @@ QWidget* createReviewPanel( QLabel** inspectorTitle, QLabel** inspectorDetail, QLabel** approvalStatus, + QPushButton** undoButton, QPushButton** approveButton, QWidget* parent) { auto* panel = new QWidget(parent); @@ -367,9 +368,16 @@ QWidget* createReviewPanel( (*approvalStatus)->setStyleSheet(ui::mutedTextStyleSheet()); layout->addWidget(*approvalStatus); + *undoButton = new QPushButton("Undo Last Edit", panel); + (*undoButton)->setFont(ui::font(ui::FontRole::Body)); + (*undoButton)->setStyleSheet(ui::secondaryButtonStyleSheet()); + (*undoButton)->setToolTip("Undo the last layout correction (Ctrl+Z)"); + layout->addWidget(*undoButton); + *approveButton = new QPushButton("Approve Layout", panel); (*approveButton)->setFont(ui::font(ui::FontRole::Body)); (*approveButton)->setStyleSheet(ui::primaryButtonStyleSheet()); + (*approveButton)->setToolTip("Resolve blocking issues before approval"); layout->addWidget(*approveButton); return panel; @@ -406,6 +414,7 @@ LayoutReviewWidget::LayoutReviewWidget( &inspectorTitleLabel_, &inspectorDetailLabel_, &approvalStatusLabel_, + &undoButton_, &approveButton_, shell_); @@ -426,6 +435,9 @@ LayoutReviewWidget::LayoutReviewWidget( approvalHandler_(importResult_); } }); + connect(undoButton_, &QPushButton::clicked, this, [this]() { + undoLastEdit(); + }); auto* undoShortcut = new QShortcut(QKeySequence::Undo, this); connect(undoShortcut, &QShortcut::activated, this, [this]() { @@ -490,10 +502,20 @@ void LayoutReviewWidget::handlePreviewSelectionChanged(const PreviewSelection& s } void LayoutReviewWidget::refreshApprovalState() { - const auto hasBlocking = safecrowd::domain::hasBlockingImportIssue(importResult_.issues); + const auto blockingCount = std::count_if(importResult_.issues.begin(), importResult_.issues.end(), [](const auto& issue) { + return issue.blocksSimulation(); + }); + const auto hasBlocking = blockingCount > 0; if (approveButton_ != nullptr) { approveButton_->setEnabled(!hasBlocking); + approveButton_->setToolTip(hasBlocking + ? QString("Resolve %1 blocking issue(s) before approval").arg(static_cast(blockingCount)) + : QString("Approve layout and continue to Scenario Authoring")); + } + + if (undoButton_ != nullptr) { + undoButton_->setEnabled(!undoHistory_.empty()); } if (approvalStatusLabel_ == nullptr) { @@ -501,7 +523,7 @@ void LayoutReviewWidget::refreshApprovalState() { } if (hasBlocking) { - approvalStatusLabel_->setText("Resolve blocking issues first"); + approvalStatusLabel_->setText(QString("Resolve %1 blocking issue(s) first").arg(static_cast(blockingCount))); return; } diff --git a/src/application/LayoutReviewWidget.h b/src/application/LayoutReviewWidget.h index 3533404..06a4019 100644 --- a/src/application/LayoutReviewWidget.h +++ b/src/application/LayoutReviewWidget.h @@ -58,6 +58,7 @@ class LayoutReviewWidget : public QWidget { QLabel* inspectorTitleLabel_{nullptr}; QLabel* inspectorDetailLabel_{nullptr}; QLabel* approvalStatusLabel_{nullptr}; + QPushButton* undoButton_{nullptr}; QPushButton* approveButton_{nullptr}; NavigationView navigationView_{NavigationView::Issues}; QString selectedIssueTargetId_{};