Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656#include "qaccessible.h"
    5757#endif
    58 #if defined(Q_OS_WINCE)
     58#if defined(Q_WS_WINCE)
    5959#include "qt_windows.h"
    6060#include "qmenubar.h"
     
    6565#elif defined(Q_WS_X11)
    6666#  include "../kernel/qt_x11_p.h"
     67#elif defined(Q_OS_SYMBIAN)
     68#   include "qfiledialog.h"
     69#   include "qfontdialog.h"
     70#   include "qcolordialog.h"
     71#   include "qwizard.h"
     72#   include "qmenubar.h"
     73#endif
     74
     75#if defined(Q_WS_S60)
     76#include "private/qt_s60_p.h"
    6777#endif
    6878
    6979#ifndef SPI_GETSNAPTODEFBUTTON
    70 define SPI_GETSNAPTODEFBUTTON  95
     80 define SPI_GETSNAPTODEFBUTTON  95
    7181#endif
    7282
     
    7787    \brief The QDialog class is the base class of dialog windows.
    7888
    79     \ingroup dialogs
     89    \ingroup dialog-classes
    8090    \ingroup abstractwidgets
    81     \mainclass
     91
    8292
    8393    A dialog window is a top-level window mostly used for short-term
     
    252262              f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
    253263{
    254 #ifdef Q_OS_WINCE
     264#ifdef Q_WS_WINCE
    255265    if (!qt_wince_is_smartphone())
    256266        setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint));
     
    281291    : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
    282292{
    283 #ifdef Q_OS_WINCE
     293#ifdef Q_WS_WINCE
    284294    if (!qt_wince_is_smartphone())
    285295        setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint));
     
    293303QDialog::~QDialog()
    294304{
    295     // Need to hide() here, as our (to-be) overridden hide()
    296     // will not be called in ~QWidget.
    297     hide();
     305    QT_TRY {
     306        // Need to hide() here, as our (to-be) overridden hide()
     307        // will not be called in ~QWidget.
     308        hide();
     309    } QT_CATCH(...) {
     310        // we're in the destructor - just swallow the exception
     311    }
    298312}
    299313
     
    365379}
    366380
    367 #ifdef Q_OS_WINCE
    368 #ifdef Q_OS_WINCE_WM
     381#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
     382#ifdef Q_WS_WINCE_WM
    369383void QDialogPrivate::_q_doneAction()
    370384{
     
    380394{
    381395    bool result = QWidget::event(e);
     396#ifdef Q_WS_WINCE
    382397    if (e->type() == QEvent::OkRequest) {
    383398        accept();
    384399        result = true;
    385400     }
     401#else
     402    if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize ))
     403        adjustPosition(parentWidget());
     404#endif
    386405    return result;
    387406}
     
    474493
    475494//On Windows Mobile we create an empty menu to hide the current menu
    476 #ifdef Q_OS_WINCE_WM
     495#ifdef Q_WS_WINCE_WM
    477496#ifndef QT_NO_MENUBAR
    478497    QMenuBar *menuBar = 0;
     
    485504    }
    486505#endif //QT_NO_MENUBAR
    487 #endif //Q_OS_WINCE_WM
    488 
    489     show();
     506#endif //Q_WS_WINCE_WM
     507
     508#ifdef Q_OS_SYMBIAN
     509#ifndef QT_NO_MENUBAR
     510    QMenuBar *menuBar = 0;
     511    if (!findChild<QMenuBar *>())
     512        menuBar = new QMenuBar(this);
     513#endif
     514
     515    if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
     516        qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this))
     517        showMaximized();
     518    else
     519#endif // Q_OS_SYMBIAN
     520
     521        show();
    490522
    491523#ifdef Q_WS_MAC
     
    506538    if (deleteOnClose)
    507539        delete this;
    508 #ifdef Q_OS_WINCE_WM
     540#ifdef Q_WS_WINCE_WM
    509541#ifndef QT_NO_MENUBAR
    510542    else if (menuBar)
    511543        delete menuBar;
    512544#endif //QT_NO_MENUBAR
    513 #endif //Q_OS_WINCE_WM
     545#endif //Q_WS_WINCE_WM
     546#ifdef Q_OS_SYMBIAN
     547#ifndef QT_NO_MENUBAR
     548    else if (menuBar)
     549        delete menuBar;
     550#endif //QT_NO_MENUBAR
     551#endif //Q_OS_SYMBIAN
     552
    514553    return res;
    515554}
     
    634673        case Qt::Key_Escape:
    635674            reject();
    636             break;
    637         case Qt::Key_Up:
    638         case Qt::Key_Left:
    639             if (focusWidget() &&
    640                  (focusWidget()->focusPolicy() == Qt::StrongFocus ||
    641                    focusWidget()->focusPolicy() == Qt::WheelFocus)) {
    642                 e->ignore();
    643                 break;
    644             }
    645             // call ours, since c++ blocks us from calling the one
    646             // belonging to focusWidget().
    647             focusNextPrevChild(false);
    648             break;
    649         case Qt::Key_Down:
    650         case Qt::Key_Right:
    651             if (focusWidget() &&
    652                  (focusWidget()->focusPolicy() == Qt::StrongFocus ||
    653                    focusWidget()->focusPolicy() == Qt::WheelFocus)) {
    654                 e->ignore();
    655                 break;
    656             }
    657             focusNextPrevChild(true);
    658675            break;
    659676        default:
     
    763780    if (d->mainDef && isActiveWindow()) {
    764781        BOOL snapToDefault = false;
    765         if ( QT_WA_INLINE( SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) ,
    766                            SystemParametersInfoA(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) )) {
     782        if (SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0)) {
    767783            if (snapToDefault)
    768784                QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center()));
     
    790806    // if the WM advertises that it will place the windows properly for us, let it do it :)
    791807    if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT)))
     808        return;
     809#endif
     810
     811#ifdef Q_WS_S60
     812    if (s60AdjustedPosition())
     813        //dialog has already been positioned
    792814        return;
    793815#endif
     
    856878}
    857879
     880#if defined(Q_WS_S60)
     881/*! \internal */
     882bool QDialog::s60AdjustedPosition()
     883{
     884    QPoint p;
     885    const QSize mainAreaSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
     886    const int statusPaneHeight = (S60->screenHeightInPixels - mainAreaSize.height())>>1;
     887    const bool doS60Positioning = !(isFullScreen()||isMaximized());
     888    if (doS60Positioning) {
     889        // naive way to deduce screen orientation
     890        if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
     891            int cbaHeight;
     892            const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer();
     893            if (!bgContainer) {
     894                cbaHeight = 0;
     895            } else {
     896                cbaHeight = qt_TSize2QSize(bgContainer->Size()).height();
     897            }
     898            p.setY(S60->screenHeightInPixels-height()-cbaHeight);
     899            p.setX(0);
     900        } else {
     901            const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
     902            TRect cbaRect = TRect();
     903            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
     904            AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
     905            switch (cbaLocation) {
     906            case AknLayoutUtils::EAknCbaLocationBottom:
     907                p.setY(S60->screenHeightInPixels - height()-cbaRect.Height());
     908                p.setX((S60->screenWidthInPixels - width())>>1);
     909                break;
     910            case AknLayoutUtils::EAknCbaLocationRight:
     911                p.setY((S60->screenHeightInPixels - height())>>1);
     912                p.setX(qMax(0,S60->screenWidthInPixels-width()-scrollbarWidth-cbaRect.Width()));
     913                break;
     914            case AknLayoutUtils::EAknCbaLocationLeft:
     915                p.setY((S60->screenHeightInPixels - height())>>1);
     916                p.setX(qMax(0,scrollbarWidth+cbaRect.Width()));
     917                break;
     918            }
     919        }
     920        move(p);
     921    }
     922    return doS60Positioning;
     923}
     924#endif
    858925
    859926/*!
     
    10151082                        QWidget::sizeHint().height());
    10161083    }
    1017 
     1084#if defined(Q_WS_S60)
     1085    // if size is not fixed, try to adjust it according to S60 layoutting
     1086    if (minimumSize() != maximumSize()) {
     1087        // In S60, dialogs are always the width of screen (in portrait, regardless of current layout)
     1088        return QSize(qMax(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height());
     1089    } else {
     1090        return QWidget::sizeHint();
     1091    }
     1092#else
    10181093    return QWidget::sizeHint();
     1094#endif //Q_WS_S60
    10191095}
    10201096
Note: See TracChangeset for help on using the changeset viewer.