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