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