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 "bytearraybase32streamencoderconfigeditor.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 ByteArrayBase32StreamEncoderConfigEditor::ByteArrayBase32StreamEncoderConfigEditor(ByteArrayBase32StreamEncoder* 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 encodingTypeLabel =
0032         i18nc("@label:listbox the type of the used encoding: Classic, Base32hex or z-base-32.",
0033               "Encoding:");
0034 
0035     mEncodingSelect = new KComboBox(this);
0036     const QStringList list {
0037         i18nc("@item:inmenu Doing the base32 using the classical encoding",
0038               "Classic"),
0039         i18nc("@item:inmenu Doing the base32 using the Base32hex encoding",
0040               "Base32hex"),
0041         i18nc("@item:inmenu Doing the base32 using the z-base-32 encoding",
0042               "z-base-32"),
0043     };
0044     mEncodingSelect->addItems(list);
0045     mEncodingSelect->setCurrentIndex(static_cast<int>(mSettings.encodingType));
0046     connect(mEncodingSelect, qOverload<int>(&KComboBox::activated),
0047             this, &ByteArrayBase32StreamEncoderConfigEditor::onSettingsChanged);
0048     pageLayout->addRow(encodingTypeLabel, mEncodingSelect);
0049 }
0050 
0051 ByteArrayBase32StreamEncoderConfigEditor::~ByteArrayBase32StreamEncoderConfigEditor() = default;
0052 
0053 AbstractSelectionView* ByteArrayBase32StreamEncoderConfigEditor::createPreviewView() const
0054 {
0055     return new ByteArrayTextStreamEncoderPreview(mEncoder);
0056 }
0057 
0058 void ByteArrayBase32StreamEncoderConfigEditor::onSettingsChanged()
0059 {
0060     mSettings.encodingType = static_cast<Base32StreamEncoderSettings::EncodingType>(mEncodingSelect->currentIndex());
0061 
0062     mEncoder->setSettings(mSettings);
0063 }
0064 
0065 }
0066 
0067 #include "moc_bytearraybase32streamencoderconfigeditor.cpp"