1 /*
2     This file is part of the Okteta Kasten module, made within the KDE community.
3 
4     SPDX-FileCopyrightText: 2006-2007, 2009, 2013 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #include "replaceprompt.hpp"
10 
11 // KF
12 #include <KLocalizedString>
13 // Qt
14 #include <QDialogButtonBox>
15 #include <QVBoxLayout>
16 #include <QPushButton>
17 
18 namespace Kasten {
19 
ReplacePrompt(QWidget * parent)20 ReplacePrompt::ReplacePrompt(QWidget* parent)
21     : QDialog(parent)
22 {
23     setModal(true);
24     setWindowTitle(i18nc("@title:window prompt for iterative replacement", "Replace"));
25 
26     // dialog buttons
27     auto* dialogButtonBox = new QDialogButtonBox;
28     QPushButton* button = dialogButtonBox->addButton(i18nc("@action:button", "Replace &All"),
29                                                      QDialogButtonBox::ApplyRole);
30     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onReplaceAllButton);
31     button = dialogButtonBox->addButton(i18nc("@action:button", "&Skip"),
32                                         QDialogButtonBox::ApplyRole);
33     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onSkipButton);
34     QPushButton* replaceButton = dialogButtonBox->addButton(i18nc("@action:button", "Replace"),
35                                                             QDialogButtonBox::ApplyRole);
36     connect(replaceButton, &QAbstractButton::clicked, this, &ReplacePrompt::onReplaceButton);
37     button = dialogButtonBox->addButton(QDialogButtonBox::Close);
38     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onCloseButton);
39 
40     // main layout
41     auto* layout = new QVBoxLayout;
42     layout->addWidget(dialogButtonBox);
43 
44     setLayout(layout);
45     resize(minimumSize());
46 
47     replaceButton->setDefault(true);
48 }
49 
onReplaceAllButton()50 void ReplacePrompt::onReplaceAllButton()
51 {
52     emit finished(ReplaceAll);
53 }
54 
onSkipButton()55 void ReplacePrompt::onSkipButton()
56 {
57     emit finished(SkipCurrent);
58 }
59 
onReplaceButton()60 void ReplacePrompt::onReplaceButton()
61 {
62     emit finished(ReplaceCurrent);
63 }
64 
onCloseButton()65 void ReplacePrompt::onCloseButton()
66 {
67     emit finished(CancelReplacing);
68 }
69 
70 }
71