Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/dialogs/qfontdialog.cpp

    r651 r769  
    990990{
    991991    Q_D(QFontDialog);
    992     if (visible)
    993         d->selectedFont = QFont();
    994 
    995 #if defined(Q_WS_MAC)
    996     bool isCurrentlyVisible = (isVisible() || d->delegate);
    997 
    998     if (!visible == !isCurrentlyVisible)
     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))
    999996        return;
    1000 
    1001     if (visible) {
    1002         if (!(d->opts & DontUseNativeDialog) && QFontDialogPrivate::sharedFontPanelAvailable) {
    1003             d->delegate = QFontDialogPrivate::openCocoaFontPanel(
    1004                               currentFont(), parentWidget(), windowTitle(), options(), d);
    1005             QFontDialogPrivate::sharedFontPanelAvailable = false;
    1006             return;
     997#ifdef Q_WS_MAC
     998    if (d->canBeNativeDialog()){
     999        if (d->setVisible_sys(visible)){
     1000            d->nativeDialogInUse = true;
     1001            // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
     1002            // updates the state correctly, but skips showing the non-native version:
     1003            setAttribute(Qt::WA_DontShowOnScreen, true);
     1004        } else {
     1005            d->nativeDialogInUse = false;
     1006            setAttribute(Qt::WA_DontShowOnScreen, false);
    10071007        }
    1008 
    1009         setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
    1010     } else {
    1011         if (d->delegate) {
    1012             QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
    1013             d->delegate = 0;
    1014             QFontDialogPrivate::sharedFontPanelAvailable = true;
    1015             return;
    1016         }
    1017     }
    1018 #endif
    1019 
     1008    }
     1009#endif // Q_WS_MAC
    10201010    QDialog::setVisible(visible);
    10211011}
     
    10331023    QDialog::done(result);
    10341024    if (result == Accepted) {
    1035         d->selectedFont = currentFont();
     1025        // We check if this is the same font we had before, if so we emit currentFontChanged
     1026        QFont selectedFont = currentFont();
     1027        if(selectedFont != d->selectedFont)
     1028            emit(currentFontChanged(selectedFont));
     1029        d->selectedFont = selectedFont;
    10361030        emit fontSelected(d->selectedFont);
    1037     } else {
     1031    } else
    10381032        d->selectedFont = QFont();
    1039     }
    10401033    if (d->receiverToDisconnectOnClose) {
    10411034        disconnect(this, SIGNAL(fontSelected(QFont)),
     
    10461039}
    10471040
     1041#ifdef Q_WS_MAC
     1042bool QFontDialogPrivate::canBeNativeDialog()
     1043{
     1044    Q_Q(QFontDialog);
     1045    if (nativeDialogInUse)
     1046        return true;
     1047    if (q->testAttribute(Qt::WA_DontShowOnScreen))
     1048        return false;
     1049    if (opts & QFontDialog::DontUseNativeDialog)
     1050        return false;
     1051
     1052    QLatin1String staticName(QFontDialog::staticMetaObject.className());
     1053    QLatin1String dynamicName(q->metaObject()->className());
     1054    return (staticName == dynamicName);
     1055}
     1056#endif // Q_WS_MAC
     1057
    10481058/*!
    10491059    \fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
Note: See TracChangeset for help on using the changeset viewer.