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 class NopAlarmClient : public AlarmClient 00044 { 00045 public: 00046 void startDaemon() {} 00047 void stopDaemon() {} 00048 }; 00049 00050 KOGlobals *KOGlobals::mSelf = 0; 00051 00052 static KStaticDeleter<KOGlobals> koGlobalsDeleter; 00053 00054 KOGlobals *KOGlobals::self() 00055 { 00056 if (!mSelf) { 00057 koGlobalsDeleter.setObject( mSelf, new KOGlobals ); 00058 } 00059 00060 return mSelf; 00061 } 00062 00063 KOGlobals::KOGlobals() 00064 { 00065 // Needed to distinguish from global KInstance 00066 // in case we are a KPart 00067 mOwnInstance = new KInstance("korganizer"); 00068 mOwnInstance->config()->setGroup("General"); 00069 00070 mAlarmClient = new AlarmClient; 00071 } 00072 00073 KConfig* KOGlobals::config() const 00074 { 00075 return mOwnInstance->config(); 00076 } 00077 00078 KOGlobals::~KOGlobals() 00079 { 00080 delete mAlarmClient; 00081 mAlarmClient = 0; 00082 00083 delete mOwnInstance; 00084 mOwnInstance = 0; 00085 } 00086 00087 const KCalendarSystem *KOGlobals::calendarSystem() const 00088 { 00089 return KGlobal::locale()->calendar(); 00090 } 00091 00092 AlarmClient *KOGlobals::alarmClient() const 00093 { 00094 return mAlarmClient; 00095 } 00096 00097 void KOGlobals::fitDialogToScreen( QWidget *wid, bool force ) 00098 { 00099 bool resized = false; 00100 00101 int w = wid->frameSize().width(); 00102 int h = wid->frameSize().height(); 00103 00104 QRect desk = KGlobalSettings::desktopGeometry(wid); 00105 if ( w > desk.width() ) { 00106 w = desk.width(); 00107 resized = true; 00108 } 00109 // Yuck this hack is ugly. Is the -30 really to circumvent the size of 00110 // kicker?! 00111 if ( h > desk.height() - 30 ) { 00112 h = desk.height() - 30; 00113 resized = true; 00114 } 00115 00116 if ( resized || force ) { 00117 wid->resize( w, h ); 00118 wid->move( desk.x(), desk.y()+15 ); 00119 if ( force ) wid->setFixedSize( w, h ); 00120 } 00121 } 00122 00123 bool KOGlobals::reverseLayout() 00124 { 00125 #if QT_VERSION >= 0x030000 00126 return QApplication::reverseLayout(); 00127 #else 00128 return false; 00129 #endif 00130 } 00131 00132 QPixmap KOGlobals::smallIcon(const QString& name) 00133 { 00134 return SmallIcon(name, mOwnInstance); 00135 } 00136 00137 QIconSet KOGlobals::smallIconSet(const QString& name, int size) 00138 { 00139 return SmallIconSet(name, size, mOwnInstance); 00140 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003