File indexing completed on 2024-05-26 05:56:50
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2010, 2014 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 "bytespergroupdialog.hpp" 0010 0011 // KF 0012 #include <KLocalizedString> 0013 // Qt 0014 #include <QFormLayout> 0015 #include <QVBoxLayout> 0016 #include <QSpinBox> 0017 #include <QDialogButtonBox> 0018 // Std 0019 #include <limits> 0020 0021 namespace Kasten { 0022 0023 BytesPerGroupDialog::BytesPerGroupDialog(QWidget* parent) 0024 : QDialog(parent) 0025 { 0026 setAttribute(Qt::WA_DeleteOnClose, true); 0027 0028 auto* pageLayout = new QFormLayout(); 0029 0030 mGroupedBytesCountEdit = new QSpinBox(this); 0031 mGroupedBytesCountEdit->setRange(0, std::numeric_limits<int>::max()); 0032 const QString noGroupingText = i18nc("@label", 0033 "No grouping."); 0034 mGroupedBytesCountEdit->setSpecialValueText(noGroupingText); 0035 const QString groupedBytesCountLabel = 0036 i18nc("@label:spinbox number of bytes which are grouped", 0037 "Bytes per Group:"); 0038 pageLayout->addRow(groupedBytesCountLabel, mGroupedBytesCountEdit); 0039 0040 auto* dialogButtonBox = new QDialogButtonBox; 0041 dialogButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0042 connect(dialogButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0043 connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0044 0045 auto* layout = new QVBoxLayout; 0046 0047 layout->addLayout(pageLayout); 0048 layout->addWidget(dialogButtonBox); 0049 setLayout(layout); 0050 0051 const QString caption = 0052 i18nc("@title:window", "Bytes per Group"); 0053 setWindowTitle(caption); 0054 0055 connect(this, &QDialog::finished, this, &BytesPerGroupDialog::onFinished); 0056 } 0057 0058 BytesPerGroupDialog::~BytesPerGroupDialog() = default; 0059 0060 int BytesPerGroupDialog::groupedBytesCount() const { return mGroupedBytesCountEdit->value(); } 0061 0062 void BytesPerGroupDialog::setGroupedBytesCount(int groupedBytesCount) 0063 { 0064 mGroupedBytesCountEdit->setValue(groupedBytesCount); 0065 } 0066 0067 void BytesPerGroupDialog::onFinished(int result) 0068 { 0069 if (result != QDialog::Accepted) { 0070 return; 0071 } 0072 0073 Q_EMIT bytesPerGroupAccepted(groupedBytesCount()); 0074 } 0075 0076 } 0077 0078 #include "moc_bytespergroupdialog.cpp"