File indexing completed on 2024-11-24 04:43:06
0001 /* 0002 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "confirmbeforedeletingmessageboxwidget.h" 0008 #include <QCheckBox> 0009 #include <QLabel> 0010 #include <QVBoxLayout> 0011 0012 #include <KLocalizedString> 0013 #include <QStyle> 0014 #include <QStyleOption> 0015 0016 ConfirmBeforeDeletingMessageBoxWidget::ConfirmBeforeDeletingMessageBoxWidget(QWidget *parent) 0017 : QWidget(parent) 0018 , mLabelInfo(new QLabel(this)) 0019 , mUseSameResultForOtherCheck(new QCheckBox(i18n("Apply to All"), this)) 0020 { 0021 auto mainLayout = new QHBoxLayout(this); 0022 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0023 mainLayout->setContentsMargins({}); 0024 0025 const QIcon tmpIcon = style()->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, this); 0026 auto iconLabel = new QLabel(this); 0027 iconLabel->setObjectName(QLatin1StringView("iconLabel")); 0028 if (!tmpIcon.isNull()) { 0029 QStyleOption option; 0030 option.initFrom(this); 0031 iconLabel->setPixmap(tmpIcon.pixmap(style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, this))); 0032 } 0033 mainLayout->addWidget(iconLabel); 0034 0035 auto textLayout = new QVBoxLayout; 0036 textLayout->setObjectName(QLatin1StringView("textLayout")); 0037 textLayout->setContentsMargins({}); 0038 0039 mainLayout->addLayout(textLayout); 0040 0041 mLabelInfo->setObjectName(QLatin1StringView("mLabelInfo")); 0042 mLabelInfo->setWordWrap(true); 0043 textLayout->addWidget(mLabelInfo, Qt::AlignTop); 0044 0045 mUseSameResultForOtherCheck->setObjectName(QLatin1StringView("mUseSameResultForOtherCheck")); 0046 textLayout->addWidget(mUseSameResultForOtherCheck); 0047 0048 mUseSameResultForOtherCheck->setChecked(false); 0049 } 0050 0051 ConfirmBeforeDeletingMessageBoxWidget::~ConfirmBeforeDeletingMessageBoxWidget() = default; 0052 0053 void ConfirmBeforeDeletingMessageBoxWidget::setInfo(const QString &str) 0054 { 0055 mLabelInfo->setText(str); 0056 } 0057 0058 bool ConfirmBeforeDeletingMessageBoxWidget::useSameResult() const 0059 { 0060 return mUseSameResultForOtherCheck->isChecked(); 0061 } 0062 0063 #include "moc_confirmbeforedeletingmessageboxwidget.cpp"