File indexing completed on 2024-05-19 15:27:50
0001 /* This file is part of KGraphViewer. 0002 Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr> 0003 0004 KGraphViewer is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; if not, write to the Free Software 0015 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0016 02110-1301, USA 0017 */ 0018 0019 /* This file was part of the KDE project 0020 Copyright (C) 2005 Jarosław Staniek <staniek@kde.org> 0021 0022 This program is free software; you can redistribute it and/or 0023 modify it under the terms of the GNU Library General Public 0024 License as published by the Free Software Foundation; either 0025 version 2 of the License, or (at your option) any later version. 0026 */ 0027 0028 #ifndef kgvGlobal_h 0029 #define kgvGlobal_h 0030 0031 #include <QApplication> 0032 #include <QFont> 0033 #include <QMap> 0034 #include <QScreen> 0035 #include <QStringList> 0036 0037 class KConfig; 0038 0039 class KgvGlobal 0040 { 0041 public: 0042 /// For KgvApplication 0043 static void initialize() 0044 { 0045 (void)self(); // I don't want to make KGlobal instances public, so self() is private 0046 } 0047 /** 0048 * Return the default font for KOffice programs. 0049 * This is (currently) the same as the KDE-global default font, 0050 * except that it is guaranteed to have a point size set, 0051 * never a pixel size (see @ref QFont). 0052 */ 0053 static QFont defaultFont() 0054 { 0055 return self()->_defaultFont(); 0056 } 0057 0058 /** 0059 * @return the global KConfig object around kofficerc. 0060 * kofficerc is used for KOffice-wide settings, from totally unrelated classes, 0061 * so this is the centralization of the KConfig object so that the file is 0062 * parsed only once 0063 */ 0064 static KConfig *kofficeConfig() 0065 { 0066 return self()->_kofficeConfig(); 0067 } 0068 0069 static int dpiX() 0070 { 0071 return qApp->primaryScreen()->physicalDotsPerInchX(); 0072 } 0073 static int dpiY() 0074 { 0075 return qApp->primaryScreen()->physicalDotsPerInchY(); 0076 } 0077 0078 /// Return the list of available languages, in their displayable form 0079 /// (translated names) 0080 // static QStringList listOfLanguages() { 0081 // return self()->_listOfLanguages(); 0082 // } 0083 /// Return the list of available languages, in their internal form 0084 /// e.g. "fr" or "en_US", here called "tag" 0085 // static QStringList listTagOfLanguages() { // TODO rename to listOfLanguageTags 0086 // return self()->_listOfLanguageTags(); 0087 // } 0088 /// For a given language display name, return its tag 0089 static QString tagOfLanguage(const QString &_lang); 0090 /// For a given language tag, return its display name 0091 static QString languageFromTag(const QString &_lang); 0092 0093 ~KgvGlobal(); 0094 0095 private: 0096 static KgvGlobal *self(); 0097 KgvGlobal(); 0098 QFont _defaultFont(); 0099 // QStringList _listOfLanguages(); 0100 // QStringList _listOfLanguageTags(); 0101 KConfig *_kofficeConfig(); 0102 // void createListOfLanguages(); 0103 0104 int m_pointSize; 0105 typedef QMap<QString, QString> LanguageMap; 0106 LanguageMap m_langMap; // display-name -> language tag 0107 KConfig *m_kofficeConfig; 0108 // No BC problem here, constructor is private, feel free to add members 0109 0110 // Singleton pattern. Maybe this should even be refcounted, so 0111 // that it gets cleaned up when closing all koffice parts in e.g. konqueror? 0112 static KgvGlobal *s_global; 0113 friend class this_is_a_singleton; // work around gcc warning 0114 }; 0115 0116 #endif // koGlobal