src/gui/dialogs/qfontdialog.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   172 
   172 
   173 void QFontDialogPrivate::init()
   173 void QFontDialogPrivate::init()
   174 {
   174 {
   175     Q_Q(QFontDialog);
   175     Q_Q(QFontDialog);
   176 
   176 
       
   177 #ifdef Q_WS_MAC
       
   178     nativeDialogInUse = false;
       
   179     delegate = 0;
       
   180 #endif
       
   181 
   177     q->setSizeGripEnabled(true);
   182     q->setSizeGripEnabled(true);
   178     q->setWindowTitle(QFontDialog::tr("Select Font"));
   183     q->setWindowTitle(QFontDialog::tr("Select Font"));
   179 
   184 
   180     // grid
   185     // grid
   181     familyEdit = new QLineEdit(q);
   186     familyEdit = new QLineEdit(q);
   327     styleList->installEventFilter(q);
   332     styleList->installEventFilter(q);
   328     sizeList->installEventFilter(q);
   333     sizeList->installEventFilter(q);
   329 
   334 
   330     familyList->setFocus();
   335     familyList->setFocus();
   331     retranslateStrings();
   336     retranslateStrings();
   332 
       
   333 #ifdef Q_WS_MAC
       
   334     delegate = 0;
       
   335 #endif
       
   336 }
   337 }
   337 
   338 
   338 /*!
   339 /*!
   339   \internal
   340   \internal
   340  Destroys the font dialog and frees up its storage.
   341  Destroys the font dialog and frees up its storage.
   343 QFontDialog::~QFontDialog()
   344 QFontDialog::~QFontDialog()
   344 {
   345 {
   345 #ifdef Q_WS_MAC
   346 #ifdef Q_WS_MAC
   346     Q_D(QFontDialog);
   347     Q_D(QFontDialog);
   347     if (d->delegate) {
   348     if (d->delegate) {
   348         QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
   349         d->closeCocoaFontPanel();
   349         QFontDialogPrivate::sharedFontPanelAvailable = true;
       
   350         return;
   350         return;
   351     }
   351     }
   352 #endif
   352 #endif
   353 }
   353 }
   354 
   354 
   426 }
   426 }
   427 
   427 
   428 QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
   428 QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
   429                                   const QString &title, QFontDialog::FontDialogOptions options)
   429                                   const QString &title, QFontDialog::FontDialogOptions options)
   430 {
   430 {
   431 #ifdef Q_WS_MAC
       
   432     if (!(options & QFontDialog::DontUseNativeDialog)
       
   433             && QFontDialogPrivate::sharedFontPanelAvailable) {
       
   434         return QFontDialogPrivate::execCocoaFontPanel(ok, initial, parent,
       
   435                        title.isEmpty() ? QFontDialog::tr("Select Font") : title, options);
       
   436     }
       
   437 #endif
       
   438 
       
   439     QFontDialog dlg(parent);
   431     QFontDialog dlg(parent);
   440     dlg.setOptions(options);
   432     dlg.setOptions(options);
   441     dlg.setCurrentFont(initial);
   433     dlg.setCurrentFont(initial);
   442     if (!title.isEmpty())
   434     if (!title.isEmpty())
   443         dlg.setWindowTitle(title);
   435         dlg.setWindowTitle(title);
   986 /*!
   978 /*!
   987     \reimp
   979     \reimp
   988 */
   980 */
   989 void QFontDialog::setVisible(bool visible)
   981 void QFontDialog::setVisible(bool visible)
   990 {
   982 {
   991     Q_D(QFontDialog);
   983     if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible)
   992     if (visible) {
       
   993         if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
       
   994             return;
       
   995     } else if  (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
       
   996         return;
   984         return;
   997 #ifdef Q_WS_MAC
   985 #ifdef Q_WS_MAC
       
   986     Q_D(QFontDialog);
   998     if (d->canBeNativeDialog()){
   987     if (d->canBeNativeDialog()){
   999         if (d->setVisible_sys(visible)){
   988         if (d->setVisible_sys(visible)){
  1000             d->nativeDialogInUse = true;
   989             d->nativeDialogInUse = true;
  1001             // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
   990             // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
  1002             // updates the state correctly, but skips showing the non-native version:
   991             // updates the state correctly, but skips showing the non-native version: