-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOverwriteClustersConfirmationDialog.cpp
More file actions
53 lines (38 loc) · 2.04 KB
/
Copy pathOverwriteClustersConfirmationDialog.cpp
File metadata and controls
53 lines (38 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: LGPL-3.0-or-later
// A corresponding LICENSE file is located in the root directory of this source tree
// Copyright (C) 2023 BioVault (Biomedical Visual Analytics Unit LUMC - TU Delft)
#include "OverwriteClustersConfirmationDialog.h"
#include <Application.h>
#include <QVBoxLayout>
#include <QLabel>
using namespace mv;
using namespace mv::util;
OverwriteClustersConfirmationDialog::OverwriteClustersConfirmationDialog(QWidget* parent, std::uint32_t numberOfUserClusters, std::uint32_t numberOfUserModifiedClusters) :
QDialog(parent),
_alwaysAskPermissionAction(this, "Always ask permission"),
_discardAction(this, "Discard"),
_cancelAction(this, "Cancel")
{
setWindowIcon(StyledIcon("shuffle"));
setWindowTitle("About to overwrite all cluster(s)");
setModal(true);
// Check whether to show the dialog again or not
_alwaysAskPermissionAction.setChecked(true);
auto layout = new QVBoxLayout();
setLayout(layout);
// Ask for confirmation question
const auto confirmationQuestion = QString("You made changes to %1 cluster%2, would you like to discard these changes?").arg(QString::number(numberOfUserModifiedClusters), numberOfUserModifiedClusters > 1 ? "s" : "");
layout->addWidget(new QLabel(confirmationQuestion));
auto bottomLayout = new QHBoxLayout();
bottomLayout->addWidget(_alwaysAskPermissionAction.createWidget(this));
bottomLayout->addStretch(1);
bottomLayout->addWidget(_discardAction.createWidget(this));
bottomLayout->addWidget(_cancelAction.createWidget(this));
layout->addStretch(1);
layout->addLayout(bottomLayout);
connect(&_alwaysAskPermissionAction, &gui::ToggleAction::toggled, this, [this](bool toggled) {
Application::current()->setSetting("OverwriteClustersAskConfirmation", toggled);
});
connect(&_discardAction, &gui::TriggerAction::triggered, this, &OverwriteClustersConfirmationDialog::accept);
connect(&_cancelAction, &gui::TriggerAction::triggered, this, &OverwriteClustersConfirmationDialog::reject);
}