File indexing completed on 2024-12-01 04:36:38

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "configureautocorrectionwidget.h"
0008 #include "ruqola.h"
0009 
0010 #if HAVE_TEXT_AUTOCORRECTION_WIDGETS
0011 #include "textautocorrectioncore/textautocorrectionsettings.h"
0012 #include <TextAutoCorrectionCore/AutoCorrection>
0013 #include <TextAutoCorrectionWidgets/AutoCorrectionWidget>
0014 #endif
0015 
0016 #include <QVBoxLayout>
0017 
0018 ConfigureAutoCorrectionWidget::ConfigureAutoCorrectionWidget(QWidget *parent)
0019     : QWidget{parent}
0020 #if HAVE_TEXT_AUTOCORRECTION_WIDGETS
0021     , mAutoCorrectionWidget(new TextAutoCorrectionWidgets::AutoCorrectionWidget(this))
0022 #endif
0023 {
0024     auto mainLayout = new QVBoxLayout(this);
0025     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0026     mainLayout->setContentsMargins({});
0027     mainLayout->addWidget(mAutoCorrectionWidget);
0028     // We don't have html support here.
0029     mAutoCorrectionWidget->setHasHtmlSupport(false);
0030     mAutoCorrectionWidget->setAutoCorrection(Ruqola::self()->autoCorrection());
0031 }
0032 
0033 ConfigureAutoCorrectionWidget::~ConfigureAutoCorrectionWidget() = default;
0034 
0035 void ConfigureAutoCorrectionWidget::save()
0036 {
0037     mAutoCorrectionWidget->writeConfig();
0038 #if HAVE_TEXT_AUTOCORRECTION_WIDGETS
0039     TextAutoCorrectionCore::TextAutoCorrectionSettings::self()->save();
0040 #endif
0041 }
0042 
0043 void ConfigureAutoCorrectionWidget::load()
0044 {
0045     mAutoCorrectionWidget->loadConfig();
0046 }
0047 
0048 #include "moc_configureautocorrectionwidget.cpp"