27 #include <tqptrlist.h> 30 #include <kapplication.h> 31 #include <kaboutdata.h> 35 #include <kcharsets.h> 36 #include <kiconloader.h> 37 #include <kstandarddirs.h> 38 #include <kinstance.h> 39 #include "kstaticdeleter.h" 44 #define MYASSERT(x) if (!x) \ 45 qFatal("Fatal error: you need to have a KInstance object before\n" \ 46 "you do anything that requires it! Examples of this are config\n" \ 47 "objects, standard directories or translations."); 52 static void kglobal_init();
58 return _instance->
dirs();
65 return _instance->
config();
96 KLocale::initInstance();
98 _instance->
aboutData()->translateInternalProgramName();
106 if( _charsets == 0 ) {
133 class KStringDict :
public TQDict<TQString>
136 KStringDict() : TQDict<TQString>(139) { }
149 _stringDict =
new KStringDict;
150 _stringDict->setAutoDelete(
true );
153 TQString *result = _stringDict->find(str);
156 result =
new TQString(str);
157 _stringDict->insert(str, result);
162 class KStaticDeleterList:
public TQPtrList<KStaticDeleterBase>
165 KStaticDeleterList() { }
171 if (!_staticDeleters)
173 if (_staticDeleters->find(obj) == -1)
174 _staticDeleters->append(obj);
181 _staticDeleters->removeRef(obj);
187 if (!KGlobal::_staticDeleters)
190 for(;_staticDeleters->count();)
192 _staticDeleters->take(0)->destructObject();
195 delete KGlobal::_staticDeleters;
196 KGlobal::_staticDeleters = 0;
201 KStringDict *KGlobal::_stringDict = 0;
206 KStaticDeleterList *KGlobal::_staticDeleters = 0;
210 static void kglobal_freeAll();
211 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad )
213 if (reason == DLL_PROCESS_DETACH)
218 __attribute__((destructor))
220 static void kglobal_freeAll()
222 delete KGlobal::_locale;
223 KGlobal::_locale = 0;
224 delete KGlobal::_charsets;
225 KGlobal::_charsets = 0;
226 delete KGlobal::_stringDict;
227 KGlobal::_stringDict = 0;
233 static void kglobal_init()
235 if (KGlobal::_staticDeleters)
238 KGlobal::_staticDeleters =
new KStaticDeleterList;
241 int kasciistricmp(
const char *str1,
const char *str2 )
243 const unsigned char *s1 = (
const unsigned char *)str1;
244 const unsigned char *s2 = (
const unsigned char *)str2;
246 unsigned char c1, c2;
249 return s1 ? 1 : (s2 ? -1 : 0);
251 return *s1 ? 1 : (*s2 ? -1 : 0);
252 for (;*s1; ++s1, ++s2) {
254 if (c1 >=
'A' && c1 <=
'Z')
256 if (c2 >=
'A' && c2 <=
'Z')
262 return *s1 ? res : (*s2 ? -1 : 0);
KConfig variant using shared memory.
static KLocale * locale()
Returns the global locale object.
KStandardDirs * dirs() const
Returns the application standard dirs object.
Charset font and encoder/decoder handling.
static KCharsets * charsets()
The global charset manager.
static KIconLoader * iconLoader()
Returns an iconloader object.
static const TQString & staticQString(const char *str)
Creates a static TQString.
static void setActiveInstance(KInstance *d)
The instance currently active (useful in a multi-instance application, such as a KParts application)...
const KAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
TQCString instanceName() const
Returns the name of the instance.
static KStandardDirs * dirs()
Returns the application standard dirs object.
static void registerStaticDeleter(KStaticDeleterBase *d)
Registers a static deleter.
Site-independent access to standard KDE directories.
Access to KDE global objects for use in shared libraries.
KConfig * config() const
Returns the general config object ("appnamerc").
static KInstance * instance()
Returns the global instance.
KSharedConfig * sharedConfig() const
Returns the general config object ("appnamerc").
void setActiveCatalogue(const TQString &catalog)
Sets the active catalog for translation lookup.
Access KDE Configuration entries.
KLocale provides support for country specific stuff like the national language.
static void unregisterStaticDeleter(KStaticDeleterBase *d)
Unregisters a static deleter.
KIconLoader * iconLoader() const
Returns an iconloader object.
static void deleteStaticDeleters()
Calls KStaticDeleterBase::destructObject() on all registered static deleters and unregisters them all...
static KSharedConfig * sharedConfig()
Returns the general config object.
Static deleters are used to manage static resources.
static KConfig * config()
Returns the general config object.