File indexing completed on 2025-01-19 05:20:19
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 "bytearrayuuencodingstreamencoderconfigeditor.hpp" 0010 0011 // lib 0012 #include "bytearraytextstreamencoderpreview.hpp" 0013 // KF 0014 #include <KLocalizedString> 0015 #include <KComboBox> 0016 // Qt 0017 #include <QFormLayout> 0018 #include <QLineEdit> 0019 0020 namespace Kasten { 0021 0022 ByteArrayUuencodingStreamEncoderConfigEditor::ByteArrayUuencodingStreamEncoderConfigEditor(ByteArrayUuencodingStreamEncoder* encoder, QWidget* parent) 0023 : AbstractModelStreamEncoderConfigEditor(parent) 0024 , mEncoder(encoder) 0025 { 0026 mSettings = mEncoder->settings(); 0027 0028 auto* pageLayout = new QFormLayout(this); 0029 pageLayout->setContentsMargins(0, 0, 0, 0); 0030 0031 // internal file name 0032 const QString fileNameLabel = 0033 i18nc("@label:textbox file name internally given to the encoded data", 0034 "Internal name of file:"); 0035 0036 mFileNameEdit = new QLineEdit(this); 0037 mFileNameEdit->setClearButtonEnabled(true); 0038 mFileNameEdit->setText(mSettings.fileName); 0039 connect(mFileNameEdit, &QLineEdit::textChanged, this, &ByteArrayUuencodingStreamEncoderConfigEditor::onSettingsChanged); 0040 pageLayout->addRow(fileNameLabel, mFileNameEdit); 0041 0042 // data type 0043 const QString encodingTypeLabel = 0044 i18nc("@label:listbox the type of the used encoding: historical or Base64.", 0045 "Encoding:"); 0046 0047 mEncodingSelect = new KComboBox(this); 0048 const QStringList list { 0049 i18nc("@item:inmenu Doing the uuencoding using the historical encoding", 0050 "Historical"), 0051 i18nc("@item:inmenu Doing the uuencoding using the base64 encoding", 0052 "Base64"), 0053 }; 0054 mEncodingSelect->addItems(list); 0055 mEncodingSelect->setCurrentIndex(static_cast<int>(mSettings.encodingType)); 0056 connect(mEncodingSelect, qOverload<int>(&KComboBox::activated), 0057 this, &ByteArrayUuencodingStreamEncoderConfigEditor::onSettingsChanged); 0058 pageLayout->addRow(encodingTypeLabel, mEncodingSelect); 0059 } 0060 0061 ByteArrayUuencodingStreamEncoderConfigEditor::~ByteArrayUuencodingStreamEncoderConfigEditor() = default; 0062 0063 AbstractSelectionView* ByteArrayUuencodingStreamEncoderConfigEditor::createPreviewView() const 0064 { 0065 return new ByteArrayTextStreamEncoderPreview(mEncoder); 0066 } 0067 0068 void ByteArrayUuencodingStreamEncoderConfigEditor::onSettingsChanged() 0069 { 0070 mSettings.encodingType = static_cast<UuencodingStreamEncoderSettings::EncodingType>(mEncodingSelect->currentIndex()); 0071 mSettings.fileName = mFileNameEdit->text(); 0072 0073 mEncoder->setSettings(mSettings); 0074 } 0075 0076 } 0077 0078 #include "moc_bytearrayuuencodingstreamencoderconfigeditor.cpp"