1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQApplication_h
21 #define YQApplication_h
23 #include <Qt/qobject.h>
24 #include <Qt/qtranslator.h>
27 #include "QY2Settings.h"
28 #include "YApplication.h"
31 class YQApplication: public QObject, public YApplication
42 * Use YUI::app() to get the singleton for this class.
49 virtual ~YQApplication();
55 * Set language and encoding for the locale environment ($LANG).
57 * Load UI-internal translations (e.g. for predefined dialogs like
58 * file selection) and fonts.
60 * 'language' is the ISO short code ("de_DE", "en_US", ...).
62 * 'encoding' an (optional) encoding ("utf8", ...) that will be appended if
65 * Reimplemented from YApplication.
67 virtual void setLanguage( const string & language,
68 const string & encoding = string() );
71 * Load translations for Qt's predefined dialogs like file selection box
74 void loadPredefinedQtTranslations();
77 * Set fonts according to the specified language and encoding.
79 * This is most important for some Asian languages that have overlaps in
80 * the Unicode table, like Japanese vs. Chinese.
82 void setLangFonts( const string & language,
83 const string & encoding = string() );
86 * Returns the application's default font.
88 const QFont & currentFont();
91 * Returns the application's default bold font.
93 const QFont & boldFont();
96 * Returns the application's heading font.
98 const QFont & headingFont();
101 * Delete the fonts so they will be reloaded upon their next usage.
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.
110 void pickAutoFonts();
113 * Returns 'true' if the UI automatically picks fonts, disregarding Qt
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
120 bool autoFonts() const { return _autoFonts; }
123 * Set whether or not fonts should automatically be picked.
125 void setAutoFonts( bool useAutoFonts );
131 * Constructs a key for the language specific font file:
134 * font[de_DE] = "Sans Serif"
135 * font[zh] = "ChineseSpecial, something"
136 * font[ja_JP] = "JapaneseSpecial, something"
137 * font = "Sans Serif"
139 QString fontKey( const QString & lang );
148 QFont * _currentFont;
149 QFont * _headingFont;
153 * Font family or list of font families to use ("Sans Serif" etc.)
158 * Language-specific font settings
160 QY2Settings * _langFonts;
163 * Translator for the predefined Qt dialogs
165 QTranslator * _qtTranslations;
171 int _autoNormalFontSize;
172 int _autoHeadingFontSize;
178 #endif // YQApplication_h