Changeset 769 for trunk/src/gui/dialogs


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:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r651 r769  
    645645    void mouseMoveEvent(QMouseEvent *);
    646646    void mousePressEvent(QMouseEvent *);
     647    void resizeEvent(QResizeEvent *);
    647648
    648649private:
     
    655656    void setCol(const QPoint &pt);
    656657
    657     QPixmap *pix;
     658    QPixmap pix;
    658659};
    659660
     
    791792
    792793QPoint QColorPicker::colPt()
    793 { return QPoint((360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255); }
     794{
     795    QRect r = contentsRect();
     796    return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255);
     797}
     798
    794799int QColorPicker::huePt(const QPoint &pt)
    795 { return 360 - pt.x()*360/(pWidth-1); }
     800{
     801    QRect r = contentsRect();
     802    return 360 - pt.x() * 360 / (r.width() - 1);
     803}
     804
    796805int QColorPicker::satPt(const QPoint &pt)
    797 { return 255 - pt.y()*255/(pHeight-1) ; }
     806{
     807    QRect r = contentsRect();
     808    return 255 - pt.y() * 255 / (r.height() - 1);
     809}
     810
    798811void QColorPicker::setCol(const QPoint &pt)
    799 { setCol(huePt(pt), satPt(pt)); }
     812{
     813    setCol(huePt(pt), satPt(pt));
     814}
    800815
    801816QColorPicker::QColorPicker(QWidget* parent)
     
    805820    setCol(150, 255);
    806821
    807     QImage img(pWidth, pHeight, QImage::Format_RGB32);
     822    setAttribute(Qt::WA_NoSystemBackground);
     823    setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
     824}
     825
     826QColorPicker::~QColorPicker()
     827{
     828}
     829
     830QSize QColorPicker::sizeHint() const
     831{
     832    return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth());
     833}
     834
     835void QColorPicker::setCol(int h, int s)
     836{
     837    int nhue = qMin(qMax(0,h), 359);
     838    int nsat = qMin(qMax(0,s), 255);
     839    if (nhue == hue && nsat == sat)
     840        return;
     841
     842    QRect r(colPt(), QSize(20,20));
     843    hue = nhue; sat = nsat;
     844    r = r.united(QRect(colPt(), QSize(20,20)));
     845    r.translate(contentsRect().x()-9, contentsRect().y()-9);
     846    //    update(r);
     847    repaint(r);
     848}
     849
     850void QColorPicker::mouseMoveEvent(QMouseEvent *m)
     851{
     852    QPoint p = m->pos() - contentsRect().topLeft();
     853    setCol(p);
     854    emit newCol(hue, sat);
     855}
     856
     857void QColorPicker::mousePressEvent(QMouseEvent *m)
     858{
     859    QPoint p = m->pos() - contentsRect().topLeft();
     860    setCol(p);
     861    emit newCol(hue, sat);
     862}
     863
     864void QColorPicker::paintEvent(QPaintEvent* )
     865{
     866    QPainter p(this);
     867    drawFrame(&p);
     868    QRect r = contentsRect();
     869
     870    p.drawPixmap(r.topLeft(), pix);
     871    QPoint pt = colPt() + r.topLeft();
     872    p.setPen(Qt::black);
     873
     874    p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black);
     875    p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black);
     876
     877}
     878
     879void QColorPicker::resizeEvent(QResizeEvent *ev)
     880{
     881    QFrame::resizeEvent(ev);
     882
     883    int w = width() - frameWidth() * 2;
     884    int h = height() - frameWidth() * 2;
     885    QImage img(w, h, QImage::Format_RGB32);
    808886    int x, y;
    809887    uint *pixel = (uint *) img.scanLine(0);
    810     for (y = 0; y < pHeight; y++) {
    811         const uint *end = pixel + pWidth;
     888    for (y = 0; y < h; y++) {
     889        const uint *end = pixel + w;
    812890        x = 0;
    813891        while (pixel < end) {
     
    820898        }
    821899    }
    822     pix = new QPixmap(QPixmap::fromImage(img));
    823     setAttribute(Qt::WA_NoSystemBackground);
    824     setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
    825 }
    826 
    827 QColorPicker::~QColorPicker()
    828 {
    829     delete pix;
    830 }
    831 
    832 QSize QColorPicker::sizeHint() const
    833 {
    834     return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth());
    835 }
    836 
    837 void QColorPicker::setCol(int h, int s)
    838 {
    839     int nhue = qMin(qMax(0,h), 359);
    840     int nsat = qMin(qMax(0,s), 255);
    841     if (nhue == hue && nsat == sat)
    842         return;
    843 
    844     QRect r(colPt(), QSize(20,20));
    845     hue = nhue; sat = nsat;
    846     r = r.united(QRect(colPt(), QSize(20,20)));
    847     r.translate(contentsRect().x()-9, contentsRect().y()-9);
    848     //    update(r);
    849     repaint(r);
    850 }
    851 
    852 void QColorPicker::mouseMoveEvent(QMouseEvent *m)
    853 {
    854     QPoint p = m->pos() - contentsRect().topLeft();
    855     setCol(p);
    856     emit newCol(hue, sat);
    857 }
    858 
    859 void QColorPicker::mousePressEvent(QMouseEvent *m)
    860 {
    861     QPoint p = m->pos() - contentsRect().topLeft();
    862     setCol(p);
    863     emit newCol(hue, sat);
    864 }
    865 
    866 void QColorPicker::paintEvent(QPaintEvent* )
    867 {
    868     QPainter p(this);
    869     drawFrame(&p);
    870     QRect r = contentsRect();
    871 
    872     p.drawPixmap(r.topLeft(), *pix);
    873     QPoint pt = colPt() + r.topLeft();
    874     p.setPen(Qt::black);
    875 
    876     p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black);
    877     p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black);
    878 
    879 }
     900    pix = QPixmap::fromImage(img);
     901}
     902
    880903
    881904class QColSpinBox : public QSpinBox
     
    10791102#ifdef QT_SMALL_COLORDIALOG
    10801103#  ifdef Q_WS_S60
    1081     QS60Data s60Data = QS60Data();
    1082     const bool nonTouchUI = !s60Data.hasTouchscreen;
     1104    const bool nonTouchUI = !S60->hasTouchscreen;
    10831105#  elif defined Q_WS_MAEMO_5
    10841106    const bool nonTouchUI = false;
     
    15071529#if defined(QT_SMALL_COLORDIALOG)
    15081530#  if defined(Q_WS_S60)
    1509     QS60Data s60Data = QS60Data();
    1510     const bool nonTouchUI = !s60Data.hasTouchscreen;
     1531    const bool nonTouchUI = !S60->hasTouchscreen;
    15111532#  elif defined(Q_WS_MAEMO_5)
    15121533    const bool nonTouchUI = false;
  • trunk/src/gui/dialogs/qcolordialog_mac.mm

    r651 r769  
    9797- (void)showColorPanel;
    9898- (void)exec;
     99- (void)setResultSet:(BOOL)result;
    99100@end
    100101
     
    157158    delete mQtColor;
    158159    [super dealloc];
     160}
     161
     162- (void)setResultSet:(BOOL)result
     163{
     164    mResultSet = result;
    159165}
    160166
     
    321327                mPriv->colorDialog()->accept();
    322328            }
    323         }
     329        } 
    324330    }
    325331}
     
    434440        [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)];
    435441    }
    436 
     442    [delegate setResultSet:false];
    437443    setCocoaPanelColor(initial);
    438444    [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel];
  • trunk/src/gui/dialogs/qdialog.cpp

    r651 r769  
    7070#   include "qcolordialog.h"
    7171#   include "qwizard.h"
    72 #   include "qmenubar.h"
    7372#endif
    7473
     
    416415     }
    417416#else
    418     if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize ))
    419         adjustPosition(parentWidget());
     417    if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) {
     418        if (!testAttribute(Qt::WA_Moved)) {
     419            Qt::WindowStates state = windowState();
     420            adjustPosition(parentWidget());
     421            setAttribute(Qt::WA_Moved, false); // not really an explicit position
     422            if (state != windowState())
     423                setWindowState(state);
     424        }
     425    }
    420426#endif
    421427    return result;
     
    523529
    524530#ifdef Q_OS_SYMBIAN
    525 #ifndef QT_NO_MENUBAR
    526     QMenuBar *menuBar = 0;
    527     if (!findChild<QMenuBar *>())
    528         menuBar = new QMenuBar(this);
    529 #endif
    530 
    531531    if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
    532532        qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this))
     
    560560#endif //QT_NO_MENUBAR
    561561#endif //Q_WS_WINCE_WM
    562 #ifdef Q_OS_SYMBIAN
    563 #ifndef QT_NO_MENUBAR
    564     else if (menuBar)
    565         delete menuBar;
    566 #endif //QT_NO_MENUBAR
    567 #endif //Q_OS_SYMBIAN
    568 
    569562    return res;
    570563}
     
    808801{
    809802    if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
    810         Qt::WindowStates  state = windowState();
     803        Qt::WindowStates  state = windowState();
    811804        adjustPosition(parentWidget());
    812805        setAttribute(Qt::WA_Moved, false); // not really an explicit position
    813         if (state != windowState())
    814             setWindowState(state);
     806        if (state != windowState())
     807            setWindowState(state);
    815808    }
    816809}
     
    912905                cbaHeight = qt_TSize2QSize(bgContainer->Size()).height();
    913906            }
    914             p.setY(S60->screenHeightInPixels-height()-cbaHeight);
     907            p.setY(S60->screenHeightInPixels - height() - cbaHeight);
    915908            p.setX(0);
    916909        } else {
    917910            const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
    918             TRect cbaRect = TRect();
    919             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
    920             AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
    921             switch (cbaLocation) {
    922             case AknLayoutUtils::EAknCbaLocationBottom:
    923                 p.setY(S60->screenHeightInPixels - height()-cbaRect.Height());
    924                 p.setX((S60->screenWidthInPixels - width())>>1);
    925                 break;
    926             case AknLayoutUtils::EAknCbaLocationRight:
    927                 p.setY((S60->screenHeightInPixels - height())>>1);
    928                 p.setX(qMax(0,S60->screenWidthInPixels-width()-scrollbarWidth-cbaRect.Width()));
    929                 break;
    930             case AknLayoutUtils::EAknCbaLocationLeft:
    931                 p.setY((S60->screenHeightInPixels - height())>>1);
    932                 p.setX(qMax(0,scrollbarWidth+cbaRect.Width()));
    933                 break;
     911            TRect staConTopRect = TRect();
     912            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, staConTopRect);
     913            if (staConTopRect.IsEmpty()) {
     914                TRect cbaRect = TRect();
     915                AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
     916                AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
     917                switch (cbaLocation) {
     918                case AknLayoutUtils::EAknCbaLocationBottom:
     919                    p.setY(S60->screenHeightInPixels - height() - cbaRect.Height());
     920                    p.setX((S60->screenWidthInPixels - width()) >> 1);
     921                    break;
     922                case AknLayoutUtils::EAknCbaLocationRight:
     923                    p.setY((S60->screenHeightInPixels - height()) >> 1);
     924                    p.setX(qMax(0,S60->screenWidthInPixels - width() - scrollbarWidth - cbaRect.Width()));
     925                    break;
     926                case AknLayoutUtils::EAknCbaLocationLeft:
     927                    p.setY((S60->screenHeightInPixels - height()) >> 1);
     928                    p.setX(qMax(0,scrollbarWidth + cbaRect.Width()));
     929                    break;
     930                }
     931            } else {
     932                p.setY((S60->screenHeightInPixels - height()) >> 1);
     933                p.setX(qMax(0,S60->screenWidthInPixels - width()));
    934934            }
    935935        }
  • trunk/src/gui/dialogs/qfiledialog.cpp

    r651 r769  
    230230
    231231    \value HideNameFilterDetails Indicates if the is hidden or not.
    232     This value is obsolete and does nothing since Qt 4.5:
    233232
    234233    \value DontUseSheet In previous versions of Qt, the static
    235234    functions would create a sheet by default if the static function
    236     was given a parent. This is no longer supported in Qt 4.5, The
     235    was given a parent. This is no longer supported and does nothing in Qt 4.5, The
    237236    static functions will always be an application modal dialog. If
    238237    you want to use sheets, use QFileDialog::open() instead.
  • trunk/src/gui/dialogs/qfiledialog.ui

    r651 r769  
    8484        <string>Back</string>
    8585       </property>
     86       <property name="accessibleName">
     87        <string>Back</string>
     88       </property>
     89       <property name="accessibleDescription">
     90        <string>Go back</string>
     91       </property>
    8692      </widget>
    8793     </item>
     
    9197        <string>Forward</string>
    9298       </property>
     99       <property name="accessibleName">
     100        <string>Forward</string>
     101       </property>
     102       <property name="accessibleDescription">
     103        <string>Go forward</string>
     104       </property>
    93105      </widget>
    94106     </item>
     
    98110        <string>Parent Directory</string>
    99111       </property>
     112       <property name="accessibleName">
     113        <string>Parent Directory</string>
     114       </property>
     115       <property name="accessibleDescription">
     116        <string>Go to the parent directory</string>
     117       </property>
    100118      </widget>
    101119     </item>
     
    105123        <string>Create New Folder</string>
    106124       </property>
     125       <property name="accessibleName">
     126        <string>Create New Folder</string>
     127       </property>
     128       <property name="accessibleDescription">
     129        <string>Create a New Folder</string>
     130       </property>
    107131      </widget>
    108132     </item>
     
    112136        <string>List View</string>
    113137       </property>
     138       <property name="accessibleName">
     139        <string>List View</string>
     140       </property>
     141       <property name="accessibleDescription">
     142        <string>Change to list view mode</string>
     143       </property>
    114144      </widget>
    115145     </item>
     
    118148       <property name="toolTip" >
    119149        <string>Detail View</string>
     150       </property>
     151       <property name="accessibleName">
     152        <string>Detail View</string>
     153       </property>
     154       <property name="accessibleDescription">
     155        <string>Change to detail view mode</string>
    120156       </property>
    121157      </widget>
  • trunk/src/gui/dialogs/qfilesystemmodel.cpp

    r651 r769  
    13611361        return d->index(rootPath());
    13621362
     1363    //We remove the watcher on the previous path
     1364    if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) {
     1365        //This remove the watcher for the old rootPath
     1366        d->fileInfoGatherer.removePath(rootPath());
     1367        //This line "marks" the node as dirty, so the next fetchMore
     1368        //call on the path will ask the gatherer to install a watcher again
     1369        //But it doesn't re-fetch everything
     1370        d->node(rootPath())->populatedChildren = false;
     1371    }
     1372
    13631373    // We have a new valid root path
    13641374    d->rootDir = newPathDir;
  • 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)
  • trunk/src/gui/dialogs/qfontdialog.h

    r651 r769  
    132132    Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
    133133    Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
     134#if defined(Q_WS_MAC)
     135    Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
     136#endif
    134137};
    135138
  • trunk/src/gui/dialogs/qfontdialog_mac.mm

    r651 r769  
    5050#include <private/qt_cocoa_helpers_mac_p.h>
    5151#include <private/qt_mac_p.h>
     52#include <qabstracteventdispatcher.h>
    5253#include <qdebug.h>
    5354#import <AppKit/AppKit.h>
     
    373374            mModalSession = 0;
    374375        }
    375 
     376        // Hack alert!
     377        // Since this code path was never intended to be followed when starting from exec
     378        // we need to force the dialog to communicate the new font, otherwise the signal
     379        // won't get emitted.
     380        if(code == NSOKButton)
     381            mPriv->sampleEdit->setFont([self qtFont]);
    376382        mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
    377383    } else {
     
    568574        }
    569575    }
    570 
    571576    return delegate;
    572577}
     
    641646}
    642647
     648void *QFontDialogPrivate::_q_constructNativePanel()
     649{
     650    QMacCocoaAutoReleasePool pool;
     651
     652    bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
     653    NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
     654    [sharedFontPanel setHidesOnDeactivate:false];
     655
     656    // hack to ensure that QCocoaApplication's validModesForFontPanel:
     657    // implementation is honored
     658    if (!sharedFontPanelExisted) {
     659        [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel];
     660        [sharedFontPanel close];
     661    }
     662
     663    NSPanel *ourPanel = 0;
     664    NSView *stolenContentView = 0;
     665    NSButton *okButton = 0;
     666    NSButton *cancelButton = 0;
     667
     668    CGFloat dialogExtraWidth = 0.0;
     669    CGFloat dialogExtraHeight = 0.0;
     670
     671    // compute dialogExtra{Width,Height}
     672    dialogExtraWidth = 2.0 * DialogSideMargin;
     673    dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
     674                        + ButtonBottomMargin;
     675
     676    // compute initial contents rectangle
     677    NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
     678    contentRect.size.width += dialogExtraWidth;
     679    contentRect.size.height += dialogExtraHeight;
     680
     681    // create the new panel
     682    ourPanel = [[NSPanel alloc] initWithContentRect:contentRect
     683                styleMask:StyleMask
     684                    backing:NSBackingStoreBuffered
     685                        defer:YES];
     686    [ourPanel setReleasedWhenClosed:YES];
     687
     688    stolenContentView = [sharedFontPanel contentView];
     689
     690    // steal the font panel's contents view
     691    [stolenContentView retain];
     692    [sharedFontPanel setContentView:0];
     693
     694    {
     695        // create a new content view and add the stolen one as a subview
     696        NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
     697        NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
     698        [ourContentView addSubview:stolenContentView];
     699
     700        // create OK and Cancel buttons and add these as subviews
     701        okButton = macCreateButton("&OK", ourContentView);
     702        cancelButton = macCreateButton("Cancel", ourContentView);
     703
     704        [ourPanel setContentView:ourContentView];
     705        [ourPanel setDefaultButtonCell:[okButton cell]];
     706    }
     707    // create a delegate and set it
     708    QCocoaFontPanelDelegate *delegate =
     709            [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
     710                                             stolenContentView:stolenContentView
     711                                                      okButton:okButton
     712                                                  cancelButton:cancelButton
     713                                                          priv:this
     714                                                    extraWidth:dialogExtraWidth
     715                                                   extraHeight:dialogExtraHeight];
     716    [ourPanel setDelegate:delegate];
     717    [[NSFontManager sharedFontManager] setDelegate:delegate];
     718#ifdef QT_MAC_USE_COCOA
     719    [[NSFontManager sharedFontManager] setTarget:delegate];
     720#endif
     721    setFont(delegate, QApplication::font());
     722
     723    {
     724        // hack to get correct initial layout
     725        NSRect frameRect = [ourPanel frame];
     726        frameRect.size.width += 1.0;
     727        [ourPanel setFrame:frameRect display:NO];
     728        frameRect.size.width -= 1.0;
     729        frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
     730        [ourPanel setFrame:frameRect display:NO];
     731        [ourPanel center];
     732    }
     733    NSString *title = @"Select font";
     734    [ourPanel setTitle:title];
     735
     736    [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
     737    return delegate;
     738}
     739
     740void QFontDialogPrivate::mac_nativeDialogModalHelp()
     741{
     742    // Copied from QFileDialogPrivate
     743    // Do a queued meta-call to open the native modal dialog so it opens after the new
     744    // event loop has started to execute (in QDialog::exec). Using a timer rather than
     745    // a queued meta call is intentional to ensure that the call is only delivered when
     746    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
     747    // running (which is the case if e.g a top-most QEventLoop has been
     748    // interrupted, and the second-most event loop has not yet been reactivated (regardless
     749    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
     750    if (nativeDialogInUse) {
     751        Q_Q(QFontDialog);
     752        QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
     753    }
     754}
     755
     756// The problem with the native font dialog is that OS X does not
     757// offer a proper dialog, but a panel (i.e. without Ok and Cancel buttons).
     758// This means we need to "construct" a native dialog by taking the panel
     759// and "adding" the buttons.
     760void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
     761{
     762    QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
     763    Q_Q(QFontDialog);
     764    QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
     765    NSWindow *ourPanel = [delegate actualPanel];
     766    [ourPanel retain];
     767    int rval = [NSApp runModalForWindow:ourPanel];
     768    QAbstractEventDispatcher::instance()->interrupt();
     769    [ourPanel release];
     770    [delegate cleanUpAfterMyself];
     771    [delegate release];
     772    bool isOk = (rval == NSOKButton);
     773    if(isOk)
     774        rescode = QDialog::Accepted;
     775    else
     776        rescode = QDialog::Rejected;
     777}
     778
     779bool QFontDialogPrivate::setVisible_sys(bool visible)
     780{
     781    Q_Q(QFontDialog);
     782    if (!visible == q->isHidden())
     783        return false;
     784    return visible;
     785}
     786
    643787QT_END_NAMESPACE
    644788
  • trunk/src/gui/dialogs/qfontdialog_p.h

    r651 r769  
    153153
    154154    void *delegate;
     155    bool nativeDialogInUse;
     156    bool canBeNativeDialog();
     157    bool setVisible_sys(bool visible);
     158    void *_q_constructNativePanel();
     159    void _q_macRunNativeAppModalPanel();
     160    void mac_nativeDialogModalHelp();
    155161
    156162    static bool sharedFontPanelAvailable;
  • trunk/src/gui/dialogs/qmessagebox.cpp

    r651 r769  
    6666#include <QtGui/qclipboard.h>
    6767
     68#ifndef QT_NO_STYLE_S60
     69#include <qs60style.h>
     70#endif
     71
    6872#ifdef Q_WS_WINCE
    6973extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
     
    315319            width = hardLimit;
    316320        }
     321    }
    317322#ifdef Q_WS_S60
    318323        // in S60 portait messageBoxes should always occupy maximum width
     
    324329        }
    325330#endif
    326     }
    327331
    328332    if (informativeLabel) {
     
    354358                     ? layout->totalHeightForWidth(width)
    355359                     : layout->totalMinimumSize().height();
     360
     361#ifndef QT_NO_STYLE_S60
     362        QS60Style *s60Style = 0;
     363        s60Style = qobject_cast<QS60Style *>(QApplication::style());
     364
     365        //use custom pixel metric to deduce the minimum height of the messagebox
     366        if (s60Style)
     367            height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight));
     368#endif
     369
    356370    q->setFixedSize(width, height);
    357371    QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
  • trunk/src/gui/dialogs/qprintdialog.h

    r651 r769  
    5757class QPrinter;
    5858
    59 #if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)) || defined (Q_WS_PM)
     59#if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)) || defined (Q_WS_PM)
    6060class QUnixPrintWidgetPrivate;
    6161
     
    9898
    9999#if defined (Q_OS_UNIX) && defined (QT3_SUPPORT)
    100     void setPrinter(QPrinter *, bool = false);
    101     QPrinter *printer() const;
    102     void addButton(QPushButton *button);
     100    QT3_SUPPORT void setPrinter(QPrinter *, bool = false);
     101    QT3_SUPPORT QPrinter *printer() const;
     102    QT3_SUPPORT void addButton(QPushButton *button);
    103103#endif
    104104
  • trunk/src/gui/dialogs/qprintdialog_unix.cpp

    r762 r769  
    155155    void setupPrinter();
    156156    void setOptionsPane(QPrintDialogPrivate *pane);
     157#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     158    void setCupsProperties();
     159#endif
    157160
    158161// slots
     
    970973void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
    971974{
    972     if (propertiesDialog == 0) {
     975    if (!propertiesDialog) {
    973976        propertiesDialog = new QPrintPropertiesDialog(q);
    974977        propertiesDialog->setResult(QDialog::Rejected);
     
    989992    propertiesDialog->exec();
    990993}
     994
     995#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     996void QUnixPrintWidgetPrivate::setCupsProperties()
     997{
     998    if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) {
     999        QPrintEngine *engine = printer->printEngine();
     1000        const ppd_option_t* pageSizes = cups->pageSizes();
     1001        QByteArray cupsPageSize;
     1002        for (int i = 0; i < pageSizes->num_choices; ++i) {
     1003            if (static_cast<int>(pageSizes->choices[i].marked) == 1)
     1004                cupsPageSize = pageSizes->choices[i].choice;
     1005        }
     1006        engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize));
     1007        engine->setProperty(PPK_CupsOptions, cups->options());
     1008
     1009        QRect pageRect = cups->pageRect(cupsPageSize);
     1010        engine->setProperty(PPK_CupsPageRect, pageRect);
     1011
     1012        QRect paperRect = cups->paperRect(cupsPageSize);
     1013        engine->setProperty(PPK_CupsPaperRect, paperRect);
     1014
     1015        for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) {
     1016            QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps));
     1017            if (size.width == paperRect.width() && size.height == paperRect.height())
     1018                printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));
     1019        }
     1020    }
     1021}
     1022#endif
    9911023
    9921024void QUnixPrintWidgetPrivate::setupPrinter()
     
    10181050    if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted)
    10191051        propertiesDialog->setupPrinter();
     1052#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     1053    if (!propertiesDialog)
     1054        setCupsProperties();
     1055#endif
    10201056}
    10211057
  • trunk/src/gui/dialogs/qprintpreviewdialog.cpp

    r651 r769  
    274274    QVBoxLayout *vboxLayout = new QVBoxLayout;
    275275    vboxLayout->setContentsMargins(0, 0, 0, 0);
     276#ifdef Q_WS_MAC
     277    // We query the widgets about their size and then we fix the size.
     278    // This should do the trick for the laying out part...
     279    QSize pageNumEditSize, pageNumLabelSize;
     280    pageNumEditSize = pageNumEdit->minimumSizeHint();
     281    pageNumLabelSize = pageNumLabel->minimumSizeHint();
     282    pageNumEdit->resize(pageNumEditSize);
     283    pageNumLabel->resize(pageNumLabelSize);
     284#endif
    276285    QFormLayout *formLayout = new QFormLayout;
     286#ifdef Q_WS_MAC
     287    // We have to change the growth policy in Mac.
     288    formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
     289#endif
    277290    formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
    278291    formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
Note: See TracChangeset for help on using the changeset viewer.