lib

KoGlobal.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00003    Copyright 2002, 2003 David Faure <faure@kde.org>
00004    Copyright 2003 Nicolas GOUTTE <goutte@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef koGlobal_h
00023 #define koGlobal_h
00024 
00025 #include <qstringlist.h>
00026 #include <qfont.h>
00027 #include <qmap.h>
00028 class KConfig;
00029 
00030 #include <koffice_export.h>
00031 class KOFFICECORE_EXPORT KoGlobal
00032 {
00033 public:
00035     static void initialize()  {
00036         (void)self(); // I don't want to make KGlobal instances public, so self() is private
00037     }
00044     static QFont defaultFont()  {
00045         return self()->_defaultFont();
00046     }
00047 
00054     static KConfig* kofficeConfig() {
00055         return self()->_kofficeConfig();
00056     }
00057 
00058     static int dpiX() {
00059         return self()->m_dpiX;
00060     }
00061     static int dpiY() {
00062         return self()->m_dpiY;
00063     }
00065     static void setDPI( int x, int y );
00066 
00069     static QStringList listOfLanguages() {
00070         return self()->_listOfLanguages();
00071     }
00074     static QStringList listTagOfLanguages() { // TODO rename to listOfLanguageTags
00075         return self()->_listOfLanguageTags();
00076     }
00078     static QString tagOfLanguage( const QString & _lang );
00080     static QString languageFromTag( const QString &_lang );
00081 
00082     ~KoGlobal();
00083 
00084 private:
00085     static KoGlobal* self();
00086     KoGlobal();
00087     QFont _defaultFont();
00088     QStringList _listOfLanguages();
00089     QStringList _listOfLanguageTags();
00090     KConfig* _kofficeConfig();
00091     void createListOfLanguages();
00092 
00093     int m_pointSize;
00094     typedef QMap<QString, QString> LanguageMap;
00095     LanguageMap m_langMap; // display-name -> language tag
00096     KConfig* m_kofficeConfig;
00097     int m_dpiX;
00098     int m_dpiY;
00099     // No BC problem here, constructor is private, feel free to add members
00100 
00101     // Singleton pattern. Maybe this should even be refcounted, so
00102     // that it gets cleaned up when closing all koffice parts in e.g. konqueror?
00103     static KoGlobal* s_global;
00104     friend class this_is_a_singleton; // work around gcc warning
00105 };
00106 
00107 #endif // koGlobal
KDE Home | KDE Accessibility Home | Description of Access Keys