File indexing completed on 2024-12-22 04:45:35

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "administratorcustomsoundscreatewidget.h"
0008 #include <KLineEditEventHandler>
0009 #include <KLocalizedString>
0010 #include <KUrlRequester>
0011 #include <QFormLayout>
0012 #include <QLineEdit>
0013 
0014 AdministratorCustomSoundsCreateWidget::AdministratorCustomSoundsCreateWidget(QWidget *parent)
0015     : QWidget(parent)
0016     , mName(new QLineEdit(this))
0017     , mSelectFile(new KUrlRequester(this))
0018 {
0019     auto mainLayout = new QFormLayout(this);
0020     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0021     mainLayout->setContentsMargins({});
0022 
0023     mName->setObjectName(QStringLiteral("mName"));
0024     KLineEditEventHandler::catchReturnKey(mName);
0025 
0026     mSelectFile->setObjectName(QStringLiteral("mSelectFile"));
0027 
0028     mainLayout->addRow(i18n("Name:"), mName);
0029     mainLayout->addRow(i18n("File:"), mSelectFile);
0030 }
0031 
0032 AdministratorCustomSoundsCreateWidget::~AdministratorCustomSoundsCreateWidget() = default;
0033 
0034 void AdministratorCustomSoundsCreateWidget::setCustomSoundInfo(const CustomSoundInfo &info)
0035 {
0036     mSelectFile->setUrl(info.fileNameUrl);
0037     mName->setText(info.name);
0038 }
0039 
0040 AdministratorCustomSoundsCreateWidget::CustomSoundInfo AdministratorCustomSoundsCreateWidget::customSoundInfo() const
0041 {
0042     AdministratorCustomSoundsCreateWidget::CustomSoundInfo info;
0043     info.fileNameUrl = mSelectFile->url();
0044     info.name = mName->text().trimmed();
0045     return info;
0046 }
0047 
0048 #include "moc_administratorcustomsoundscreatewidget.cpp"