File indexing completed on 2025-01-05 05:23:51
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2010 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 "bytearrayihexstreamencoderconfigeditor.hpp" 0010 0011 // lib 0012 #include "bytearraytextstreamencoderpreview.hpp" 0013 // KF 0014 #include <KLocalizedString> 0015 #include <KComboBox> 0016 // Qt 0017 #include <QFormLayout> 0018 0019 namespace Kasten { 0020 0021 ByteArrayIHexStreamEncoderConfigEditor::ByteArrayIHexStreamEncoderConfigEditor(ByteArrayIHexStreamEncoder* encoder, QWidget* parent) 0022 : AbstractModelStreamEncoderConfigEditor(parent) 0023 , mEncoder(encoder) 0024 { 0025 mSettings = mEncoder->settings(); 0026 0027 auto* pageLayout = new QFormLayout(this); 0028 pageLayout->setContentsMargins(0, 0, 0, 0); 0029 0030 // data type 0031 const QString addressSizeLabel = 0032 i18nc("@label:listbox the size in bits of the addresses.", 0033 "Address size:"); 0034 0035 mAddressSizeSelect = new KComboBox(this); 0036 // keep order in sync with IHexStreamEncoderSettings::AddressSizeId 0037 const QStringList addressSizeList { 0038 i18nc("@item:inmenu address size", 0039 "32-bit"), 0040 i18nc("@item:inmenu address size", 0041 "16-bit"), 0042 i18nc("@item:inmenu address size", 0043 "8-bit"), 0044 }; 0045 mAddressSizeSelect->addItems(addressSizeList); 0046 mAddressSizeSelect->setCurrentIndex(static_cast<int>(mSettings.addressSizeId)); 0047 connect(mAddressSizeSelect, qOverload<int>(&KComboBox::activated), 0048 this, &ByteArrayIHexStreamEncoderConfigEditor::onSettingsChanged); 0049 pageLayout->addRow(addressSizeLabel, mAddressSizeSelect); 0050 } 0051 0052 ByteArrayIHexStreamEncoderConfigEditor::~ByteArrayIHexStreamEncoderConfigEditor() = default; 0053 0054 AbstractSelectionView* ByteArrayIHexStreamEncoderConfigEditor::createPreviewView() const 0055 { 0056 return new ByteArrayTextStreamEncoderPreview(mEncoder); 0057 } 0058 0059 void ByteArrayIHexStreamEncoderConfigEditor::onSettingsChanged() 0060 { 0061 mSettings.addressSizeId = static_cast<IHexStreamEncoderSettings::AddressSizeId>(mAddressSizeSelect->currentIndex()); 0062 0063 mEncoder->setSettings(mSettings); 0064 } 0065 0066 } 0067 0068 #include "moc_bytearrayihexstreamencoderconfigeditor.cpp"