koglobals.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00066
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
00110
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 }
This file is part of the documentation for korganizer Library Version 3.2.2.