Changeset 846 for trunk/src/gui/widgets
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 158 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/widgets/qabstractbutton.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractbutton.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractbutton_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractscrollarea.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 296 296 layoutChildren(); 297 297 #ifndef Q_WS_MAC 298 #ifndef QT_NO_GESTURES 298 299 viewport->grabGesture(Qt::PanGesture); 300 #endif 299 301 #endif 300 302 } … … 547 549 d->viewport->installEventFilter(d->viewportFilter.data()); 548 550 #ifndef Q_WS_MAC 551 #ifndef QT_NO_GESTURES 549 552 d->viewport->grabGesture(Qt::PanGesture); 553 #endif 550 554 #endif 551 555 d->layoutChildren(); … … 961 965 case QEvent::TouchEnd: 962 966 return false; 967 #ifndef QT_NO_GESTURES 963 968 case QEvent::Gesture: 964 969 { … … 981 986 return false; 982 987 } 988 #endif // QT_NO_GESTURES 983 989 case QEvent::StyleChange: 984 990 case QEvent::LayoutDirectionChange: 985 991 case QEvent::ApplicationLayoutDirectionChange: 992 case QEvent::LayoutRequest: 986 993 d->layoutChildren(); 987 994 // fall through … … 1006 1013 using one of the specialized event handlers instead. 1007 1014 1008 Speciali sed handlers for viewport events are: paintEvent(),1015 Specialized handlers for viewport events are: paintEvent(), 1009 1016 mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), 1010 1017 mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(), … … 1036 1043 return QFrame::event(e); 1037 1044 case QEvent::LayoutRequest: 1045 #ifndef QT_NO_GESTURES 1038 1046 case QEvent::Gesture: 1039 1047 case QEvent::GestureOverride: 1040 1048 return event(e); 1049 #endif 1041 1050 default: 1042 1051 break; -
trunk/src/gui/widgets/qabstractscrollarea.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractscrollarea_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 class QScrollBar; 64 64 class QAbstractScrollAreaScrollBarContainer; 65 class Q_ AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate65 class Q_GUI_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate 66 66 { 67 67 Q_DECLARE_PUBLIC(QAbstractScrollArea) -
trunk/src/gui/widgets/qabstractslider.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 220 220 , isAutoRepeating(false) 221 221 , repeatMultiplier(1) 222 #endif 223 { 222 { 223 firstRepeat.invalidate(); 224 #else 225 { 226 #endif 227 224 228 } 225 229 … … 713 717 714 718 offset_accumulated += stepsToScrollF; 719 #ifndef Q_WS_MAC 720 // Don't scroll more than one page in any case: 715 721 stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); 722 #else 723 // Native UI-elements on Mac can scroll hundreds of lines at a time as 724 // a result of acceleration. So keep the same behaviour in Qt, and 725 // don't restrict stepsToScroll to certain maximum (pageStep): 726 stepsToScroll = int(offset_accumulated); 727 #endif 716 728 offset_accumulated -= int(offset_accumulated); 717 729 if (stepsToScroll == 0) … … 757 769 #ifdef QT_KEYPAD_NAVIGATION 758 770 if (ev->isAutoRepeat()) { 759 if ( d->firstRepeat.isNull())760 d->firstRepeat = QTime::currentTime();771 if (!d->firstRepeat.isValid()) 772 d->firstRepeat.start(); 761 773 else if (1 == d->repeatMultiplier) { 762 774 // This is the interval in milli seconds which one key repetition 763 775 // takes. 764 const int repeatMSecs = d->firstRepeat. msecsTo(QTime::currentTime());776 const int repeatMSecs = d->firstRepeat.elapsed(); 765 777 766 778 /** … … 780 792 781 793 } 782 else if ( !d->firstRepeat.isNull()) {783 d->firstRepeat = QTime();794 else if (d->firstRepeat.isValid()) { 795 d->firstRepeat.invalidate(); 784 796 d->repeatMultiplier = 1; 785 797 } -
trunk/src/gui/widgets/qabstractslider.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractslider_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 55 55 56 56 #include "QtCore/qbasictimer.h" 57 #include "QtCore/qelapsedtimer.h" 57 58 #include "private/qwidget_p.h" 58 59 #include "qstyle.h" … … 104 105 * The time of when the first auto repeating key press event occurs. 105 106 */ 106 Q TimefirstRepeat;107 QElapsedTimer firstRepeat; 107 108 108 109 #endif -
trunk/src/gui/widgets/qabstractspinbox.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 1249 1249 Q_D(QAbstractSpinBox); 1250 1250 1251 QPointer<QMenu> menu = d->edit->createStandardContextMenu(); 1252 if (!menu) 1253 return; 1254 1251 1255 d->reset(); 1252 QPointer<QMenu> menu = d->edit->createStandardContextMenu();1253 1256 1254 1257 QAction *selAll = new QAction(tr("&Select All"), menu); -
trunk/src/gui/widgets/qabstractspinbox.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qabstractspinbox_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qbuttongroup.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qbuttongroup.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcalendartextnavigator_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcalendarwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcalendarwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcheckbox.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 292 292 QStyleOptionButton opt; 293 293 initStyleOption(&opt); 294 QSize sz = style()->itemTextRect(fm, QRect( 0, 0, 1, 1), Qt::TextShowMnemonic, false,294 QSize sz = style()->itemTextRect(fm, QRect(), Qt::TextShowMnemonic, false, 295 295 text()).size(); 296 296 if (!opt.icon.isNull()) -
trunk/src/gui/widgets/qcheckbox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcocoamenu_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include <private/qt_cocoa_helpers_mac_p.h> 48 48 #include <private/qapplication_p.h> 49 #include <private/qaction_p.h> 49 50 50 51 #include <QtGui/QMenu> … … 71 72 if (self) { 72 73 qmenu = menu; 74 previousAction = 0; 73 75 [self setAutoenablesItems:NO]; 74 76 [self setDelegate:self]; … … 82 84 83 85 if (!item) { 84 // ### According to the docs everything will be highlighted. Not sure what we should do in 85 // Qt, so just return. 86 if (previousAction) { 87 qt_mac_clear_status_text(previousAction); 88 previousAction = 0; 89 } 86 90 return; 87 91 } 88 92 89 if (QAction *action = reinterpret_cast<QAction *>([item tag])) 93 if (QAction *action = reinterpret_cast<QAction *>([item tag])) { 94 QMenu *qtmenu = static_cast<QT_MANGLE_NAMESPACE(QCocoaMenu) *>(menu)->qmenu; 95 previousAction = action; 90 96 action->activate(QAction::Hover); 97 qt_mac_menu_emit_hovered(qtmenu, action); 98 action->showStatusText(0); // 0 widget -> action's parent 99 } 91 100 } 92 101 … … 101 110 } 102 111 103 - (void)menu WillClose:(NSMenu*)menu;112 - (void)menuDidClose:(NSMenu*)menu; 104 113 { 105 114 qt_mac_emit_menuSignals(((QT_MANGLE_NAMESPACE(QCocoaMenu) *)menu)->qmenu, false); 115 if (previousAction) { 116 qt_mac_clear_status_text(previousAction); 117 previousAction = 0; 118 } 106 119 } 107 120 … … 176 189 } 177 190 191 - (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector 192 { 193 NSInteger index = [super indexOfItemWithTarget:anObject andAction:actionSelector]; 194 static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:"); 195 if (index == -1 && selForOFCP == actionSelector) { 196 // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object 197 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; 198 return [super indexOfItemWithTarget:loader andAction:actionSelector]; 199 } 200 return index; 201 } 202 178 203 @end 179 204 … … 195 220 qt_mac_menus_open_count += delta; 196 221 } 222 223 void qt_mac_clear_status_text(QAction *action) 224 { 225 action->d_func()->showStatusText(0, QString()); 226 } 227 228 void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action) 229 { 230 emit menu->hovered(action); 231 } 232 233 197 234 QT_END_NAMESPACE 198 235 -
trunk/src/gui/widgets/qcocoamenu_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 57 57 QT_FORWARD_DECLARE_CLASS(QMenu) 58 QT_FORWARD_DECLARE_CLASS(QAction) 58 59 59 60 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 … … 62 63 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item; 63 64 - (void)menuWillOpen:(NSMenu*)menu; 64 - (void)menu WillClose:(NSMenu*)menu;65 - (void)menuDidClose:(NSMenu*)menu; 65 66 - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier 66 67 whichItem:(NSMenuItem**)outItem; … … 72 73 { 73 74 QMenu *qmenu; 75 QAction *previousAction; 74 76 } 75 77 - (id)initWithQMenu:(QMenu*)menu; 76 78 - (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action; 79 - (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector; 77 80 @end 78 81 #endif -
trunk/src/gui/widgets/qcocoatoolbardelegate_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 59 59 QT_FORWARD_DECLARE_CLASS(QCFString); 60 60 61 @implementation Q CocoaToolBarDelegate61 @implementation QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) 62 62 63 63 - (id)initWithMainWindowLayout:(QMainWindowLayout *)layout -
trunk/src/gui/widgets/qcocoatoolbardelegate_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 62 62 @class NSToolbarItem; 63 63 64 @interface Q CocoaToolBarDelegate: NSObject {64 @interface QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) : NSObject { 65 65 QT_PREPEND_NAMESPACE(QMainWindowLayout) *mainWindowLayout; 66 66 NSToolbarItem *toolbarItem; -
trunk/src/gui/widgets/qcombobox.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #include <qtreeview.h> 58 58 #include <qheaderview.h> 59 #include <qmath.h> 59 60 #ifndef QT_NO_IM 60 61 #include "qinputcontext.h" … … 113 114 { 114 115 QStyleOptionMenuItem menuOption; 115 menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); 116 117 QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); 118 QVariant value = index.data(Qt::ForegroundRole); 119 if (qVariantCanConvert<QBrush>(value)) { 120 resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value)); 121 resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value)); 122 resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); 123 } 124 menuOption.palette = resolvedpalette; 116 125 menuOption.state = QStyle::State_None; 117 126 if (mCombo->window()->isActiveWindow()) … … 324 333 325 334 // height 326 sh.setHeight(qMax( fm.height(), 14) + 2);335 sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); 327 336 if (hasIcon) { 328 337 sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); … … 390 399 QStyleOptionComboBox opt = comboStyleOption(); 391 400 if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) 392 view-> clearSelection();401 view->setCurrentIndex(QModelIndex()); 393 402 #endif 394 403 } … … 696 705 emit resetButton(); 697 706 combo->update(); 707 // QGraphicsScenePrivate::removePopup closes the combo box popup, it hides it non-explicitly. 708 // Hiding/showing the QComboBox after this will unexpectedly show the popup as well. 709 // Re-hiding the popup container makes sure it is explicitly hidden. 710 if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) 711 proxy->hide(); 698 712 } 699 713 … … 897 911 highlights an item in the combobox popup list. All three signals 898 912 exist in two versions, one with a QString argument and one with an 899 \c int argument. If the user select es or highlights a pixmap, only913 \c int argument. If the user selects or highlights a pixmap, only 900 914 the \c int signals are emitted. Whenever the text of an editable 901 915 combobox is changed the editTextChanged() signal is emitted. … … 1284 1298 By default, this property has a value of 10. 1285 1299 1286 \note This property is ignored for non-editable comboboxes in Mac style. 1300 \note This property is ignored for non-editable comboboxes in styles that returns 1301 false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. 1287 1302 */ 1288 1303 int QComboBox::maxVisibleItems() const … … 2364 2379 #endif 2365 2380 ++count; 2366 if (!usePopup && count > d->maxVisibleItems) {2381 if (!usePopup && count >= d->maxVisibleItems) { 2367 2382 toCheck.clear(); 2368 2383 break; … … 2462 2477 //by default popup is centered on screen in landscape 2463 2478 listRect.moveCenter(screen.center()); 2464 if (staConTopRect.IsEmpty() ) {2479 if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) { 2465 2480 // landscape without stacon, menu should be at the right 2466 2481 (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) : … … 2835 2850 d->updateArrow(QStyle::State_Sunken); 2836 2851 #ifdef QT_KEYPAD_NAVIGATION 2837 if (!d->lineEdit) { 2852 //if the container already exists, then d->viewContainer() is safe to call 2853 if (d->container) { 2838 2854 #endif 2839 2855 // We've restricted the next couple of lines, because by not calling -
trunk/src/gui/widgets/qcombobox.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 112 112 113 113 inline int findText(const QString &text, 114 Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const114 Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const 115 115 { return findData(text, Qt::DisplayRole, flags); } 116 116 int findData(const QVariant &data, int role = Qt::UserRole, 117 Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const;117 Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const; 118 118 119 119 enum InsertPolicy { -
trunk/src/gui/widgets/qcombobox_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qcommandlinkbutton.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include "qcolor.h" 48 48 #include "qfont.h" 49 #include <qmath.h> 49 50 50 51 #include "private/qpushbutton_p.h" … … 118 119 int leftMargin() const { return 7; } 119 120 int rightMargin() const { return 4; } 120 int bottomMargin() const { return 4; }121 int bottomMargin() const { return 10; } 121 122 122 123 QString description; … … 174 175 { 175 176 Q_Q(const QCommandLinkButton); 176 return q->rect().adjusted(textOffset(), topMargin(), 177 -rightMargin(), 0); 177 QRect r = q->rect().adjusted(textOffset(), topMargin(), -rightMargin(), 0); 178 if (description.isEmpty()) 179 { 180 QFontMetrics fm(titleFont()); 181 r.setTop(r.top() + qMax(0, (q->icon().actualSize(q->iconSize()).height() 182 - fm.height()) / 2)); 183 } 184 185 return r; 178 186 } 179 187 … … 243 251 layout.endLayout(); 244 252 } 245 return q Round(descriptionheight);253 return qCeil(descriptionheight); 246 254 } 247 255 … … 254 262 QSize size = sizeHint(); 255 263 int minimumHeight = qMax(d->descriptionOffset() + d->bottomMargin(), 256 icon Size().height() + d->topMargin());264 icon().actualSize(iconSize()).height() + d->topMargin()); 257 265 size.setHeight(minimumHeight); 258 266 return size; … … 328 336 // find the width available for the description area 329 337 return qMax(heightWithoutDescription + d->descriptionHeight(width), 330 iconSize().height() + d->topMargin() + d->bottomMargin()); 338 icon().actualSize(iconSize()).height() + d->topMargin() + 339 d->bottomMargin()); 331 340 } 332 341 … … 341 350 initStyleOption(&option); 342 351 343 //Enable command link appear ence on Vista352 //Enable command link appearance on Vista 344 353 option.features |= QStyleOptionButton::CommandLinkButton; 345 354 option.text = QString(); -
trunk/src/gui/widgets/qcommandlinkbutton.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdatetimeedit.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 249 249 /*! 250 250 \property QDateTimeEdit::date 251 \brief the QDate that is set in the QDateTimeEdit251 \brief the QDate that is set in the widget 252 252 253 253 By default, this property contains a date that refers to January 1, 2000. … … 280 280 /*! 281 281 \property QDateTimeEdit::time 282 \brief the QTime that is set in the QDateTimeEdit282 \brief the QTime that is set in the widget 283 283 284 284 By default, this property contains a time of 00:00:00 and 0 milliseconds. … … 755 755 pop-up. The editor does not automatically take ownership of the calendar widget. 756 756 757 \note calendarPopup must be set to true before setting the calendar widget. 757 758 \sa calendarPopup 758 759 */ … … 832 833 and QDateTime::fromString() 833 834 834 Example format strings (assuming that the date is 2nd of July 1969):835 Example format strings (assuming that the date is 2nd of July 1969): 835 836 836 837 \table 837 838 \header \i Format \i Result 838 \row \i dd.MM.yyyy 839 \row \i dd.MM.yyyy \i 02.07.1969 839 840 \row \i MMM d yy \i Jul 2 69 840 841 \row \i MMMM d yy \i July 2 69 … … 902 903 /*! 903 904 \property QDateTimeEdit::calendarPopup 904 \brief the current calend er pop-up showing mode.905 \brief the current calendar pop-up showing mode. 905 906 \since 4.2 906 907 … … 1176 1177 } 1177 1178 QAbstractSpinBox::keyPressEvent(event); 1178 if (select && ! (event->modifiers() & Qt::ShiftModifier) && !d->edit->hasSelectedText()) {1179 if (select && !d->edit->hasSelectedText()) { 1179 1180 if (inserted && d->sectionAt(d->edit->cursorPosition()) == QDateTimeParser::NoSectionIndex) { 1180 1181 QString str = d->displayText(); … … 1555 1556 } 1556 1557 1557 /*!1558 \property QTimeEdit::time1559 \brief the QTime that is shown in the widget1560 1561 By default, this property contains a time of 00:00:00 and 0 milliseconds.1562 */1563 1564 1558 1565 1559 /*! … … 1615 1609 { 1616 1610 } 1617 1618 /*!1619 \property QDateEdit::date1620 \brief the QDate that is shown in the widget1621 1622 By default, this property contains a date referring to January 1, 2000.1623 */1624 1611 1625 1612 -
trunk/src/gui/widgets/qdatetimeedit.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 207 207 { 208 208 Q_OBJECT 209 Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true)210 209 public: 211 210 QTimeEdit(QWidget *parent = 0); … … 216 215 { 217 216 Q_OBJECT 218 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true)219 217 public: 220 218 QDateEdit(QWidget *parent = 0); -
trunk/src/gui/widgets/qdatetimeedit_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdial.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdial.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdialogbuttonbox.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 104 104 105 105 Currently the buttons are laid out in the following way if the button box is horizontal: 106 \table 100%106 \table 107 107 \row \o \inlineimage buttonbox-gnomelayout-horizontal.png GnomeLayout Horizontal 108 108 \o Button box laid out in horizontal GnomeLayout … … 117 117 The buttons are laid out the following way if the button box is vertical: 118 118 119 \table 100% 119 \table 120 \row \o GnomeLayout 121 \o KdeLayout 122 \o MacLayout 123 \o WinLayout 120 124 \row \o \inlineimage buttonbox-gnomelayout-vertical.png GnomeLayout Vertical 121 \o Button box laid out in vertical GnomeLayout 122 \row \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical 123 \o Button box laid out in vertical KdeLayout 124 \row \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical 125 \o Button box laid out in vertical MacLayout 126 \row \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical 127 \o Button box laid out in vertical WinLayout 125 \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical 126 \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical 127 \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical 128 128 \endtable 129 129 130 130 Additionally, button boxes that contain only buttons with ActionRole or 131 HelpRole can be considered modeless and have an alternate look on the mac: 132 133 \table 100% 134 \row \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout 135 \o modeless horizontal MacLayout 136 \row \o \inlineimage buttonbox-mac-modeless-vertical.png Screenshot of modeless vertical MacLayout 137 \o modeless vertical MacLayout 131 HelpRole can be considered modeless and have an alternate look on Mac OS X: 132 133 \table 134 \row \o modeless horizontal MacLayout 135 \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout 138 136 \endtable 139 137 … … 261 259 }; 262 260 261 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 263 262 class QDialogButtonEnabledProxy : public QObject 264 263 { … … 284 283 QAction *target; 285 284 }; 286 285 #endif 287 286 288 287 class QDialogButtonBoxPrivate : public QWidgetPrivate … … 317 316 void retranslateStrings(); 318 317 const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const; 319 #if def QT_SOFTKEYS_ENABLED318 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 320 319 QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role); 321 320 #endif … … 574 573 QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed())); 575 574 buttonLists[role].append(button); 576 #if def QT_SOFTKEYS_ENABLED575 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 577 576 QAction *action = createSoftKey(button, role); 578 577 softKeyActions.insert(button, action); … … 583 582 } 584 583 585 #if def QT_SOFTKEYS_ENABLED584 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 586 585 QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role) 587 586 { … … 721 720 QPushButton *button = it.key(); 722 721 button->setText(QDialogButtonBox::tr(buttonText)); 723 #if def QT_SOFTKEYS_ENABLED722 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 724 723 QAction *action = softKeyActions.value(button, 0); 725 724 if (action) … … 1000 999 } 1001 1000 } 1002 #if def QT_SOFTKEYS_ENABLED1001 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 1003 1002 QAction *action = d->softKeyActions.value(button, 0); 1004 1003 if (action) { … … 1246 1245 d->retranslateStrings(); 1247 1246 } 1248 #if def QT_SOFTKEYS_ENABLED1247 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) 1249 1248 else if (event->type() == QEvent::ParentChange) { 1250 1249 QWidget *dialog = 0; -
trunk/src/gui/widgets/qdialogbuttonbox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdockarealayout.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 61 61 QT_BEGIN_NAMESPACE 62 62 63 // qmainwindow.cpp 64 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 65 63 66 enum { StateFlagVisible = 1, StateFlagFloating = 2 }; 64 67 … … 221 224 #endif 222 225 226 static const int zero = 0; 227 223 228 QDockAreaLayoutInfo::QDockAreaLayoutInfo() 224 : sep( 0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)225 #ifndef QT_NO_TABBAR 226 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) , tabBarVisible(false)227 #endif 228 { 229 } 230 231 QDockAreaLayoutInfo::QDockAreaLayoutInfo( int_sep, QInternal::DockPosition _dockPos,229 : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) 230 #ifndef QT_NO_TABBAR 231 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) 232 #endif 233 { 234 } 235 236 QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, 232 237 Qt::Orientation _o, int tbshape, 233 238 QMainWindow *window) 234 239 : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) 235 240 #ifndef QT_NO_TABBAR 236 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) , tabBarVisible(false)241 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) 237 242 #endif 238 243 { … … 282 287 { 283 288 if (!first) 284 a += sep;289 a += *sep; 285 290 a += pick(o, min_size); 286 291 } … … 295 300 296 301 #ifndef QT_NO_TABBAR 297 if (tabbed) {298 QSize tbm = tabBarMinimumSize();302 QSize tbm = tabBarMinimumSize(); 303 if (!tbm.isNull()) { 299 304 switch (tabBarShape) { 300 305 case QTabBar::RoundedNorth: … … 350 355 { 351 356 if (!first) 352 a += sep;357 a += *sep; 353 358 a += pick(o, max_size); 354 359 } … … 368 373 369 374 #ifndef QT_NO_TABBAR 370 if (tabbed) {371 QSize tbh = tabBarSizeHint();375 QSize tbh = tabBarSizeHint(); 376 if (!tbh.isNull()) { 372 377 switch (tabBarShape) { 373 378 case QTabBar::RoundedNorth: … … 416 421 if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem) 417 422 && !previous->hasFixedSize(o)) { 418 a += sep;423 a += *sep; 419 424 } 420 425 a += gap ? item.size : pick(o, size_hint); … … 492 497 493 498 if (!first) 494 result += info.sep;499 result += *info.sep; 495 500 result += min; 496 501 … … 517 522 518 523 if (!first) 519 result += info.sep;524 result += *info.sep; 520 525 result += max; 521 526 … … 556 561 QLayoutStruct &ls = layout_struct_list[j++]; 557 562 ls.init(); 558 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep;563 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep; 559 564 ls.empty = false; 560 565 } … … 939 944 ls.empty = true; 940 945 } else { 941 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;946 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; 942 947 ls.empty = false; 943 948 ls.pos = item.pos; … … 957 962 continue; 958 963 QLayoutStruct &ls = list[i]; 959 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;964 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; 960 965 item.size = ls.size - separatorSpace; 961 966 item.pos = ls.pos; … … 1042 1047 1043 1048 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { 1044 item.pos += sep;1045 item.size -= sep;1049 item.pos += *sep; 1050 item.size -= *sep; 1046 1051 } 1047 1052 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1048 item.size -= sep;1053 item.size -= *sep; 1049 1054 1050 1055 QPoint pos; … … 1084 1089 { 1085 1090 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { 1086 item.pos -= sep;1087 item.size += sep;1091 item.pos -= *sep; 1092 item.size += *sep; 1088 1093 } 1089 1094 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1090 item.size += sep;1095 item.size += *sep; 1091 1096 } 1092 1097 … … 1256 1261 gap_size = pick(o, r.size()); 1257 1262 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) 1258 sep_size += sep;1263 sep_size += *sep; 1259 1264 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1260 sep_size += sep;1265 sep_size += *sep; 1261 1266 } 1262 1267 if (gap_size + sep_size > space) … … 1365 1370 rpick(o, pos) = item.pos + item.size; 1366 1371 QSize s = rect.size(); 1367 rpick(o, s) = sep;1372 rpick(o, s) = *sep; 1368 1373 1369 1374 return QRect(pos, s); … … 1414 1419 1415 1420 QRect sepRect = separatorRect(i); 1416 if (!sepRect.isNull() && sep == 1)1421 if (!sepRect.isNull() && *sep == 1) 1417 1422 sepRect.adjust(-2, -2, 2, 2); 1418 1423 //we also make sure we don't find a separator that's not there … … 1479 1484 QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const 1480 1485 { 1481 QMainWindowLayout *result = q object_cast<QMainWindowLayout*>(mainWindow->layout());1486 QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); 1482 1487 Q_ASSERT(result != 0); 1483 1488 return result; … … 1499 1504 QSize tbh = tabBarSizeHint(); 1500 1505 1501 if ( tabBarVisible) {1506 if (!tbh.isNull()) { 1502 1507 switch (tabBarShape) { 1503 1508 case QTabBar::RoundedNorth: … … 1561 1566 } 1562 1567 #ifndef QT_NO_TABBAR 1563 if ( sep == 1)1568 if (*sep == 1) 1564 1569 updateSeparatorWidgets(); 1565 1570 #endif //QT_NO_TABBAR … … 1984 1989 } 1985 1990 } 1986 1991 if (testing) { 1992 //was it is not really added to the layout, we need to delete the object here 1993 delete item.widgetItem; 1994 } 1987 1995 } 1988 1996 } else if (nextMarker == SequenceMarker) { … … 2014 2022 setCurrentTabId(tabId(item_list.at(index))); 2015 2023 } 2016 if (!testing && sep == 1)2024 if (!testing && *sep == 1) 2017 2025 updateSeparatorWidgets(); 2018 2026 #endif … … 2075 2083 2076 2084 #ifndef QT_NO_TABBAR 2077 void QDockAreaLayoutInfo::updateTabBar() const 2085 //returns whether the tabbar is visible or not 2086 bool QDockAreaLayoutInfo::updateTabBar() const 2078 2087 { 2079 2088 if (!tabbed) 2080 return ;2089 return false; 2081 2090 2082 2091 QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); … … 2146 2155 tabBar->blockSignals(blocked); 2147 2156 2148 that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1; 2149 2150 if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) { 2151 that->tabBarMin = tabBar->minimumSizeHint(); 2152 that->tabBarHint = tabBar->sizeHint(); 2153 } 2157 //returns if the tabbar is visible or not 2158 return ( (gap ? 1 : 0) + tabBar->count()) > 1; 2154 2159 } 2155 2160 … … 2159 2164 return; 2160 2165 tabBarShape = shape; 2161 if (tabBar != 0) {2166 if (tabBar != 0) 2162 2167 tabBar->setShape(static_cast<QTabBar::Shape>(shape)); 2163 tabBarMin = QSize();2164 tabBarHint = QSize();2165 }2166 2168 2167 2169 for (int i = 0; i < item_list.count(); ++i) { … … 2174 2176 QSize QDockAreaLayoutInfo::tabBarMinimumSize() const 2175 2177 { 2176 if (! tabbed)2178 if (!updateTabBar()) 2177 2179 return QSize(0, 0); 2178 2180 2179 updateTabBar(); 2180 2181 return tabBarMin; 2181 return tabBar->minimumSizeHint(); 2182 2182 } 2183 2183 2184 2184 QSize QDockAreaLayoutInfo::tabBarSizeHint() const 2185 2185 { 2186 if (! tabbed)2186 if (!updateTabBar()) 2187 2187 return QSize(0, 0); 2188 2188 2189 updateTabBar(); 2190 2191 return tabBarHint; 2189 return tabBar->sizeHint(); 2192 2190 } 2193 2191 … … 2236 2234 QSize tbh = tabBarSizeHint(); 2237 2235 2238 if ( tabBarVisible) {2236 if (!tbh.isNull()) { 2239 2237 switch (tabBarShape) { 2240 2238 case QTabBar::RoundedNorth: … … 2277 2275 #endif 2278 2276 docks[QInternal::LeftDock] 2279 = QDockAreaLayoutInfo( sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);2277 = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win); 2280 2278 docks[QInternal::RightDock] 2281 = QDockAreaLayoutInfo( sep, QInternal::RightDock, Qt::Vertical, tabShape, win);2279 = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win); 2282 2280 docks[QInternal::TopDock] 2283 = QDockAreaLayoutInfo( sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);2281 = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win); 2284 2282 docks[QInternal::BottomDock] 2285 = QDockAreaLayoutInfo( sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);2283 = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); 2286 2284 centralWidgetItem = 0; 2287 2285 … … 2995 2993 dockWidget->d_func()->setWindowState(true, true, r); 2996 2994 } 2997 dockWidget->show(); 2998 // dockWidget->setVisible(!placeHolder->hidden); 2995 dockWidget->setVisible(!placeHolder->hidden); 2999 2996 #ifdef Q_WS_X11 3000 2997 if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag … … 3032 3029 int tbshape = 0; 3033 3030 #endif 3034 QDockAreaLayoutInfo new_info( sep, pos, orientation, tbshape, mainWindow);3031 QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow); 3035 3032 new_info.item_list.append(new QDockAreaLayoutInfo(info)); 3036 3033 new_info.item_list.append(dockWidgetItem); … … 3077 3074 void QDockAreaLayout::apply(bool animate) 3078 3075 { 3079 QWidgetAnimator &widgetAnimator 3080 = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator; 3076 QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator; 3081 3077 3082 3078 for (int i = 0; i < QInternal::DockCount; ++i) … … 3168 3164 3169 3165 #ifndef QT_NO_TABBAR 3170 // Sets the correct positions for the sep erator widgets3166 // Sets the correct positions for the separator widgets 3171 3167 // Allocates new sepearator widgets with getSeparatorWidget 3172 3168 void QDockAreaLayout::updateSeparatorWidgets() const … … 3183 3179 sepWidget = separatorWidgets.at(j); 3184 3180 } else { 3185 sepWidget = q object_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget();3181 sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget(); 3186 3182 separatorWidgets.append(sepWidget); 3187 3183 } … … 3328 3324 } 3329 3325 3326 void QDockAreaLayout::styleChangedEvent() 3327 { 3328 sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); 3329 fitLayout(); 3330 } 3331 3330 3332 QT_END_NAMESPACE 3331 3333 -
trunk/src/gui/widgets/qdockarealayout_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 84 84 // a widgetItem if this is a node of the tree (QDockAreaLayoutItem::widgetItem) 85 85 // 86 // A path indetifies uniquely one object in this tree, the first number be eing the side and all the following86 // A path indetifies uniquely one object in this tree, the first number being the side and all the following 87 87 // indexes into the QDockAreaLayoutInfo::item_list. 88 88 … … 129 129 public: 130 130 QDockAreaLayoutInfo(); 131 QDockAreaLayoutInfo( int_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,131 QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o, 132 132 int tbhape, QMainWindow *window); 133 133 … … 190 190 QMainWindowLayout *mainWindowLayout() const; 191 191 192 intsep;192 const int *sep; 193 193 mutable QVector<QWidget*> separatorWidgets; 194 194 QInternal::DockPosition dockPos; … … 209 209 bool tabbed; 210 210 QTabBar *tabBar; 211 QSize tabBarMin, tabBarHint;212 211 int tabBarShape; 213 bool tabBarVisible; 214 215 void updateTabBar() const; 212 213 bool updateTabBar() const; 216 214 void setTabBarShape(int shape); 217 215 QSize tabBarMinimumSize() const; … … 301 299 QSet<QWidget*> usedSeparatorWidgets() const; 302 300 #endif //QT_NO_TABBAR 301 void styleChangedEvent(); 303 302 }; 304 303 -
trunk/src/gui/widgets/qdockwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 69 69 extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp 70 70 71 // qmainwindow.cpp 72 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 73 71 74 static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) 72 75 { return (priv->features & feature) == feature; } … … 691 694 QMainWindow *win = qobject_cast<QMainWindow*>(parent); 692 695 Q_ASSERT(win != 0); 693 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(win->layout());696 QMainWindowLayout *layout = qt_mainwindow_layout(win); 694 697 Q_ASSERT(layout != 0); 695 698 if (layout->pluggingWidget != 0) // the main window is animating a docking operation … … 712 715 return; 713 716 714 QMainWindowLayout *layout 715 = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 717 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 716 718 Q_ASSERT(layout != 0); 717 719 … … 740 742 741 743 if (state->dragging) { 742 QMainWindowLayout *mwLayout = 743 qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 744 QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 744 745 Q_ASSERT(mwLayout != 0); 745 746 … … 781 782 return false; 782 783 783 QMainWindowLayout *mainWinLayout 784 = qobject_cast<QMainWindowLayout*>(mainWin->layout()); 784 QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin); 785 785 if (mainWinLayout == 0) 786 786 return false; … … 848 848 849 849 QDockWidgetLayout *dwlayout 850 = qobject_cast<QDockWidgetLayout*>(layout); 851 QMainWindowLayout *mwlayout 852 = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout()); 850 = qobject_cast<QDockWidgetLayout *>(layout); 851 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 853 852 if (!dwlayout->nativeWindowDeco()) { 854 853 if (!state->dragging … … 944 943 #ifdef Q_OS_MAC 945 944 else { // workaround for lack of mouse-grab on Mac 946 QMainWindowLayout *layout 947 = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 945 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 948 946 Q_ASSERT(layout != 0); 949 947 … … 981 979 return; 982 980 983 QMainWindowLayout *layout 984 = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 981 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 985 982 Q_ASSERT(layout != 0); 986 983 … … 1010 1007 1011 1008 if (!floating && parent) { 1012 QMainWindowLayout *mwlayout = q object_cast<QMainWindowLayout *>(q->parentWidget()->layout());1013 if ( !mwlayout ||mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)1009 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 1010 if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) 1014 1011 return; // this dockwidget can't be redocked 1015 1012 } … … 1056 1053 emit q->topLevelChanged(floating); 1057 1054 if (!floating && parent) { 1058 QMainWindowLayout *mwlayout = q object_cast<QMainWindowLayout *>(q->parentWidget()->layout());1055 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 1059 1056 if (mwlayout) 1060 1057 emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); … … 1270 1267 1271 1268 d->setWindowState(floating, false, floating ? r : QRect()); 1269 1272 1270 if (floating && r.isNull()) { 1273 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); 1274 QRect titleArea = layout->titleArea(); 1275 int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height(); 1276 QPoint p = mapToGlobal(QPoint(h, h)); 1277 move(p); 1271 if (x() < 0 || y() < 0) //may happen if we have been hidden 1272 move(QPoint()); 1273 setAttribute(Qt::WA_Moved, false); //we want it at the default position 1278 1274 } 1279 1275 } … … 1328 1324 { 1329 1325 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); 1330 if (QMainWindowLayout *winLayout = 1331 (win ? qobject_cast<QMainWindowLayout*>(win->layout()) : 0)) 1326 if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) { 1332 1327 if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)) 1333 1328 info->updateTabBar(); 1329 } 1334 1330 } 1335 1331 #endif // QT_NO_TABBAR … … 1384 1380 1385 1381 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); 1386 QMainWindowLayout *layout = 0; 1387 if (win != 0) 1388 layout = qobject_cast<QMainWindowLayout*>(win->layout()); 1382 QMainWindowLayout *layout = qt_mainwindow_layout(win); 1389 1383 1390 1384 switch (event->type()) { … … 1538 1532 /*! 1539 1533 \since 4.3 1534 1540 1535 Sets an arbitrary \a widget as the dock widget's title bar. If \a widget 1541 is 0, the title bar widget is removed, but not deleted. 1536 is 0, any custom title bar widget previously set on the dock widget is 1537 removed, but not deleted, and the default title bar will be used 1538 instead. 1542 1539 1543 1540 If a title bar widget is set, QDockWidget will not use native window … … 1547 1544 1548 1545 \list 1549 \ iMouse events that are not explicitly handled by the title bar widget1546 \o Mouse events that are not explicitly handled by the title bar widget 1550 1547 must be ignored by calling QMouseEvent::ignore(). These events then 1551 1548 propagate to the QDockWidget parent, which handles them in the usual … … 1553 1550 when it is double-clicked, etc. 1554 1551 1555 \ iWhen DockWidgetVerticalTitleBar is set on QDockWidget, the title1552 \o When DockWidgetVerticalTitleBar is set on QDockWidget, the title 1556 1553 bar widget is repositioned accordingly. In resizeEvent(), the title 1557 1554 bar should check what orientation it should assume: 1558 1555 \snippet doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp 0 1559 1556 1560 \ iThe title bar widget must have a valid QWidget::sizeHint() and1557 \o The title bar widget must have a valid QWidget::sizeHint() and 1561 1558 QWidget::minimumSizeHint(). These functions should take into account 1562 1559 the current orientation of the title bar. 1560 1561 \o It is not possible to remove a title bar from a dock widget. However, 1562 a similar effect can be achieved by setting a default constructed 1563 QWidget as the title bar widget. 1563 1564 \endlist 1564 1565 1565 Using qobject_cast as shown above, the title bar widget has full access1566 Using qobject_cast() as shown above, the title bar widget has full access 1566 1567 to its parent QDockWidget. Hence it can perform such operations as docking 1567 1568 and hiding in response to user actions. -
trunk/src/gui/widgets/qdockwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qdockwidget_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 170 170 }; 171 171 172 /* The size hints of a QDockWidget will depend on w ether it is docked or not.172 /* The size hints of a QDockWidget will depend on whether it is docked or not. 173 173 This layout item always returns the size hints as if the dock widget was docked. */ 174 174 -
trunk/src/gui/widgets/qeffects.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "qapplication.h" 43 43 #ifndef QT_NO_EFFECTS 44 #include "qdatetime.h"45 44 #include "qdesktopwidget.h" 46 45 #include "qeffects_p.h" … … 51 50 #include "qpointer.h" 52 51 #include "qtimer.h" 52 #include "qelapsedtimer.h" 53 53 #include "qdebug.h" 54 54 … … 104 104 bool showWidget; 105 105 QTimer anim; 106 Q TimecheckTime;106 QElapsedTimer checkTime; 107 107 double windowOpacity; 108 108 }; … … 385 385 386 386 QTimer anim; 387 Q TimecheckTime;387 QElapsedTimer checkTime; 388 388 389 389 QPixmap pm; -
trunk/src/gui/widgets/qeffects_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qfocusframe.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 54 54 Q_DECLARE_PUBLIC(QFocusFrame) 55 55 QWidget *widget; 56 56 QWidget *frameParent; 57 bool showFrameAboveWidget; 57 58 public: 58 59 QFocusFramePrivate() { 59 60 widget = 0; 61 frameParent = 0; 60 62 sendChildEvents = false; 63 showFrameAboveWidget = false; 61 64 } 62 65 void updateSize(); … … 67 70 { 68 71 Q_Q(QFocusFrame); 69 q->setParent( widget->parentWidget());72 q->setParent(frameParent); 70 73 updateSize(); 71 74 if (q->parentWidget()->rect().intersects(q->geometry())) { 72 if ( q->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, q))75 if (showFrameAboveWidget) 73 76 q->raise(); 74 77 else … … 85 88 int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin), 86 89 hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin); 87 QRect geom(widget->x()-hmargin, widget->y()-vmargin, 90 QPoint pos(widget->x(), widget->y()); 91 if (q->parentWidget() != widget->parentWidget()) 92 pos = widget->parentWidget()->mapTo(q->parentWidget(), pos); 93 QRect geom(pos.x()-hmargin, pos.y()-vmargin, 88 94 widget->width()+(hmargin*2), widget->height()+(vmargin*2)); 89 95 if(q->geometry() == geom) … … 177 183 { 178 184 Q_D(QFocusFrame); 179 if(widget == d->widget) 185 186 if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)) 187 d->showFrameAboveWidget = true; 188 else 189 d->showFrameAboveWidget = false; 190 191 if (widget == d->widget) 180 192 return; 181 182 if(d->widget) 183 d->widget->removeEventFilter(this); 184 if(widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) { 193 if (d->widget) { 194 // Remove event filters from the widget hierarchy. 195 QWidget *p = d->widget; 196 do { 197 p->removeEventFilter(this); 198 if (!d->showFrameAboveWidget || p == d->frameParent) 199 break; 200 p = p->parentWidget(); 201 }while (p); 202 } 203 if (widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) { 185 204 d->widget = widget; 186 widget->installEventFilter(this); 205 d->widget->installEventFilter(this); 206 QWidget *p = widget->parentWidget(); 207 QWidget *prev = 0; 208 if (d->showFrameAboveWidget) { 209 // Find the right parent for the focus frame. 210 while (p) { 211 // Traverse the hirerarchy of the 'widget' for setting event filter. 212 // During this if come across toolbar or a top level, use that 213 // as the parent for the focus frame. If we find a scroll area 214 // use its viewport as the parent. 215 bool isScrollArea = false; 216 if (p->isWindow() || p->inherits("QToolBar") || (isScrollArea = p->inherits("QAbstractScrollArea"))) { 217 d->frameParent = p; 218 // The previous one in the hierarchy will be the viewport. 219 if (prev && isScrollArea) 220 d->frameParent = prev; 221 break; 222 } else { 223 p->installEventFilter(this); 224 prev = p; 225 p = p->parentWidget(); 226 } 227 } 228 } else { 229 d->frameParent = p; 230 } 187 231 d->update(); 188 232 } else { … … 211 255 QFocusFrame::paintEvent(QPaintEvent *) 212 256 { 257 Q_D(QFocusFrame); 213 258 QStylePainter p(this); 214 259 QStyleOption option; 215 260 initStyleOption(&option); 261 int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin); 262 int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin); 263 QWidgetPrivate *wd = qt_widget_private(d->widget); 264 QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2); 265 p.setClipRect(rect); 216 266 p.drawControl(QStyle::CE_FocusFrame, option); 217 267 } … … 234 284 break; 235 285 case QEvent::ParentChange: 236 d->update(); 286 if (d->showFrameAboveWidget) { 287 QWidget *w = d->widget; 288 setWidget(0); 289 setWidget(w); 290 } else { 291 d->update(); 292 } 237 293 break; 238 294 case QEvent::Show: … … 255 311 break; 256 312 } 313 } else if (d->showFrameAboveWidget) { 314 // Handle changes in the parent widgets we are monitoring. 315 switch(e->type()) { 316 case QEvent::Move: 317 case QEvent::Resize: 318 d->updateSize(); 319 break; 320 case QEvent::ZOrderChange: 321 raise(); 322 break; 323 default: 324 break; 325 } 257 326 } 258 327 return false; -
trunk/src/gui/widgets/qfocusframe.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qfontcombobox.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qfontcombobox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qframe.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 245 245 Returns the frame style. 246 246 247 The default value is QFrame:: NoFrame.247 The default value is QFrame::Plain. 248 248 249 249 \sa setFrameStyle(), frameShape(), frameShadow() -
trunk/src/gui/widgets/qframe.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qframe_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qgroupbox.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qgroupbox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qlabel.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 54 54 #include "qlabel_p.h" 55 55 #include "private/qstylesheetstyle_p.h" 56 #include <qmath.h> 56 57 57 58 QT_BEGIN_NAMESPACE … … 635 636 #endif 636 637 else if (isTextLabel) { 637 int align = QStyle::visualAlignment( q->layoutDirection(), QFlag(this->align));638 int align = QStyle::visualAlignment(textDirection(), QFlag(this->align)); 638 639 // Add indentation 639 640 int m = indent; … … 662 663 control->setTextWidth(-1); 663 664 } 664 br = QRect(QPoint(0, 0), control->size().toSize()); 665 666 QSizeF controlSize = control->size(); 667 br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height()))); 665 668 666 669 // restore state … … 680 683 bool tryWidth = (w < 0) && (align & Qt::TextWordWrap); 681 684 if (tryWidth) 682 w = fm.averageCharWidth() * 80;685 w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width()); 683 686 else if (w < 0) 684 687 w = 2000; … … 782 785 } 783 786 787 /*! 788 Selects text from position \a start and for \a length characters. 789 790 \sa selectedText() 791 792 \bold{Note:} The textInteractionFlags set on the label need to include 793 either TextSelectableByMouse or TextSelectableByKeyboard. 794 795 \since 4.7 796 */ 797 void QLabel::setSelection(int start, int length) 798 { 799 Q_D(QLabel); 800 if (d->control) { 801 d->ensureTextPopulated(); 802 QTextCursor cursor = d->control->textCursor(); 803 cursor.setPosition(start); 804 cursor.setPosition(start + length, QTextCursor::KeepAnchor); 805 d->control->setTextCursor(cursor); 806 } 807 } 808 809 /*! 810 \property QLabel::hasSelectedText 811 \brief whether there is any text selected 812 813 hasSelectedText() returns true if some or all of the text has been 814 selected by the user; otherwise returns false. 815 816 By default, this property is false. 817 818 \sa selectedText() 819 820 \bold{Note:} The textInteractionFlags set on the label need to include 821 either TextSelectableByMouse or TextSelectableByKeyboard. 822 823 \since 4.7 824 */ 825 bool QLabel::hasSelectedText() const 826 { 827 Q_D(const QLabel); 828 if (d->control) 829 return d->control->textCursor().hasSelection(); 830 return false; 831 } 832 833 /*! 834 \property QLabel::selectedText 835 \brief the selected text 836 837 If there is no selected text this property's value is 838 an empty string. 839 840 By default, this property contains an empty string. 841 842 \sa hasSelectedText() 843 844 \bold{Note:} The textInteractionFlags set on the label need to include 845 either TextSelectableByMouse or TextSelectableByKeyboard. 846 847 \since 4.7 848 */ 849 QString QLabel::selectedText() const 850 { 851 Q_D(const QLabel); 852 if (d->control) 853 return d->control->textCursor().selectedText(); 854 return QString(); 855 } 856 857 /*! 858 selectionStart() returns the index of the first selected character in the 859 label or -1 if no text is selected. 860 861 \sa selectedText() 862 863 \bold{Note:} The textInteractionFlags set on the label need to include 864 either TextSelectableByMouse or TextSelectableByKeyboard. 865 866 \since 4.7 867 */ 868 int QLabel::selectionStart() const 869 { 870 Q_D(const QLabel); 871 if (d->control && d->control->textCursor().hasSelection()) 872 return d->control->textCursor().selectionStart(); 873 return -1; 874 } 875 784 876 /*!\reimp 785 877 */ … … 863 955 } 864 956 ev->accept(); 865 menu-> exec(ev->globalPos());866 delete menu;957 menu->setAttribute(Qt::WA_DeleteOnClose); 958 menu->popup(ev->globalPos()); 867 959 #endif 868 960 } … … 968 1060 QRect cr = contentsRect(); 969 1061 cr.adjust(d->margin, d->margin, -d->margin, -d->margin); 970 int align = QStyle::visualAlignment(layoutDirection(), QFlag(d->align)); 1062 int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection() 1063 : layoutDirection(), QFlag(d->align)); 971 1064 972 1065 #ifndef QT_NO_MOVIE … … 1028 1121 painter.restore(); 1029 1122 } else { 1030 int flags = align; 1123 int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight 1124 : Qt::TextForceRightToLeft); 1031 1125 if (d->hasShortcut) { 1032 1126 flags |= Qt::TextShowMnemonic; … … 1356 1450 } else if (ev->type() == QEvent::ContentsRectChange) { 1357 1451 d->updateLabel(); 1358 } else if (ev->type() == QEvent::LayoutDirectionChange) {1359 if (d->isTextLabel && d->control) {1360 d->sendControlEvent(ev);1361 }1362 1452 } 1363 1453 QFrame::changeEvent(ev); … … 1395 1485 } 1396 1486 1487 Qt::LayoutDirection QLabelPrivate::textDirection() const 1488 { 1489 if (control) { 1490 QTextOption opt = control->document()->defaultTextOption(); 1491 return opt.textDirection(); 1492 } 1493 1494 return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; 1495 } 1397 1496 1398 1497 /*! … … 1412 1511 QRect cr = q->contentsRect(); 1413 1512 cr.adjust(margin, margin, -margin, -margin); 1414 const int align = QStyle::visualAlignment(q->layoutDirection(), QFlag(this->align)); 1513 const int align = QStyle::visualAlignment(isTextLabel ? textDirection() 1514 : q->layoutDirection(), QFlag(this->align)); 1415 1515 int m = indent; 1416 1516 if (m < 0 && q->frameWidth()) // no indent, but we do have a frame … … 1473 1573 return; 1474 1574 ensureTextPopulated(); 1475 Q_Q(const QLabel);1476 1575 if (control) { 1477 1576 QTextDocument *doc = control->document(); … … 1484 1583 else 1485 1584 opt.setWrapMode(QTextOption::ManualWrap); 1486 1487 opt.setTextDirection(q->layoutDirection());1488 1585 1489 1586 doc->setDefaultTextOption(opt); -
trunk/src/gui/widgets/qlabel.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) 67 67 Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) 68 Q_PROPERTY(bool hasSelectedText READ hasSelectedText) 69 Q_PROPERTY(QString selectedText READ selectedText) 68 70 69 71 public: … … 111 113 void setTextInteractionFlags(Qt::TextInteractionFlags flags); 112 114 Qt::TextInteractionFlags textInteractionFlags() const; 115 116 void setSelection(int, int); 117 bool hasSelectedText() const; 118 QString selectedText() const; 119 int selectionStart() const; 113 120 114 121 public Q_SLOTS: -
trunk/src/gui/widgets/qlabel_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 #include "qlabel.h" 57 57 58 #include " ../text/qtextdocumentlayout_p.h"58 #include "private/qtextdocumentlayout_p.h" 59 59 #include "private/qtextcontrol_p.h" 60 60 #include "qtextdocumentfragment.h" … … 133 133 QRect documentRect() const; 134 134 QPoint layoutPoint(const QPoint& p) const; 135 Qt::LayoutDirection textDirection() const; 135 136 #ifndef QT_NO_CONTEXTMENU 136 137 QMenu *createStandardContextMenu(const QPoint &pos); -
trunk/src/gui/widgets/qlcdnumber.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qlcdnumber.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qlinecontrol.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 137 137 \sa insert() 138 138 */ 139 void QLineControl::paste( )140 { 141 QString clip = QApplication::clipboard()->text( QClipboard::Clipboard);139 void QLineControl::paste(QClipboard::Mode clipboardMode) 140 { 141 QString clip = QApplication::clipboard()->text(clipboardMode); 142 142 if (!clip.isEmpty() || hasSelectedText()) { 143 143 separate(); //make it a separate undo/redo command … … 420 420 421 421 int c = m_cursor; // cursor position after insertion of commit string 422 if (event->replacementStart() == 0)422 if (event->replacementStart() <= 0) 423 423 c += event->commitString().length() + qMin(-event->replacementStart(), event->replacementLength()); 424 424 … … 528 528 if (m_preeditCursor != -1) 529 529 cursor += m_preeditCursor; 530 if (!m_blinkPeriod || m_blinkStatus)530 if (!m_hideCursor && (!m_blinkPeriod || m_blinkStatus)) 531 531 m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth); 532 532 } … … 537 537 538 538 Sets the selection to cover the word at the given cursor position. 539 The word bound ries isdefined by the behavior of QTextLayout::SkipWords539 The word boundaries are defined by the behavior of QTextLayout::SkipWords 540 540 cursor mode. 541 541 */ … … 1212 1212 \internal 1213 1213 1214 If the current cursor position differs from the last emit ed cursor1214 If the current cursor position differs from the last emitted cursor 1215 1215 position, emits cursorPositionChanged(). 1216 1216 */ … … 1307 1307 } 1308 1308 m_blinkPeriod = msec; 1309 } 1310 1311 void QLineControl::resetCursorBlinkTimer() 1312 { 1313 if (m_blinkPeriod == 0 || m_blinkTimer == 0) 1314 return; 1315 killTimer(m_blinkTimer); 1316 m_blinkTimer = startTimer(m_blinkPeriod / 2); 1317 m_blinkStatus = 1; 1309 1318 } 1310 1319 … … 1351 1360 switch(ev->type()){ 1352 1361 #ifndef QT_NO_GRAPHICSVIEW 1362 case QEvent::GraphicsSceneMouseDoubleClick: 1353 1363 case QEvent::GraphicsSceneMouseMove: 1354 1364 case QEvent::GraphicsSceneMouseRelease: … … 1440 1450 break; 1441 1451 } 1452 case QEvent::GraphicsSceneMouseDoubleClick: 1442 1453 case QEvent::MouseButtonDblClick: 1443 1454 if (ev->button() == Qt::LeftButton) { … … 1577 1588 } 1578 1589 else if (event == QKeySequence::Paste) { 1579 if (!isReadOnly()) 1580 paste(); 1590 if (!isReadOnly()) { 1591 QClipboard::Mode mode = QClipboard::Clipboard; 1592 #ifdef Q_WS_X11 1593 if (event->modifiers() == (Qt::CTRL | Qt::SHIFT) && event->key() == Qt::Key_Insert) 1594 mode = QClipboard::Selection; 1595 #endif 1596 paste(mode); 1597 } 1581 1598 } 1582 1599 else if (event == QKeySequence::Cut) { … … 1762 1779 break; 1763 1780 #endif 1764 1765 1781 default: 1766 1782 if (!handled) -
trunk/src/gui/widgets/qlinecontrol_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 79 79 public: 80 80 QLineControl(const QString &txt = QString()) 81 : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::L eftToRight),81 : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto), 82 82 m_hideCursor(false), m_separator(0), m_readOnly(0), 83 83 m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0), … … 95 95 } 96 96 97 int nextMaskBlank(int pos); 98 int prevMaskBlank(int pos); 99 100 bool isUndoAvailable() const; 101 bool isRedoAvailable() const; 102 void clearUndo(); 103 bool isModified() const; 104 void setModified(bool modified); 105 106 bool allSelected() const; 107 bool hasSelectedText() const; 108 109 int width() const; 110 int height() const; 111 int ascent() const; 112 qreal naturalTextWidth() const; 97 int nextMaskBlank(int pos) 98 { 99 int c = findInMask(pos, true, false); 100 m_separator |= (c != pos); 101 return (c != -1 ? c : m_maxLength); 102 } 103 104 int prevMaskBlank(int pos) 105 { 106 int c = findInMask(pos, false, false); 107 m_separator |= (c != pos); 108 return (c != -1 ? c : 0); 109 } 110 111 bool isUndoAvailable() const { return !m_readOnly && m_undoState; } 112 bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); } 113 void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; } 114 115 bool isModified() const { return m_modifiedState != m_undoState; } 116 void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; } 117 118 bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); } 119 bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; } 120 121 int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; } 122 int height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; } 123 int ascent() const { return m_ascent; } 124 qreal naturalTextWidth() const { return m_textLayout.lineAt(0).naturalTextWidth(); } 113 125 114 126 void setSelection(int start, int length); 115 127 116 QString selectedText() const; 117 QString textBeforeSelection() const; 118 QString textAfterSelection() const; 119 120 int selectionStart() const; 121 int selectionEnd() const; 122 bool inSelection(int x) const; 123 124 void removeSelection(); 125 126 int start() const; 127 int end() const; 128 inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); } 129 QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); } 130 QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); } 131 132 int selectionStart() const { return hasSelectedText() ? m_selstart : -1; } 133 int selectionEnd() const { return hasSelectedText() ? m_selend : -1; } 134 bool inSelection(int x) const 135 { 136 if (m_selstart >= m_selend) 137 return false; 138 int pos = xToPos(x, QTextLine::CursorOnCharacter); 139 return pos >= m_selstart && pos < m_selend; 140 } 141 142 void removeSelection() 143 { 144 int priorState = m_undoState; 145 removeSelectedText(); 146 finishChange(priorState); 147 } 148 149 int start() const { return 0; } 150 int end() const { return m_text.length(); } 128 151 129 152 #ifndef QT_NO_CLIPBOARD 130 153 void copy(QClipboard::Mode mode = QClipboard::Clipboard) const; 131 void paste(); 132 #endif 133 134 int cursor() const; 135 int preeditCursor() const; 136 137 int cursorWidth() const; 138 void setCursorWidth(int value); 154 void paste(QClipboard::Mode mode = QClipboard::Clipboard); 155 #endif 156 157 int cursor() const{ return m_cursor; } 158 int preeditCursor() const { return m_preeditCursor; } 159 160 int cursorWidth() const { return m_cursorWidth; } 161 void setCursorWidth(int value) { m_cursorWidth = value; } 162 139 163 140 164 void moveCursor(int pos, bool mark = false); 141 void cursorForward(bool mark, int steps); 142 void cursorWordForward(bool mark); 143 void cursorWordBackward(bool mark); 144 void home(bool mark); 145 void end(bool mark); 165 void cursorForward(bool mark, int steps) 166 { 167 int c = m_cursor; 168 if (steps > 0) { 169 while (steps--) 170 c = m_textLayout.nextCursorPosition(c); 171 } else if (steps < 0) { 172 while (steps++) 173 c = m_textLayout.previousCursorPosition(c); 174 } 175 moveCursor(c, mark); 176 } 177 178 void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } 179 void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } 180 181 void home(bool mark) { moveCursor(0, mark); } 182 void end(bool mark) { moveCursor(text().length(), mark); } 146 183 147 184 int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; 148 185 QRect cursorRect() const; 149 186 150 qreal cursorToX(int cursor) const; 151 qreal cursorToX() const; 152 153 bool isReadOnly() const; 154 void setReadOnly(bool enable); 155 156 QString text() const; 157 void setText(const QString &txt); 158 159 QString displayText() const; 187 qreal cursorToX(int cursor) const { return m_textLayout.lineAt(0).cursorToX(cursor); } 188 qreal cursorToX() const 189 { 190 int cursor = m_cursor; 191 if (m_preeditCursor != -1) 192 cursor += m_preeditCursor; 193 return cursorToX(cursor); 194 } 195 196 bool isReadOnly() const { return m_readOnly; } 197 void setReadOnly(bool enable) { m_readOnly = enable; } 198 199 QString text() const 200 { 201 QString res = m_maskData ? stripString(m_text) : m_text; 202 return (res.isNull() ? QString::fromLatin1("") : res); 203 } 204 void setText(const QString &txt) { internalSetText(txt, -1, false); } 205 QString displayText() const { return m_textLayout.text(); } 160 206 161 207 void backspace(); 162 208 void del(); 163 void deselect(); 164 void selectAll(); 209 void deselect() { internalDeselect(); finishChange(); } 210 void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); } 211 165 212 void insert(const QString &); 166 213 void clear(); 167 void undo() ;168 void redo() ;214 void undo() { internalUndo(); finishChange(-1, true); } 215 void redo() { internalRedo(); finishChange(); } 169 216 void selectWordAtPos(int); 170 217 171 uint echoMode() const; 172 void setEchoMode(uint mode); 173 174 void setMaxLength(int maxLength); 175 int maxLength() const; 218 uint echoMode() const { return m_echoMode; } 219 void setEchoMode(uint mode) 220 { 221 m_echoMode = mode; 222 m_passwordEchoEditing = false; 223 updateDisplayText(); 224 } 225 226 int maxLength() const { return m_maxLength; } 227 void setMaxLength(int maxLength) 228 { 229 if (m_maskData) 230 return; 231 m_maxLength = maxLength; 232 setText(m_text); 233 } 176 234 177 235 #ifndef QT_NO_VALIDATOR 178 const QValidator *validator() const ;179 void setValidator(const QValidator * );236 const QValidator *validator() const { return m_validator; } 237 void setValidator(const QValidator *v) { m_validator = const_cast<QValidator*>(v); } 180 238 #endif 181 239 182 240 #ifndef QT_NO_COMPLETER 183 QCompleter *completer() const; 184 void setCompleter(const QCompleter*); 241 QCompleter *completer() const { return m_completer; } 242 /* Note that you must set the widget for the completer separately */ 243 void setCompleter(const QCompleter *c) { m_completer = const_cast<QCompleter*>(c); } 185 244 void complete(int key); 186 245 #endif 187 246 188 void setCursorPosition(int pos);189 int cursorPosition() const;190 191 bool hasAcceptableInput() const ;247 int cursorPosition() const { return m_cursor; } 248 void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); } 249 250 bool hasAcceptableInput() const { return hasAcceptableInput(m_text); } 192 251 bool fixup(); 193 252 194 QString inputMask() const; 195 void setInputMask(const QString &mask); 253 QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); } 254 void setInputMask(const QString &mask) 255 { 256 parseInputMask(mask); 257 if (m_maskData) 258 moveCursor(nextMaskBlank(0)); 259 } 196 260 197 261 // input methods 198 262 #ifndef QT_NO_IM 199 bool composeMode() const ;200 void setPreeditArea(int cursor, const QString &text) ;201 #endif 202 203 QString preeditAreaText() const ;263 bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); } 264 void setPreeditArea(int cursor, const QString &text) { m_textLayout.setPreeditArea(cursor, text); } 265 #endif 266 267 QString preeditAreaText() const { return m_textLayout.preeditAreaText(); } 204 268 205 269 void updatePasswordEchoEditing(bool editing); 206 bool passwordEchoEditing() const; 207 208 QChar passwordCharacter() const; 209 void setPasswordCharacter(const QChar &character); 210 211 Qt::LayoutDirection layoutDirection() const; 212 void setLayoutDirection(Qt::LayoutDirection direction); 213 void setFont(const QFont &font); 270 bool passwordEchoEditing() const { return m_passwordEchoEditing; } 271 272 QChar passwordCharacter() const { return m_passwordCharacter; } 273 void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); } 274 275 Qt::LayoutDirection layoutDirection() const { 276 if (m_layoutDirection == Qt::LayoutDirectionAuto) { 277 if (m_text.isEmpty()) 278 return QApplication::keyboardInputDirection(); 279 return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; 280 } 281 return m_layoutDirection; 282 } 283 void setLayoutDirection(Qt::LayoutDirection direction) 284 { 285 if (direction != m_layoutDirection) { 286 m_layoutDirection = direction; 287 updateDisplayText(); 288 } 289 } 290 291 void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); } 214 292 215 293 void processInputMethodEvent(QInputMethodEvent *event); … … 217 295 void processKeyEvent(QKeyEvent* ev); 218 296 219 int cursorBlinkPeriod() const ;297 int cursorBlinkPeriod() const { return m_blinkPeriod; } 220 298 void setCursorBlinkPeriod(int msec); 221 222 QString cancelText() const; 223 void setCancelText(const QString &text); 224 225 const QPalette &palette() const; 226 void setPalette(const QPalette &); 299 void resetCursorBlinkTimer(); 300 301 QString cancelText() const { return m_cancelText; } 302 void setCancelText(const QString &text) { m_cancelText = text; } 303 304 const QPalette &palette() const { return m_palette; } 305 void setPalette(const QPalette &p) { m_palette = p; } 227 306 228 307 enum DrawFlags { … … 364 443 }; 365 444 366 inline int QLineControl::nextMaskBlank(int pos)367 {368 int c = findInMask(pos, true, false);369 m_separator |= (c != pos);370 return (c != -1 ? c : m_maxLength);371 }372 373 inline int QLineControl::prevMaskBlank(int pos)374 {375 int c = findInMask(pos, false, false);376 m_separator |= (c != pos);377 return (c != -1 ? c : 0);378 }379 380 inline bool QLineControl::isUndoAvailable() const381 {382 return !m_readOnly && m_undoState;383 }384 385 inline bool QLineControl::isRedoAvailable() const386 {387 return !m_readOnly && m_undoState < (int)m_history.size();388 }389 390 inline void QLineControl::clearUndo()391 {392 m_history.clear();393 m_modifiedState = m_undoState = 0;394 }395 396 inline bool QLineControl::isModified() const397 {398 return m_modifiedState != m_undoState;399 }400 401 inline void QLineControl::setModified(bool modified)402 {403 m_modifiedState = modified ? -1 : m_undoState;404 }405 406 inline bool QLineControl::allSelected() const407 {408 return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length();409 }410 411 inline bool QLineControl::hasSelectedText() const412 {413 return !m_text.isEmpty() && m_selend > m_selstart;414 }415 416 inline int QLineControl::width() const417 {418 return qRound(m_textLayout.lineAt(0).width()) + 1;419 }420 421 inline qreal QLineControl::naturalTextWidth() const422 {423 return m_textLayout.lineAt(0).naturalTextWidth();424 }425 426 inline int QLineControl::height() const427 {428 return qRound(m_textLayout.lineAt(0).height()) + 1;429 }430 431 inline int QLineControl::ascent() const432 {433 return m_ascent;434 }435 436 inline QString QLineControl::selectedText() const437 {438 if (hasSelectedText())439 return m_text.mid(m_selstart, m_selend - m_selstart);440 return QString();441 }442 443 inline QString QLineControl::textBeforeSelection() const444 {445 if (hasSelectedText())446 return m_text.left(m_selstart);447 return QString();448 }449 450 inline QString QLineControl::textAfterSelection() const451 {452 if (hasSelectedText())453 return m_text.mid(m_selend);454 return QString();455 }456 457 inline int QLineControl::selectionStart() const458 {459 return hasSelectedText() ? m_selstart : -1;460 }461 462 inline int QLineControl::selectionEnd() const463 {464 return hasSelectedText() ? m_selend : -1;465 }466 467 inline int QLineControl::start() const468 {469 return 0;470 }471 472 inline int QLineControl::end() const473 {474 return m_text.length();475 }476 477 inline void QLineControl::removeSelection()478 {479 int priorState = m_undoState;480 removeSelectedText();481 finishChange(priorState);482 }483 484 inline bool QLineControl::inSelection(int x) const485 {486 if (m_selstart >= m_selend)487 return false;488 int pos = xToPos(x, QTextLine::CursorOnCharacter);489 return pos >= m_selstart && pos < m_selend;490 }491 492 inline int QLineControl::cursor() const493 {494 return m_cursor;495 }496 497 inline int QLineControl::preeditCursor() const498 {499 return m_preeditCursor;500 }501 502 inline int QLineControl::cursorWidth() const503 {504 return m_cursorWidth;505 }506 507 inline void QLineControl::setCursorWidth(int value)508 {509 m_cursorWidth = value;510 }511 512 inline void QLineControl::cursorForward(bool mark, int steps)513 {514 int c = m_cursor;515 if (steps > 0) {516 while (steps--)517 c = m_textLayout.nextCursorPosition(c);518 } else if (steps < 0) {519 while (steps++)520 c = m_textLayout.previousCursorPosition(c);521 }522 moveCursor(c, mark);523 }524 525 inline void QLineControl::cursorWordForward(bool mark)526 {527 moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark);528 }529 530 inline void QLineControl::home(bool mark)531 {532 moveCursor(0, mark);533 }534 535 inline void QLineControl::end(bool mark)536 {537 moveCursor(text().length(), mark);538 }539 540 inline void QLineControl::cursorWordBackward(bool mark)541 {542 moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark);543 }544 545 inline qreal QLineControl::cursorToX(int cursor) const546 {547 return m_textLayout.lineAt(0).cursorToX(cursor);548 }549 550 inline qreal QLineControl::cursorToX() const551 {552 int cursor = m_cursor;553 if (m_preeditCursor != -1)554 cursor += m_preeditCursor;555 return cursorToX(cursor);556 }557 558 inline bool QLineControl::isReadOnly() const559 {560 return m_readOnly;561 }562 563 inline void QLineControl::setReadOnly(bool enable)564 {565 m_readOnly = enable;566 }567 568 inline QString QLineControl::text() const569 {570 QString res = m_maskData ? stripString(m_text) : m_text;571 return (res.isNull() ? QString::fromLatin1("") : res);572 }573 574 inline void QLineControl::setText(const QString &txt)575 {576 internalSetText(txt, -1, false);577 }578 579 inline QString QLineControl::displayText() const580 {581 return m_textLayout.text();582 }583 584 inline void QLineControl::deselect()585 {586 internalDeselect();587 finishChange();588 }589 590 inline void QLineControl::selectAll()591 {592 m_selstart = m_selend = m_cursor = 0;593 moveCursor(m_text.length(), true);594 }595 596 inline void QLineControl::undo()597 {598 internalUndo();599 finishChange(-1, true);600 }601 602 inline void QLineControl::redo()603 {604 internalRedo();605 finishChange();606 }607 608 inline uint QLineControl::echoMode() const609 {610 return m_echoMode;611 }612 613 inline void QLineControl::setEchoMode(uint mode)614 {615 m_echoMode = mode;616 m_passwordEchoEditing = false;617 updateDisplayText();618 }619 620 inline void QLineControl::setMaxLength(int maxLength)621 {622 if (m_maskData)623 return;624 m_maxLength = maxLength;625 setText(m_text);626 }627 628 inline int QLineControl::maxLength() const629 {630 return m_maxLength;631 }632 633 #ifndef QT_NO_VALIDATOR634 inline const QValidator *QLineControl::validator() const635 {636 return m_validator;637 }638 639 inline void QLineControl::setValidator(const QValidator *v)640 {641 m_validator = const_cast<QValidator*>(v);642 }643 #endif644 645 #ifndef QT_NO_COMPLETER646 inline QCompleter *QLineControl::completer() const647 {648 return m_completer;649 }650 651 /* Note that you must set the widget for the completer seperately */652 inline void QLineControl::setCompleter(const QCompleter* c)653 {654 m_completer = const_cast<QCompleter*>(c);655 }656 #endif657 658 inline void QLineControl::setCursorPosition(int pos)659 {660 if (pos < 0)661 pos = 0;662 if (pos <= m_text.length())663 moveCursor(pos);664 }665 666 inline int QLineControl::cursorPosition() const667 {668 return m_cursor;669 }670 671 inline bool QLineControl::hasAcceptableInput() const672 {673 return hasAcceptableInput(m_text);674 }675 676 inline QString QLineControl::inputMask() const677 {678 return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString();679 }680 681 inline void QLineControl::setInputMask(const QString &mask)682 {683 parseInputMask(mask);684 if (m_maskData)685 moveCursor(nextMaskBlank(0));686 }687 688 // input methods689 #ifndef QT_NO_IM690 inline bool QLineControl::composeMode() const691 {692 return !m_textLayout.preeditAreaText().isEmpty();693 }694 695 inline void QLineControl::setPreeditArea(int cursor, const QString &text)696 {697 m_textLayout.setPreeditArea(cursor, text);698 }699 #endif700 701 inline QString QLineControl::preeditAreaText() const702 {703 return m_textLayout.preeditAreaText();704 }705 706 inline bool QLineControl::passwordEchoEditing() const707 {708 return m_passwordEchoEditing;709 }710 711 inline QChar QLineControl::passwordCharacter() const712 {713 return m_passwordCharacter;714 }715 716 inline void QLineControl::setPasswordCharacter(const QChar &character)717 {718 m_passwordCharacter = character;719 updateDisplayText();720 }721 722 inline Qt::LayoutDirection QLineControl::layoutDirection() const723 {724 return m_layoutDirection;725 }726 727 inline void QLineControl::setLayoutDirection(Qt::LayoutDirection direction)728 {729 if (direction != m_layoutDirection) {730 m_layoutDirection = direction;731 updateDisplayText();732 }733 }734 735 inline void QLineControl::setFont(const QFont &font)736 {737 m_textLayout.setFont(font);738 updateDisplayText();739 }740 741 inline int QLineControl::cursorBlinkPeriod() const742 {743 return m_blinkPeriod;744 }745 746 inline QString QLineControl::cancelText() const747 {748 return m_cancelText;749 }750 751 inline void QLineControl::setCancelText(const QString &text)752 {753 m_cancelText = text;754 }755 756 inline const QPalette & QLineControl::palette() const757 {758 return m_palette;759 }760 761 inline void QLineControl::setPalette(const QPalette &p)762 {763 m_palette = p;764 }765 766 445 QT_END_NAMESPACE 767 446 -
trunk/src/gui/widgets/qlineedit.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 140 140 The length of the text can be constrained to maxLength(). The text 141 141 can be arbitrarily constrained using a validator() or an 142 inputMask(), or both. 142 inputMask(), or both. When switching between a validator and an input mask 143 on the same line edit, it is best to clear the validator or input mask to 144 prevent undefined behavior. 145 143 146 144 147 A related class is QTextEdit which allows multi-line, rich text … … 384 387 } 385 388 386 // ### Qt 4.7: remove this #if guard387 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)388 389 /*! 389 390 \since 4.7 … … 415 416 } 416 417 } 417 #endif418 418 419 419 /*! … … 543 543 return; 544 544 Qt::InputMethodHints imHints = inputMethodHints(); 545 if (mode == Password ) {545 if (mode == Password || mode == NoEcho) { 546 546 imHints |= Qt::ImhHiddenText; 547 547 } else { 548 548 imHints &= ~Qt::ImhHiddenText; 549 } 550 if (mode != Normal) { 551 imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); 552 } else { 553 imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); 549 554 } 550 555 setInputMethodHints(imHints); … … 1644 1649 if (!event->text().isEmpty() && event->text().at(0).isPrint() 1645 1650 && !isReadOnly()) 1646 {1647 1651 setEditFocus(true); 1648 #ifndef Q_OS_SYMBIAN 1649 clear(); 1650 #endif 1651 } else { 1652 else { 1652 1653 event->ignore(); 1653 1654 return; … … 1666 1667 #endif 1667 1668 d->control->processKeyEvent(event); 1668 if (event->isAccepted()) 1669 if (event->isAccepted()) { 1670 if (layoutDirection() != d->control->layoutDirection()) 1671 setLayoutDirection(d->control->layoutDirection()); 1669 1672 d->control->setCursorBlinkPeriod(0); 1673 } 1670 1674 } 1671 1675 … … 1705 1709 if (QApplication::keypadNavigationEnabled() 1706 1710 && hasFocus() && !hasEditFocus() 1707 && !e->preeditString().isEmpty()) {1711 && !e->preeditString().isEmpty()) 1708 1712 setEditFocus(true); 1709 #ifndef Q_OS_SYMBIAN1710 selectAll(); // so text is replaced rather than appended to1711 #endif1712 }1713 1713 #endif 1714 1714 … … 1867 1867 1868 1868 QFontMetrics fm = fontMetrics(); 1869 Qt::Alignment va = QStyle::visualAlignment( layoutDirection(), QFlag(d->alignment));1869 Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); 1870 1870 switch (va & Qt::AlignVertical_Mask) { 1871 1871 case Qt::AlignBottom: … … 1882 1882 QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); 1883 1883 1884 int minLB = qMax(0, -fm.minLeftBearing()); 1885 int minRB = qMax(0, -fm.minRightBearing()); 1886 1884 1887 if (d->control->text().isEmpty()) { 1885 1888 if (!hasFocus() && !d->placeholderText.isEmpty()) { … … 1888 1891 QPen oldpen = p.pen(); 1889 1892 p.setPen(col); 1890 p.drawText(lineRect, va, d->placeholderText); 1893 lineRect.adjust(minLB, 0, 0, 0); 1894 QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); 1895 p.drawText(lineRect, va, elidedText); 1891 1896 p.setPen(oldpen); 1892 1897 return; … … 1902 1907 // minLB, minRB), the line edit rect (lineRect) and the cursor position 1903 1908 // (cix). 1904 int minLB = qMax(0, -fm.minLeftBearing());1905 int minRB = qMax(0, -fm.minRightBearing());1906 1909 int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; 1907 1910 if ((minLB + widthUsed) <= lineRect.width()) { … … 1930 1933 // right 1931 1934 d->hscroll = widthUsed - lineRect.width() + 1; 1932 } 1935 } else { 1936 //in case the text is bigger than the lineedit, the hscroll can never be negative 1937 d->hscroll = qMax(0, d->hscroll); 1938 } 1939 1933 1940 // the y offset is there to keep the baseline constant in case we have script changes in the text. 1934 1941 QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); … … 1950 1957 flags |= QLineControl::DrawSelections; 1951 1958 // Palette only used for selections/mask and may not be in sync 1952 if(d->control->palette() != pal) 1959 if (d->control->palette() != pal 1960 || d->control->palette().currentColorGroup() != pal.currentColorGroup()) 1953 1961 d->control->setPalette(pal); 1954 1962 } … … 2053 2061 void QLineEdit::contextMenuEvent(QContextMenuEvent *event) 2054 2062 { 2055 QPointer<QMenu> menu = createStandardContextMenu(); 2056 menu->exec(event->globalPos()); 2057 delete menu; 2058 } 2059 2060 #if defined(Q_WS_WIN) 2063 if (QMenu *menu = createStandardContextMenu()) { 2064 menu->setAttribute(Qt::WA_DeleteOnClose); 2065 menu->popup(event->globalPos()); 2066 } 2067 } 2068 2069 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 2061 2070 extern bool qt_use_rtl_extensions; 2062 2071 #endif … … 2130 2139 #endif 2131 2140 2132 #if defined(Q_WS_WIN) 2141 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 2133 2142 if (!d->control->isReadOnly() && qt_use_rtl_extensions) { 2134 2143 #else … … 2163 2172 } 2164 2173 update(); 2165 break;2166 case QEvent::LayoutDirectionChange:2167 d->control->setLayoutDirection(layoutDirection());2168 2174 break; 2169 2175 default: -
trunk/src/gui/widgets/qlineedit.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 84 84 Q_PROPERTY(bool redoAvailable READ isRedoAvailable) 85 85 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) 86 // ### Qt 4.7: remove this #if guard87 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)88 86 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) 89 #endif90 87 91 88 public: … … 103 100 QString displayText() const; 104 101 105 // ### Qt 4.7: remove this #if guard106 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)107 102 QString placeholderText() const; 108 103 void setPlaceholderText(const QString &); 109 #endif110 104 111 105 int maxLength() const; -
trunk/src/gui/widgets/qlineedit_p.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qlineedit_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmaccocoaviewcontainer_mac.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmacnativewidget_mac.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmacnativewidget_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmainwindow.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 //#define QT_EXPERIMENTAL_CLIENT_DECORATIONS 43 42 44 #include "qmainwindow.h" 43 45 #include "qmainwindowlayout_p.h" … … 77 79 #ifdef Q_WS_MAC 78 80 , useHIToolBar(false) 81 , activateUnifiedToolbarAfterFullScreen(false) 79 82 #endif 80 83 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) … … 88 91 #ifdef Q_WS_MAC 89 92 bool useHIToolBar; 93 bool activateUnifiedToolbarAfterFullScreen; 90 94 #endif 91 95 void init(); … … 100 104 uint cursorAdjusted : 1; 101 105 #endif 106 107 static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) 108 { 109 return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); 110 } 102 111 }; 103 112 113 QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) 114 { 115 return QMainWindowPrivate::mainWindowLayout(mainWindow); 116 } 117 118 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 119 Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) 120 { 121 QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout()); 122 Q_ASSERT(topLayout); 123 124 int row = 0; 125 int column = 0; 126 127 switch (area) { 128 case Qt::LeftDockWidgetArea: 129 row = 1; 130 column = 0; 131 break; 132 case Qt::TopDockWidgetArea: 133 row = 0; 134 column = 1; 135 break; 136 case Qt::BottomDockWidgetArea: 137 row = 2; 138 column = 1; 139 break; 140 case Qt::RightDockWidgetArea: 141 row = 1; 142 column = 2; 143 break; 144 default: 145 Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); 146 return; 147 } 148 149 if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) 150 delete oldItem->widget(); 151 topLayout->addWidget(widget, row, column); 152 } 153 #endif 154 104 155 void QMainWindowPrivate::init() 105 156 { 106 157 Q_Q(QMainWindow); 107 layout = new QMainWindowLayout(q); 158 159 #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS 160 QGridLayout *topLayout = new QGridLayout(q); 161 topLayout->setContentsMargins(0, 0, 0, 0); 162 163 layout = new QMainWindowLayout(q, topLayout); 164 165 topLayout->addItem(layout, 1, 1); 166 #else 167 layout = new QMainWindowLayout(q, 0); 168 #endif 169 108 170 const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); 109 171 iconSize = QSize(metric, metric); … … 443 505 QMenuBar *QMainWindow::menuBar() const 444 506 { 445 QMenuBar *menuBar = qobject_cast<QMenuBar *>( d_func()->layout->menuBar());507 QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); 446 508 if (!menuBar) { 447 509 QMainWindow *self = const_cast<QMainWindow *>(this); … … 462 524 void QMainWindow::setMenuBar(QMenuBar *menuBar) 463 525 { 464 Q_D(QMainWindow); 465 if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { 526 QLayout *topLayout = layout(); 527 528 if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { 466 529 // Reparent corner widgets before we delete the old menu bar. 467 QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>( d->layout->menuBar());530 QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); 468 531 if (menuBar) { 469 532 // TopLeftCorner widget. … … 479 542 oldMenuBar->deleteLater(); 480 543 } 481 d->layout->setMenuBar(menuBar);544 topLayout->setMenuBar(menuBar); 482 545 } 483 546 … … 1375 1438 1376 1439 case QEvent::StyleChange: 1440 #ifndef QT_NO_DOCKWIDGET 1441 d->layout->layoutState.dockAreaLayout.styleChangedEvent(); 1442 #endif 1377 1443 if (!d->explicitIconSize) 1378 1444 setIconSize(QSize()); … … 1438 1504 disappear since it is considered to be part of the title bar. Qt 4.5 and up will now work around this by pulling 1439 1505 the toolbars out and back into the regular toolbar and vice versa when you swap out. 1440 However, a good practice would be that turning off the unified toolbar before you call1441 showFullScreen() and restoring it after you call showNormal().1442 1506 \endlist 1443 1507 … … 1454 1518 1455 1519 // ### Disable the unified toolbar when using anything but the native graphics system. 1456 if (windowSurface()) 1520 // ### Disable when using alien widgets as well 1521 if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false) 1457 1522 return; 1458 1523 … … 1536 1601 #ifndef QT_NO_MENU 1537 1602 QMenu *popup = createPopupMenu(); 1538 if (popup && !popup->isEmpty()) { 1539 popup->exec(event->globalPos()); 1540 event->accept(); 1541 } 1542 delete popup; 1603 if (popup) { 1604 if (!popup->isEmpty()) { 1605 popup->setAttribute(Qt::WA_DeleteOnClose); 1606 popup->popup(event->globalPos()); 1607 event->accept(); 1608 } else { 1609 delete popup; 1610 } 1611 } 1543 1612 #endif 1544 1613 } -
trunk/src/gui/widgets/qmainwindow.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmainwindowlayout.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 161 161 void qt_dumpLayout(QTextStream &qout, QMainWindow *window) 162 162 { 163 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(window->layout());163 QMainWindowLayout *layout = qt_mainwindow_layout(window); 164 164 dumpLayout(qout, layout->layoutState.dockAreaLayout, QString()); 165 165 } … … 236 236 #else 237 237 if (centralWidgetItem != 0) { 238 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(mainWindow->layout());238 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); 239 239 Q_ASSERT(layout != 0); 240 240 layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated); … … 944 944 if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { 945 945 // If we hit this case, someone has pressed the "toolbar button" which will 946 // toggle the unified toolbar visib lity, because that's what the user wants.946 // toggle the unified toolbar visibility, because that's what the user wants. 947 947 // We might be in a situation where someone has hidden all the toolbars 948 948 // beforehand (maybe in construction), but now they've hit this button and … … 1675 1675 } 1676 1676 1677 QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow )1678 : QLayout( mainwindow)1677 QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout) 1678 : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow) 1679 1679 , layoutState(mainwindow) 1680 1680 , savedState(mainwindow) … … 1699 1699 #endif 1700 1700 { 1701 if (parentLayout) 1702 setParent(parentLayout); 1703 1701 1704 #ifndef QT_NO_DOCKWIDGET 1702 1705 #ifndef QT_NO_TABBAR -
trunk/src/gui/widgets/qmainwindowlayout_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 49 49 #else 50 50 #include <private/qcocoatoolbardelegate_mac_p.h> 51 #import <private/qcocoawindowdelegate_mac_p.h> 51 52 #endif 52 53 … … 338 339 339 340 layoutState.mainWindow->setUpdatesEnabled(false); // reduces a little bit of flicker, not all though 341 #if defined(QT_MAC_USE_COCOA) 342 QMacCocoaAutoReleasePool pool; 343 NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView]; 344 if (useMacToolbar) { 345 [cView setPostsFrameChangedNotifications:YES]; 346 [[NSNotificationCenter defaultCenter] addObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] 347 selector: @selector(syncContentViewFrame:) 348 name: NSViewFrameDidChangeNotification 349 object: cView]; 350 } 351 #endif 340 352 if (!useMacToolbar) { 341 353 macWindowToolbarShow(layoutState.mainWindow, false); … … 357 369 syncUnifiedToolbarVisibility(); 358 370 } 371 #if defined(QT_MAC_USE_COCOA) 372 if (!useMacToolbar) { 373 [cView setPostsFrameChangedNotifications:NO]; 374 [[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] 375 name: NSViewFrameDidChangeNotification 376 object: cView]; 377 } 378 #endif 359 379 layoutState.mainWindow->setUpdatesEnabled(true); 360 380 } … … 411 431 [macToolbar setDisplayMode:NSToolbarDisplayModeIconOnly]; 412 432 [macToolbar setSizeMode:NSToolbarSizeModeRegular]; 413 [macToolbar setDelegate:[[Q CocoaToolBarDelegatealloc] initWithMainWindowLayout:this]];433 [macToolbar setDelegate:[[QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) alloc] initWithMainWindowLayout:this]]; 414 434 [window setToolbar:macToolbar]; 415 435 [macToolbar release]; -
trunk/src/gui/widgets/qmainwindowlayout_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 160 160 QMainWindowLayoutState layoutState, savedState; 161 161 162 explicit QMainWindowLayout(QMainWindow *mainwindow);162 QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout); 163 163 ~QMainWindowLayout(); 164 164 … … 336 336 void fixSizeInUnifiedToolbar(QToolBar *tb) const; 337 337 bool useHIToolBar; 338 bool activateUnifiedToolbarAfterFullScreen; 338 339 void syncUnifiedToolbarVisibility(); 339 340 bool blockVisiblityCheck; -
trunk/src/gui/widgets/qmdiarea.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmdiarea.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmdiarea_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmdisubwindow.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmdisubwindow.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmdisubwindow_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmenu.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 86 86 QT_BEGIN_NAMESPACE 87 87 88 QPointer<QMenu> QMenuPrivate::mouseDown; 89 QBasicTimer QMenuPrivate::menuDelayTimer; 90 QBasicTimer QMenuPrivate::sloppyDelayTimer; 88 QMenu *QMenuPrivate::mouseDown = 0; 89 int QMenuPrivate::sloppyDelayTimer = 0; 91 90 92 91 /* QMenu code */ … … 264 263 const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; 265 264 266 //for compat ability now - will have to refactor this away..265 //for compatibility now - will have to refactor this away 267 266 tabWidth = 0; 268 267 maxIconWidth = 0; … … 489 488 if (!delay) 490 489 q->internalDelayedPopup(); 491 else 492 QMenuPrivate::menuDelayTimer.start(delay, q);490 else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible())) 491 menuDelayTimer.start(delay, q); 493 492 if (activateFirst && action->menu()) 494 493 action->menu()->d_func()->setFirstActionActive(); … … 545 544 Q_Q(QMenu); 546 545 tearoffHighlighted = 0; 547 if (action == currentAction) {548 if (!action || !action->menu() || action->menu() == activeMenu) {549 if(QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {550 if(causedPopup.action && menu->d_func()->activeMenu == q)551 menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);552 }553 }554 return;555 }556 546 if (currentAction) 557 547 q->update(actionRect(currentAction)); … … 567 557 emitHighlighted = action; 568 558 #endif 559 569 560 currentAction = action; 570 561 if (action) { … … 1164 1155 bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos) 1165 1156 { 1166 //determines if the mouse has moved (ie its in tial position has1157 //determines if the mouse has moved (ie its initial position has 1167 1158 //changed by more than QApplication::startDragDistance() 1168 1159 //or if there were at least 6 mouse motions) … … 1330 1321 addActions() and insertAction() functions. 1331 1322 1323 \warning To make QMenu visible on the screen, exec() or popup() should be 1324 used instead of show(). 1325 1332 1326 \section1 QMenu on Qt for Windows CE 1333 1327 … … 1805 1799 { 1806 1800 Q_D(QMenu); 1807 if (d->scroll) { //reset scroll state from last popup 1801 #ifndef Q_OS_SYMBIAN 1802 if (d->scroll) { // reset scroll state from last popup 1808 1803 d->scroll->scrollOffset = 0; 1809 1804 d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; 1810 1805 } 1806 #endif 1811 1807 d->tearoffHighlighted = 0; 1812 1808 d->motions = 0; … … 1834 1830 QRect screen; 1835 1831 #ifndef QT_NO_GRAPHICSVIEW 1836 bool isEmbedded = d->nearestGraphicsProxyWidget(this);1832 bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); 1837 1833 if (isEmbedded) 1838 1834 screen = d->popupGeometry(this); … … 1860 1856 #endif 1861 1857 if (d->ncols > 1) { 1862 pos.setY(screen.top() +desktopFrame);1858 pos.setY(screen.top() + desktopFrame); 1863 1859 } else if (atAction) { 1864 for (int i = 0, above_height = 0; i < d->actions.count(); i++) {1860 for (int i = 0, above_height = 0; i < d->actions.count(); i++) { 1865 1861 QAction *action = d->actions.at(i); 1866 1862 if (action == atAction) { … … 1877 1873 && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) { 1878 1874 int below_height = above_height + d->scroll->scrollOffset; 1879 for (int i2 = i; i2 < d->actionRects.count(); i2++)1875 for (int i2 = i; i2 < d->actionRects.count(); i2++) 1880 1876 below_height += d->actionRects.at(i2).height(); 1881 1877 size.setHeight(below_height); … … 1890 1886 QPoint mouse = QCursor::pos(); 1891 1887 d->mousePopupPos = mouse; 1892 const bool snapToMouse = (QRect(p.x() -3, p.y()-3, 6, 6).contains(mouse));1888 const bool snapToMouse = (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse)); 1893 1889 1894 1890 if (adjustToDesktop) { 1895 // handle popup falling "off screen"1891 // handle popup falling "off screen" 1896 1892 if (isRightToLeft()) { 1897 if (snapToMouse) //position flowing left from the mouse1898 pos.setX(mouse.x() -size.width());1893 if (snapToMouse) // position flowing left from the mouse 1894 pos.setX(mouse.x() - size.width()); 1899 1895 1900 1896 #ifndef QT_NO_MENUBAR 1901 // if in a menubar, it should be right-aligned1897 // if in a menubar, it should be right-aligned 1902 1898 if (qobject_cast<QMenuBar*>(d->causedPopup.widget)) 1903 1899 pos.rx() -= size.width(); 1904 1900 #endif //QT_NO_MENUBAR 1905 1901 1906 if (pos.x() < screen.left() +desktopFrame)1907 pos.setX(qMax(p.x(), screen.left() +desktopFrame));1908 if (pos.x() +size.width()-1 > screen.right()-desktopFrame)1909 pos.setX(qMax(p.x() -size.width(), screen.right()-desktopFrame-size.width()+1));1902 if (pos.x() < screen.left() + desktopFrame) 1903 pos.setX(qMax(p.x(), screen.left() + desktopFrame)); 1904 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame) 1905 pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1)); 1910 1906 } else { 1911 if (pos.x() +size.width()-1 > screen.right()-desktopFrame)1912 pos.setX(screen.right() -desktopFrame-size.width()+1);1913 if (pos.x() < screen.left() +desktopFrame)1907 if (pos.x() + size.width() - 1 > screen.right() - desktopFrame) 1908 pos.setX(screen.right() - desktopFrame - size.width() + 1); 1909 if (pos.x() < screen.left() + desktopFrame) 1914 1910 pos.setX(screen.left() + desktopFrame); 1915 1911 } … … 1925 1921 if (pos.y() < screen.top() + desktopFrame) 1926 1922 pos.setY(screen.top() + desktopFrame); 1927 if (pos.y() +size.height()-1 > screen.bottom() - desktopFrame) {1923 if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) { 1928 1924 if (d->scroll) { 1929 1925 d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); 1930 1926 int y = qMax(screen.y(),pos.y()); 1931 size.setHeight(screen.bottom() -(desktopFrame*2)-y);1927 size.setHeight(screen.bottom() - (desktopFrame * 2) - y); 1932 1928 } else { 1933 1929 // Too big for screen, bias to see bottom of menu (for some reason) 1934 pos.setY(screen.bottom() -size.height()+1);1930 pos.setY(screen.bottom() - size.height() + 1); 1935 1931 } 1936 1932 } … … 1941 1937 int vGuess = QEffects::DownScroll; 1942 1938 if (isRightToLeft()) { 1943 if ((snapToMouse && (pos.x() + size.width() /2 > mouse.x())) ||1944 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() /2 > d->causedPopup.widget->x()))1939 if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) || 1940 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x())) 1945 1941 hGuess = QEffects::RightScroll; 1946 1942 } else { 1947 if ((snapToMouse && (pos.x() + size.width() /2 < mouse.x())) ||1948 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() /2 < d->causedPopup.widget->x()))1943 if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) || 1944 (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x())) 1949 1945 hGuess = QEffects::LeftScroll; 1950 1946 } 1951 1947 1952 1948 #ifndef QT_NO_MENUBAR 1953 if ((snapToMouse && (pos.y() + size.height() /2 < mouse.y())) ||1949 if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) || 1954 1950 (qobject_cast<QMenuBar*>(d->causedPopup.widget) && 1955 pos.y() + size.width() /2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))1951 pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y())) 1956 1952 vGuess = QEffects::UpScroll; 1957 1953 #endif … … 2303 2299 2304 2300 if (action && action == d->currentAction) { 2305 if (action->menu()) 2306 action->menu()->d_func()->setFirstActionActive(); 2307 else { 2301 if (!action->menu()){ 2308 2302 #if defined(Q_WS_WIN) 2309 2303 //On Windows only context menus can be activated with the right button … … 2379 2373 } break; 2380 2374 case QEvent::ContextMenu: 2381 if( QMenuPrivate::menuDelayTimer.isActive()) {2382 QMenuPrivate::menuDelayTimer.stop();2375 if(d->menuDelayTimer.isActive()) { 2376 d->menuDelayTimer.stop(); 2383 2377 internalDelayedPopup(); 2384 2378 } … … 2815 2809 if (d->sloppyRegion.contains(e->pos())) { 2816 2810 d->sloppyAction = action; 2817 QMenuPrivate::sloppyDelayTimer .start(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6, this);2811 QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); 2818 2812 } else { 2819 2813 d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); … … 2853 2847 if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone) 2854 2848 d->scroll->scrollTimer.stop(); 2855 } else if( QMenuPrivate::menuDelayTimer.timerId() == e->timerId()) {2856 QMenuPrivate::menuDelayTimer.stop();2849 } else if(d->menuDelayTimer.timerId() == e->timerId()) { 2850 d->menuDelayTimer.stop(); 2857 2851 internalDelayedPopup(); 2858 } else if(QMenuPrivate::sloppyDelayTimer.timerId() == e->timerId()) { 2859 QMenuPrivate::sloppyDelayTimer.stop(); 2852 } else if(QMenuPrivate::sloppyDelayTimer == e->timerId()) { 2853 killTimer(QMenuPrivate::sloppyDelayTimer); 2854 QMenuPrivate::sloppyDelayTimer = 0; 2860 2855 internalSetSloppyAction(); 2861 2856 } else if(d->searchBufferTimer.timerId() == e->timerId()) { -
trunk/src/gui/widgets/qmenu.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 418 418 friend bool qt_mac_activate_action(OSMenuRef, uint, QAction::ActionEvent, bool); 419 419 friend void qt_mac_emit_menuSignals(QMenu *, bool); 420 friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action); 420 421 #endif 421 422 }; -
trunk/src/gui/widgets/qmenu_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 248 248 //now walk up firing for each "caused" widget (like in the platform independent menu) 249 249 QWidget *caused = 0; 250 if ( GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) {250 if (action_e == QAction::Hover && GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) { 251 251 MenuRef caused_menu = 0; 252 252 if (QMenu *qmenu2 = qobject_cast<QMenu*>(caused)) … … 261 261 GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(widget), 0, &widget); 262 262 if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) { 263 if (action_e == QAction::Trigger) { 264 emit qmenu->triggered(action->action); 265 } else if (action_e == QAction::Hover) { 266 action->action->showStatusText(widget); 267 emit qmenu->hovered(action->action); 268 } 263 action->action->showStatusText(widget); 264 emit qmenu->hovered(action->action); 269 265 } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) { 270 if (action_e == QAction::Trigger) { 271 emit qmenubar->triggered(action->action); 272 } else if (action_e == QAction::Hover) { 273 action->action->showStatusText(widget); 274 emit qmenubar->hovered(action->action); 275 } 266 action->action->showStatusText(widget); 267 emit qmenubar->hovered(action->action); 276 268 break; //nothing more.. 277 269 } … … 279 271 //walk up 280 272 if (GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, 281 sizeof(caused), 0, &caused) != noErr)273 sizeof(caused), 0, &caused) != noErr) 282 274 break; 283 275 if (QMenu *qmenu2 = qobject_cast<QMenu*>(caused)) … … 650 642 initWithTitle:qt_mac_QStringToNSString(title) 651 643 action:@selector(qtDispatcherToQAction:) keyEquivalent:@""]; 652 [item setTarget: getMenuLoader()];644 [item setTarget:nil]; 653 645 return item; 654 646 } … … 674 666 } 675 667 #else 668 bool modalWindowOnScreen = qApp->activeModalWidget() != 0; 676 669 for (NSMenuItem *item in [menu itemArray]) { 677 670 OSMenuRef submenu = [item submenu]; … … 683 676 if ([item tag]) { 684 677 QAction *action = reinterpret_cast<QAction *>([item tag]); 685 syncNSMenuItemEnabled(item, action->isEnabled()); 686 } else { 687 syncNSMenuItemEnabled(item, YES); 688 } 678 syncNSMenuItemEnabled(item, action->isEnabled()); 679 } else { 680 syncNSMenuItemEnabled(item, YES); 681 } 682 // We sneak in some extra code here to handle a menu problem: 683 // If there is no window on screen, we cannot set 'nil' as 684 // menu item target, because then cocoa will disable the item 685 // (guess it assumes that there will be no first responder to 686 // catch the trigger anyway?) OTOH, If we have a modal window, 687 // then setting the menu loader as target will make cocoa not 688 // deliver the trigger because the loader is then seen as modally 689 // shaddowed). So either way there are shortcomings. Instead, we 690 // decide the target as late as possible: 691 [item setTarget:modalWindowOnScreen ? nil : getMenuLoader()]; 689 692 } else { 690 693 syncNSMenuItemEnabled(item, NO); … … 750 753 } 751 754 752 void qt_mac_clear_menubar()753 {754 if (QApplication::testAttribute(Qt::AA_MacPluginApplication))755 return;756 757 #ifndef QT_MAC_USE_COCOA758 MenuRef clear_menu = 0;759 if (CreateNewMenu(0, 0, &clear_menu) == noErr) {760 SetRootMenu(clear_menu);761 ReleaseMenu(clear_menu);762 } else {763 qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__);764 }765 ClearMenuBar();766 qt_mac_command_set_enabled(0, kHICommandPreferences, false);767 InvalMenuBar();768 #else769 QMacCocoaAutoReleasePool pool;770 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();771 NSMenu *menu = [loader menu];772 [loader ensureAppMenuInMenu:menu];773 [NSApp setMainMenu:menu];774 #endif775 }776 777 778 755 QMacMenuAction::~QMacMenuAction() 779 756 { … … 944 921 { 945 922 QString ret; 923 extern QString qt_mac_applicationmenu_string(int type); 946 924 #ifdef QT_MAC_USE_COCOA 947 925 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); … … 951 929 #ifndef QT_MAC_USE_COCOA 952 930 else if (action->command == kHICommandAbout) 953 ret = QMenuBar::tr("About %1").arg(qAppName());931 ret = qt_mac_applicationmenu_string(6).arg(qAppName()); 954 932 else if (action->command == kHICommandAboutQt) 955 933 ret = QMenuBar::tr("About Qt"); 956 934 else if (action->command == kHICommandPreferences) 957 ret = QMenuBar::tr("Preferences");935 ret = qt_mac_applicationmenu_string(4); 958 936 else if (action->command == kHICommandQuit) 959 ret = QMenuBar::tr("Quit %1").arg(qAppName()); 960 #else 961 else if (action->menuItem == [loader aboutMenuItem]) 962 ret = QMenuBar::tr("About %1").arg(qAppName()); 963 else if (action->menuItem == [loader aboutQtMenuItem]) 964 ret = QMenuBar::tr("About Qt"); 965 else if (action->menuItem == [loader preferencesMenuItem]) 966 ret = QMenuBar::tr("Preferences"); 967 else if (action->menuItem == [loader quitMenuItem]) 968 ret = QMenuBar::tr("Quit %1").arg(qAppName()); 937 ret = qt_mac_applicationmenu_string(5).arg(qAppName()); 938 #else 939 else if (action->menuItem == [loader aboutMenuItem]) { 940 ret = qt_mac_applicationmenu_string(6).arg(qAppName()); 941 } else if (action->menuItem == [loader aboutQtMenuItem]) { 942 if (action->action->text() == QString("About Qt")) 943 ret = QMenuBar::tr("About Qt"); 944 else 945 ret = action->action->text(); 946 } else if (action->menuItem == [loader preferencesMenuItem]) { 947 ret = qt_mac_applicationmenu_string(4); 948 } else if (action->menuItem == [loader quitMenuItem]) { 949 ret = qt_mac_applicationmenu_string(5).arg(qAppName()); 950 } 969 951 #endif 970 952 return ret; … … 1131 1113 [cmd retain]; 1132 1114 [cmd setAction:@selector(qtDispatcherToQAction:)]; 1133 [cmd setTarget: getMenuLoader()];1115 [cmd setTarget:nil]; 1134 1116 [action->menuItem release]; 1135 1117 action->menuItem = cmd; … … 1421 1403 [item setTitle: qt_mac_QStringToNSString(finalString)]; 1422 1404 } 1423 [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))]; 1405 1406 if (action->action->menuRole() == QAction::AboutRole || action->action->menuRole() == QAction::QuitRole) 1407 [item setTitle:qt_mac_QStringToNSString(text)]; 1408 else 1409 [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))]; 1424 1410 1425 1411 // Cocoa Enabled … … 1846 1832 mac_menubar = 0; 1847 1833 1848 if ( qt_mac_current_menubar.qmenubar == q) {1834 if (!qt_mac_current_menubar.qmenubar || qt_mac_current_menubar.qmenubar == q) { 1849 1835 #ifdef QT_MAC_USE_COCOA 1850 1836 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); … … 1937 1923 based on the modality type of modalWidget. 1938 1924 */ 1939 static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) 1940 { 1941 if (modalWidget == 0 || menuBar == 0) 1925 static bool qt_mac_should_disable_menu(QMenuBar *menuBar) 1926 { 1927 QWidget *modalWidget = qApp->activeModalWidget(); 1928 if (!modalWidget) 1942 1929 return false; 1943 1930 1944 // If there is an application modal window on 1945 // screen, the entries of the menubar should be disabled: 1931 if (menuBar && menuBar == menubars()->value(modalWidget)) 1932 // The menu bar is owned by the modal widget. 1933 // In that case we should enable it: 1934 return false; 1935 1936 // When there is an application modal window on screen, the entries of 1937 // the menubar should be disabled. The exception in Qt is that if the 1938 // modal window is the only window on screen, then we enable the menu bar. 1946 1939 QWidget *w = modalWidget; 1940 QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); 1947 1941 while (w) { 1948 if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) 1949 return true; 1942 if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) { 1943 for (int i=0; i<topLevelWidgets.size(); ++i) { 1944 QWidget *top = topLevelWidgets.at(i); 1945 if (w != top && top->isVisible()) { 1946 // INVARIANT: we found another visible window 1947 // on screen other than our modalWidget. We therefore 1948 // disable the menu bar to follow normal modality logic: 1949 return true; 1950 } 1951 } 1952 // INVARIANT: We have only one window on screen that happends 1953 // to be application modal. We choose to enable the menu bar 1954 // in that case to e.g. enable the quit menu item. 1955 return false; 1956 } 1950 1957 w = w->parentWidget(); 1951 1958 } 1952 1959 1953 1960 // INVARIANT: modalWidget is window modal. Disable menu entries 1954 // if the menu bar belongs to an ancestor of modalWidget: 1955 return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); 1956 } 1957 1958 /*! 1959 \internal 1960 1961 This function will update the current menu bar and set it as the 1962 active menu bar in the Menu Manager. 1963 1964 \warning This function is not portable. 1965 1966 \sa QMenu::macMenu(), QMenuBar::macMenu() 1967 */ 1968 bool QMenuBar::macUpdateMenuBar() 1969 { 1970 cancelAllMenuTracking(); 1971 QMenuBar *mb = 0; 1972 //find a menu bar 1961 // if the menu bar belongs to an ancestor of modalWidget. If menuBar 1962 // is nil, we understand it as the default menu bar set by the nib: 1963 return menuBar ? qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget) : false; 1964 } 1965 1966 static QWidget *findWindowThatShouldDisplayMenubar() 1967 { 1973 1968 QWidget *w = qApp->activeWindow(); 1974 1975 1969 if (!w) { 1970 // We have no active window on screen. Try to 1971 // find a window from the list of top levels: 1976 1972 QWidgetList tlws = QApplication::topLevelWidgets(); 1977 1973 for(int i = 0; i < tlws.size(); ++i) { … … 1984 1980 } 1985 1981 } 1982 return w; 1983 } 1984 1985 static QMenuBar *findMenubarForWindow(QWidget *w) 1986 { 1987 QMenuBar *mb = 0; 1986 1988 if (w) { 1987 1989 mb = menubars()->value(w); … … 1997 1999 mb = menubars()->value((w = w->parentWidget())); 1998 2000 } 1999 if (!mb) 2001 2002 if (!mb) { 2003 // We could not find a menu bar for the window. Lets 2004 // check if we have a global (parentless) menu bar instead: 2000 2005 mb = fallback; 2001 //now set it 2006 } 2007 2008 return mb; 2009 } 2010 2011 void qt_mac_clear_menubar() 2012 { 2013 if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) 2014 return; 2015 2016 #ifndef QT_MAC_USE_COCOA 2017 MenuRef clear_menu = 0; 2018 if (CreateNewMenu(0, 0, &clear_menu) == noErr) { 2019 SetRootMenu(clear_menu); 2020 ReleaseMenu(clear_menu); 2021 } else { 2022 qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__); 2023 } 2024 ClearMenuBar(); 2025 qt_mac_command_set_enabled(0, kHICommandPreferences, false); 2026 InvalMenuBar(); 2027 #else 2028 QMacCocoaAutoReleasePool pool; 2029 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); 2030 NSMenu *menu = [loader menu]; 2031 [loader ensureAppMenuInMenu:menu]; 2032 [NSApp setMainMenu:menu]; 2033 const bool modal = qt_mac_should_disable_menu(0); 2034 if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) 2035 qt_mac_set_modal_state(menu, modal); 2036 qt_mac_current_menubar.qmenubar = 0; 2037 qt_mac_current_menubar.modal = modal; 2038 #endif 2039 } 2040 2041 /*! 2042 \internal 2043 2044 This function will update the current menu bar and set it as the 2045 active menu bar in the Menu Manager. 2046 2047 \warning This function is not portable. 2048 2049 \sa QMenu::macMenu(), QMenuBar::macMenu() 2050 */ 2051 bool QMenuBar::macUpdateMenuBar() 2052 { 2053 #ifdef QT_MAC_USE_COCOA 2054 QMacCocoaAutoReleasePool pool; 2055 if (!qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar))) 2056 return QMenuBarPrivate::macUpdateMenuBarImmediatly(); 2057 return true; 2058 #else 2059 return QMenuBarPrivate::macUpdateMenuBarImmediatly(); 2060 #endif 2061 } 2062 2063 bool QMenuBarPrivate::macUpdateMenuBarImmediatly() 2064 { 2002 2065 bool ret = false; 2066 cancelAllMenuTracking(); 2067 QWidget *w = findWindowThatShouldDisplayMenubar(); 2068 QMenuBar *mb = findMenubarForWindow(w); 2069 extern bool qt_mac_app_fullscreen; //qapplication_mac.mm 2070 2071 // We need to see if we are in full screen mode, if so we need to 2072 // switch the full screen mode to be able to show or hide the menubar. 2073 if(w && mb) { 2074 // This case means we are creating a menubar, check if full screen 2075 if(w->isFullScreen()) { 2076 // Ok, switch to showing the menubar when hovering over it. 2077 SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); 2078 qt_mac_app_fullscreen = true; 2079 } 2080 } else if(w) { 2081 // Removing a menubar 2082 if(w->isFullScreen()) { 2083 // Ok, switch to not showing the menubar when hovering on it 2084 SetSystemUIMode(kUIModeAllHidden, 0); 2085 qt_mac_app_fullscreen = true; 2086 } 2087 } 2088 2003 2089 if (mb && mb->isNativeMenuBar()) { 2090 bool modal = QApplicationPrivate::modalState(); 2004 2091 #ifdef QT_MAC_USE_COCOA 2005 2092 QMacCocoaAutoReleasePool pool; … … 2031 2118 } 2032 2119 #endif 2033 QWidget *modalWidget = qApp->activeModalWidget();2034 if (mb != menubars()->value(modalWidget)) {2035 qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget));2036 }2120 // Check if menu is modally shaddowed and should be disabled: 2121 modal = qt_mac_should_disable_menu(mb); 2122 if (mb != qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal) 2123 qt_mac_set_modal_state(menu, modal); 2037 2124 } 2038 2125 qt_mac_current_menubar.qmenubar = mb; 2039 qt_mac_current_menubar.modal = QApplicationPrivate::modalState();2126 qt_mac_current_menubar.modal = modal; 2040 2127 ret = true; 2041 2128 } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) { 2042 const bool modal = QApplicationPrivate::modalState(); 2129 // INVARIANT: The currently active menu bar (if any) is not native. But we do have a 2130 // native menu bar from before. So we need to decide whether or not is should be enabled: 2131 const bool modal = qt_mac_should_disable_menu(qt_mac_current_menubar.qmenubar); 2043 2132 if (modal != qt_mac_current_menubar.modal) { 2044 2133 ret = true; … … 2052 2141 syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar); 2053 2142 #endif 2054 QWidget *modalWidget = qApp->activeModalWidget(); 2055 if (qt_mac_current_menubar.qmenubar != menubars()->value(modalWidget)) { 2056 qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget)); 2057 } 2143 qt_mac_set_modal_state(menu, modal); 2058 2144 } 2059 2145 qt_mac_current_menubar.modal = modal; 2060 2146 } 2061 2147 } 2062 if(!ret) 2148 2149 if (!ret) { 2063 2150 qt_mac_clear_menubar(); 2151 } 2064 2152 return ret; 2065 2153 } … … 2132 2220 2133 2221 QT_END_NAMESPACE 2222 -
trunk/src/gui/widgets/qmenu_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 203 203 204 204 //selection 205 static Q Pointer<QMenu>mouseDown;205 static QMenu *mouseDown; 206 206 QPoint mousePopupPos; 207 207 uint hasHadMouse : 1; … … 213 213 QAction *cancelAction; 214 214 #endif 215 staticQBasicTimer menuDelayTimer;215 QBasicTimer menuDelayTimer; 216 216 enum SelectionReason { 217 217 SelectedFromKeyboard, … … 273 273 274 274 //sloppy selection 275 static QBasicTimersloppyDelayTimer;275 static int sloppyDelayTimer; 276 276 mutable QAction *sloppyAction; 277 277 QRegion sloppyRegion; -
trunk/src/gui/widgets/qmenu_symbian.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 49 49 #include <private/qmenu_p.h> 50 50 #include <private/qmenubar_p.h> 51 #include < qt_s60_p.h>51 #include <private/qt_s60_p.h> 52 52 #include <QtCore/qlibrary.h> 53 53 … … 169 169 if (action->action->menu()->actions().size() > 0) { 170 170 for (int c2= 0; c2 < action->action->menu()->actions().size(); ++c2) { 171 QS ymbianMenuAction *symbianAction2 = new QSymbianMenuAction;171 QScopedPointer<QSymbianMenuAction> symbianAction2(new QSymbianMenuAction); 172 172 symbianAction2->action = action->action->menu()->actions().at(c2); 173 173 QMenu * menu = symbianAction2->action->menu(); 174 174 symbianAction2->command = qt_symbian_menu_static_cmd_id++; 175 qt_symbian_insert_action(symbianAction2 , &(menuItem->children));175 qt_symbian_insert_action(symbianAction2.data(), &(menuItem->children)); 176 176 } 177 177 } … … 433 433 { 434 434 for (int i = 0; i <actions.size(); ++i) { 435 QS ymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction;435 QScopedPointer<QSymbianMenuAction> symbianActionTopLevel(new QSymbianMenuAction); 436 436 symbianActionTopLevel->action = actions.at(i); 437 437 symbianActionTopLevel->parent = 0; 438 438 symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; 439 qt_symbian_insert_action(symbianActionTopLevel , &symbianMenus);439 qt_symbian_insert_action(symbianActionTopLevel.data(), &symbianMenus); 440 440 } 441 441 } -
trunk/src/gui/widgets/qmenu_wince.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmenu_wince_resource_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmenubar.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 103 103 QStyleOptionToolButton opt; 104 104 initStyleOption(&opt); 105 // We do not need to draw both exten tion arrows105 // We do not need to draw both extension arrows 106 106 opt.features &= ~QStyleOptionToolButton::HasMenu; 107 107 p.drawComplexControl(QStyle::CC_ToolButton, opt); … … 269 269 QRect QMenuBarPrivate::actionRect(QAction *act) const 270 270 { 271 Q_Q(const QMenuBar);272 271 const int index = actions.indexOf(act); 273 if (index == -1)274 return QRect();275 272 276 273 //makes sure the geometries are up-to-date 277 274 const_cast<QMenuBarPrivate*>(this)->updateGeometries(); 278 275 279 if (index >= actionRects.count())276 if (index < 0 || index >= actionRects.count()) 280 277 return QRect(); // that can happen in case of native menubar 281 278 282 QRect ret = actionRects.at(index); 283 return QStyle::visualRect(q->layoutDirection(), q->rect(), ret); 279 return actionRects.at(index); 284 280 } 285 281 … … 506 502 //keep moving along.. 507 503 x += rect.width() + itemSpacing; 504 505 //make sure we follow the layout direction 506 rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect); 508 507 } 509 508 } … … 770 769 const int end = increment == -1 ? 0 : actions.count() - 1; 771 770 772 for (int i = start; start!= end;) {771 for (int i = start; i != end;) { 773 772 i += increment; 774 773 QAction *current = actions.at(i); … … 1630 1629 1631 1630 /*! 1632 \internal1633 1634 Return the item at \a pt, or 0 if there is no item there or if it is 1635 a separator item.1631 Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if 1632 the location has a separator. 1633 1634 \sa addAction(), addSeparator() 1636 1635 */ 1637 1636 QAction *QMenuBar::actionAt(const QPoint &pt) const … … 1642 1641 1643 1642 /*! 1644 \internal1645 1646 Returns the geometry of action \a act.1643 Returns the geometry of action \a act as a QRect. 1644 1645 \sa actionAt() 1647 1646 */ 1648 1647 QRect QMenuBar::actionGeometry(QAction *act) const … … 1838 1837 1839 1838 /*! 1840 \internal 1841 1842 This sets widget \a w to be shown directly on the left of the first or 1843 the right of the last menu item, depending on \a corner. 1839 \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner) 1840 1841 This sets the given \a widget to be shown directly on the left of the first 1842 menu item, or on the right of the last menu item, depending on \a corner. 1843 1844 The menu bar takes ownership of \a widget, reparenting it into the menu bar. 1845 However, if the \a corner already contains a widget, this previous widget 1846 will no longer be managed and will still be a visible child of the menu bar. 1847 1848 \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner 1849 will result in a warning. 1844 1850 */ 1845 1851 void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) … … 1871 1877 1872 1878 /*! 1873 \internal 1874 1875 Returns the widget in the left of the first or the right of the last menu 1876 item, depending on \a corner. 1879 Returns the widget on the left of the first or on the right of the last menu 1880 item, depending on \a corner. 1881 1882 \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner 1883 will result in a warning. 1877 1884 */ 1878 1885 QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const … … 1933 1940 } 1934 1941 macUpdateMenuBar(); 1935 1936 setVisible(false); 1937 1942 updateGeometry(); 1943 if (!d->nativeMenuBar && parentWidget()) 1944 setVisible(true); 1938 1945 #endif 1939 1946 } -
trunk/src/gui/widgets/qmenubar.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmenubar_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 197 197 } 198 198 } *mac_menubar; 199 static bool macUpdateMenuBarImmediatly(); 199 200 bool macWidgetHasNativeMenubar(QWidget *widget); 200 201 void macCreateMenuBar(QWidget *); … … 269 270 } *symbian_menubar; 270 271 static int symbianCommands(int command); 272 #endif 271 273 #ifdef QT_SOFTKEYS_ENABLED 272 274 QAction *menuBarAction; 273 275 #endif 274 #endif275 276 }; 276 277 #endif -
trunk/src/gui/widgets/qmenudata.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qmenudata.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qplaintextedit.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 912 912 913 913 if (moveCursor) { 914 cursor.setVisualNavigation(true); 914 915 // move using movePosition to keep the cursor's x 915 916 lastY += verticalOffset(); … … 944 945 if (!centerOnScroll && q->isVisible()) { 945 946 QTextBlock block = doc->lastBlock(); 946 const int visible = static_cast<int>(viewport->rect().height() - margin - 1);947 inty = 0;947 const qreal visible = viewport->rect().height() - margin - 1; 948 qreal y = 0; 948 949 int visibleFromBottom = 0; 949 950 … … 953 954 continue; 954 955 } 955 y += int(documentLayout->blockBoundingRect(block).height());956 y += documentLayout->blockBoundingRect(block).height(); 956 957 957 958 QTextLayout *layout = block.layout(); … … 962 963 QTextLine line = layout->lineAt(lineNumber); 963 964 const QRectF lr = line.naturalTextRect(); 964 if ( int(lr.top()) >= y - visible)965 if (lr.top() >= y - visible) 965 966 break; 966 967 ++lineNumber; … … 1320 1321 } 1321 1322 1323 /*! 1324 Returns the reference of the anchor at position \a pos, or an 1325 empty string if no anchor exists at that point. 1326 1327 \since 4.7 1328 */ 1329 QString QPlainTextEdit::anchorAt(const QPoint &pos) const 1330 { 1331 Q_D(const QPlainTextEdit); 1332 int cursorPos = d->control->hitTest(pos + QPoint(d->horizontalOffset(), 1333 d->verticalOffset()), 1334 Qt::ExactHit); 1335 if (cursorPos < 0) 1336 return QString(); 1337 1338 QTextDocumentPrivate *pieceTable = document()->docHandle(); 1339 QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); 1340 QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); 1341 return fmt.anchorHref(); 1342 } 1322 1343 1323 1344 /*! … … 1456 1477 } 1457 1478 #endif 1479 #ifndef QT_NO_GESTURES 1458 1480 else if (e->type() == QEvent::Gesture) { 1459 1481 QGestureEvent *ge = static_cast<QGestureEvent *>(e); … … 1479 1501 return true; 1480 1502 } 1503 #endif // QT_NO_GESTURES 1481 1504 return QAbstractScrollArea::event(e); 1482 1505 } … … 2394 2417 2395 2418 The default value depends on whether the QPlainTextEdit is read-only 2396 or editable , and whether it is a QTextBrowser or not.2419 or editable. 2397 2420 */ 2398 2421 -
trunk/src/gui/widgets/qplaintextedit.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 160 160 QRect cursorRect() const; 161 161 162 QString anchorAt(const QPoint &pos) const; 163 162 164 bool overwriteMode() const; 163 165 void setOverwriteMode(bool overwrite); -
trunk/src/gui/widgets/qplaintextedit_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qprintpreviewwidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 470 470 471 471 Construct the QPrintPreviewWidget either by passing in an 472 exis iting QPrinter object, or have QPrintPreviewWidget create a472 existing QPrinter object, or have QPrintPreviewWidget create a 473 473 default constructed QPrinter object for you. 474 474 -
trunk/src/gui/widgets/qprintpreviewwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qprogressbar.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qprogressbar.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 94 94 95 95 void setInvertedAppearance(bool invert); 96 bool invertedAppearance(); 96 bool invertedAppearance(); //### Qt5 make const 97 bool invertedAppearance() const { return const_cast<QProgressBar *>(this)->invertedAppearance(); } 97 98 void setTextDirection(QProgressBar::Direction textDirection); 98 QProgressBar::Direction textDirection(); 99 QProgressBar::Direction textDirection(); //### Qt5 make const 100 QProgressBar::Direction textDirection() const { return const_cast<QProgressBar *>(this)->textDirection(); } 99 101 100 102 void setFormat(const QString &format); -
trunk/src/gui/widgets/qpushbutton.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 59 59 #include "qlayoutitem.h" 60 60 #include "qdialogbuttonbox.h" 61 #ifdef Q_WS_MAC 62 #include "qmacstyle_mac.h" 63 #include "private/qmacstyle_mac_p.h" 64 #endif // Q_WS_MAC 61 65 62 66 #ifndef QT_NO_ACCESSIBILITY … … 680 684 } 681 685 686 #ifdef Q_WS_MAC 687 /*! \reimp */ 688 bool QPushButton::hitButton(const QPoint &pos) const 689 { 690 QStyleOptionButton opt; 691 initStyleOption(&opt); 692 if (qt_mac_buttonIsRenderedFlat(this, &opt)) 693 return QAbstractButton::hitButton(pos); 694 695 // Now that we know we are using the native style, let's proceed. 696 Q_D(const QPushButton); 697 QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d); 698 // In OSX buttons are round, which causes the hit method to be special. 699 // We cannot simply relay on detecting if something is inside the rect or not, 700 // we need to check if it is inside the "rounded area" or not. A point might 701 // be inside the rect but not inside the rounded area. 702 // Notice this method is only reimplemented for OSX. 703 return nonConst->hitButton(pos); 704 } 705 706 bool QPushButtonPrivate::hitButton(const QPoint &pos) 707 { 708 Q_Q(QPushButton); 709 QRect roundedRect(q->rect().left() + QMacStylePrivate::PushButtonLeftOffset, 710 q->rect().top() + QMacStylePrivate::PushButtonContentPadding, 711 q->rect().width() - QMacStylePrivate::PushButtonRightOffset, 712 q->rect().height() - QMacStylePrivate::PushButtonBottomOffset); 713 return roundedRect.contains(pos); 714 } 715 #endif // Q_WS_MAC 716 682 717 #ifdef QT3_SUPPORT 683 718 /*! -
trunk/src/gui/widgets/qpushbutton.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 92 92 protected: 93 93 bool event(QEvent *e); 94 #ifdef Q_WS_MAC 95 bool hitButton(const QPoint &pos) const; 96 #endif // Q_WS_MAC 94 97 void paintEvent(QPaintEvent *); 95 98 void keyPressEvent(QKeyEvent *); -
trunk/src/gui/widgets/qpushbutton_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 70 70 inline void init() { resetLayoutItemMargins(); } 71 71 static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } 72 #ifdef Q_WS_MAC 73 bool hitButton(const QPoint &pos); 74 #endif 72 75 #ifndef QT_NO_MENU 73 76 QPoint adjustedMenuPosition(); -
trunk/src/gui/widgets/qradiobutton.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 196 196 QStyleOptionButton opt; 197 197 initStyleOption(&opt); 198 QSize sz = style()->itemTextRect(fontMetrics(), QRect( 0, 0, 1, 1), Qt::TextShowMnemonic,198 QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic, 199 199 false, text()).size(); 200 200 if (!opt.icon.isNull()) -
trunk/src/gui/widgets/qradiobutton.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qrubberband.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qrubberband.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qscrollarea.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 122 122 If a scroll area is used to display the contents of a widget that 123 123 contains child widgets arranged in a layout, it is important to 124 reali se that the size policy of the layout will also determine the124 realize that the size policy of the layout will also determine the 125 125 size of the widget. This is especially useful to know if you intend 126 126 to dynamically change the contents of the layout. In such cases, … … 483 483 else if (focusRect.right() > visibleRect.right()) 484 484 d->hbar->setValue(focusRect.right() - d->viewport->width()); 485 else 485 else if (focusRect.left() < visibleRect.left()) 486 486 d->hbar->setValue(focusRect.left()); 487 487 … … 490 490 else if (focusRect.bottom() > visibleRect.bottom()) 491 491 d->vbar->setValue(focusRect.bottom() - d->viewport->height()); 492 else 492 else if (focusRect.top() < visibleRect.top()) 493 493 d->vbar->setValue(focusRect.top()); 494 494 } -
trunk/src/gui/widgets/qscrollarea.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qscrollarea_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qscrollbar.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 48 48 #include "qstyleoption.h" 49 49 #include "qmenu.h" 50 #include <QtCore/q datetime.h>50 #include <QtCore/qelapsedtimer.h> 51 51 52 52 #ifndef QT_NO_SCROLLBAR … … 524 524 #ifndef QT_NO_WHEELEVENT 525 525 case QEvent::Wheel: { 526 event->ignore(); 526 527 // override wheel event without adding virtual function override 527 528 QWheelEvent *ev = static_cast<QWheelEvent *>(event); … … 613 614 const int initialDelay = 500; // default threshold 614 615 d->activateControl(d->pressedControl, initialDelay); 615 Q Timetime;616 QElapsedTimer time; 616 617 time.start(); 617 618 repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this)); -
trunk/src/gui/widgets/qscrollbar.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qsizegrip.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qsizegrip.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qslider.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 622 622 623 623 This is a value interval, not a pixel interval. If it is 0, the 624 slider will choose between lineStep() and pageStep().624 slider will choose between singleStep() and pageStep(). 625 625 626 626 The default value is 0. -
trunk/src/gui/widgets/qslider.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qspinbox.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qspinbox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qsplashscreen.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 186 186 Draws the \a message text onto the splash screen with color \a 187 187 color and aligns the text according to the flags in \a alignment. 188 189 To make sure the splash screen is repainted immediately, you can 190 call \l{QCoreApplication}'s 191 \l{QCoreApplication::}{processEvents()} after the call to 192 showMessage(). You usually want this to make sure that the message 193 is kept up to date with what your application is doing (e.g., 194 loading files). 188 195 189 196 \sa Qt::Alignment, clearMessage() -
trunk/src/gui/widgets/qsplashscreen.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qsplitter.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 125 125 /*! 126 126 Sets the orientation of the splitter handle to \a orientation. 127 This is usually prop ogated from the QSplitter.127 This is usually propagated from the QSplitter. 128 128 129 129 \sa QSplitter::setOrientation() … … 223 223 return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s) 224 224 .expandedTo(QApplication::globalStrut()); 225 } 226 227 /*! 228 \reimp 229 */ 230 void QSplitterHandle::resizeEvent(QResizeEvent *event) 231 { 232 Q_D(const QSplitterHandle); 233 234 // When splitters are only 1 pixel large we increase the 235 // actual grab area to five pixels 236 237 // Note that QSplitter uses contentsRect for layouting 238 // and ensures that handles are drawn on top of widgets 239 // We simply use the contents margins for draggin and only 240 // paint the mask area 241 bool useTinyMode = (d->s->handleWidth() == 1); 242 setAttribute(Qt::WA_MouseNoMask, useTinyMode); 243 if (useTinyMode) { 244 if (orientation() == Qt::Horizontal) 245 setContentsMargins(2, 0, 2, 0); 246 else 247 setContentsMargins(0, 2, 0, 2); 248 setMask(QRegion(contentsRect())); 249 } 250 251 QWidget::resizeEvent(event); 225 252 } 226 253 … … 302 329 QPainter p(this); 303 330 QStyleOption opt(0); 304 opt.rect = rect();331 opt.rect = contentsRect(); 305 332 opt.palette = palette(); 306 333 if (orientation() == Qt::Horizontal) … … 1277 1304 return; 1278 1305 QWidget *w = static_cast<QWidget*>(c->child()); 1279 1280 1306 if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) { 1281 1307 d->insertWidget_helper(d->list.count(), w, false); … … 1307 1333 if (pos < 0) { 1308 1334 if (d->rubberBand) 1309 QTimer::singleShot(0, d->rubberBand, SLOT(deleteLater()));1335 d->rubberBand->deleteLater(); 1310 1336 return; 1311 1337 } … … 1314 1340 int hw = handleWidth(); 1315 1341 if (!d->rubberBand) { 1316 d->rubberBand = new QRubberBand(QRubberBand::Line); 1342 QBoolBlocker b(d->blockChildAdd); 1343 d->rubberBand = new QRubberBand(QRubberBand::Line, this); 1317 1344 // For accessibility to identify this special widget. 1318 1345 d->rubberBand->setObjectName(QLatin1String("qt_rubberband")); 1319 1346 } 1320 if (d->orient == Qt::Horizontal) 1321 d->rubberBand->setGeometry(QRect(QPoint(pos + hw / 2 - rBord, r.y()), 1322 QSize(2 * rBord, r.height())).translated(mapToGlobal(QPoint()))); 1323 else 1324 d->rubberBand->setGeometry(QRect(QPoint(r.x(), pos + hw / 2 - rBord), 1325 QSize(r.width(), 2 * rBord)).translated(mapToGlobal(QPoint()))); 1326 if (!d->rubberBand->isVisible()) 1327 d->rubberBand->show(); 1347 1348 const QRect newGeom = d->orient == Qt::Horizontal ? QRect(QPoint(pos + hw / 2 - rBord, r.y()), QSize(2 * rBord, r.height())) 1349 : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord)); 1350 d->rubberBand->setGeometry(newGeom); 1351 d->rubberBand->show(); 1328 1352 } 1329 1353 … … 1556 1580 int l = 0; 1557 1581 int t = 0; 1558 QObjectList childList = children(); 1559 for (int i = 0; i < childList.size(); ++i) { 1560 if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) { 1561 if (w->isHidden()) 1562 continue; 1563 QSize s = w->sizeHint(); 1564 if (s.isValid()) { 1565 l += d->pick(s); 1566 t = qMax(t, d->trans(s)); 1567 } 1582 for (int i = 0; i < d->list.size(); ++i) { 1583 QWidget *w = d->list.at(i)->widget; 1584 if (w->isHidden()) 1585 continue; 1586 QSize s = w->sizeHint(); 1587 if (s.isValid()) { 1588 l += d->pick(s); 1589 t = qMax(t, d->trans(s)); 1568 1590 } 1569 1591 } … … 1668 1690 By default, this property contains a value that depends on the user's platform 1669 1691 and style preferences. 1692 1693 If you set handleWidth to 1, the actual grab area will grow to overlap a 1694 few pixels of it's respective widgets. 1670 1695 */ 1671 1696 -
trunk/src/gui/widgets/qsplitter.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 173 173 void mousePressEvent(QMouseEvent *); 174 174 void mouseReleaseEvent(QMouseEvent *); 175 void resizeEvent(QResizeEvent *); 175 176 bool event(QEvent *); 176 177 -
trunk/src/gui/widgets/qsplitter_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qstackedwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 187 187 188 188 /*! 189 Removes the given \a widget from the QStackedWidget.190 191 \bold{Note:} The ownership of \a widget remains the same.192 The widget is \e not deleted, but simply removed from the widget's 193 stacked layout, causing it to be hidden.189 Removes \a widget from the QStackedWidget. i.e., \a widget is \e 190 not deleted but simply removed from the stacked layout, causing it 191 to be hidden. 192 193 \bold{Note:} Ownership of \a widget reverts to the application. 194 194 195 195 \sa addWidget(), insertWidget(), currentWidget() -
trunk/src/gui/widgets/qstackedwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qstatusbar.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 576 576 vbox->addSpacing(2); 577 577 d->box->activate(); 578 repaint();578 update(); 579 579 } 580 580 -
trunk/src/gui/widgets/qstatusbar.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtabbar.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 74 74 QT_BEGIN_NAMESPACE 75 75 76 76 77 inline static bool verticalTabs(QTabBar::Shape shape) 77 78 { … … 100 101 metrics.right = 0; 101 102 qt_mac_updateContentBorderMetricts(window, metrics); 102 103 // hide the base line separator if the tabs have docuemnt mode enabled (Cocoa) 104 qt_mac_showBaseLineSeparator(window, !documentMode); 103 #if QT_MAC_USE_COCOA 104 // In Cocoa we need to keep track of the drawRect method. 105 // If documentMode is enabled we need to change it, unless 106 // a toolbar is present. 107 // Notice that all the information is kept in the window, 108 // that's why we get the private widget for it instead of 109 // the private widget for this widget. 110 QWidgetPrivate *privateWidget = qt_widget_private(q->window()); 111 if(privateWidget) 112 privateWidget->changeMethods = documentMode; 113 // Since in Cocoa there is no simple way to remove the baseline, so we just ask the 114 // top level to do the magic for us. 115 privateWidget->syncUnifiedMode(); 116 #endif // QT_MAC_USE_COCOA 105 117 } 106 118 #endif … … 620 632 } 621 633 622 void QTabBarPrivate::layoutWidgets(int index)634 void QTabBarPrivate::layoutWidgets(int start) 623 635 { 624 636 Q_Q(QTabBar); 625 int start = 0; 626 int end = q->count(); 627 if (index != -1) { 628 start = qMax(index, 0); 629 end = qMin(end, start + 1); 630 } 631 for (int i = start; i < end; ++i) { 637 for (int i = start; i < q->count(); ++i) { 632 638 layoutTab(i); 633 639 } … … 1211 1217 d->makeVisible(index); 1212 1218 d->tabList[index].lastTab = oldIndex; 1213 d->layoutWidgets(oldIndex); 1214 d->layoutWidgets(index); 1219 if (oldIndex >= 0 && oldIndex < count()) 1220 d->layoutTab(oldIndex); 1221 d->layoutTab(index); 1222 #ifndef QT_NO_ACCESSIBILITY 1223 if (QAccessible::isActive()) { 1224 QAccessible::updateAccessibility(this, index + 1, QAccessible::Focus); 1225 QAccessible::updateAccessibility(this, index + 1, QAccessible::Selection); 1226 } 1227 #endif 1215 1228 #ifdef QT3_SUPPORT 1216 1229 emit selected(index); … … 1987 2000 Q_D(QTabBar); 1988 2001 if (event->type() == QEvent::StyleChange) { 1989 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); 2002 if (!d->elideModeSetByUser) 2003 d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); 1990 2004 if (!d->useScrollButtonsSetByUser) 1991 2005 d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); … … 2020 2034 Q_D(QTabBar); 2021 2035 d->elideMode = mode; 2036 d->elideModeSetByUser = true; 2022 2037 d->refresh(); 2023 2038 } … … 2236 2251 { 2237 2252 Q_D(QTabBar); 2253 2238 2254 d->documentMode = enabled; 2239 2255 d->updateMacBorderMetrics(); -
trunk/src/gui/widgets/qtabbar.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtabbar_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 QTabBarPrivate() 77 77 :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), 78 drawBase(true), scrollOffset(0), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false),78 drawBase(true), scrollOffset(0), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false), 79 79 selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), 80 80 dragInProgress(false), documentMode(false), movingTab(0) … … 179 179 void refresh(); 180 180 void layoutTabs(); 181 void layoutWidgets(int index = -1);181 void layoutWidgets(int start = 0); 182 182 void layoutTab(int index); 183 183 void updateMacBorderMetrics(); … … 187 187 QSize iconSize; 188 188 Qt::TextElideMode elideMode; 189 bool elideModeSetByUser; 189 190 bool useScrollButtons; 190 191 bool useScrollButtonsSetByUser; -
trunk/src/gui/widgets/qtabwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 543 543 Q_D(QTabWidget); 544 544 d->tabs->setTabEnabled(index, enable); 545 if (QWidget *widget = d->stack->widget(index)) 546 widget->setEnabled(enable); 545 547 } 546 548 -
trunk/src/gui/widgets/qtabwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtextbrowser.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtextbrowser.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtextedit.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 774 774 remains the owner of the object. 775 775 776 If the current document is a child of the text editor, then it is deleted.776 The editor does not delete the current document, even if it is a child of the editor. 777 777 778 778 \sa document() … … 1213 1213 if (QApplication::keypadNavigationEnabled()) { 1214 1214 if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) { 1215 if (e->text()[0].isPrint()) {1215 if (e->text()[0].isPrint()) 1216 1216 setEditFocus(true); 1217 #ifndef Q_OS_SYMBIAN 1218 clear(); 1219 #endif 1220 } else { 1217 else { 1221 1218 e->ignore(); 1222 1219 return; … … 1678 1675 if (d->control->textInteractionFlags() & Qt::TextEditable 1679 1676 && QApplication::keypadNavigationEnabled() 1680 && !hasEditFocus()) {1677 && !hasEditFocus()) 1681 1678 setEditFocus(true); 1682 #ifndef Q_OS_SYMBIAN1683 selectAll(); // so text is replaced rather than appended to1684 #endif1685 }1686 1679 #endif 1687 1680 d->sendControlEvent(e); -
trunk/src/gui/widgets/qtextedit.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtextedit_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbar.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 83 83 #endif 84 84 85 // qmainwindow.cpp 86 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 87 85 88 /****************************************************************************** 86 89 ** QToolBarPrivate … … 198 201 QMainWindow *win = qobject_cast<QMainWindow*>(parent); 199 202 Q_ASSERT(win != 0); 200 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(win->layout());203 QMainWindowLayout *layout = qt_mainwindow_layout(win); 201 204 Q_ASSERT(layout != 0); 202 205 if (layout->pluggingWidget != 0) // the main window is animating a docking operation … … 224 227 QMainWindow *win = qobject_cast<QMainWindow*>(parent); 225 228 Q_ASSERT(win != 0); 226 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(win->layout());229 QMainWindowLayout *layout = qt_mainwindow_layout(win); 227 230 Q_ASSERT(layout != 0); 228 231 … … 248 251 249 252 if (state->dragging) { 250 QMainWindowLayout *layout = 251 qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 253 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 252 254 Q_ASSERT(layout != 0); 253 255 … … 341 343 return true; 342 344 343 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(win->layout());345 QMainWindowLayout *layout = qt_mainwindow_layout(win); 344 346 Q_ASSERT(layout != 0); 345 347 … … 534 536 535 537 /*! 538 \fn void QToolBar::visibilityChanged(bool visible) 539 \since 4.7 540 541 This signal is emitted when the toolbar becomes \a visible (or 542 invisible). This happens when the widget is hidden or shown. 543 */ 544 545 /*! 536 546 Constructs a QToolBar with the given \a parent. 537 547 */ … … 581 591 if (mainwindow) { 582 592 #ifdef Q_WS_MAC 583 QMainWindowLayout *mainwin_layout = q object_cast<QMainWindowLayout *>(mainwindow->layout());593 QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); 584 594 if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() 585 595 && mainwindow->testAttribute(Qt::WA_WState_Created)) … … 1123 1133 case QEvent::Show: 1124 1134 d->toggleViewAction->setChecked(event->type() == QEvent::Show); 1135 emit visibilityChanged(event->type() == QEvent::Show); 1125 1136 #if defined(Q_WS_MAC) 1126 1137 if (toolbarInUnifiedToolBar(this)) { 1127 1138 // I can static_cast because I did the qobject_cast in the if above, therefore 1128 1139 // we must have a QMainWindowLayout here. 1129 QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout());1140 QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget())); 1130 1141 mwLayout->fixSizeInUnifiedToolbar(this); 1131 1142 mwLayout->syncUnifiedToolbarVisibility(); … … 1281 1292 } 1282 1293 1294 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 1295 1283 1296 /*! 1284 1297 \internal … … 1307 1320 return; 1308 1321 1309 QMainWindowLayout *layout = q object_cast<QMainWindowLayout *>(mainWindow->layout());1322 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); 1310 1323 Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", 1311 1324 "QMainWindow->layout() != QMainWindowLayout"); -
trunk/src/gui/widgets/qtoolbar.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 144 144 void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); 145 145 void topLevelChanged(bool topLevel); 146 void visibilityChanged(bool visible); 146 147 147 148 protected: -
trunk/src/gui/widgets/qtoolbar_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbararealayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 60 60 QT_BEGIN_NAMESPACE 61 61 62 // qmainwindow.cpp 63 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow); 64 62 65 QSize QToolBarAreaLayoutItem::minimumSize() const 63 66 { … … 873 876 void QToolBarAreaLayout::apply(bool animate) 874 877 { 875 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(mainWindow->layout());878 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); 876 879 Q_ASSERT(layout != 0); 877 880 -
trunk/src/gui/widgets/qtoolbararealayout_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbarextension.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 QStyleOptionToolButton opt; 77 77 initStyleOption(&opt); 78 // We do not need to draw both exten tion arrows78 // We do not need to draw both extension arrows 79 79 opt.features &= ~QStyleOptionToolButton::HasMenu; 80 80 p.drawComplexControl(QStyle::CC_ToolButton, opt); -
trunk/src/gui/widgets/qtoolbarextension_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbarlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 58 58 QT_BEGIN_NAMESPACE 59 59 60 // qmainwindow.cpp 61 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 62 60 63 /****************************************************************************** 61 64 ** QToolBarItem … … 405 408 Qt::ToolBarArea area = win->toolBarArea(tb); 406 409 if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { 407 static_cast<QMainWindowLayout *>(win->layout())->fixSizeInUnifiedToolbar(tb);410 qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb); 408 411 } 409 412 } … … 655 658 return; 656 659 if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) { 660 #ifdef QT_NO_DOCKWIDGET 661 animating = false; 662 #else 657 663 animating = !tb->isWindow() && win->isAnimated(); 658 QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); 664 #endif 665 QMainWindowLayout *layout = qt_mainwindow_layout(win); 659 666 if (expanded) { 660 667 tb->raise(); -
trunk/src/gui/widgets/qtoolbarlayout_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbarseparator.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbarseparator_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbox.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbox.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbutton.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qtoolbutton.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qvalidator.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 401 401 if (overflow || !ok) 402 402 return Invalid; 403 if (entered >= b && entered <= t) 404 return Acceptable; 403 if (entered >= b && entered <= t) { 404 locale().toInt(input, &ok); 405 return ok ? Acceptable : Intermediate; 406 } 405 407 406 408 if (entered >= 0) { … … 413 415 } 414 416 417 /*! \reimp */ 418 void QIntValidator::fixup(QString &input) const 419 { 420 QByteArray buff; 421 if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) { 422 QLocale cl(QLocale::C); 423 if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) 424 return; 425 } 426 bool ok, overflow; 427 qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); 428 if (ok && !overflow) 429 input = locale().toString(entered); 430 } 415 431 416 432 /*! … … 484 500 485 501 QDoubleValidator::Notation notation; 502 503 QValidator::State validateWithLocale(QString & input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const; 486 504 }; 487 505 … … 508 526 In addition, QDoubleValidator is always guaranteed to accept a number 509 527 formatted according to the "C" locale. QDoubleValidator will not accept 510 numbers with thousand-sep erators.528 numbers with thousand-separators. 511 529 512 530 \sa QIntValidator, QRegExpValidator, {Line Edits Example} … … 639 657 } 640 658 659 State currentLocaleValidation = d->validateWithLocale(input, numMode, locale()); 660 if (currentLocaleValidation == Acceptable || locale().language() == QLocale::C) 661 return currentLocaleValidation; 662 State cLocaleValidation = d->validateWithLocale(input, numMode, QLocale(QLocale::C)); 663 return qMax(currentLocaleValidation, cLocaleValidation); 664 } 665 666 QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const 667 { 668 Q_Q(const QDoubleValidator); 641 669 QByteArray buff; 642 if (!locale().d()->validateChars(input, numMode, &buff, dec)) { 643 QLocale cl(QLocale::C); 644 if (!cl.d()->validateChars(input, numMode, &buff, dec)) 645 return Invalid; 646 } 670 if (!locale.d()->validateChars(input, numMode, &buff, q->dec)) 671 return QValidator::Invalid; 647 672 648 673 if (buff.isEmpty()) 649 return Intermediate;650 651 if ( b >= 0 && buff.startsWith('-'))652 return Invalid;653 654 if ( t < 0 && buff.startsWith('+'))655 return Invalid;674 return QValidator::Intermediate; 675 676 if (q->b >= 0 && buff.startsWith('-')) 677 return QValidator::Invalid; 678 679 if (q->t < 0 && buff.startsWith('+')) 680 return QValidator::Invalid; 656 681 657 682 bool ok, overflow; 658 683 double i = QLocalePrivate::bytearrayToDouble(buff.constData(), &ok, &overflow); 659 684 if (overflow) 660 return Invalid;685 return QValidator::Invalid; 661 686 if (!ok) 662 return Intermediate;663 664 if (i >= b && i <=t)665 return Acceptable;666 667 if ( d->notation ==StandardNotation) {668 double max = qMax(qAbs( b), qAbs(t));687 return QValidator::Intermediate; 688 689 if (i >= q->b && i <= q->t) 690 return QValidator::Acceptable; 691 692 if (notation == QDoubleValidator::StandardNotation) { 693 double max = qMax(qAbs(q->b), qAbs(q->t)); 669 694 if (max < LLONG_MAX) { 670 695 qlonglong n = pow10(numDigits(qlonglong(max))) - 1; 671 696 if (qAbs(i) > n) 672 return Invalid;697 return QValidator::Invalid; 673 698 } 674 699 } 675 700 676 return Intermediate;701 return QValidator::Intermediate; 677 702 } 678 703 -
trunk/src/gui/widgets/qvalidator.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 106 106 107 107 QValidator::State validate(QString &, int &) const; 108 void fixup(QString &input) const; 108 109 109 110 void setBottom(int); … … 137 138 Q_PROPERTY(double top READ top WRITE setTop) 138 139 Q_PROPERTY(int decimals READ decimals WRITE setDecimals) 140 Q_ENUMS(Notation) 139 141 Q_PROPERTY(Notation notation READ notation WRITE setNotation) 140 142 141 143 public: 142 explicit QDoubleValidator(QObject * parent );144 explicit QDoubleValidator(QObject * parent = 0); 143 145 QDoubleValidator(double bottom, double top, int decimals, QObject * parent); 144 146 ~QDoubleValidator(); … … 184 186 185 187 public: 186 explicit QRegExpValidator(QObject *parent );188 explicit QRegExpValidator(QObject *parent = 0); 187 189 QRegExpValidator(const QRegExp& rx, QObject *parent); 188 190 ~QRegExpValidator(); -
trunk/src/gui/widgets/qwidgetanimator.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qwidgetanimator_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qwidgetresizehandler.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qwidgetresizehandler_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/qworkspace.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include "qbitmap.h" 46 46 #include "qcursor.h" 47 #include "qdatetime.h"48 47 #include "qdesktopwidget.h" 49 48 #include "qevent.h" … … 60 59 #include "qstyle.h" 61 60 #include "qstyleoption.h" 61 #include "qelapsedtimer.h" 62 62 #include "qtooltip.h" 63 63 #include "qdebug.h" … … 451 451 if (d->flags & Qt::WindowSystemMenuHint) { 452 452 d->buttonDown = QStyle::SC_None; 453 static Q Time*t = 0;453 static QElapsedTimer *t = 0; 454 454 static QWorkspaceTitleBar *tc = 0; 455 455 if (!t) 456 t = new Q Time;456 t = new QElapsedTimer; 457 457 if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) { 458 458 emit showOperationMenu(); … … 1840 1840 { 1841 1841 Q_D(QWorkspace); 1842 static Q Time* t = 0;1842 static QElapsedTimer* t = 0; 1843 1843 static QWorkspace* tc = 0; 1844 1844 if (o == d->maxtools) { … … 1848 1848 QMenuBar* b = (QMenuBar*)o->parent(); 1849 1849 if (!t) 1850 t = new Q Time;1850 t = new QElapsedTimer; 1851 1851 if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) { 1852 1852 if (isRightToLeft()) { -
trunk/src/gui/widgets/qworkspace.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/widgets/widgets.pri
r561 r846 165 165 } 166 166 167 symbian *: {167 symbian: { 168 168 SOURCES += widgets/qmenu_symbian.cpp 169 169 }
Note:
See TracChangeset
for help on using the changeset viewer.