Changeset View
Changeset View
Standalone View
Standalone View
src/part/KgvGlobal.h
Show All 22 Lines | 19 | /* This file was part of the KDE project | |||
---|---|---|---|---|---|
23 | modify it under the terms of the GNU Library General Public | 23 | modify it under the terms of the GNU Library General Public | ||
24 | License as published by the Free Software Foundation; either | 24 | License as published by the Free Software Foundation; either | ||
25 | version 2 of the License, or (at your option) any later version. | 25 | version 2 of the License, or (at your option) any later version. | ||
26 | */ | 26 | */ | ||
27 | 27 | | |||
28 | #ifndef kgvGlobal_h | 28 | #ifndef kgvGlobal_h | ||
29 | #define kgvGlobal_h | 29 | #define kgvGlobal_h | ||
30 | 30 | | |||
31 | #include <QStringList> | 31 | #include <QApplication> | ||
32 | #include <QFont> | 32 | #include <QFont> | ||
33 | #include <QMap> | 33 | #include <QMap> | ||
34 | #include <QScreen> | 34 | #include <QScreen> | ||
35 | #include <QApplication> | 35 | #include <QStringList> | ||
36 | 36 | | |||
37 | class KConfig; | 37 | class KConfig; | ||
38 | 38 | | |||
39 | class KgvGlobal | 39 | class KgvGlobal | ||
40 | { | 40 | { | ||
41 | public: | 41 | public: | ||
42 | /// For KgvApplication | 42 | /// For KgvApplication | ||
43 | static void initialize() { | 43 | static void initialize() | ||
44 | { | ||||
44 | (void)self(); // I don't want to make KGlobal instances public, so self() is private | 45 | (void)self(); // I don't want to make KGlobal instances public, so self() is private | ||
45 | } | 46 | } | ||
46 | /** | 47 | /** | ||
47 | * Return the default font for KOffice programs. | 48 | * Return the default font for KOffice programs. | ||
48 | * This is (currently) the same as the KDE-global default font, | 49 | * This is (currently) the same as the KDE-global default font, | ||
49 | * except that it is guaranteed to have a point size set, | 50 | * except that it is guaranteed to have a point size set, | ||
50 | * never a pixel size (see @ref QFont). | 51 | * never a pixel size (see @ref QFont). | ||
51 | */ | 52 | */ | ||
52 | static QFont defaultFont() { | 53 | static QFont defaultFont() | ||
54 | { | ||||
53 | return self()->_defaultFont(); | 55 | return self()->_defaultFont(); | ||
54 | } | 56 | } | ||
55 | 57 | | |||
56 | /** | 58 | /** | ||
57 | * @return the global KConfig object around kofficerc. | 59 | * @return the global KConfig object around kofficerc. | ||
58 | * kofficerc is used for KOffice-wide settings, from totally unrelated classes, | 60 | * kofficerc is used for KOffice-wide settings, from totally unrelated classes, | ||
59 | * so this is the centralization of the KConfig object so that the file is | 61 | * so this is the centralization of the KConfig object so that the file is | ||
60 | * parsed only once | 62 | * parsed only once | ||
61 | */ | 63 | */ | ||
62 | static KConfig* kofficeConfig() { | 64 | static KConfig *kofficeConfig() | ||
65 | { | ||||
63 | return self()->_kofficeConfig(); | 66 | return self()->_kofficeConfig(); | ||
64 | } | 67 | } | ||
65 | 68 | | |||
66 | static int dpiX() { | 69 | static int dpiX() | ||
70 | { | ||||
67 | return qApp->primaryScreen()->physicalDotsPerInchX(); | 71 | return qApp->primaryScreen()->physicalDotsPerInchX(); | ||
68 | } | 72 | } | ||
69 | static int dpiY() { | 73 | static int dpiY() | ||
74 | { | ||||
70 | return qApp->primaryScreen()->physicalDotsPerInchY(); | 75 | return qApp->primaryScreen()->physicalDotsPerInchY(); | ||
71 | } | 76 | } | ||
72 | 77 | | |||
73 | /// Return the list of available languages, in their displayable form | 78 | /// Return the list of available languages, in their displayable form | ||
74 | /// (translated names) | 79 | /// (translated names) | ||
75 | // static QStringList listOfLanguages() { | 80 | // static QStringList listOfLanguages() { | ||
76 | // return self()->_listOfLanguages(); | 81 | // return self()->_listOfLanguages(); | ||
77 | // } | 82 | // } | ||
78 | /// Return the list of available languages, in their internal form | 83 | /// Return the list of available languages, in their internal form | ||
79 | /// e.g. "fr" or "en_US", here called "tag" | 84 | /// e.g. "fr" or "en_US", here called "tag" | ||
80 | // static QStringList listTagOfLanguages() { // TODO rename to listOfLanguageTags | 85 | // static QStringList listTagOfLanguages() { // TODO rename to listOfLanguageTags | ||
81 | // return self()->_listOfLanguageTags(); | 86 | // return self()->_listOfLanguageTags(); | ||
82 | // } | 87 | // } | ||
83 | /// For a given language display name, return its tag | 88 | /// For a given language display name, return its tag | ||
84 | static QString tagOfLanguage( const QString & _lang ); | 89 | static QString tagOfLanguage(const QString &_lang); | ||
85 | /// For a given language tag, return its display name | 90 | /// For a given language tag, return its display name | ||
86 | static QString languageFromTag( const QString &_lang ); | 91 | static QString languageFromTag(const QString &_lang); | ||
87 | 92 | | |||
88 | ~KgvGlobal(); | 93 | ~KgvGlobal(); | ||
89 | 94 | | |||
90 | private: | 95 | private: | ||
91 | static KgvGlobal* self(); | 96 | static KgvGlobal *self(); | ||
92 | KgvGlobal(); | 97 | KgvGlobal(); | ||
93 | QFont _defaultFont(); | 98 | QFont _defaultFont(); | ||
94 | // QStringList _listOfLanguages(); | 99 | // QStringList _listOfLanguages(); | ||
95 | // QStringList _listOfLanguageTags(); | 100 | // QStringList _listOfLanguageTags(); | ||
96 | KConfig* _kofficeConfig(); | 101 | KConfig *_kofficeConfig(); | ||
97 | // void createListOfLanguages(); | 102 | // void createListOfLanguages(); | ||
98 | 103 | | |||
99 | int m_pointSize; | 104 | int m_pointSize; | ||
100 | typedef QMap<QString, QString> LanguageMap; | 105 | typedef QMap<QString, QString> LanguageMap; | ||
101 | LanguageMap m_langMap; // display-name -> language tag | 106 | LanguageMap m_langMap; // display-name -> language tag | ||
102 | KConfig* m_kofficeConfig; | 107 | KConfig *m_kofficeConfig; | ||
103 | // No BC problem here, constructor is private, feel free to add members | 108 | // No BC problem here, constructor is private, feel free to add members | ||
104 | 109 | | |||
105 | // Singleton pattern. Maybe this should even be refcounted, so | 110 | // Singleton pattern. Maybe this should even be refcounted, so | ||
106 | // that it gets cleaned up when closing all koffice parts in e.g. konqueror? | 111 | // that it gets cleaned up when closing all koffice parts in e.g. konqueror? | ||
107 | static KgvGlobal* s_global; | 112 | static KgvGlobal *s_global; | ||
108 | friend class this_is_a_singleton; // work around gcc warning | 113 | friend class this_is_a_singleton; // work around gcc warning | ||
109 | }; | 114 | }; | ||
110 | 115 | | |||
111 | #endif // koGlobal | 116 | #endif // koGlobal |