Messagelib

messageviewersettings.cpp
1 /*
2  This file is part of KMail.
3 
4  SPDX-FileCopyrightText: 2005 David Faure <[email protected]>
5 
6  SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
7 */
8 
9 #include "messageviewersettings.h"
10 #include <QTimer>
11 
12 using namespace MessageViewer;
13 
14 MessageViewerSettings *MessageViewerSettings::mSelf = nullptr;
15 
16 MessageViewerSettings *MessageViewerSettings::self()
17 {
18  if (!mSelf) {
19  mSelf = new MessageViewerSettings();
20  mSelf->load();
21  }
22 
23  return mSelf;
24 }
25 
26 MessageViewerSettings::MessageViewerSettings()
27 {
28  mConfigSyncTimer = new QTimer(this);
29  mConfigSyncTimer->setSingleShot(true);
30  connect(mConfigSyncTimer, &QTimer::timeout, this, &MessageViewerSettings::slotSyncNow);
31 }
32 
34 {
35  if (!mConfigSyncTimer->isActive()) {
36  mConfigSyncTimer->start(0);
37  }
38 }
39 
40 void MessageViewerSettings::slotSyncNow()
41 {
42  config()->sync();
43 }
44 
45 MessageViewerSettings::~MessageViewerSettings() = default;
bool isActive() const const
void timeout()
The MessageViewerSettings class.
void requestSync()
Call this slot instead of directly KConfig::sync() to minimize the overall config writes...
void start(int msec)
void setSingleShot(bool singleShot)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.