libyui-qt  2.52.2
YQApplication.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQApplication.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23  Textdomain "qt"
24 /-*/
25 
26 #include <unistd.h> // access()
27 
28 #include <QApplication>
29 #include <QLocale>
30 #include <QRegExp>
31 #include <QFileDialog>
32 #include <QDesktopWidget>
33 #include <QMessageBox>
34 #include <QSettings>
35 #include <QFontDatabase>
36 #include <QMenu>
37 #include <QLibraryInfo>
38 
39 #include <fontconfig/fontconfig.h>
40 
41 #define YUILogComponent "qt-ui"
42 #include <yui/YUILog.h>
43 #include <yui/YUISymbols.h>
44 #include <yui/Libyui_config.h>
45 
46 #include "YQUI.h"
47 
48 #include "utf8.h"
49 #include "YQi18n.h"
50 
51 #include "YQApplication.h"
52 #include "YQPackageSelectorPluginStub.h"
53 #include "YQGraphPluginStub.h"
54 #include "YQContextMenu.h"
55 
56 using std::string;
57 
58 // Qt5 requires the explicit font initialization; otherwise it picks up
59 // any random matching fonts, and tends to choose the worst one
60 // (e.g. bitmap fonts) in the end. (bnc#879991)
61 // Note that this is also set in LANG_FONTS_FILE
62 static const char * default_font_family = "Sans Serif";
63 
64 
66  : YApplication()
67  , _currentFont( 0 )
68  , _headingFont( 0 )
69  , _boldFont( 0 )
70  , _langFonts( 0 )
71  , _qtTranslations( 0 )
72  , _autoFonts( false )
73  , _autoNormalFontSize( -1 )
74  , _autoHeadingFontSize( -1 )
75  , _leftHandedMouse( false )
76  , _askedForLeftHandedMouse( false )
77  , _contextMenuPos ( QPoint (0, 0) )
78  , _contextMenu ( 0 )
79 {
80  yuiDebug() << "YQApplication constructor start" << endl;
81 
82  yuiMilestone() << "QIcon::themeName = '" << QIcon::themeName() << "'" << endl;
83 
84  //setIconBasePath( ICONDIR "/icons/22x22/apps/" );
85  // the above works too, but let's try it the icon-loader way - FaTE #306356
86  iconLoader()->addIconSearchPath( ICONDIR "/icons/" );
88  _fontFamily = default_font_family;
89 
90  yuiDebug() << "YQApplication constructor end" << endl;
91 }
92 
93 
95 {
96  delete _langFonts;
97  delete _qtTranslations;
98 
99  deleteFonts();
100 }
101 
102 static string glob_language = "";
103 
104 void
105 YQApplication::setLanguage( const string & language,
106  const string & encoding )
107 {
108  glob_language = language;
109  YApplication::setLanguage( language, encoding );
111 
112  bool oldReverseLayout = YApplication::reverseLayout();
113  setLayoutDirection( language );
114  setLangFonts( language, encoding );
115 
116  if ( oldReverseLayout != YApplication::reverseLayout() )
117  {
118  YDialog * dialog = YDialog::topmostDialog( false ); // don't throw
119 
120  if ( dialog )
121  dialog->recalcLayout();
122  }
123 }
124 
125 
126 void
128 {
129  QString path = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
130  QString language;
131 
132  if (glob_language == "")
133  language = QLocale::system().name();
134  else
135  language = glob_language.c_str();
136 
137  QString transFile = QString( "qt_%1.qm").arg( language );
138 
139  yuiMilestone() << "Selected language: " << language << endl;
140 
141  if ( path.isEmpty() )
142  {
143  yuiWarning() << "Qt locale directory not set - "
144  << "no translations for predefined Qt dialogs"
145  << endl;
146  return;
147  }
148 
149  if ( ! _qtTranslations )
150  _qtTranslations = new QTranslator();
151 
152  if ( !_qtTranslations->load( transFile, path ) )
153  {
154  yuiWarning() << "Can't load translations for predefined Qt dialogs for "
155  << language << endl;
156  }
157  else
158  {
159  yuiMilestone() << "Loaded translations for predefined Qt dialogs for "
160  << language << endl;
161 
162  qApp->installTranslator( _qtTranslations );
163 
164  if ( qApp->layoutDirection() == Qt::RightToLeft )
165  YApplication::setReverseLayout( true );
166  }
167 }
168 
169 
170 void
171 YQApplication::setLayoutDirection( const string & language )
172 {
173  QString lang( language.c_str() );
174 
175  // Force reverse layout for Arabic, Farsi and Hebrew.
176  // Alternatively, we could use QLocale::textDirection().
177 
178  if ( lang.startsWith( "ar" ) || // Arabic
179  lang.startsWith( "fa" ) || // Farsi
180  lang.startsWith( "he" ) ) // Hebrew
181  {
182  yuiMilestone() << "Using reverse layout for " << language << endl;
183 
184  qApp->setLayoutDirection( Qt::RightToLeft );
185  YApplication::setReverseLayout( true );
186  }
187  else
188  {
189  qApp->setLayoutDirection( Qt::LeftToRight );
190  YApplication::setReverseLayout( false );
191  }
192 
193  // Qt tries to figure that out by having translators translate a message
194  // "QT_LAYOUT_DIRECTION" to "RTL" for right-to-left languages (i.e.,
195  // Arabic, Hebrew) with QQapplication::tr(). This of course only works if
196  // there are translations for those languages for QTranslator in the first
197  // place, i.e. it only works if translations for the predefined Qt dialogs
198  // (file selection dialog etc.) are available - and being loaded.
199  //
200  // libqt4-x11 contains Arabic translations for those Qt standard dialogs in
201  // /usr/share/qt4/translations/qt_ar.qm, but (as of Sept. 2008) no Hebrew
202  // translations.
203  //
204  // Anyway, that Qt standard way is not very reliable. And they only do it
205  // at program startup anyway. Any later loading of those translations will
206  // not help.
207 }
208 
209 
210 void
211 YQApplication::setLangFonts( const string & language, const string & encoding )
212 {
213  if ( ! _langFonts )
214  {
215  // FIXME, LANG_FONTS_FILE is defined in the generic interface,
216  // in yui/Libyui_config.h
217  _langFonts = new QSettings( LANG_FONTS_FILE, QSettings::IniFormat );
218  Q_CHECK_PTR( _langFonts );
219 
220  if ( _langFonts->status() != QSettings::NoError )
221  yuiError() << "Error reading " << _langFonts->fileName() << endl;
222  else
223  yuiMilestone() << _langFonts->fileName() << " read OK"
224  << qPrintable( _langFonts->allKeys().join( "-" ) )
225  << endl;
226  }
227 
228  QString lang = language.c_str();
229 
230  if ( ! encoding.empty() )
231  lang += QString( "." ) + encoding.c_str();
232 
233  QString key;
234  bool reloadFont = false;
235 
236  if ( ! _langFonts->contains( fontKey( lang ) ) ) // Try with encoding ("zh_CN.UTF8" etc.)
237  {
238  lang = language.c_str(); // Try without encoding ("zh_CN")
239 
240  if ( ! _langFonts->contains( fontKey( lang ) ) )
241  lang.replace( QRegExp( "_.*$" ), "" ); // Cut off trailing country ("_CN")
242  }
243 
244  if ( _langFonts->contains( fontKey( lang ) ) )
245  {
246  QStringList fontList =
247  _langFonts->value( fontKey( lang ), "" ).toString().split( "," );
248  for ( int i = 0; i < fontList.size(); ++i )
249  {
250  yuiMilestone() << fontKey( lang ) << " adding " << fontList.at( i ) << endl;
251  QFontDatabase::addApplicationFont( fontList.at( i ) );
252  }
253 
254  reloadFont = true;
255  }
256 
257  if ( _fontFamily.isEmpty() )
258  {
259  _fontFamily = default_font_family;
260  reloadFont = true;
261  }
262 
263  if (reloadFont)
264  {
265  yuiMilestone() << "Reloading fonts" << endl;
266 
267  // update fonts
268  deleteFonts();
269 
270  foreach ( QWidget *widget, QApplication::allWidgets() )
271  {
272  QFont wfont( widget->font() );
273  wfont.setFamily( _fontFamily );
274  widget->setFont( wfont );
275  }
276 
277  QFont font( qApp->font() );
278  font.setFamily( _fontFamily );
279  qApp->setFont(font); // font, informWidgets
280 
281  yuiMilestone() << "Removing the key " << lang << endl;
282  _langFonts->remove( fontKey( lang ) );
283  }
284  else
285  {
286  yuiDebug() << "No font change" << endl;
287  }
288 
289 }
290 
291 
292 QString
293 YQApplication::fontKey( const QString & lang )
294 {
295  if ( lang.isEmpty() )
296  return "font";
297  else
298  return QString( "font[%1]").arg( lang );
299 }
300 
301 
302 const QFont &
304 {
305  /**
306  * Brute force approach to make sure we'll really get a complete Unicode font:
307  * Explicitly load the one font that we made sure to contain all required
308  * characters, including Latin1, Latin2, Japanese, Korean, and the
309  * characters used for glyphs.
310  *
311  * There are many fonts that claim to be Unicode, but most of them contain
312  * just a sorry excuse for a complete Unicode character set. Qt can't know
313  * how complete a font is, so it chooses one that might be better in otherf
314  * aspects, but lacks necessary characters.
315  **/
316 
317  if ( ! _currentFont )
318  {
319  if ( autoFonts() )
320  {
321  pickAutoFonts();
322 
323  _currentFont = new QFont( _fontFamily );
324  _currentFont->setPixelSize( _autoNormalFontSize );
325  _currentFont->setWeight( QFont::Normal );
326 
327  yuiMilestone() << "Loaded " << _autoNormalFontSize
328  << " pixel font: " << _currentFont->toString()
329  << endl;
330 
331  qApp->setFont( * _currentFont); // font, informWidgets
332  }
333  else
334  {
335  // yuiDebug() << "Copying QApplication::font()" << endl;
336  _currentFont = new QFont( qApp->font() );
337  }
338  }
339 
340  return * _currentFont;
341 }
342 
343 
344 const QFont &
346 {
347  if ( ! _boldFont )
348  {
349  _boldFont = new QFont( currentFont() );
350  _boldFont->setBold( true );
351  }
352 
353  return * _boldFont;
354 }
355 
356 
357 const QFont &
359 {
360  /**
361  * Brute force load the heading font - see currentFont() above for more.
362  **/
363 
364  if ( ! _headingFont )
365  {
366  if ( autoFonts() )
367  {
368  pickAutoFonts();
369 
370  _headingFont = new QFont( _fontFamily );
371  _headingFont->setPixelSize( _autoHeadingFontSize );
372  _headingFont->setWeight( QFont::Bold );
373 
374  yuiMilestone() << "Loaded " << _autoHeadingFontSize
375  << " pixel bold font: " << _headingFont->toString()
376  << endl;
377  }
378  else
379  {
380  _headingFont = new QFont( _fontFamily, 14, QFont::Bold );
381  }
382  }
383 
384  return * _headingFont;
385 }
386 
387 
388 void
390 {
391  delete _currentFont;
392  delete _headingFont;
393  delete _boldFont;
394 
395  _currentFont = 0;
396  _headingFont = 0;
397  _boldFont = 0;
398 }
399 
400 
401 void
402 YQApplication::setAutoFonts( bool useAutoFonts )
403 {
404  _autoFonts = useAutoFonts;
405 }
406 
407 
408 void
410 {
411  if ( _autoNormalFontSize >= 0 ) // Use cached values
412  return;
413 
414  int x = defaultWidth();
415  int y = defaultHeight();
416 
417  int normal = 10;
418  int heading = 12;
419 
420  if ( x >= 800 && y >= 600 )
421  {
422  normal = 10;
423  heading = 12;
424  }
425 
426  if ( x >= 1024 && y >= 768 )
427  {
428  normal = 12;
429  heading = 14;
430  }
431 
432  if ( x >= 1280 && y >= 1024 )
433  {
434  normal = 14;
435  heading = 18;
436  }
437 
438  if ( x >= 1400 )
439  {
440  normal = 16;
441  heading = 20;
442  }
443 
444  if ( x >= 1600 )
445  {
446  normal = 18;
447  heading = 24;
448  }
449 
450  if ( x >= 2048 ) // Sounds futuristic? Just wait one or two years...
451  {
452  normal = 20;
453  heading = 28;
454  }
455 
456  _autoNormalFontSize = normal;
457  _autoHeadingFontSize = heading;
458 
459  yuiMilestone() << "Selecting auto fonts - normal: " << _autoNormalFontSize
460  << ", heading: " << _autoHeadingFontSize << " (bold)"
461  << endl;
462 }
463 
464 
465 string
466 YQApplication::glyph( const string & sym )
467 {
468  QChar unicodeChar;
469 
470  // Hint: Use the 'xfd' program to view characters available in the Unicode font.
471 
472  if ( sym == YUIGlyph_ArrowLeft ) unicodeChar = QChar( reverseLayout() ? 0x2192 : 0x2190 );
473  else if ( sym == YUIGlyph_ArrowRight ) unicodeChar = QChar( reverseLayout() ? 0x2190 : 0x2192 );
474  else if ( sym == YUIGlyph_ArrowUp ) unicodeChar = QChar( 0x2191 );
475  else if ( sym == YUIGlyph_ArrowDown ) unicodeChar = QChar( 0x2193 );
476  else if ( sym == YUIGlyph_CheckMark ) unicodeChar = QChar( 0x2714 );
477  else if ( sym == YUIGlyph_BulletArrowRight ) unicodeChar = QChar( 0x279c );
478  else if ( sym == YUIGlyph_BulletCircle ) unicodeChar = QChar( 0x274d );
479  else if ( sym == YUIGlyph_BulletSquare ) unicodeChar = QChar( 0x274f );
480  else return "";
481 
482  return toUTF8( QString( unicodeChar ) );
483 }
484 
485 
486 string
487 YQApplication::askForExistingDirectory( const string & startDir,
488  const string & headline )
489 {
490  normalCursor();
491 
492  QString dirName =
493  QFileDialog::getExistingDirectory( 0, // parent
494  fromUTF8( headline ) , // caption
495  fromUTF8( startDir ), QFileDialog::DontUseNativeDialog); // dir
496 
497  busyCursor();
498 
499  return toUTF8( dirName );
500 }
501 
502 
503 string
504 YQApplication::askForExistingFile( const string & startWith,
505  const string & filter,
506  const string & headline )
507 {
508  normalCursor();
509 
510  QFileDialog* dialog = new QFileDialog( 0, // parent
511  fromUTF8( headline ), // caption
512  fromUTF8( startWith ), // dir
513  fromUTF8( filter )); // filter
514  dialog->setFileMode( QFileDialog::ExistingFile );
515  dialog->setFilter( QDir::System | dialog->filter() );
516  dialog->setOptions( QFileDialog::DontUseNativeDialog );
517 
518  QString fileName;
519  if( dialog->exec() == QDialog::Accepted )
520  fileName = dialog->selectedFiles().value( 0 );
521  delete dialog;
522 
523  busyCursor();
524 
525  return toUTF8( fileName );
526 }
527 
528 
529 string
530 YQApplication::askForSaveFileName( const string & startWith,
531  const string & filter,
532  const string & headline )
533 {
534  normalCursor();
535 
536  QString fileName = askForSaveFileName( fromUTF8( startWith ),
537  fromUTF8( filter ),
538  fromUTF8( headline ) );
539  busyCursor();
540 
541  return toUTF8( fileName );
542 }
543 
544 
545 bool
546 YQApplication::openContextMenu( const YItemCollection & itemCollection )
547 {
548  QWidget* parent = 0;
549  YDialog * currentDialog = YDialog::currentDialog( false );
550 
551  if (currentDialog)
552  parent = (QWidget *) currentDialog->widgetRep();
553 
554  YQContextMenu* menu = new YQContextMenu(parent, _contextMenuPos );
555  menu->addItems(itemCollection);
556 
557  return true;
558 }
559 
560 
561 QString
562 YQApplication::askForSaveFileName( const QString & startWith,
563  const QString & filter,
564  const QString & headline )
565 {
566  QString fileName;
567 
568  QWidget* parent = 0;
569  YDialog * currentDialog = YDialog::currentDialog( false );
570  if (currentDialog)
571  parent = (QWidget *) currentDialog->widgetRep();
572 
573 
574  // Leave the mouse cursor alone - this function might be called from
575  // some other widget, not only from UI::AskForSaveFileName().
576 
577  fileName = QFileDialog::getSaveFileName( parent, // parent
578  headline, // caption
579  startWith, // dir
580  filter, 0, QFileDialog::DontUseNativeDialog ); // filter
581 
582  if ( fileName.isEmpty() ) // this includes fileName.isNull()
583  return QString();
584 
585  return fileName;
586 }
587 
588 
589 int
590 YQApplication::displayWidth()
591 {
592  return qApp->desktop()->width();
593 }
594 
595 
596 int
597 YQApplication::displayHeight()
598 {
599  return qApp->desktop()->height();
600 }
601 
602 
603 int
604 YQApplication::displayDepth()
605 {
606  return qApp->desktop()->depth();
607 }
608 
609 
610 long
611 YQApplication::displayColors()
612 {
613  return 1L << qApp->desktop()->depth();
614 }
615 
616 
617 int
618 YQApplication::defaultWidth()
619 {
620  return YQUI::ui()->defaultSize( YD_HORIZ );
621 }
622 
623 
624 int
625 YQApplication::defaultHeight()
626 {
627  return YQUI::ui()->defaultSize( YD_VERT );
628 }
629 
630 
631 bool
632 YQApplication::leftHandedMouse()
633 {
634  return _leftHandedMouse;
635 }
636 
637 
638 void
640 {
641  if ( _askedForLeftHandedMouse )
642  return;
643 
644  QString message =
645  _( "You clicked the right mouse button "
646  "where a left-click was expected."
647  "\n"
648  "Switch left and right mouse buttons?"
649  );
650 
651  QWidget* parent = 0;
652  YDialog * currentDialog = YDialog::currentDialog( false );
653  if (currentDialog)
654  parent = (QWidget *) currentDialog->widgetRep();
655 
656  int button = QMessageBox::question( parent,
657  // Popup dialog caption
658  _( "Unexpected Click" ),
659  message,
660  QMessageBox::Yes | QMessageBox::Default,
661  QMessageBox::No,
662  QMessageBox::Cancel | QMessageBox::Escape );
663 
664  if ( button == QMessageBox::Yes )
665  {
666  int result;
667  const char * command =
668  _leftHandedMouse ?
669  "xmodmap -e \"pointer = 1 2 3\"": // switch back to right-handed mouse
670  "xmodmap -e \"pointer = 3 2 1\""; // switch to left-handed mouse
671 
672  _leftHandedMouse = ! _leftHandedMouse; // might be set repeatedly!
673  _askedForLeftHandedMouse = false; // give the user a chance to switch back
674  yuiMilestone() << "Switching mouse buttons: " << command << endl;
675 
676  result = system( command );
677  if (result < 0)
678  yuiError() << "Calling '" << command << "' failed" << endl;
679  else if (result > 0)
680  yuiError() << "Running '" << command << "' exited with " << result << endl;
681  }
682  else if ( button == 1 ) // No
683  {
684  _askedForLeftHandedMouse = true;
685  }
686 }
687 
688 
689 int YQApplication::deviceUnits( YUIDimension dim, float layoutUnits )
690 {
691  if ( dim==YD_HORIZ ) layoutUnits *= ( 640.0/80 );
692  else layoutUnits *= ( 480.0/25 );
693 
694  return (int) ( layoutUnits + 0.5 );
695 }
696 
697 
698 float YQApplication::layoutUnits( YUIDimension dim, int deviceUnits )
699 {
700  float size = (float) deviceUnits;
701 
702  if ( dim==YD_HORIZ ) size *= ( 80/640.0 );
703  else size *= ( 25/480.0 );
704 
705  return size;
706 }
707 
708 
710 {
711  qApp->beep();
712 }
713 
714 
716 {
717  YQUI::ui()->busyCursor();
718 }
719 
720 
722 {
723  YQUI::ui()->normalCursor();
724 }
725 
726 
727 void YQApplication::makeScreenShot( const string & fileName )
728 {
729  YQUI::ui()->makeScreenShot( fileName );
730 }
731 
732 
735 {
736  static YQPackageSelectorPluginStub * plugin = 0;
737 
738  if ( ! plugin )
739  {
740  plugin = new YQPackageSelectorPluginStub();
741 
742  // This is a deliberate memory leak: If an application requires a
743  // PackageSelector, it is a package selection application by
744  // definition. In this case, the ncurses_pkg plugin is intentionally
745  // kept open to avoid repeated start-up cost of the plugin and libzypp.
746  }
747 
748  return plugin;
749 }
750 
751 
754 {
755  static YQGraphPluginStub * plugin = 0;
756 
757  if ( ! plugin )
758  {
759  plugin = new YQGraphPluginStub();
760 
761  // This is a deliberate memory leak: Plugin is intentionally
762  // kept open to avoid repeated start-up cost of the plugin.
763  }
764 
765  return plugin;
766 }
767 
768 
769 void
770 YQApplication::setContextMenuPos( QPoint contextMenuPos )
771 {
772  _contextMenuPos = contextMenuPos;
773 }
774 
775 
776 void YQApplication::setApplicationTitle ( const string & title )
777 {
778  QString qtTitle = fromUTF8( title );
779  YApplication::setApplicationTitle ( title );
780  YQUI::ui()->setApplicationTitle(qtTitle);
781  qApp->setApplicationName(qtTitle);
782 }
783 
784 
785 void YQApplication::setApplicationIcon ( const string & icon )
786 {
787  QString qtIcon = fromUTF8( icon );
788  YApplication::setApplicationIcon ( icon );
789  QString icon_name = QFileInfo( qtIcon ).baseName();
790 
791  if ( QIcon::hasThemeIcon( icon_name ) )
792  {
793  qApp->setWindowIcon( QIcon::fromTheme ( icon_name ) );
794  }
795  else
796  {
797  QPixmap pixmap( qtIcon );
798 
799  if ( !pixmap.isNull() )
800  qApp->setWindowIcon( QIcon( pixmap ) );
801  }
802 }
int defaultSize(YUIDimension dim) const
Returns size for opt(defaultsize) dialogs (in one dimension).
Definition: YQUI.cc:587
virtual void normalCursor()
Change the (mouse) cursor back from busy status to normal.
virtual int deviceUnits(YUIDimension dim, float layoutUnits)
Convert logical layout spacing units into device dependent units.
virtual std::string glyph(const std::string &glyphSymbolName)
Return a std::string for a named glyph.
void setLayoutDirection(const std::string &language)
Set the layout direction (left-to-right or right-to-left) from &#39;language&#39;.
void maybeLeftHandedUser()
A mouse click with the wrong mouse button was detected - e.g., a right click on a push button...
virtual QPoint contextMenuPos()
Return position of the context menu (in gloabl coordinates)
virtual ~YQApplication()
Destructor.
void setApplicationTitle(const QString &title)
Sets the application name for the window title.
Definition: YQUI.h:290
virtual void setApplicationTitle(const std::string &title)
Set the application title.
virtual void busyCursor()
Change the (mouse) cursor to indicate busy status.
QSettings * _langFonts
Language-specific font settings.
virtual void beep()
Beep.
void makeScreenShot(std::string filename)
Make a screen shot in .png format and save it to &#39;filename&#39;.
void setAutoFonts(bool useAutoFonts)
Set whether or not fonts should automatically be picked.
void setLangFonts(const std::string &language, const std::string &encoding=std::string())
Set fonts according to the specified language and encoding.
void deleteFonts()
Delete the fonts so they will be reloaded upon their next usage.
QTranslator * _qtTranslations
Translator for the predefined Qt dialogs.
virtual bool openContextMenu(const YItemCollection &itemCollection)
Open a context menu for a widget.
QString fontKey(const QString &lang)
Constructs a key for the language specific font file: "font[lang]" for font[de_DE] = "Sans Serif" fon...
static YQGraphPluginStub * graphPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
virtual void setContextMenuPos(QPoint contextMenuPos)
Sets the position of the context menu (in gloabl coordinates)
virtual void setApplicationIcon(const std::string &icon)
Set the application Icon.
virtual void makeScreenShot(const std::string &fileName)
Make a screen shot and save it to the specified file.
const QFont & headingFont()
Returns the application&#39;s heading font.
bool autoFonts() const
Returns &#39;true&#39; if the UI automatically picks fonts, disregarding Qt standard settings.
QString _fontFamily
Font family or list of font families to use ("Sans Serif" etc.)
YQApplication()
Constructor.
virtual std::string askForExistingDirectory(const std::string &startDir, const std::string &headline)
Open a directory selection box and prompt the user for an existing directory.
virtual std::string askForSaveFileName(const std::string &startWith, const std::string &filter, const std::string &headline)
Open a file selection box and prompt the user for a file to save data to.
void busyCursor()
Show mouse cursor indicating busy state.
Definition: YQUI.cc:562
virtual void setLanguage(const std::string &language, const std::string &encoding=std::string())
Set language and encoding for the locale environment ($LANG).
virtual float layoutUnits(YUIDimension dim, int deviceUnits)
Convert device dependent units into logical layout spacing units.
const QFont & boldFont()
Returns the application&#39;s default bold font.
void loadPredefinedQtTranslations()
Load translations for Qt&#39;s predefined dialogs like file selection box etc.
void normalCursor()
Show normal mouse cursor not indicating busy status.
Definition: YQUI.cc:568
void pickAutoFonts()
Determine good fonts based on defaultsize geometry and set _auto_normal_font_size and _auto_heading_f...
static YQPackageSelectorPluginStub * packageSelectorPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
static YQUI * ui()
Access the global Qt-UI.
Definition: YQUI.h:83
const QFont & currentFont()
Returns the application&#39;s default font.
virtual std::string askForExistingFile(const std::string &startWith, const std::string &filter, const std::string &headline)
Open a file selection box and prompt the user for an existing file.