25#include <tqfontinfo.h>
26#include <tdeglobalsettings.h>
29#include <ksimpleconfig.h>
30#include <kstandarddirs.h>
31#include <kstaticdeleter.h>
33#include <kiconloader.h>
34#include <kstandarddirs.h>
37KoGlobal* KoGlobal::s_global = 0L;
38static KStaticDeleter<KoGlobal> sdg;
40KoGlobal* KoGlobal::self()
43 sdg.setObject( s_global,
new KoGlobal );
48 : m_pointSize( -1 ), m_kofficeConfig( 0L )
51 setlocale( LC_NUMERIC,
"C" );
54 TDEGlobal::locale()->insertCatalogue(
"koffice");
56 KImageIO::registerFormats();
59 TDEGlobal::dirs()->addPrefix(PREFIX);
62 TDEGlobal::iconLoader()->addAppDir(
"koffice");
68 m_dpiX = TQPaintDevice::x11AppDpiX();
69 m_dpiY = TQPaintDevice::x11AppDpiY();
78 delete m_kofficeConfig;
81TQFont KoGlobal::_defaultFont()
83 TQFont font = TDEGlobalSettings::generalFont();
85 if ( font.pointSize() == -1 )
88 if ( m_pointSize == -1 )
89 m_pointSize = TQFontInfo(font).pointSize();
90 Q_ASSERT( m_pointSize != -1 );
91 font.setPointSize( m_pointSize );
98TQStringList KoGlobal::_listOfLanguageTags()
100 if ( m_langMap.isEmpty() )
101 createListOfLanguages();
102 return m_langMap.values();
105TQStringList KoGlobal::_listOfLanguages()
107 if ( m_langMap.empty() )
108 createListOfLanguages();
109 return m_langMap.keys();
112void KoGlobal::createListOfLanguages()
114 TDEConfig config(
"all_languages",
true,
false,
"locale" );
117 TQMap<TQString, bool> seenLanguages;
118 const TQStringList langlist = config.groupList();
119 for ( TQStringList::ConstIterator itall = langlist.begin();
120 itall != langlist.end(); ++itall )
122 const TQString tag = *itall;
123 config.setGroup( tag );
124 const TQString
name = config.readEntry(
"Name", tag);
129 m_langMap.insert( name, tag );
131 seenLanguages.insert( tag,
true );
138 const TQStringList translationList = TDEGlobal::dirs()->findAllResources(
"locale",
139 TQString::fromLatin1(
"*/entry.desktop"));
140 for ( TQStringList::ConstIterator it = translationList.begin();
141 it != translationList.end(); ++it )
145 int index = tag.findRev(
'/');
146 tag = tag.left(index);
147 index = tag.findRev(
'/');
148 tag = tag.mid(index+1);
150 if ( seenLanguages.find( tag ) == seenLanguages.end() ) {
151 KSimpleConfig entry(*it);
152 entry.setGroup(
"KCM Locale");
154 const TQString
name = entry.readEntry(
"Name", tag);
156 m_langMap.insert( name, tag );
169TQString KoGlobal::tagOfLanguage(
const TQString & _lang)
171 const LanguageMap& map = self()->m_langMap;
172 TQMap<TQString,TQString>::ConstIterator it = map.find( _lang );
173 if ( it != map.end() )
178TQString KoGlobal::languageFromTag(
const TQString &langTag )
180 const LanguageMap& map = self()->m_langMap;
181 TQMap<TQString,TQString>::ConstIterator it = map.begin();
182 const TQMap<TQString,TQString>::ConstIterator end = map.end();
183 for ( ; it != end; ++it )
184 if ( it.data() == langTag )
191TDEConfig* KoGlobal::_kofficeConfig()
193 if ( !m_kofficeConfig ) {
194 m_kofficeConfig =
new TDEConfig(
"kofficerc" );
196 return m_kofficeConfig;
199void KoGlobal::setDPI(
int x,
int y )
202 KoGlobal* s = self();
const char * name(StdAction id)