File indexing completed on 2025-01-05 05:23:54

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 "bytearrayxxencodingstreamencoderconfigeditor.hpp"
0010 
0011 // lib
0012 #include "bytearraytextstreamencoderpreview.hpp"
0013 // KF
0014 #include <KLocalizedString>
0015 // Qt
0016 #include <QFormLayout>
0017 #include <QLineEdit>
0018 
0019 namespace Kasten {
0020 
0021 ByteArrayXxencodingStreamEncoderConfigEditor::ByteArrayXxencodingStreamEncoderConfigEditor(ByteArrayXxencodingStreamEncoder* 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     // internal file name
0031     const QString fileNameLabel =
0032         i18nc("@label:textbox file name internally given to the encoded data",
0033               "Internal name of file:");
0034 
0035     mFileNameEdit = new QLineEdit(this);
0036     mFileNameEdit->setClearButtonEnabled(true);
0037     mFileNameEdit->setText(mSettings.fileName);
0038     connect(mFileNameEdit, &QLineEdit::textChanged, this, &ByteArrayXxencodingStreamEncoderConfigEditor::onSettingsChanged);
0039     pageLayout->addRow(fileNameLabel, mFileNameEdit);
0040 }
0041 
0042 ByteArrayXxencodingStreamEncoderConfigEditor::~ByteArrayXxencodingStreamEncoderConfigEditor() = default;
0043 
0044 AbstractSelectionView* ByteArrayXxencodingStreamEncoderConfigEditor::createPreviewView() const
0045 {
0046     return new ByteArrayTextStreamEncoderPreview(mEncoder);
0047 }
0048 
0049 void ByteArrayXxencodingStreamEncoderConfigEditor::onSettingsChanged()
0050 {
0051     mSettings.fileName = mFileNameEdit->text();
0052 
0053     mEncoder->setSettings(mSettings);
0054 }
0055 
0056 }
0057 
0058 #include "moc_bytearrayxxencodingstreamencoderconfigeditor.cpp"