File indexing completed on 2025-01-05 05:23:52
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 "bytearraysrecstreamencoderconfigeditor.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 ByteArraySRecStreamEncoderConfigEditor::ByteArraySRecStreamEncoderConfigEditor(ByteArraySRecStreamEncoder* 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 const QStringList list { 0037 i18nc("@item:inmenu address size", 0038 "32-bit"), 0039 i18nc("@item:inmenu address size", 0040 "24-bit"), 0041 i18nc("@item:inmenu address size", 0042 "16-bit"), 0043 }; 0044 mAddressSizeSelect->addItems(list); 0045 mAddressSizeSelect->setCurrentIndex(static_cast<int>(mSettings.addressSizeId)); 0046 connect(mAddressSizeSelect, qOverload<int>(&KComboBox::activated), 0047 this, &ByteArraySRecStreamEncoderConfigEditor::onSettingsChanged); 0048 pageLayout->addRow(addressSizeLabel, mAddressSizeSelect); 0049 } 0050 0051 ByteArraySRecStreamEncoderConfigEditor::~ByteArraySRecStreamEncoderConfigEditor() = default; 0052 0053 AbstractSelectionView* ByteArraySRecStreamEncoderConfigEditor::createPreviewView() const 0054 { 0055 return new ByteArrayTextStreamEncoderPreview(mEncoder); 0056 } 0057 0058 void ByteArraySRecStreamEncoderConfigEditor::onSettingsChanged() 0059 { 0060 mSettings.addressSizeId = static_cast<SRecStreamEncoderSettings::AddressSizeId>(mAddressSizeSelect->currentIndex()); 0061 0062 mEncoder->setSettings(mSettings); 0063 } 0064 0065 } 0066 0067 #include "moc_bytearraysrecstreamencoderconfigeditor.cpp"