Debian Codegraph @

src/libs/widgets/KoGlobal.h

raw
1 /* This file is part of the KDE project
2 SPDX-FileCopyrightText: 1998, 1999 Torben Weis <[email protected]>
3 SPDX-FileCopyrightText: 2002, 2003 David Faure <[email protected]>
4 SPDX-FileCopyrightText: 2003 Nicolas GOUTTE <[email protected]>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9 #ifndef KOGLOBAL_H
10 #define KOGLOBAL_H
11
12 #include <QStringList>
13 #include <QFont>
14 #include <QMap>
15
16 #include "kowidgets_export.h"
17
18 class KConfig;
19
20 class KOWIDGETS_EXPORT KoGlobal
21 {
22 public:
23 KoGlobal();
24
25 /// For KoApplication
26 static void initialize() {
27 (void)self(); // I don't want to make KGlobal instances public, so self() is private
28 }
29 /**
30 * Return the default font for Calligra programs.
31 * This is (currently) the same as the KDE-global default font,
32 * except that it is guaranteed to have a point size set,
33 * never a pixel size (see @ref QFont).
34 */
35 static QFont defaultFont() {
36 return self()->_defaultFont();
37 }
38
39 /**
40 * @return the global KConfig object around calligraplanrc.
41 * calligraplanrc is used for Plan-wide settings, from totally unrelated classes,
42 * so this is the centralization of the KConfig object so that the file is
43 * parsed only once
44 */
45 static KConfig* planConfig() {
46 return self()->_planConfig();
47 }
48
49 /// Return the list of available languages, in their displayable form
50 /// (translated names)
51 static QStringList listOfLanguages() {
52 return self()->_listOfLanguages();
53 }
54 /// Return the list of available languages, in their internal form
55 /// e.g. "fr" or "en_US", here called "tag"
56 static QStringList listOfLanguageTags() {
57 return self()->_listOfLanguageTags();
58 }
59 /// For a given language display name, return its tag
60 static QString tagOfLanguage(const QString & _lang);
61 /// For a given language tag, return its display name
62 static QString languageFromTag(const QString &_lang);
63
64 ~KoGlobal();
65
66 private:
67 static KoGlobal* self();
68
69 QFont _defaultFont();
70 QStringList _listOfLanguages();
71 QStringList _listOfLanguageTags();
72 KConfig* _planConfig();
73 void createListOfLanguages();
74
75 int m_pointSize;
76 typedef QMap<QString, QString> LanguageMap;
77 LanguageMap m_langMap; // display-name -> language tag
78 KConfig* m_planConfig;
79 // No BC problem here, constructor is private, feel free to add members
80
81 friend class this_is_a_singleton; // work around gcc warning
82 };
83
84 #endif // KOGLOBAL