]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQApplication.h
Qt3support--
[duncan/yast2-qt4.git] / src / YQApplication.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQApplication.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQApplication_h
21 #define YQApplication_h
22
23 #include <Qt/qobject.h>
24 #include <Qt/qtranslator.h>
25 #include <qfont.h>
26
27 #include "QY2Settings.h"
28 #include "YApplication.h"
29
30
31 class YQApplication: public QObject, public YApplication
32 {
33     Q_OBJECT
34
35 protected:
36
37     friend class YQUI;
38
39     /**
40      * Constructor.
41      *
42      * Use YUI::app() to get the singleton for this class.
43      **/
44     YQApplication();
45
46     /**
47      * Destructor.
48      **/
49     virtual ~YQApplication();
50
51
52 public:
53
54     /**
55      * Set language and encoding for the locale environment ($LANG).
56      *
57      * Load UI-internal translations (e.g. for predefined dialogs like
58      * file selection) and fonts.
59      *
60      * 'language' is the ISO short code ("de_DE", "en_US", ...).
61      *
62      * 'encoding' an (optional) encoding ("utf8", ...) that will be appended if
63      *  present.
64      *
65      * Reimplemented from YApplication.
66      **/
67     virtual void setLanguage( const string & language,
68                               const string & encoding = string() );
69
70     /**
71      * Load translations for Qt's predefined dialogs like file selection box
72      * etc.
73      **/
74     void loadPredefinedQtTranslations();
75
76     /**
77      * Set fonts according to the specified language and encoding.
78      *
79      * This is most important for some Asian languages that have overlaps in
80      * the Unicode table, like Japanese vs. Chinese.
81      **/
82     void setLangFonts( const string & language,
83                        const string & encoding = string() );
84
85     /**
86      * Returns the application's default font.
87      **/
88     const QFont & currentFont();
89
90     /**
91      * Returns the application's default bold font.
92      **/
93     const QFont & boldFont();
94
95     /**
96      * Returns the application's heading font.
97      **/
98     const QFont & headingFont();
99
100     /**
101      * Delete the fonts so they will be reloaded upon their next usage.
102      **/
103     void deleteFonts();
104
105     /**
106      * Determine good fonts based on defaultsize geometry and set
107      * _auto_normal_font_size and _auto_heading_font_size accordingly.
108      * Caches the values, so it's safe to call this repeatedly.
109      **/
110     void pickAutoFonts();
111
112     /**
113      * Returns 'true' if the UI  automatically picks fonts, disregarding Qt
114      * standard settings.
115      *
116      * This makes sense during system installation system where the display DPI
117      * cannot reliably be retrieved and thus Qt uses random font sizes based on
118      * that random DPI.
119      **/
120     bool autoFonts() const { return _autoFonts; }
121
122     /**
123      * Set whether or not fonts should automatically be picked.
124      **/
125     void setAutoFonts( bool useAutoFonts );
126
127
128 protected:
129
130     /**
131      * Constructs a key for the language specific font file:
132      *     "font[lang]"
133      * for
134      *     font[de_DE] = "Sans Serif"
135      *     font[zh] = "ChineseSpecial, something"
136      *     font[ja_JP] = "JapaneseSpecial, something"
137      *     font = "Sans Serif"
138      **/
139     QString fontKey( const QString & lang );
140
141
142     //
143     // Data members
144     //
145
146     // Fonts
147
148     QFont * _currentFont;
149     QFont * _headingFont;
150     QFont * _boldFont;
151
152     /**
153      * Font family or list of font families to use ("Sans Serif" etc.)
154      **/
155     QString _fontFamily;
156
157     /**
158      * Language-specific font settings
159      **/
160     QY2Settings * _langFonts;
161
162     /**
163      * Translator for the predefined Qt dialogs
164      **/
165     QTranslator * _qtTranslations;
166
167     /**
168      * For auto fonts
169      **/
170     bool _autoFonts;
171     int  _autoNormalFontSize;
172     int  _autoHeadingFontSize;
173
174
175 };
176
177
178 #endif // YQApplication_h