diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
commit | 802498fcd43558a10bb7477d3957cdd27fd8ec09 (patch) | |
tree | c40ddd859b032ffa7ed9c6df1173312c0bb1947d /src/gui/widgets | |
parent | 901fee7e610ec53f744416aeeca89c4605923120 (diff) | |
parent | 538e7b8ddf45936bb274ed3230b591b3459edfa7 (diff) | |
download | Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.zip Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.gz Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.bz2 |
Merge remote branch 'qt/master' into file-engine-refactor
Conflicts:
demos/declarative/minehunt/minehunt.pro
src/corelib/io/io.pri
src/corelib/io/qfsfileengine.cpp
src/corelib/io/qfsfileengine_unix.cpp
src/corelib/io/qfsfileengine_win.cpp
src/s60installs/bwins/QtCoreu.def
src/s60installs/bwins/QtDeclarativeu.def
src/s60installs/bwins/QtGuiu.def
src/s60installs/eabi/QtCoreu.def
src/s60installs/eabi/QtDeclarativeu.def
src/s60installs/eabi/QtGuiu.def
tests/auto/qapplication/test/test.pro
tests/auto/qaudioinput/qaudioinput.pro
tests/auto/qaudiooutput/qaudiooutput.pro
tests/auto/qchar/qchar.pro
tests/auto/qdiriterator/qdiriterator.pro
tests/auto/qsound/qsound.pro
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qabstractslider.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qcocoamenu_mac.mm | 22 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qdatetimeedit.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindow.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout_mac.mm | 31 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout_p.h | 15 | ||||
-rw-r--r-- | src/gui/widgets/qmenu.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/qmenubar.cpp | 30 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qvalidator.cpp | 45 | ||||
-rw-r--r-- | src/gui/widgets/widgets.pri | 2 |
14 files changed, 131 insertions, 56 deletions
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index f38bae7..a8b39f4 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -722,7 +722,7 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb #else // Native UI-elements on Mac can scroll hundreds of lines at a time as // a result of acceleration. So keep the same behaviour in Qt, and - // dont restrict stepsToScroll to certain maximum (pageStep): + // don't restrict stepsToScroll to certain maximum (pageStep): stepsToScroll = int(offset_accumulated); #endif offset_accumulated -= int(offset_accumulated); diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm index 15fae23..b670186 100644 --- a/src/gui/widgets/qcocoamenu_mac.mm +++ b/src/gui/widgets/qcocoamenu_mac.mm @@ -156,10 +156,14 @@ QT_USE_NAMESPACE // In every other case we return NO, which means that Cocoa can do as it pleases // (i.e., fire the menu action). NSMenuItem *whichItem; + // Change the private unicode keys to the ones used in setting the "Key Equivalents" + extern NSString *qt_mac_removePrivateUnicode(NSString* string); + NSString *characters = qt_mac_removePrivateUnicode([event characters]); if ([self hasShortcut:menu - forKey:[event characters] - forModifiers:([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) - whichItem:&whichItem]) { + forKey:characters + // Interested only in Shift, Cmd, Ctrl & Alt Keys, so ignoring masks like, Caps lock, Num Lock ... + forModifiers:([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask)) + whichItem:&whichItem]) { QWidget *widget = 0; QAction *qaction = 0; if (whichItem && [whichItem tag]) { @@ -170,6 +174,9 @@ QT_USE_NAMESPACE qApp->activePopupWidget()->focusWidget() : qApp->activePopupWidget()); else if (QApplicationPrivate::focus_widget) widget = QApplicationPrivate::focus_widget; + // If we could not find any receivers, pass it to the active window + if (!widget) + widget = qApp->activeWindow(); if (qaction && widget) { int key = qaction->shortcut(); QKeyEvent accel_ev(QEvent::ShortcutOverride, (key & (~Qt::KeyboardModifierMask)), @@ -177,11 +184,10 @@ QT_USE_NAMESPACE accel_ev.ignore(); qt_sendSpontaneousEvent(widget, &accel_ev); if (accel_ev.isAccepted()) { - if (qt_dispatchKeyEvent(event, widget)) { - *target = nil; - *action = nil; - return YES; - } + qt_dispatchKeyEvent(event, widget); + *target = nil; + *action = nil; + return YES; } } } diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index b857e94..ced0d73f 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2486,7 +2486,7 @@ void QComboBox::showPopup() listRect.setWidth(listRect.height()); //by default popup is centered on screen in landscape listRect.moveCenter(screen.center()); - if (staConTopRect.IsEmpty()) { + if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) { // landscape without stacon, menu should be at the right (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) : listRect.setLeft(screen.left()); diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 36a3147..f2e8fd2 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -832,11 +832,11 @@ QString QDateTimeEdit::sectionText(Section section) const This format is the same as the one used described in QDateTime::toString() and QDateTime::fromString() - Example format strings(assuming that the date is 2nd of July 1969): + Example format strings (assuming that the date is 2nd of July 1969): \table \header \i Format \i Result - \row \i dd.MM.yyyy \i 02.07.1969 + \row \i dd.MM.yyyy \i 02.07.1969 \row \i MMM d yy \i Jul 2 69 \row \i MMMM d yy \i July 2 69 \endtable diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index f338f40..a283da6 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -112,7 +112,7 @@ void QLineControl::updateDisplayText(bool forceUpdate) Copies the currently selected text into the clipboard using the given \a mode. - + \note If the echo mode is set to a mode other than Normal then copy will not work. This is to prevent using copy as a method of bypassing password features of the line control. @@ -486,7 +486,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) /*! \internal - Draws the display text for the line control using the given + Draws the display text for the line control using the given \a painter, \a clip, and \a offset. Which aspects of the display text are drawn is specified by the given \a flags. diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index caaef68..0a33220 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -139,7 +139,10 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const The length of the text can be constrained to maxLength(). The text can be arbitrarily constrained using a validator() or an - inputMask(), or both. + inputMask(), or both. When switching between a validator and an input mask + on the same line edit, it is best to clear the validator or input mask to + prevent undefined behavior. + A related class is QTextEdit which allows multi-line, rich text editing. diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 4ca11b0..da902d5 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -78,6 +78,7 @@ public: : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_WS_MAC , useHIToolBar(false) + , activateUnifiedToolbarAfterFullScreen(false) #endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) @@ -89,6 +90,7 @@ public: Qt::ToolButtonStyle toolButtonStyle; #ifdef Q_WS_MAC bool useHIToolBar; + bool activateUnifiedToolbarAfterFullScreen; #endif void init(); QList<int> hoverSeparator; @@ -502,7 +504,7 @@ void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) */ QMenuBar *QMainWindow::menuBar() const { - QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar()); + QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); if (!menuBar) { QMainWindow *self = const_cast<QMainWindow *>(this); menuBar = new QMenuBar(self); @@ -1501,8 +1503,6 @@ bool QMainWindow::event(QEvent *event) \i Before Qt 4.5, if you called showFullScreen() on the main window, the QToolbar would disappear since it is considered to be part of the title bar. Qt 4.5 and up will now work around this by pulling the toolbars out and back into the regular toolbar and vice versa when you swap out. - However, a good practice would be that turning off the unified toolbar before you call - showFullScreen() and restoring it after you call showNormal(). \endlist Setting this back to false will remove these restrictions. @@ -1516,14 +1516,21 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) return; - // ### Disable the unified toolbar when using anything but the native graphics system. - // ### Disable when using alien widgets as well - if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false) + // ### Disable when using alien widgets + if (testAttribute(Qt::WA_NativeWindow) == false) { return; + } d->useHIToolBar = set; createWinId(); // We need the hiview for down below. +#ifdef QT_MAC_USE_COCOA + // Activate the unified toolbar with the raster engine. + if (windowSurface()) { + d->layout->unifiedSurface = new QUnifiedToolbarSurface(this); + } +#endif // QT_MAC_USE_COCOA + d->layout->updateHIToolBarStatus(); // Enabling the unified toolbar clears the opaque size grip setting, update it. d->macUpdateOpaqueSizeGrip(); diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index 1bfc746..9e26423 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -43,6 +43,7 @@ #include <qtoolbar.h> #include <private/qtoolbarlayout_p.h> #include <private/qt_cocoa_helpers_mac_p.h> +#include <private/qtoolbar_p.h> #ifndef QT_MAC_USE_COCOA #include <Carbon/Carbon.h> @@ -408,6 +409,7 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar beforeIndex = qtoolbarsInUnifiedToolbarList.size(); int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar); + #ifndef QT_MAC_USE_COCOA HIToolbarRef macToolbar = NULL; if ((GetWindowToolbar(window, &macToolbar) == noErr) && !macToolbar) { @@ -444,6 +446,18 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar #endif } qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar); + + // Adding to the unified toolbar surface for the raster engine. + if (layoutState.mainWindow->windowSurface()) { + QPoint offset(0, 0); + for (int i = 0; i < beforeIndex; ++i) { + offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width()); + } +#ifdef QT_MAC_USE_COCOA + unifiedSurface->insertToolbar(toolbar, offset); +#endif // QT_MAC_USE_COCOA + } + #ifndef QT_MAC_USE_COCOA QCFType<HIToolbarItemRef> outItem; const QObject *stupidArray[] = { toolbar, this }; @@ -460,6 +474,19 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar #endif } +#ifdef QT_MAC_USE_COCOA +void QMainWindowLayout::updateUnifiedToolbarOffset() +{ + QPoint offset(0, 0); + + for (int i = 1; i < qtoolbarsInUnifiedToolbarList.length(); ++i) { + offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i - 1)->size().width()); + qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset; + } +} +#endif // QT_MAC_USE_COCOA + + void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) { QHash<void *, QToolBar *>::iterator it = unifiedToolbarHash.begin(); @@ -533,11 +560,11 @@ void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const QMacCocoaAutoReleasePool pool; QWidgetItem layoutItem(tb); QSize size = layoutItem.maximumSize(); - NSSize nssize = NSMakeSize(size.width(), size.height() - 2); + NSSize nssize = NSMakeSize(size.width(), size.height()); [item setMaxSize:nssize]; size = layoutItem.minimumSize(); nssize.width = size.width(); - nssize.height = size.height() - 2; + nssize.height = size.height(); [item setMinSize:nssize]; } #else diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index e1b981c..661d49d 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -85,7 +85,11 @@ typedef HIObjectRef HIToolbarItemRef; typedef const void * CFTypeRef; typedef const struct __CFString * CFStringRef; -#endif +# ifdef QT_MAC_USE_COCOA +#include <private/qunifiedtoolbarsurface_mac_p.h> +# endif // QT_MAC_USE_COCOA + +#endif // Q_WS_MAC QT_BEGIN_NAMESPACE @@ -335,9 +339,16 @@ public: void cleanUpMacToolbarItems(); void fixSizeInUnifiedToolbar(QToolBar *tb) const; bool useHIToolBar; + bool activateUnifiedToolbarAfterFullScreen; void syncUnifiedToolbarVisibility(); bool blockVisiblityCheck; -#endif + +#ifdef QT_MAC_USE_COCOA + QUnifiedToolbarSurface *unifiedSurface; + void updateUnifiedToolbarOffset(); +#endif // QT_MAC_USE_COCOA + +#endif // Q_WS_MAC }; QT_END_NAMESPACE diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h index 7708e05..77f3b1a 100644 --- a/src/gui/widgets/qmenu.h +++ b/src/gui/widgets/qmenu.h @@ -51,6 +51,10 @@ #include <QtGui/qpixmap.h> #endif +#ifdef Q_WS_WINCE +#include <windef.h> // for HMENU +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index df16f7f..ae56fa5 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1628,10 +1628,10 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event) } /*! - \internal + Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if +the location has a separator. - Return the item at \a pt, or 0 if there is no item there or if it is - a separator item. + \sa addAction(), addSeparator() */ QAction *QMenuBar::actionAt(const QPoint &pt) const { @@ -1640,9 +1640,9 @@ QAction *QMenuBar::actionAt(const QPoint &pt) const } /*! - \internal + Returns the geometry of action \a act as a QRect. - Returns the geometry of action \a act. + \sa actionAt() */ QRect QMenuBar::actionGeometry(QAction *act) const { @@ -1836,10 +1836,17 @@ void QMenuBarPrivate::_q_updateLayout() } /*! - \internal + \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner) - This sets widget \a w to be shown directly on the left of the first or - the right of the last menu item, depending on \a corner. + This sets the given \a widget to be shown directly on the left of the first + menu item, or on the right of the last menu item, depending on \a corner. + + The menu bar takes ownership of \a widget, reparenting it into the menu bar. + However, if the \a corner already contains a widget, this previous widget + will no longer be managed and will still be a visible child of the menu bar. + + \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner + will result in a warning. */ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) { @@ -1869,10 +1876,11 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) } /*! - \internal + Returns the widget on the left of the first or on the right of the last menu + item, depending on \a corner. - Returns the widget in the left of the first or the right of the last menu - item, depending on \a corner. + \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner + will result in a warning. */ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const { diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 4541730..6b3f444 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -773,7 +773,7 @@ Qt::Alignment QTextEdit::alignment() const is the document's parent object. The parent object of the provided document remains the owner of the object. - If the current document is a child of the text editor, then it is deleted. + The editor does not delete the current document, even if it is a child of the editor. \sa document() */ diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp index b75db45..130d091 100644 --- a/src/gui/widgets/qvalidator.cpp +++ b/src/gui/widgets/qvalidator.cpp @@ -499,6 +499,8 @@ public: } QDoubleValidator::Notation notation; + + QValidator::State validateWithLocale(QString & input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const; }; @@ -654,42 +656,49 @@ QValidator::State QDoubleValidator::validate(QString & input, int &) const break; } + State currentLocaleValidation = d->validateWithLocale(input, numMode, locale()); + if (currentLocaleValidation == Acceptable || locale().language() == QLocale::C) + return currentLocaleValidation; + State cLocaleValidation = d->validateWithLocale(input, numMode, QLocale(QLocale::C)); + return qMax(currentLocaleValidation, cLocaleValidation); +} + +QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const +{ + Q_Q(const QDoubleValidator); QByteArray buff; - if (!locale().d()->validateChars(input, numMode, &buff, dec)) { - QLocale cl(QLocale::C); - if (!cl.d()->validateChars(input, numMode, &buff, dec)) - return Invalid; - } + if (!locale.d()->validateChars(input, numMode, &buff, q->dec)) + return QValidator::Invalid; if (buff.isEmpty()) - return Intermediate; + return QValidator::Intermediate; - if (b >= 0 && buff.startsWith('-')) - return Invalid; + if (q->b >= 0 && buff.startsWith('-')) + return QValidator::Invalid; - if (t < 0 && buff.startsWith('+')) - return Invalid; + if (q->t < 0 && buff.startsWith('+')) + return QValidator::Invalid; bool ok, overflow; double i = QLocalePrivate::bytearrayToDouble(buff.constData(), &ok, &overflow); if (overflow) - return Invalid; + return QValidator::Invalid; if (!ok) - return Intermediate; + return QValidator::Intermediate; - if (i >= b && i <= t) - return Acceptable; + if (i >= q->b && i <= q->t) + return QValidator::Acceptable; - if (d->notation == StandardNotation) { - double max = qMax(qAbs(b), qAbs(t)); + if (notation == QDoubleValidator::StandardNotation) { + double max = qMax(qAbs(q->b), qAbs(q->t)); if (max < LLONG_MAX) { qlonglong n = pow10(numDigits(qlonglong(max))) - 1; if (qAbs(i) > n) - return Invalid; + return QValidator::Invalid; } } - return Intermediate; + return QValidator::Intermediate; } diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 937b8d6..669b838 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -144,7 +144,7 @@ SOURCES += \ widgets/qplaintextedit.cpp \ widgets/qprintpreviewwidget.cpp -!embedded:mac { +!embedded:!qpa:mac { HEADERS += widgets/qmacnativewidget_mac.h \ widgets/qmaccocoaviewcontainer_mac.h OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \ |