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 );
128 * Open a directory selection box and prompt the user for an existing
131 * 'startDir' is the initial directory that is displayed.
133 * 'headline' is an explanatory text for the directory selection box.
134 * Graphical UIs may omit that if no window manager is running.
136 * Returns the selected directory name
137 * or an empty string if the user canceled the operation.
139 * Implemented from YApplication.
141 virtual string askForExistingDirectory( const string & startDir,
142 const string & headline );
145 * Open a file selection box and prompt the user for an existing file.
147 * 'startWith' is the initial directory or file.
149 * 'filter' is one or more blank-separated file patterns, e.g.
152 * 'headline' is an explanatory text for the file selection box.
153 * Graphical UIs may omit that if no window manager is running.
155 * Returns the selected file name
156 * or an empty string if the user canceled the operation.
158 * Implemented from YApplication.
160 virtual string askForExistingFile( const string & startWith,
161 const string & filter,
162 const string & headline );
165 * Open a file selection box and prompt the user for a file to save data
166 * to. Automatically asks for confirmation if the user selects an existing
169 * 'startWith' is the initial directory or file.
171 * 'filter' is one or more blank-separated file patterns, e.g.
174 * 'headline' is an explanatory text for the file selection box.
175 * Graphical UIs may omit that if no window manager is running.
177 * Returns the selected file name
178 * or an empty string if the user canceled the operation.
180 * Implemented from YApplication.
182 virtual string askForSaveFileName( const string & startWith,
183 const string & filter,
184 const string & headline );
186 * Lower-level version that works with QStrings and does not change
189 static QString askForSaveFileName( const QString & startWith,
190 const QString & filter,
191 const QString & headline );
197 * Constructs a key for the language specific font file:
200 * font[de_DE] = "Sans Serif"
201 * font[zh] = "ChineseSpecial, something"
202 * font[ja_JP] = "JapaneseSpecial, something"
203 * font = "Sans Serif"
205 QString fontKey( const QString & lang );
214 QFont * _currentFont;
215 QFont * _headingFont;
219 * Font family or list of font families to use ("Sans Serif" etc.)
224 * Language-specific font settings
226 QY2Settings * _langFonts;
229 * Translator for the predefined Qt dialogs
231 QTranslator * _qtTranslations;
237 int _autoNormalFontSize;
238 int _autoHeadingFontSize;
244 #endif // YQApplication_h