summaryrefslogtreecommitdiffabout
path: root/korganizer/koglobals.cpp
Unidiff
Diffstat (limited to 'korganizer/koglobals.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koglobals.cpp143
1 files changed, 143 insertions, 0 deletions
diff --git a/korganizer/koglobals.cpp b/korganizer/koglobals.cpp
new file mode 100644
index 0000000..8016034
--- a/dev/null
+++ b/korganizer/koglobals.cpp
@@ -0,0 +1,143 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qapplication.h>
25
26#include <kdebug.h>
27#include <kglobal.h>
28#include <kconfig.h>
29#include <kstandarddirs.h>
30#include <kglobalsettings.h>
31#include <klocale.h>
32
33#include <kcalendarsystem.h>
34
35#ifndef KORG_NOKALARMD
36#include "kalarmdclient.h"
37#endif
38#include "simplealarmclient.h"
39
40#include "koglobals.h"
41#include "koprefs.h"
42
43class NopAlarmClient : public AlarmClient
44{
45 public:
46 void startDaemon() {}
47 bool setCalendars( const QStringList & ) { return false; }
48 bool addCalendar( const QString & ) { return false; }
49 bool removeCalendar( const QString & ) { return false; }
50 bool reloadCalendar( const QString & ) { return false; }
51};
52
53KOGlobals *KOGlobals::mSelf = 0;
54
55KOGlobals *KOGlobals::self()
56{
57 if (!mSelf) {
58 mSelf = new KOGlobals;
59 }
60
61 return mSelf;
62}
63
64KOGlobals::KOGlobals()
65{
66 KConfig *cfg = KOGlobals::config();
67
68 cfg->setGroup("General");
69 mCalendarSystem = KGlobal::locale()->calendar();
70
71 cfg->setGroup("AlarmDaemon");
72 QString alarmClient = cfg->readEntry( "Daemon", "kalarmd" );
73 if ( alarmClient == "simple" ) {
74 mAlarmClient = new SimpleAlarmClient;
75#ifndef KORG_NOKALARMD
76 } else if ( alarmClient == "kalarmd" ) {
77 mAlarmClient = new KalarmdClient;
78#endif
79 } else {
80 mAlarmClient = new NopAlarmClient;
81 }
82}
83
84KConfig* KOGlobals::config()
85{
86 static KConfig *mConfig = 0;
87 if (!mConfig) {
88 KOPrefs *p = KOPrefs::instance();
89 mConfig = p->getConfig();
90 //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) );
91 }
92 return mConfig;
93}
94
95KOGlobals::~KOGlobals()
96{
97 delete mAlarmClient;
98}
99
100const KCalendarSystem *KOGlobals::calendarSystem() const
101{
102 return mCalendarSystem;
103}
104
105AlarmClient *KOGlobals::alarmClient() const
106{
107 return mAlarmClient;
108}
109
110void KOGlobals::fitDialogToScreen( QWidget *wid, bool force )
111{
112 bool resized = false;
113
114 int w = wid->frameSize().width();
115 int h = wid->frameSize().height();
116
117 QRect desk = KGlobalSettings::desktopGeometry(wid);
118 if ( w > desk.width() ) {
119 w = desk.width();
120 resized = true;
121 }
122 // Yuck this hack is ugly. Is the -30 really to circumvent the size of
123 // kicker?!
124 if ( h > desk.height() - 30 ) {
125 h = desk.height() - 30;
126 resized = true;
127 }
128
129 if ( resized || force ) {
130 wid->resize( w, h );
131 wid->move( desk.x(), desk.y()+15 );
132 if ( force ) wid->setFixedSize( w, h );
133 }
134}
135
136bool KOGlobals::reverseLayout()
137{
138#if QT_VERSION >= 0x030000
139 return QApplication::reverseLayout();
140#else
141 return false;
142#endif
143}