25#include <tqapplication.h>
30#include <tdestandarddirs.h>
31#include <tdeglobalsettings.h>
33#include <kstaticdeleter.h>
34#include <kiconloader.h>
36#include <kcalendarsystem.h>
39#include "alarmclient.h"
43#include "korganizer_part.h"
46class NopAlarmClient :
public AlarmClient
54KOGlobals *KOGlobals::mSelf = 0;
56static KStaticDeleter<KOGlobals> koGlobalsDeleter;
58KOGlobals *KOGlobals::self()
61 koGlobalsDeleter.setObject( mSelf,
new KOGlobals );
72 mOwnInstance =
new TDEInstance(
"korganizer" );
73 mOwnInstance->config()->setGroup(
"General" );
74 mOwnInstance->iconLoader()->addAppDir(
"tdepim" );
75 TDEGlobal::iconLoader()->addAppDir(
"tdepim" );
77 mAlarmClient =
new AlarmClient;
80TDEConfig* KOGlobals::config()
const
82 return mOwnInstance->config();
85KOGlobals::~KOGlobals()
92const KCalendarSystem *KOGlobals::calendarSystem()
const
94 return TDEGlobal::locale()->calendar();
97AlarmClient *KOGlobals::alarmClient()
const
102void KOGlobals::fitDialogToScreen( TQWidget *wid,
bool force )
104 bool resized =
false;
106 int w = wid->frameSize().width();
107 int h = wid->frameSize().height();
109 TQRect desk = TDEGlobalSettings::desktopGeometry( wid );
110 if ( w > desk.width() ) {
115 if ( h > desk.height() - 30 ) {
116 h = desk.height() - 30;
120 if ( resized || force ) {
122 wid->move( desk.x(), desk.y()+15 );
123 if ( force ) wid->setFixedSize( w, h );
127bool KOGlobals::reverseLayout()
129 return TQApplication::reverseLayout();
132TQPixmap KOGlobals::smallIcon(
const TQString& name )
134 return SmallIcon( name, mOwnInstance );
137TQIconSet KOGlobals::smallIconSet(
const TQString& name,
int size )
139 return SmallIconSet( name, size, mOwnInstance );
142TQStringList KOGlobals::holiday(
const TQDate &date )
146 if ( !mHolidays )
return hdays;
147 TQValueList<KHoliday> list = mHolidays->getHolidays( date );
148 TQValueList<KHoliday>::ConstIterator it = list.begin();
149 for ( ; it != list.end(); ++it ) {
150 hdays.append( (*it).text );
155bool KOGlobals::isWorkDay(
const TQDate &date )
157 int mask( ~( KOPrefs::instance()->mWorkWeekMask ) );
159 bool nonWorkDay = ( mask & ( 1 << ( date.dayOfWeek() - 1 ) ) );
160 if ( KOPrefs::instance()->mExcludeHolidays && mHolidays ) {
161 TQValueList<KHoliday> list = mHolidays->getHolidays( date );
162 TQValueList<KHoliday>::ConstIterator it = list.begin();
163 for ( ; it != list.end(); ++it ) {
164 nonWorkDay = nonWorkDay
165 || ( (*it).Category == KHolidays::HOLIDAY );
171int KOGlobals::getWorkWeekMask()
173 return KOPrefs::instance()->mWorkWeekMask;
176void KOGlobals::setHolidays( KHolidays *h )
182KHolidays *KOGlobals::holidays()
const