KTextAddons

textautocorrectionsettings.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "textautocorrectionsettings.h"
8#include <QTimer>
9
10using namespace TextAutoCorrectionCore;
11
12TextAutoCorrectionSettings *TextAutoCorrectionSettings::mSelf = nullptr;
13
14TextAutoCorrectionSettings *TextAutoCorrectionSettings::self()
15{
16 if (!mSelf) {
17 mSelf = new TextAutoCorrectionSettings();
18 mSelf->load();
19 }
20
21 return mSelf;
22}
23
24TextAutoCorrectionSettings::TextAutoCorrectionSettings()
25 : mConfigSyncTimer(new QTimer(this))
26{
27 mConfigSyncTimer->setSingleShot(true);
28 connect(mConfigSyncTimer, &QTimer::timeout, this, &TextAutoCorrectionSettings::slotSyncNow);
29}
30
31TextAutoCorrectionSettings::~TextAutoCorrectionSettings() = default;
32
34{
35 if (!mConfigSyncTimer->isActive()) {
36 mConfigSyncTimer->start(0);
37 }
38}
39
40void TextAutoCorrectionSettings::slotSyncNow()
41{
42 config()->sync();
43}
44
45#include "moc_textautocorrectionsettings.cpp"
void requestSync()
Call this slot instead of directly KConfig::sync() to minimize the overall config writes.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool isActive() const const
void start()
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.