korganizer Library API Documentation

koglobals.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@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 as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include <qapplication.h>
00026 
00027 #include <kdebug.h>
00028 #include <kglobal.h>
00029 #include <kconfig.h>
00030 #include <kstandarddirs.h>
00031 #include <kglobalsettings.h>
00032 #include <klocale.h>
00033 #include <kstaticdeleter.h>
00034 #include <kiconloader.h>
00035 
00036 #include <kcalendarsystem.h>
00037 
00038 #include "alarmclient.h"
00039 
00040 #include "koglobals.h"
00041 #include "korganizer_part.h"
00042 
00043 #if 0 // unused
00044 class NopAlarmClient : public AlarmClient
00045 {
00046   public:
00047     void startDaemon() {}
00048     void stopDaemon() {}
00049 };
00050 #endif
00051 
00052 KOGlobals *KOGlobals::mSelf = 0;
00053 
00054 static KStaticDeleter<KOGlobals> koGlobalsDeleter;
00055 
00056 KOGlobals *KOGlobals::self()
00057 {
00058   if (!mSelf) {
00059     koGlobalsDeleter.setObject( mSelf, new KOGlobals );
00060   }
00061 
00062   return mSelf;
00063 }
00064 
00065 KOGlobals::KOGlobals()
00066 {
00067   // Needed to distinguish from global KInstance
00068   // in case we are a KPart
00069   mOwnInstance = new KInstance("korganizer");
00070   mOwnInstance->config()->setGroup("General");
00071 
00072   mAlarmClient = new AlarmClient;
00073 }
00074 
00075 KConfig* KOGlobals::config() const
00076 {
00077   return mOwnInstance->config();
00078 }
00079 
00080 KOGlobals::~KOGlobals()
00081 {
00082   delete mAlarmClient;
00083   mAlarmClient = 0;
00084 
00085   delete mOwnInstance;
00086   mOwnInstance = 0;
00087 }
00088 
00089 const KCalendarSystem *KOGlobals::calendarSystem() const
00090 {
00091   return KGlobal::locale()->calendar();
00092 }
00093 
00094 AlarmClient *KOGlobals::alarmClient() const
00095 {
00096   return mAlarmClient;
00097 }
00098 
00099 void KOGlobals::fitDialogToScreen( QWidget *wid, bool force )
00100 {
00101   bool resized = false;
00102 
00103   int w = wid->frameSize().width();
00104   int h = wid->frameSize().height();
00105 
00106   QRect desk = KGlobalSettings::desktopGeometry(wid);
00107   if ( w > desk.width() ) {
00108     w = desk.width();
00109     resized = true;
00110   }
00111   // Yuck this hack is ugly.  Is the -30 really to circumvent the size of
00112   // kicker?!
00113   if ( h > desk.height() - 30 ) {
00114     h = desk.height() - 30;
00115     resized = true;
00116   }
00117 
00118   if ( resized || force ) {
00119     wid->resize( w, h );
00120     wid->move( desk.x(), desk.y()+15 );
00121     if ( force ) wid->setFixedSize( w, h );
00122   }
00123 }
00124 
00125 bool KOGlobals::reverseLayout()
00126 {
00127 #if QT_VERSION >= 0x030000
00128   return QApplication::reverseLayout();
00129 #else
00130   return false;
00131 #endif
00132 }
00133 
00134 QPixmap KOGlobals::smallIcon(const QString& name)
00135 {
00136   return SmallIcon(name, mOwnInstance);
00137 }
00138 
00139 QIconSet KOGlobals::smallIconSet(const QString& name, int size)
00140 {
00141   return SmallIconSet(name, size, mOwnInstance);
00142 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:43:13 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003