Skip to content
Closed
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
26 changes: 24 additions & 2 deletions src/application/LayoutReviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ QWidget* createReviewPanel(
QLabel** inspectorTitle,
QLabel** inspectorDetail,
QLabel** approvalStatus,
QPushButton** undoButton,
QPushButton** approveButton,
QWidget* parent) {
auto* panel = new QWidget(parent);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -406,6 +414,7 @@ LayoutReviewWidget::LayoutReviewWidget(
&inspectorTitleLabel_,
&inspectorDetailLabel_,
&approvalStatusLabel_,
&undoButton_,
&approveButton_,
shell_);

Expand All @@ -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]() {
Expand Down Expand Up @@ -490,18 +502,28 @@ 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<int>(blockingCount))
: QString("Approve layout and continue to Scenario Authoring"));
}

if (undoButton_ != nullptr) {
undoButton_->setEnabled(!undoHistory_.empty());
}

if (approvalStatusLabel_ == nullptr) {
return;
}

if (hasBlocking) {
approvalStatusLabel_->setText("Resolve blocking issues first");
approvalStatusLabel_->setText(QString("Resolve %1 blocking issue(s) first").arg(static_cast<int>(blockingCount)));
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/application/LayoutReviewWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_{};
Expand Down
Loading