kmail

globalsettings.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of KMail.
00003 
00004     Copyright (c) 2005 David Faure <faure@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License version 2,
00008     as published by the Free Software Foundation.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include "globalsettings.h"
00025 #include <kstaticdeleter.h>
00026 #include <qtimer.h>
00027 
00028 GlobalSettings *GlobalSettings::mSelf = 0;
00029 static KStaticDeleter<GlobalSettings> staticGlobalSettingsDeleter;
00030 
00031 GlobalSettings *GlobalSettings::self()
00032 {
00033   if ( !mSelf ) {
00034     staticGlobalSettingsDeleter.setObject( mSelf, new GlobalSettings() );
00035     mSelf->readConfig();
00036   }
00037 
00038   return mSelf;
00039 }
00040 
00041 GlobalSettings::GlobalSettings()
00042 {
00043   mConfigSyncTimer = new QTimer( this, "mConfigSyncTimer" );
00044   connect( mConfigSyncTimer, SIGNAL( timeout() ), this, SLOT( slotSyncNow() ) );
00045 }
00046 
00047 void GlobalSettings::requestSync()
00048 {
00049  if ( !mConfigSyncTimer->isActive() )
00050    mConfigSyncTimer->start( 0, true /*single shot*/ );
00051 }
00052 
00053 void GlobalSettings::slotSyncNow()
00054 {
00055   config()->sync();
00056 }
00057 
00058 GlobalSettings::~GlobalSettings()
00059 {
00060 }
00061 
00062 #include "globalsettings.moc"