File indexing completed on 2024-12-15 04:54:44

0001 /******************************************************************************
0002  *
0003  *  SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  *
0007  *******************************************************************************/
0008 
0009 #include "utils/optionseteditor.h"
0010 #include "core/optionset.h"
0011 
0012 #include <QGridLayout>
0013 #include <QLabel>
0014 
0015 #include <KLocalizedString>
0016 #include <KTextEdit>
0017 #include <QLineEdit>
0018 
0019 using namespace MessageList::Utils;
0020 using namespace MessageList::Core;
0021 
0022 OptionSetEditor::OptionSetEditor(QWidget *parent)
0023     : QTabWidget(parent)
0024 {
0025     // General tab
0026     auto tab = new QWidget(this);
0027     addTab(tab, i18nc("@title:tab General options of a view mode", "General"));
0028 
0029     auto tabg = new QGridLayout(tab);
0030 
0031     auto l = new QLabel(i18nc("@label:textbox Name of the option", "Name:"), tab);
0032     tabg->addWidget(l, 0, 0);
0033 
0034     mNameEdit = new QLineEdit(tab);
0035 
0036     tabg->addWidget(mNameEdit, 0, 1);
0037 
0038     connect(mNameEdit, &QLineEdit::textEdited, this, &OptionSetEditor::slotNameEditTextEdited);
0039 
0040     l = new QLabel(i18nc("@label:textbox Description of the option", "Description:"), tab);
0041     tabg->addWidget(l, 1, 0);
0042 
0043     mDescriptionEdit = new KTextEdit(tab);
0044     mDescriptionEdit->setAcceptRichText(false);
0045     tabg->addWidget(mDescriptionEdit, 1, 1, 2, 1);
0046 
0047     tabg->setColumnStretch(1, 1);
0048     tabg->setRowStretch(2, 1);
0049 }
0050 
0051 OptionSetEditor::~OptionSetEditor() = default;
0052 
0053 void OptionSetEditor::setReadOnly(bool readOnly)
0054 {
0055     mDescriptionEdit->setReadOnly(readOnly);
0056     mNameEdit->setReadOnly(readOnly);
0057 }
0058 
0059 KTextEdit *OptionSetEditor::descriptionEdit() const
0060 {
0061     return mDescriptionEdit;
0062 }
0063 
0064 QLineEdit *OptionSetEditor::nameEdit() const
0065 {
0066     return mNameEdit;
0067 }
0068 
0069 #include "moc_optionseteditor.cpp"