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