Changeset 561 for trunk/src/gui/dialogs/qdialog.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qdialog.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 #include "qaccessible.h" 57 57 #endif 58 #if defined(Q_ OS_WINCE)58 #if defined(Q_WS_WINCE) 59 59 #include "qt_windows.h" 60 60 #include "qmenubar.h" … … 65 65 #elif defined(Q_WS_X11) 66 66 # 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" 67 77 #endif 68 78 69 79 #ifndef SPI_GETSNAPTODEFBUTTON 70 # define SPI_GETSNAPTODEFBUTTON 9580 # define SPI_GETSNAPTODEFBUTTON 95 71 81 #endif 72 82 … … 77 87 \brief The QDialog class is the base class of dialog windows. 78 88 79 \ingroup dialog s89 \ingroup dialog-classes 80 90 \ingroup abstractwidgets 81 \mainclass 91 82 92 83 93 A dialog window is a top-level window mostly used for short-term … … 252 262 f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 253 263 { 254 #ifdef Q_ OS_WINCE264 #ifdef Q_WS_WINCE 255 265 if (!qt_wince_is_smartphone()) 256 266 setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); … … 281 291 : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 282 292 { 283 #ifdef Q_ OS_WINCE293 #ifdef Q_WS_WINCE 284 294 if (!qt_wince_is_smartphone()) 285 295 setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); … … 293 303 QDialog::~QDialog() 294 304 { 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 } 298 312 } 299 313 … … 365 379 } 366 380 367 #if def Q_OS_WINCE368 #ifdef Q_ OS_WINCE_WM381 #if defined(Q_WS_WINCE) || defined(Q_WS_S60) 382 #ifdef Q_WS_WINCE_WM 369 383 void QDialogPrivate::_q_doneAction() 370 384 { … … 380 394 { 381 395 bool result = QWidget::event(e); 396 #ifdef Q_WS_WINCE 382 397 if (e->type() == QEvent::OkRequest) { 383 398 accept(); 384 399 result = true; 385 400 } 401 #else 402 if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) 403 adjustPosition(parentWidget()); 404 #endif 386 405 return result; 387 406 } … … 474 493 475 494 //On Windows Mobile we create an empty menu to hide the current menu 476 #ifdef Q_ OS_WINCE_WM495 #ifdef Q_WS_WINCE_WM 477 496 #ifndef QT_NO_MENUBAR 478 497 QMenuBar *menuBar = 0; … … 485 504 } 486 505 #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(); 490 522 491 523 #ifdef Q_WS_MAC … … 506 538 if (deleteOnClose) 507 539 delete this; 508 #ifdef Q_ OS_WINCE_WM540 #ifdef Q_WS_WINCE_WM 509 541 #ifndef QT_NO_MENUBAR 510 542 else if (menuBar) 511 543 delete menuBar; 512 544 #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 514 553 return res; 515 554 } … … 634 673 case Qt::Key_Escape: 635 674 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 one646 // 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);658 675 break; 659 676 default: … … 763 780 if (d->mainDef && isActiveWindow()) { 764 781 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)) { 767 783 if (snapToDefault) 768 784 QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); … … 790 806 // if the WM advertises that it will place the windows properly for us, let it do it :) 791 807 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 792 814 return; 793 815 #endif … … 856 878 } 857 879 880 #if defined(Q_WS_S60) 881 /*! \internal */ 882 bool 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 858 925 859 926 /*! … … 1015 1082 QWidget::sizeHint().height()); 1016 1083 } 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 1018 1093 return QWidget::sizeHint(); 1094 #endif //Q_WS_S60 1019 1095 } 1020 1096
Note:
See TracChangeset
for help on using the changeset viewer.