File indexing completed on 2025-01-05 05:23:36

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2006-2007, 2009, 2013 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "replaceprompt.hpp"
0010 
0011 // KF
0012 #include <KLocalizedString>
0013 // Qt
0014 #include <QDialogButtonBox>
0015 #include <QVBoxLayout>
0016 #include <QPushButton>
0017 
0018 namespace Kasten {
0019 
0020 ReplacePrompt::ReplacePrompt(QWidget* parent)
0021     : QDialog(parent)
0022 {
0023     setModal(true);
0024     setWindowTitle(i18nc("@title:window prompt for iterative replacement", "Replace"));
0025 
0026     // dialog buttons
0027     auto* dialogButtonBox = new QDialogButtonBox;
0028     QPushButton* button = dialogButtonBox->addButton(i18nc("@action:button", "Replace &All"),
0029                                                      QDialogButtonBox::ApplyRole);
0030     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onReplaceAllButton);
0031     button = dialogButtonBox->addButton(i18nc("@action:button", "&Skip"),
0032                                         QDialogButtonBox::ApplyRole);
0033     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onSkipButton);
0034     QPushButton* replaceButton = dialogButtonBox->addButton(i18nc("@action:button", "Replace"),
0035                                                             QDialogButtonBox::ApplyRole);
0036     connect(replaceButton, &QAbstractButton::clicked, this, &ReplacePrompt::onReplaceButton);
0037     button = dialogButtonBox->addButton(QDialogButtonBox::Close);
0038     connect(button, &QAbstractButton::clicked, this, &ReplacePrompt::onCloseButton);
0039 
0040     // main layout
0041     auto* layout = new QVBoxLayout;
0042     layout->addWidget(dialogButtonBox);
0043 
0044     setLayout(layout);
0045     resize(minimumSize());
0046 
0047     replaceButton->setDefault(true);
0048 }
0049 
0050 void ReplacePrompt::onReplaceAllButton()
0051 {
0052     Q_EMIT finished(ReplaceAll);
0053 }
0054 
0055 void ReplacePrompt::onSkipButton()
0056 {
0057     Q_EMIT finished(SkipCurrent);
0058 }
0059 
0060 void ReplacePrompt::onReplaceButton()
0061 {
0062     Q_EMIT finished(ReplaceCurrent);
0063 }
0064 
0065 void ReplacePrompt::onCloseButton()
0066 {
0067     Q_EMIT finished(CancelReplacing);
0068 }
0069 
0070 }
0071 
0072 #include "moc_replaceprompt.cpp"