diff options
Diffstat (limited to 'src/gui')
58 files changed, 1545 insertions, 378 deletions
diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm index f6b88bb..9e4fdd1 100644 --- a/src/gui/dialogs/qcolordialog_mac.mm +++ b/src/gui/dialogs/qcolordialog_mac.mm @@ -44,6 +44,7 @@ #include <qapplication.h> #include <qtimer.h> #include <qdialogbuttonbox.h> +#include <qabstracteventdispatcher.h> #include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <qdebug.h> @@ -319,6 +320,7 @@ QT_USE_NAMESPACE QMacCocoaAutoReleasePool pool; mDialogIsExecuting = true; [NSApp runModalForWindow:mColorPanel]; + QAbstractEventDispatcher::instance()->interrupt(); if (mResultCode == NSCancelButton) mPriv->colorDialog()->reject(); else @@ -411,7 +413,7 @@ void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial, void QColorDialogPrivate::closeCocoaColorPanel() { - [[static_cast<QCocoaColorPanelDelegate *>(delegate) colorPanel] close]; + [static_cast<QCocoaColorPanelDelegate *>(delegate) onCancelClicked]; } void QColorDialogPrivate::releaseCocoaColorPanelDelegate() diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/gui/dialogs/qerrormessage.cpp index 436ef94..762936a 100644 --- a/src/gui/dialogs/qerrormessage.cpp +++ b/src/gui/dialogs/qerrormessage.cpp @@ -245,12 +245,6 @@ QErrorMessage::QErrorMessage(QWidget * parent) Q_D(QErrorMessage); QGridLayout * grid = new QGridLayout(this); d->icon = new QLabel(this); -#ifdef QT_SOFTKEYS_ENABLED - d->okAction = new QAction(this); - d->okAction->setSoftKeyRole(QAction::PositiveSoftKey); - connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept())); - addAction(d->okAction); -#endif #ifndef QT_NO_MESSAGEBOX d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); @@ -262,6 +256,13 @@ QErrorMessage::QErrorMessage(QWidget * parent) d->again->setChecked(true); grid->addWidget(d->again, 1, 1, Qt::AlignTop); d->ok = new QPushButton(this); +#ifdef QT_SOFTKEYS_ENABLED + d->okAction = new QAction(d->ok); + d->okAction->setSoftKeyRole(QAction::PositiveSoftKey); + connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept())); + addAction(d->okAction); +#endif + #if defined(Q_WS_WINCE) || defined(Q_WS_S60) d->ok->setFixedSize(0,0); diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 3a4ecce..8e4c461 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -62,6 +62,7 @@ #include <qvarlengtharray.h> #include <qdesktopwidget.h> #include <stdlib.h> +#include <qabstracteventdispatcher.h> #include "ui_qfiledialog.h" QT_BEGIN_NAMESPACE @@ -245,6 +246,8 @@ QT_USE_NAMESPACE mReturnCode = [mSavePanel runModalForDirectory:mCurrentDir file:selectable ? filename : @"untitled"]; + + QAbstractEventDispatcher::instance()->interrupt(); return (mReturnCode == NSOKButton); } diff --git a/src/gui/dialogs/qprintdialog_mac.mm b/src/gui/dialogs/qprintdialog_mac.mm index 667fc40..56a065a 100644 --- a/src/gui/dialogs/qprintdialog_mac.mm +++ b/src/gui/dialogs/qprintdialog_mac.mm @@ -122,6 +122,8 @@ QT_END_NAMESPACE QT_USE_NAMESPACE +#ifdef QT_MAC_USE_COCOA + @class QCocoaPrintPanelDelegate; @interface QCocoaPrintPanelDelegate : NSObject { @@ -197,6 +199,8 @@ QT_USE_NAMESPACE } @end +#endif + QT_BEGIN_NAMESPACE extern void macStartInterceptWindowTitle(QWidget *window); diff --git a/src/gui/dialogs/qprogressdialog.cpp b/src/gui/dialogs/qprogressdialog.cpp index 5fb10bf..f5024bb 100644 --- a/src/gui/dialogs/qprogressdialog.cpp +++ b/src/gui/dialogs/qprogressdialog.cpp @@ -453,7 +453,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton) cancelButton->show(); #else { - d->cancelAction = new QAction(cancelButton->text(), this); + d->cancelAction = new QAction(cancelButton->text(), cancelButton); d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled())); addAction(d->cancelAction); diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index 0f6d353..0102e25 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -1340,7 +1340,7 @@ bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const pushButton->setText(buttonDefaultText(wizStyle, which, this)); #ifdef QT_SOFTKEYS_ENABLED - QAction *softKey = new QAction(pushButton->text(), antiFlickerWidget); + QAction *softKey = new QAction(pushButton->text(), pushButton); QAction::SoftKeyRole softKeyRole; switch(which) { case QWizard::NextButton: diff --git a/src/gui/egl/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp index 590b666..df1179a 100644 --- a/src/gui/egl/qegl_qws.cpp +++ b/src/gui/egl/qegl_qws.cpp @@ -83,7 +83,8 @@ static QScreen *screenForDevice(QPaintDevice *device) screenNumber = 0; screen = screen->subScreens()[screenNumber]; } - while (screen->classId() == QScreen::ProxyClass) { + while (screen->classId() == QScreen::ProxyClass || + screen->classId() == QScreen::TransformedClass) { screen = static_cast<QProxyScreen *>(screen)->screen(); } return screen; diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri index fa4dd68..84253b5 100644 --- a/src/gui/embedded/directfb.pri +++ b/src/gui/embedded/directfb.pri @@ -1,7 +1,7 @@ # These defines might be necessary if your DirectFB driver doesn't # support all of the DirectFB API. # -#DEFINES += QT_NO_DIRECTFB_SUBSURFACE +#DEFINES += QT_DIRECTFB_SUBSURFACE #DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR #DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER #DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 81bbb5c..45627f6 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7287,10 +7287,16 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent QGraphicsItem::d_ptr->isObject = true; } -void QGraphicsObject::grabGesture(Qt::GestureType type, Qt::GestureContext context) +/*! + Subscribes the graphics object to the given \a gesture for the specified \a context. + + \sa QGestureEvent +*/ + +void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) { QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); - d->gestureContext.insert(type, context); + d->gestureContext.insert(gesture, context); (void)QGestureManager::instance(); // create a gesture manager } diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 15b9ff3..b7a3962 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -973,7 +973,7 @@ void QGraphicsProxyWidget::hideEvent(QHideEvent *event) void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { Q_D(QGraphicsProxyWidget); - if (!event || !d->widget || !d->widget->isVisible()) + if (!event || !d->widget || !d->widget->isVisible() || !hasFocus()) return; // Find widget position and receiver. diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 0f33a66..a624b10 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -420,8 +420,12 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { + QSet<QGraphicsItem *>::Iterator it; const QVariant booleanTrueVariant(true); - foreach (QGraphicsItem *item, unpolishedItems) { + while (!unpolishedItems.isEmpty()) { + it = unpolishedItems.begin(); + QGraphicsItem *item = *it; + unpolishedItems.erase(it); if (!item->d_ptr->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); @@ -431,7 +435,6 @@ void QGraphicsScenePrivate::_q_polishItems() QApplication::sendEvent((QGraphicsWidget *)item, &event); } } - unpolishedItems.clear(); } void QGraphicsScenePrivate::_q_processDirtyItems() @@ -549,7 +552,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) selectedItems.remove(item); hoverItems.removeAll(item); cachedItemsUnderMouse.removeAll(item); - unpolishedItems.removeAll(item); + unpolishedItems.remove(item); resetDirtyItem(item); //We remove all references of item from the sceneEventFilter arrays @@ -2484,7 +2487,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) if (!item->d_ptr->explicitlyHidden) { if (d->unpolishedItems.isEmpty()) QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); - d->unpolishedItems << item; + d->unpolishedItems.insert(item); } // Reenable selectionChanged() for individual items @@ -5294,7 +5297,7 @@ void QGraphicsScene::setActivePanel(QGraphicsItem *item) /*! \since 4.4 - Returns the current active window, or 0 if there is no window is currently + Returns the current active window, or 0 if no window is currently active. \sa QGraphicsScene::setActiveWindow() diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 5000860..8073695 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -108,7 +108,7 @@ public: QPainterPath selectionArea; int selectionChanging; QSet<QGraphicsItem *> selectedItems; - QList<QGraphicsItem *> unpolishedItems; + QSet<QGraphicsItem *> unpolishedItems; QList<QGraphicsItem *> topLevelItems; bool needSortTopLevelItems; bool holesInTopLevelSiblingIndex; diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 5412e11..46c5431 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -78,6 +78,8 @@ static QString fallbackTheme() return X11->desktopVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); + } else { + return QLatin1String("hicolor"); } #endif return QString(); @@ -87,6 +89,8 @@ QIconLoader::QIconLoader() : m_themeKey(1), m_supportsSvg(false) { m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); + if (m_systemTheme.isEmpty()) + m_systemTheme = fallbackTheme(); QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, QLatin1String("/iconengines"), @@ -107,6 +111,8 @@ void QIconLoader::updateSystemTheme() // Only change if this is not explicitly set by the user if (m_userTheme.isEmpty()) { QString theme = qt_guiPlatformPlugin()->systemIconThemeName(); + if (theme.isEmpty()) + theme = fallbackTheme(); if (theme != m_systemTheme) { m_systemTheme = theme; invalidateKey(); diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 554c0f3..9ae8d72 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -716,6 +716,8 @@ void QS60PixmapData::beginDataAccess() void QS60PixmapData::endDataAccess(bool readOnly) const { + Q_UNUSED(readOnly); + if(!cfbsBitmap) return; diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 37f4184..d91cedd 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1697,7 +1697,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) if ((event->buttons() & Qt::LeftButton) && d->selectionAllowed(index) && d->selectionModel) { setState(DragSelectingState); QItemSelectionModel::SelectionFlags command = selectionCommand(index, event); - if (command.testFlag(QItemSelectionModel::Toggle)) { + if (d->ctrlDragSelectionFlag != QItemSelectionModel::NoUpdate && command.testFlag(QItemSelectionModel::Toggle)) { command &= ~QItemSelectionModel::Toggle; command |= d->ctrlDragSelectionFlag; } @@ -2185,6 +2185,9 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) } else { d->selectionModel->setCurrentIndex(newCurrent, command); d->pressedPosition = visualRect(newCurrent).center() + d->offset(); + // We copy the same behaviour as for mousePressEvent(). + QRect rect(d->pressedPosition - d->offset(), QSize(1, 1)); + setSelection(rect, command); } return; } @@ -3026,7 +3029,7 @@ void QAbstractItemView::update(const QModelIndex &index) //this test is important for peformance reason //For example in dataChanged we simply update all the cells without checking //it can be a major bottleneck to update rects that aren't even part of the viewport - if (d->viewport->geometry().intersects(rect)) + if (d->viewport->rect().intersects(rect)) d->viewport->update(rect); } } diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 0045bd5..fc9820f 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -524,8 +524,8 @@ QSize QHeaderView::sizeHint() const Q_D(const QHeaderView); if (d->cachedSizeHint.isValid()) return d->cachedSizeHint; + d->cachedSizeHint = QSize(0, 0); //reinitialize the cached size hint const int sectionCount = count(); - d->executePostedLayout(); // get size hint for the first n sections int i = 0; diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 15bd445..a610b73 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -779,8 +779,6 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter, foreach (QSpanCollection::Span *span, visibleSpans) { int row = span->top(); int col = span->left(); - if (isHidden(row, col)) - continue; QModelIndex index = model->index(row, col, root); if (!index.isValid()) continue; @@ -1119,6 +1117,9 @@ void QTableView::setHorizontalHeader(QHeaderView *header) connect(d->horizontalHeader, SIGNAL(sectionHandleDoubleClicked(int)), this, SLOT(resizeColumnToContents(int))); connect(d->horizontalHeader, SIGNAL(geometriesChanged()), this, SLOT(updateGeometries())); + + //update the sorting enabled states on the new header + setSortingEnabled(d->sortingEnabled); } /*! @@ -1480,12 +1481,30 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi ++column; while (isRowHidden(d->logicalRow(row)) && row < bottom) ++row; + d->visualCursor = QPoint(column, row); return d->model->index(d->logicalRow(row), d->logicalColumn(column), d->root); } - int visualRow = d->visualRow(current.row()); + // Update visual cursor if current index has changed. + QPoint visualCurrent(d->visualColumn(current.column()), d->visualRow(current.row())); + if (visualCurrent != d->visualCursor) { + if (d->hasSpans()) { + QSpanCollection::Span span = d->span(current.row(), current.column()); + if (span.top() > d->visualCursor.y() || d->visualCursor.y() > span.bottom() + || span.left() > d->visualCursor.x() || d->visualCursor.x() > span.right()) + d->visualCursor = visualCurrent; + } else { + d->visualCursor = visualCurrent; + } + } + + int visualRow = d->visualCursor.y(); + if (visualRow > bottom) + visualRow = bottom; Q_ASSERT(visualRow != -1); - int visualColumn = d->visualColumn(current.column()); + int visualColumn = d->visualCursor.x(); + if (visualColumn > right) + visualColumn = right; Q_ASSERT(visualColumn != -1); if (isRightToLeft()) { @@ -1496,22 +1515,33 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi } switch (cursorAction) { - case MoveUp: + case MoveUp: { + int originalRow = visualRow; #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && visualRow == 0) visualRow = d->visualRow(model()->rowCount() - 1) + 1; + // FIXME? visualRow = bottom + 1; #endif - --visualRow; - while (visualRow > 0 && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn)) + int r = d->logicalRow(visualRow); + int c = d->logicalColumn(visualColumn); + if (r != -1 && d->hasSpans()) { + QSpanCollection::Span span = d->span(r, c); + if (span.width() > 1 || span.height() > 1) + visualRow = d->visualRow(span.top()); + } + while (visualRow >= 0) { --visualRow; - if (d->hasSpans()) { - int row = d->logicalRow(visualRow); - QSpanCollection::Span span = d->span(row, current.column()); - visualRow = d->visualRow(span.top()); - visualColumn = d->visualColumn(span.left()); + r = d->logicalRow(visualRow); + c = d->logicalColumn(visualColumn); + if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c))) + break; } + if (visualRow < 0) + visualRow = originalRow; break; - case MoveDown: + } + case MoveDown: { + int originalRow = visualRow; if (d->hasSpans()) { QSpanCollection::Span span = d->span(current.row(), current.column()); visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); @@ -1520,71 +1550,106 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi if (QApplication::keypadNavigationEnabled() && visualRow >= bottom) visualRow = -1; #endif - ++visualRow; - while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn)) + int r = d->logicalRow(visualRow); + int c = d->logicalColumn(visualColumn); + if (r != -1 && d->hasSpans()) { + QSpanCollection::Span span = d->span(r, c); + if (span.width() > 1 || span.height() > 1) + visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); + } + while (visualRow <= bottom) { ++visualRow; - if (d->hasSpans()) { - int row = d->logicalRow(visualRow); - QSpanCollection::Span span = d->span(row, current.column()); - visualColumn = d->visualColumn(span.left()); + r = d->logicalRow(visualRow); + c = d->logicalColumn(visualColumn); + if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c))) + break; } + if (visualRow > bottom) + visualRow = originalRow; break; - case MovePrevious: { - int left = 0; - while (d->isVisualColumnHiddenOrDisabled(visualRow, left) && left < right) - ++left; - if (visualColumn == left) { - visualColumn = right; - int top = 0; - while (top < bottom && d->isVisualRowHiddenOrDisabled(top, visualColumn)) - ++top; - if (visualRow == top) + } + case MovePrevious: + case MoveLeft: { + int originalRow = visualRow; + int originalColumn = visualColumn; + bool firstTime = true; + bool looped = false; + bool wrapped = false; + do { + int r = d->logicalRow(visualRow); + int c = d->logicalColumn(visualColumn); + if (firstTime && c != -1 && d->hasSpans()) { + firstTime = false; + QSpanCollection::Span span = d->span(r, c); + if (span.width() > 1 || span.height() > 1) + visualColumn = d->visualColumn(span.left()); + } + while (visualColumn >= 0) { + --visualColumn; + r = d->logicalRow(visualRow); + c = d->logicalColumn(visualColumn); + if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c))) + break; + if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) { + looped = true; + break; + } + } + if (cursorAction == MoveLeft || visualColumn >= 0) + break; + visualColumn = right + 1; + if (visualRow == 0) { + wrapped == true; visualRow = bottom; - else - --visualRow; - while (visualRow > 0 && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn)) + } else { --visualRow; - break; - } // else MoveLeft - } - case MoveLeft: - --visualColumn; - while (visualColumn > 0 && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn)) - --visualColumn; - if (d->hasSpans()) { - int column = d->logicalColumn(visualColumn); - QSpanCollection::Span span = d->span(current.row(), column); - visualRow = d->visualRow(span.top()); - visualColumn = d->visualColumn(span.left()); - } + } + } while (!looped); + if (visualColumn < 0) + visualColumn = originalColumn; break; + } case MoveNext: - if (visualColumn == right) { - visualColumn = 0; - while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn)) + case MoveRight: { + int originalRow = visualRow; + int originalColumn = visualColumn; + bool firstTime = true; + bool looped = false; + bool wrapped = false; + do { + int r = d->logicalRow(visualRow); + int c = d->logicalColumn(visualColumn); + if (firstTime && c != -1 && d->hasSpans()) { + firstTime = false; + QSpanCollection::Span span = d->span(r, c); + if (span.width() > 1 || span.height() > 1) + visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); + } + while (visualColumn <= right) { ++visualColumn; - if (visualRow == bottom) + r = d->logicalRow(visualRow); + c = d->logicalColumn(visualColumn); + if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c))) + break; + if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) { + looped = true; + break; + } + } + if (cursorAction == MoveRight || visualColumn <= right) + break; + visualColumn = -1; + if (visualRow == bottom) { + wrapped = true; visualRow = 0; - else - ++visualRow; - while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn)) + } else { ++visualRow; - break; - } // else MoveRight - case MoveRight: - if (d->hasSpans()) { - QSpanCollection::Span span = d->span(current.row(), current.column()); - visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); - } - ++visualColumn; - while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn)) - ++visualColumn; - if (d->hasSpans()) { - int column = d->logicalColumn(visualColumn); - QSpanCollection::Span span = d->span(current.row(), column); - visualRow = d->visualRow(span.top()); - } + } + } while (!looped); + if (visualColumn > right) + visualColumn = originalColumn; break; + } case MoveHome: visualColumn = 0; while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn)) @@ -1613,14 +1678,15 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi return d->model->index(newRow, current.column(), d->root); }} + d->visualCursor = QPoint(visualColumn, visualRow); int logicalRow = d->logicalRow(visualRow); int logicalColumn = d->logicalColumn(visualColumn); if (!d->model->hasIndex(logicalRow, logicalColumn, d->root)) return QModelIndex(); QModelIndex result = d->model->index(logicalRow, logicalColumn, d->root); - if (!isIndexHidden(result) && d->isIndexEnabled(result)) - return d->model->index(logicalRow, logicalColumn, d->root); + if (!d->isRowHidden(logicalRow) && !d->isColumnHidden(logicalColumn) && d->isIndexEnabled(result)) + return result; return QModelIndex(); } @@ -2375,7 +2441,8 @@ bool QTableView::isCornerButtonEnabled() const QRect QTableView::visualRect(const QModelIndex &index) const { Q_D(const QTableView); - if (!d->isIndexValid(index) || index.parent() != d->root || isIndexHidden(index) ) + if (!d->isIndexValid(index) || index.parent() != d->root + || (!d->hasSpans() && isIndexHidden(index))) return QRect(); d->executePostedLayout(); diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h index c785bd7..9fa14c2 100644 --- a/src/gui/itemviews/qtableview_p.h +++ b/src/gui/itemviews/qtableview_p.h @@ -135,7 +135,8 @@ public: rowSectionAnchor(-1), columnSectionAnchor(-1), columnResizeTimerID(0), rowResizeTimerID(0), horizontalHeader(0), verticalHeader(0), - sortingEnabled(false), geometryRecursionBlock(false) + sortingEnabled(false), geometryRecursionBlock(false), + visualCursor(QPoint()) { wrapItemText = true; #ifndef QT_NO_DRAGANDDROP @@ -183,6 +184,7 @@ public: QWidget *cornerWidget; bool sortingEnabled; bool geometryRecursionBlock; + QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. QSpanCollection spans; diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index a086498..21c4e0a 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -571,6 +571,8 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order, colItems.remove(oldRow); vit = sortedInsertionIterator(vit, colItems.end(), order, item); int newRow = qMax((int)(vit - colItems.begin()), 0); + if ((newRow < oldRow) && !(*item < *colItems.at(oldRow - 1)) && !(*colItems.at(oldRow - 1) < *item)) + newRow = oldRow; vit = colItems.insert(vit, item); if (newRow != oldRow) { changed = true; diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 06342d8..040c498 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -623,7 +623,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order, lit = sortedInsertionIterator(lit, lst.end(), order, item); int newRow = qMax(lit - lst.begin(), 0); - if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1))) + if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item )) newRow = oldRow; lit = lst.insert(lit, item); diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 88c1f73..53c2611 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -205,6 +205,7 @@ embedded { qcocoaview_mac_p.h \ qcocoaapplication_mac_p.h \ qcocoaapplicationdelegate_mac_p.h \ + qmacgesturerecognizer_mac_p.h \ qmultitouch_mac_p.h OBJECTIVE_SOURCES += \ @@ -224,7 +225,8 @@ embedded { kernel/qdesktopwidget_mac.mm \ kernel/qeventdispatcher_mac.mm \ kernel/qcocoawindowcustomthemeframe_mac.mm \ - kernel/qmultitouch_mac.mm \ + kernel/qmacgesturerecognizer_mac.mm \ + kernel/qmultitouch_mac.mm HEADERS += \ kernel/qt_cocoa_helpers_mac_p.h \ diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index afc6f63..6f6d706 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -943,7 +943,7 @@ void QApplicationPrivate::initialize() graphics_system = QGraphicsSystemFactory::create(graphics_system_name); #endif #ifndef QT_NO_WHEELEVENT -#ifdef Q_OS_MAC +#ifdef Q_OS_MAC QApplicationPrivate::wheel_scroll_lines = 1; #else QApplicationPrivate::wheel_scroll_lines = 3; @@ -1034,11 +1034,11 @@ QApplication::~QApplication() d->eventDispatcher->closingDown(); d->eventDispatcher = 0; + QApplicationPrivate::is_app_closing = true; + QApplicationPrivate::is_app_running = false; delete qt_desktopWidget; qt_desktopWidget = 0; - QApplicationPrivate::is_app_closing = true; - QApplicationPrivate::is_app_running = false; #ifndef QT_NO_CLIPBOARD delete qt_clipboard; @@ -5619,11 +5619,32 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); } +/*! + \since 4.6 + + Registers the given \a recognizer in the gesture framework and returns a gesture ID + for it. + + The application takes ownership of the \a recognizer and returns the gesture type + ID associated with it. For gesture recognizers which handle custom QGesture + objects (i.e., those which return Qt::CustomGesture in a QGesture::gestureType() + function) the return value is a gesture ID between Qt::CustomGesture and + Qt::LastGestureType, inclusive. + + \sa unregisterGestureRecognizer(), QGestureRecognizer::createGesture(), QGesture +*/ Qt::GestureType QApplication::registerGestureRecognizer(QGestureRecognizer *recognizer) { return QGestureManager::instance()->registerGestureRecognizer(recognizer); } +/*! + \since 4.6 + + Unregisters all gesture recognizers of the specified \a type. + + \sa registerGestureRecognizer() +*/ void QApplication::unregisterGestureRecognizer(Qt::GestureType type) { QGestureManager::instance()->unregisterGestureRecognizer(type); diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index acd1041..cb9dda4 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -352,7 +352,8 @@ QSymbianControl::~QSymbianControl() { if (S60->curWin == this) S60->curWin = 0; - setFocusSafely(false); + if (!QApplicationPrivate::is_app_closing) + setFocusSafely(false); S60->appUi()->RemoveFromStack(this); delete m_longTapDetector; } @@ -463,12 +464,47 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) QT_TRYCATCH_LEAVING(HandlePointerEvent(pEvent)); } +typedef QPair<QWidget*,QMouseEvent> Event; + +/* + * Helper function called by HandlePointerEvent - separated to keep that function readable + */ +static void generateEnterLeaveEvents(QList<Event> &events, QWidget *widgetUnderPointer, + QPoint globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers) +{ + //moved to another widget, create enter and leave events + if (S60->lastPointerEventTarget) { + QMouseEvent mEventLeave(QEvent::Leave, S60->lastPointerEventTarget->mapFromGlobal( + S60->lastCursorPos), S60->lastCursorPos, button, QApplicationPrivate::mouse_buttons, + modifiers); + events.append(Event(S60->lastPointerEventTarget, mEventLeave)); + } + if (widgetUnderPointer) { + QMouseEvent mEventEnter(QEvent::Enter, widgetUnderPointer->mapFromGlobal(globalPos), + globalPos, button, QApplicationPrivate::mouse_buttons, modifiers); + + events.append(Event(widgetUnderPointer, mEventEnter)); +#ifndef QT_NO_CURSOR + S60->curWin = widgetUnderPointer->effectiveWinId(); + if (!QApplication::overrideCursor()) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_set_pointer_sprite(widgetUnderPointer->cursor()); + else +#endif + qt_symbian_setWindowCursor(widgetUnderPointer->cursor(), S60->curWin); + } +#endif + } +} + + void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) { - //### refactor me, getting too complex QMouseEvent::Type type; Qt::MouseButton button; mapS60MouseEventTypeToQt(&type, &button, &pEvent); + Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers); if (m_previousEventLongTap) if (type == QEvent::MouseButtonRelease){ @@ -480,79 +516,76 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) return; // store events for later sending/saving - QWidget *alienWidget; - typedef QPair<QWidget*,QMouseEvent> Event; QList<Event > events; QPoint widgetPos = QPoint(pEvent.iPosition.iX, pEvent.iPosition.iY); TPoint controlScreenPos = PositionRelativeToScreen(); QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos; - if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove) - { - // get the widget where the event happened - alienWidget = qwidget->childAt(widgetPos); - if (!alienWidget) - alienWidget = qwidget; - S60->mousePressTarget = alienWidget; + // widgets interested in the event + QWidget *widgetUnderPointer = qwidget->childAt(widgetPos); + if (!widgetUnderPointer) + widgetUnderPointer = qwidget; //i.e. this container widget + + QWidget *widgetWithMouseGrab = QWidget::mouseGrabber(); + + // handle auto grab of pointer when pressing / releasing + if (!widgetWithMouseGrab && type == QEvent::MouseButtonPress) { + //if previously auto-grabbed, generate a fake mouse release (platform bug: mouse release event was lost) + if (S60->mousePressTarget) { + QMouseEvent mEvent(QEvent::MouseButtonRelease, S60->mousePressTarget->mapFromGlobal(globalPos), globalPos, + button, QApplicationPrivate::mouse_buttons, modifiers); + events.append(Event(S60->mousePressTarget,mEvent)); + } + //auto grab the mouse + widgetWithMouseGrab = S60->mousePressTarget = widgetUnderPointer; + widgetWithMouseGrab->grabMouse(); + } + if (widgetWithMouseGrab && widgetWithMouseGrab == S60->mousePressTarget && type == QEvent::MouseButtonRelease) { + //release the auto grab - note this release event still goes to the autograb widget + S60->mousePressTarget = 0; + widgetWithMouseGrab->releaseMouse(); } - alienWidget = S60->mousePressTarget; + QWidget *widgetToReceiveMouseEvent; + if (widgetWithMouseGrab) + widgetToReceiveMouseEvent = widgetWithMouseGrab; + else + widgetToReceiveMouseEvent = widgetUnderPointer; - if (alienWidget != S60->lastPointerEventTarget) - if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove) - { - //moved to another widget, create enter and leave events - if (S60->lastPointerEventTarget) - { - QMouseEvent mEventLeave(QEvent::Leave, S60->lastPointerEventTarget->mapFromGlobal(S60->lastCursorPos), S60->lastCursorPos, - button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); - events.append(Event(S60->lastPointerEventTarget,mEventLeave)); - } - if (alienWidget) { - QMouseEvent mEventEnter(QEvent::Enter, alienWidget->mapFromGlobal(globalPos), - globalPos, button, QApplicationPrivate::mouse_buttons, mapToQtModifiers( - pEvent.iModifiers)); + //queue QEvent::Enter and QEvent::Leave, if the pointer has moved + if (widgetUnderPointer != S60->lastPointerEventTarget && (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove)) + generateEnterLeaveEvents(events, widgetUnderPointer, globalPos, button, modifiers); - events.append(Event(alienWidget, mEventEnter)); -#ifndef QT_NO_CURSOR - S60->curWin = alienWidget->effectiveWinId(); - if (!QApplication::overrideCursor()) { -#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS - if (S60->brokenPointerCursors) - qt_symbian_set_pointer_sprite(alienWidget->cursor()); - else -#endif - qt_symbian_setWindowCursor(alienWidget->cursor(), S60->curWin); - } -#endif - } - } + //save global state S60->lastCursorPos = globalPos; + S60->lastPointerEventPos = widgetPos; + S60->lastPointerEventTarget = widgetUnderPointer; + #if !defined(QT_NO_CURSOR) && !defined(Q_SYMBIAN_FIXED_POINTER_CURSORS) if (S60->brokenPointerCursors) qt_symbian_move_cursor_sprite(); #endif - S60->lastPointerEventPos = widgetPos; - S60->lastPointerEventTarget = alienWidget; - if (alienWidget) - { - QMouseEvent mEvent(type, alienWidget->mapFromGlobal(globalPos), globalPos, - button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); - events.append(Event(alienWidget,mEvent)); - QEventDispatcherS60 *dispatcher; - // It is theoretically possible for someone to install a different event dispatcher. - if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(alienWidget->d_func()->threadData->eventDispatcher)) != 0) { - if (dispatcher->excludeUserInputEvents()) { - for (int i=0;i < events.count();++i) - { - Event next = events[i]; - dispatcher->saveInputEvent(this, next.first, new QMouseEvent(next.second)); - } - return; + + //queue this event. + Q_ASSERT(widgetToReceiveMouseEvent); + QMouseEvent mEvent(type, widgetToReceiveMouseEvent->mapFromGlobal(globalPos), globalPos, + button, QApplicationPrivate::mouse_buttons, modifiers); + events.append(Event(widgetToReceiveMouseEvent,mEvent)); + QEventDispatcherS60 *dispatcher; + // It is theoretically possible for someone to install a different event dispatcher. + if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(widgetToReceiveMouseEvent->d_func()->threadData->eventDispatcher)) != 0) { + if (dispatcher->excludeUserInputEvents()) { + for (int i=0;i < events.count();++i) + { + Event next = events[i]; + dispatcher->saveInputEvent(this, next.first, new QMouseEvent(next.second)); } + return; } } + + //send events in the queue for (int i=0;i < events.count();++i) { Event next = events[i]; @@ -688,7 +721,7 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), - false, 1, keyEvent.iScanCode, s60Keysym, mods); + false, 1, keyEvent.iScanCode, s60Keysym, keyEvent.iModifiers); // WId wid = reinterpret_cast<RWindowGroup *>(keyEvent.Handle())->Child(); // if (!wid) // Could happen if window isn't shown yet. @@ -948,7 +981,8 @@ void QSymbianControl::setFocusSafely(bool focus) S60->appUi()->RemoveFromStack(this); QT_TRAP_THROWING(S60->appUi()->AddToStackL(this, ECoeStackPriorityDefault, ECoeStackFlagStandard)); - lastFocusedControl = 0; + if(this == lastFocusedControl) + lastFocusedControl = 0; this->SetFocus(false); } } @@ -1121,6 +1155,11 @@ void qt_init(QApplicationPrivate * /* priv */, int) ; } */ + + // Register WId with the metatype system. This is to enable + // QWidgetPrivate::create_sys to used delayed slot invokation in order + // to destroy WId objects during reparenting. + qRegisterMetaType<WId>("WId"); } /***************************************************************************** diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 540f0a2..5bb25fa 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -819,13 +819,16 @@ void qt_init(QApplicationPrivate *priv, int) priv->GetGestureInfo = 0; priv->GetGestureExtraArgs = 0; + priv->CloseGestureInfoHandle = 0; + priv->SetGestureConfig = 0; + priv->GetGestureConfig = 0; + priv->BeginPanningFeedback = 0; + priv->UpdatePanningFeedback = 0; + priv->EndPanningFeedback = 0; #if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES) priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo; priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments; - priv->CloseGestureInfoHandle = (PtrCloseGestureInfoHandle) 0; - priv->SetGestureConfig = (PtrSetGestureConfig) 0; - priv->GetGestureConfig = (PtrGetGestureConfig) 0; #elif !defined(Q_WS_WINCE) priv->GetGestureInfo = (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"), diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index b1c5fc5..4c2a14a 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1066,7 +1066,10 @@ extern "C" { sendToPopup = true; } - if (widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled)) { + if (widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled) + && !(widgetToGetKey->inputMethodHints() & Qt::ImhDigitsOnly + || widgetToGetKey->inputMethodHints() & Qt::ImhFormattedNumbersOnly + || widgetToGetKey->inputMethodHints() & Qt::ImhHiddenText)) { [qt_mac_nativeview_for(widgetToGetKey) interpretKeyEvents:[NSArray arrayWithObject: theEvent]]; } if (sendKeyEvents && !composing) { @@ -1420,29 +1423,29 @@ Qt::DropAction QDragManager::drag(QDrag *o) // convert the image to NSImage. NSImage *image = (NSImage *)qt_mac_create_nsimage(pix); [image retain]; - DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; + DnDParams dndParams = *[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]; // save supported actions - [dndParams->view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; - NSPoint imageLoc = {dndParams->localPoint.x - hotspot.x(), - dndParams->localPoint.y + pix.height() - hotspot.y()}; + [dndParams.view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)]; + NSPoint imageLoc = {dndParams.localPoint.x - hotspot.x(), + dndParams.localPoint.y + pix.height() - hotspot.y()}; NSSize mouseOffset = {0.0, 0.0}; NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - NSPoint windowPoint = [dndParams->theEvent locationInWindow]; + NSPoint windowPoint = [dndParams.theEvent locationInWindow]; dragPrivate()->executed_action = Qt::ActionMask; // do the drag - [dndParams->view retain]; - [dndParams->view dragImage:image + [dndParams.view retain]; + [dndParams.view dragImage:image at:imageLoc offset:mouseOffset - event:dndParams->theEvent + event:dndParams.theEvent pasteboard:pboard - source:dndParams->view + source:dndParams.view slideBack:YES]; - [dndParams->view release]; + [dndParams.view release]; [image release]; dragPrivate()->executed_action = Qt::IgnoreAction; object = 0; - Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction)); + Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams.performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { // check if the receiver points us to a file location. diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/gui/kernel/qcursor_s60.cpp index 0d8283d..7f5c32a 100644 --- a/src/gui/kernel/qcursor_s60.cpp +++ b/src/gui/kernel/qcursor_s60.cpp @@ -110,7 +110,7 @@ void qt_symbian_set_cursor_visible(bool visible) { else cursorSpriteVisible--; Q_ASSERT(cursorSpriteVisible >=0); - + if (cursorSpriteVisible && !S60->mouseInteractionEnabled) { #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS if (S60->brokenPointerCursors) @@ -119,7 +119,7 @@ void qt_symbian_set_cursor_visible(bool visible) { #endif S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); } else if (!cursorSpriteVisible && S60->mouseInteractionEnabled) { -#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS if (S60->brokenPointerCursors) qt_symbian_hide_pointer_sprite(); else @@ -188,7 +188,7 @@ Qt::HANDLE QCursor::handle() const return reinterpret_cast<Qt::HANDLE> (&(d->pcurs)); #ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS - // don't construct shape cursors, QApplication_s60 will use the system cursor instead + // don't construct shape cursors, QApplication_s60 will use the system cursor instead if (!(d->bm)) return 0; #endif @@ -228,12 +228,12 @@ void QCursorData::loadShapeFromResource(RWsSpriteBase& target, QString resource, /* * Constructs the native cursor from resources compiled into QtGui * This is needed only when the platform doesn't have system cursors. - * + * * System cursors are higher performance, since they are constructed once * and shared by all applications by specifying the shape number. * Due to symbian platform security considerations, and the fact most * existing phones have a broken RWsPointerCursor, system cursors are not - * being used. + * being used. */ void QCursorData::constructShapeSprite(RWsSpriteBase& target) { @@ -346,7 +346,7 @@ void QCursorData::constructCursorSprite(RWsSpriteBase& target) member->iMaskBitmap = pixmap.mask().toSymbianCFbsBitmap(); } else { - member->iMaskBitmap = pixmap.createHeuristicMask().toSymbianCFbsBitmap(); + member->iMaskBitmap = 0; //opaque rectangle cursor (due to EDrawModePEN) } } @@ -371,11 +371,11 @@ void qt_symbian_show_pointer_sprite() } else { cursorSprite = QCursor(Qt::ArrowCursor); } - + cursorSprite.d->scurs = RWsSprite(S60->wsSession()); QPoint pos = QCursor::pos(); cursorSprite.d->scurs.Construct(S60->windowGroup(), TPoint(pos.x(), pos.y()), ESpriteNoChildClip | ESpriteNoShadows); - + cursorSprite.d->constructCursorSprite(cursorSprite.d->scurs); cursorSprite.d->scurs.Activate(); } @@ -409,7 +409,7 @@ void qt_symbian_set_pointer_sprite(const QCursor& cursor) * RWsPointerCursor, this function is called in response to pointer events * and when QCursor::setPos() is called. * Performance is worse than a real pointer cursor, due to extra context - * switches vs. the window server moving the cursor by itself. + * switches vs. the window server moving the cursor by itself. */ void qt_symbian_move_cursor_sprite() { @@ -421,7 +421,7 @@ void qt_symbian_move_cursor_sprite() /* * Translate from Qt::CursorShape to OS system pointer cursor list index. * Currently we control the implementation of the system pointer cursor list, - * so this function is trivial. That may not always be the case. + * so this function is trivial. That may not always be the case. */ TInt qt_symbian_translate_cursor_shape(Qt::CursorShape shape) { @@ -462,7 +462,7 @@ void qt_symbian_set_cursor(QWidget *w, bool force) /* * Makes the specified cursor appear above a specific native window group * Called from QSymbianControl and QApplication::restoreOverrideCursor - * + * * Window server is needed for this, so there is no equivalent when using * the sprite workaround. */ @@ -486,7 +486,7 @@ void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &nod /* * Makes the specified cursor appear above a specific native window * Called from QSymbianControl and QApplication::restoreOverrideCursor - * + * * Window server is needed for this, so there is no equivalent when using * the sprite workaround. */ diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp index 3d6ecd2..a8d3ac5 100644 --- a/src/gui/kernel/qdnd_s60.cpp +++ b/src/gui/kernel/qdnd_s60.cpp @@ -277,7 +277,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) qApp->installEventFilter(this); - global_accepted_action = Qt::MoveAction; + global_accepted_action = defaultAction(dragPrivate()->possible_actions, Qt::NoModifier); qt_symbian_dnd_dragging = true; eventLoop = new QEventLoop; @@ -288,7 +288,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) #ifndef QT_NO_CURSOR qt_symbian_set_cursor_visible(false); - + overrideCursor = QCursor(); //deref the cursor data qt_symbian_dnd_dragging = false; #endif diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 4316714..2ff6d65 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3563,6 +3563,7 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar) \brief The QTouchEvent class contains parameters that describe a touch event. \since 4.6 \ingroup events + \ingroup multitouch \section1 Enabling Touch Events @@ -4195,32 +4196,49 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T \class QGestureEvent \since 4.6 \ingroup events + \ingroup gestures - \brief The QGestureEvent class provides the description of triggered - gestures. + \brief The QGestureEvent class provides the description of triggered gestures. - The QGestureEvent class contains a list of gestures that are being executed - right now (\l{QGestureEvent::}{activeGestures()}) and a list of gestures - that are \l{QGestureEvent::canceledGestures}{cancelled} (a gesture might be - cancelled because the window lost focus, or because of timeout, etc). + The QGestureEvent class contains a list of gestures, which can be obtained using the + allGestures() function. - \sa QGesture + The gestures are either active or canceled. A list of those that are currently being + executed can be obtained using the activeGestures() function. A list of those which + were previously active and have been canceled can be accessed using the + canceledGestures() function. A gesture might be canceled if the current window loses + focus, for example, or because of a timeout, or for other reasons. + + If the event handler does not accept the event by calling the generic + QEvent::accept() function, all individual QGesture object that were not accepted + will be propagated up the parent widget chain until a widget accepts them + individually, by calling QGestureEvent::accept() for each of them, or an event + filter consumes the event. + + \sa QGesture, QGestureRecognizer, + QWidget::grabGesture(), QGraphicsObject::grabGesture() */ /*! Creates new QGestureEvent containing a list of \a gestures. */ -QGestureEvent::QGestureEvent(const QList<QGesture*> &gestures) +QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures) : QEvent(QEvent::Gesture), gestures_(gestures) { } -QList<QGesture*> QGestureEvent::allGestures() const +/*! + Returns all gestures that are delivered in the event. +*/ +QList<QGesture *> QGestureEvent::allGestures() const { return gestures_; } -QGesture* QGestureEvent::gesture(Qt::GestureType type) +/*! + Returns a gesture object by \a type. +*/ +QGesture *QGestureEvent::gesture(Qt::GestureType type) const { for(int i = 0; i < gestures_.size(); ++i) if (gestures_.at(i)->gestureType() == type) @@ -4228,16 +4246,35 @@ QGesture* QGestureEvent::gesture(Qt::GestureType type) return 0; } -QList<QGesture*> QGestureEvent::activeGestures() const +/*! + Returns a list of active (not canceled) gestures. +*/ +QList<QGesture *> QGestureEvent::activeGestures() const { return gestures_; } -QList<QGesture*> QGestureEvent::canceledGestures() const +/*! + Returns a list of canceled gestures. +*/ +QList<QGesture *> QGestureEvent::canceledGestures() const { return gestures_; } +/*! + Sets the accept flag of the given \a gesture object to the specified \a value. + + Setting the accept flag indicates that the event receiver wants the \a gesture. + Unwanted gestures may be propagated to the parent widget. + + By default, gestures in events of type QEvent::Gesture are accepted, and + gestures in QEvent::GestureOverride events are ignored. + + For convenience, the accept flag can also be set with + \l{QGestureEvent::accept()}{accept(gesture)}, and cleared with + \l{QGestureEvent::ignore()}{ignore(gesture)}. +*/ void QGestureEvent::setAccepted(QGesture *gesture, bool value) { setAccepted(false); @@ -4245,19 +4282,80 @@ void QGestureEvent::setAccepted(QGesture *gesture, bool value) gesture->d_func()->accept = value; } +/*! + Sets the accept flag of the given \a gesture object, the equivalent of calling + \l{QGestureEvent::setAccepted()}{setAccepted(gesture, true)}. + + Setting the accept flag indicates that the event receiver wants the + gesture. Unwanted gestures may be propagated to the parent widget. + + \sa QGestureEvent::ignore() +*/ void QGestureEvent::accept(QGesture *gesture) { setAccepted(gesture, true); } +/*! + Clears the accept flag parameter of the given \a gesture object, the equivalent + of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. + + Clearing the accept flag indicates that the event receiver does not + want the gesture. Unwanted gestures may be propgated to the parent widget. + + \sa QGestureEvent::accept() +*/ void QGestureEvent::ignore(QGesture *gesture) { setAccepted(gesture, false); } +/*! + Returns true if the \a gesture is accepted; otherwise returns false. +*/ bool QGestureEvent::isAccepted(QGesture *gesture) const { return gesture ? gesture->d_func()->accept : false; } +#ifdef Q_NO_USING_KEYWORD +/*! + \fn void QGestureEvent::setAccepted(bool accepted) + + Sets or clears the event's internal flag that determines whether it should + be delivered to other objects. + + Calling this function with a value of true for \a accepted indicates that the + caller has accepted the event and that it should not be propagated further. + Calling this function with a value of false indicates that the caller has + ignored the event and that it should be delivered to other objects. + + For convenience, the accept flag can also be set with accept(), and cleared + with ignore(). + + \sa QEvent::accepted +*/ +/*! + \fn bool QGestureEvent::isAccepted() const + + Returns true is the event has been accepted; otherwise returns false. + + \sa QEvent::accepted +*/ +/*! + \fn void QGestureEvent::accept() + + Accepts the event, the equivalent of calling setAccepted(true). + + \sa QEvent::accept() +*/ +/*! + \fn void QGestureEvent::ignore() + + Ignores the event, the equivalent of calling setAccepted(false). + + \sa QEvent::ignore() +*/ +#endif + QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 224b479..3516222 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -826,7 +826,7 @@ public: QGestureEvent(const QList<QGesture *> &gestures); QList<QGesture *> allGestures() const; - QGesture *gesture(Qt::GestureType type); + QGesture *gesture(Qt::GestureType type) const; QList<QGesture *> activeGestures() const; QList<QGesture *> canceledGestures() const; diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 7152705..c9dd949 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -136,14 +136,19 @@ void QEventDispatcherMacPrivate::activateTimer(CFRunLoopTimerRef, void *info) if (tmr == 0 || tmr->pending == true) return; // Can't send another timer event if it's pending. - tmr->pending = true; - QTimerEvent e(tmr->id); - qt_sendSpontaneousEvent(tmr->obj, &e); - // Get the value again in case the timer gets unregistered during the sendEvent. - tmr = macTimerHash.value(timerID); - if (tmr != 0) - tmr->pending = false; + if (blockSendPostedEvents) { + QCoreApplication::postEvent(tmr->obj, new QTimerEvent(tmr->id)); + } else { + tmr->pending = true; + QTimerEvent e(tmr->id); + qt_sendSpontaneousEvent(tmr->obj, &e); + // Get the value again in case the timer gets unregistered during the sendEvent. + tmr = macTimerHash.value(timerID); + if (tmr != 0) + tmr->pending = false; + } + } void QEventDispatcherMac::registerTimer(int timerId, int interval, QObject *obj) @@ -767,7 +772,7 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession() // Sadly, we need to introduce this little event flush // to stop dialogs from blinking/poping in front if a // modal session restart was needed: - while (NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask + while (NSEvent *event = [NSApp nextEventMatchingMask:0 untilDate:nil inMode:NSDefaultRunLoopMode dequeue: YES]) { @@ -942,7 +947,7 @@ Boolean QEventDispatcherMacPrivate::postedEventSourceEqualCallback(const void *i inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents) { - if (blockSendPostedEvents) { + if (blockSendPostedEvents || d->interrupt) { CFRunLoopSourceSignal(d->postedEventsSource); } else { if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index bb74aec..fc8df49 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -47,46 +47,103 @@ QT_BEGIN_NAMESPACE /*! \class QGesture \since 4.6 + \ingroup gestures - \brief The QGesture class represents a gesture, containing all - properties that describe a gesture. + \brief The QGesture class represents a gesture, containing properties that + describe the corresponding user input. - The widget receives a QGestureEvent with a list of QGesture - objects that represent gestures that are occuring on it. The class - has a list of properties that can be queried by the user to get - some gesture-specific arguments (i.e. position of the tap in the - DoubleTap gesture). + Gesture objects are not constructed directly by developers. They are created by + the QGestureRecognizer object that is registered with the application; see + QApplication::registerGestureRecognizer(). - When creating custom gesture recognizers, they might add new - properties to the gesture object, or custom gesture developers - might subclass the QGesture objects to provide some extended - information. + \section1 Gesture Properties + + The class has a list of properties that can be queried by the user to get + some gesture-specific arguments. For example, the pinch gesture has a scale + factor that is exposed as a property. + + Developers of custom gesture recognizers can add additional properties in + order to provide additional information about a gesture. This can be done + by adding new dynamic properties to a QGesture object, or by subclassing + the QGesture class (or one of its subclasses). + + \section1 Lifecycle of a Gesture Object + + A QGesture instance is created when the application calls QWidget::grabGesture() + or QGraphicsObject::grabGesture() to configure a widget or graphics object (the + target object) for gesture input. One gesture object is created for each target + object. + + The registered gesture recognizer monitors the input events for the target + object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the + properties of the gesture object as required. + + The gesture object may be delivered to the target object in a QGestureEvent if + the corresponding gesture is active or has just been canceled. Each event that + is delivered contains a list of gesture objects, since support for more than + one gesture may be enabled for the target object. Due to the way events are + handled in Qt, gesture events may be filtered by other objects. \sa QGestureEvent, QGestureRecognizer */ -QGesture::QGesture(Qt::GestureType type, QObject *parent) - : QObject(*new QGesturePrivate, parent) -{ - d_func()->gestureType = type; -} +/*! + Constructs a new gesture object with the given \a parent. + QGesture objects are created by gesture recognizers in the + QGestureRecognizer::createGesture() function. +*/ QGesture::QGesture(QObject *parent) : QObject(*new QGesturePrivate, parent) { d_func()->gestureType = Qt::CustomGesture; } -QGesture::QGesture(QGesturePrivate &dd, Qt::GestureType type, QObject *parent) +/*! + \internal +*/ +QGesture::QGesture(QGesturePrivate &dd, QObject *parent) : QObject(dd, parent) { - d_func()->gestureType = type; } +/*! + Destroys the gesture object. +*/ QGesture::~QGesture() { } +/*! + \property QGesture::state + \brief the current state of the gesture +*/ + +/*! + \property QGesture::gestureType + \brief the type of the gesture +*/ + +/*! + \property QGesture::hotSpot + + \brief The point that is used to find the receiver for the gesture event. + + If the hot-spot is not set, the targetObject is used as the receiver of the + gesture event. +*/ + +/*! + \property QGesture::hasHotSpot + \brief whether the gesture has a hot-spot +*/ + +/*! + \property QGesture::targetObject + \brief the target object which will receive the gesture event if the hotSpot is + not set +*/ + Qt::GestureType QGesture::gestureType() const { return d_func()->gestureType; @@ -97,7 +154,7 @@ Qt::GestureState QGesture::state() const return d_func()->state; } -QObject* QGesture::targetObject() const +QObject *QGesture::targetObject() const { return d_func()->targetObject; } @@ -129,12 +186,59 @@ void QGesture::unsetHotSpot() d_func()->isHotSpotSet = false; } -// QPanGesture +/*! + \class QPanGesture + \since 4.6 + \brief The QPanGesture class describes a panning gesture made by the user. + \ingroup gestures + + \image pangesture.png + + \sa {Gestures Programming}, QPinchGesture, QSwipeGesture +*/ + +/*! + \property QPanGesture::totalOffset + \brief the total offset from the first input position to the current input + position + The total offset measures the total change in position of the user's input + covered by the gesture on the input device. +*/ + +/*! + \property QPanGesture::lastOffset + \brief the last offset recorded for this gesture + + The last offset contains the change in position of the user's input as + reported in the \l offset property when a previous gesture event was + delivered for this gesture. + + If no previous event was delivered with information about this gesture + (i.e., this gesture object contains information about the first movement + in the gesture) then this property contains a zero size. +*/ + +/*! + \property QPanGesture::offset + \brief the offset from the previous input position to the current input + position + + The offset measures the change in position of the user's input on the + input device. +*/ + +/*! + \property QPanGesture::acceleration +*/ + +/*! + \internal +*/ QPanGesture::QPanGesture(QObject *parent) - : QGesture(*new QPanGesturePrivate, Qt::PanGesture, parent) + : QGesture(*new QPanGesturePrivate, parent) { - + d_func()->gestureType = Qt::PanGesture; } QSizeF QPanGesture::totalOffset() const @@ -178,12 +282,143 @@ void QPanGesture::setAcceleration(qreal value) d_func()->acceleration = value; } -// QPinchGesture +/*! + \class QPinchGesture + \since 4.6 + \brief The QPinchGesture class describes a pinch gesture made my the user. + \ingroup multitouch + \ingroup gestures + + A pinch gesture is a form of multitouch user input in which the user typically + touches two points on the input device with a thumb and finger, before moving + them closer together or further apart to change the scale factor, zoom, or level + of detail of the user interface. + + \image pinchgesture.png + + Instead of repeatedly applying the same pinching gesture, the user may + continue to touch the input device in one place, and apply a second touch + to a new point, continuing the gesture. When this occurs, gesture events + will continue to be delivered to the target object, containing an instance + of QPinchGesture in the Qt::GestureUpdated state. + + \sa {Gestures Programming}, QPanGesture, QSwipeGesture +*/ + +/*! + \enum QPinchGesture::WhatChange + + This enum describes the changes that can occur to the properties of + the gesture object. + + \value ScaleFactorChanged The scale factor held by scaleFactor changed. + \value RotationAngleChanged The rotation angle held by rotationAngle changed. + \value CenterPointChanged The center point held by centerPoint changed. + + \sa whatChanged +*/ + +/*! + \property QPinchGesture::whatChanged + \brief the property of the gesture that has changed + + This property indicates which of the other properties has changed since + the previous gesture event included information about this gesture. You + can use this information to determine which aspect of your user interface + needs to be updated. + + \sa scaleFactor, rotationAngle, centerPoint +*/ + +/*! + \property QPinchGesture::totalScaleFactor + \brief the total scale factor + The total scale factor measures the total change in scale factor from the + original value to the current scale factor. + + \sa scaleFactor, lastScaleFactor +*/ +/*! + \property QPinchGesture::lastScaleFactor + \brief the last scale factor recorded for this gesture + + The last scale factor contains the scale factor reported in the + \l scaleFactor property when a previous gesture event included + information about this gesture. + + If no previous event was delivered with information about this gesture + (i.e., this gesture object contains information about the first movement + in the gesture) then this property contains zero. + + \sa scaleFactor, totalScaleFactor +*/ +/*! + \property QPinchGesture::scaleFactor + \brief the current scale factor + + The scale factor measures the scale factor associated with the distance + between two of the user's inputs on a multitouch device. + + \sa totalScaleFactor, lastScaleFactor +*/ + +/*! + \property QPinchGesture::totalRotationAngle + \brief the total angle covered by the gesture + + This total angle measures the complete angle covered by the gesture. Usually, this + is equal to the value held by the \l rotationAngle property, except in the case where + the user performs multiple rotations by removing and repositioning one of the touch + points, as described above. In this case, the total angle will be the sum of the + rotation angles for the multiple stages of the gesture. + + \sa rotationAngle, lastRotationAngle +*/ +/*! + \property QPinchGesture::lastRotationAngle + \brief the last reported angle covered by the gesture motion + + The last rotation angle is the angle as reported in the \l rotationAngle property + when a previous gesture event was delivered for this gesture. + + \sa rotationAngle, totalRotationAngle +*/ +/*! + \property QPinchGesture::rotationAngle + \brief the angle covered by the gesture motion + + \sa totalRotationAngle, lastRotationAngle +*/ + +/*! + \property QPinchGesture::startCenterPoint + \brief the starting position of the center point + + \sa centerPoint, lastCenterPoint +*/ +/*! + \property QPinchGesture::lastCenterPoint + \brief the last position of the center point recorded for this gesture + + \sa centerPoint, startCenterPoint +*/ +/*! + \property QPinchGesture::centerPoint + \brief the current center point + + The center point is the midpoint between the two input points in the gesture. + + \sa startCenterPoint, lastCenterPoint +*/ + +/*! + \internal +*/ QPinchGesture::QPinchGesture(QObject *parent) - : QGesture(*new QPinchGesturePrivate, Qt::PinchGesture, parent) + : QGesture(*new QPinchGesturePrivate, parent) { - + d_func()->gestureType = Qt::PinchGesture; } QPinchGesture::WhatChanged QPinchGesture::whatChanged() const @@ -289,31 +524,91 @@ void QPinchGesture::setRotationAngle(qreal value) d_func()->rotationAngle = value; } -// QSwipeGesture +/*! + \class QSwipeGesture + \since 4.6 + \brief The QSwipeGesture class describes a swipe gesture made by the user. + \ingroup gestures + + \image swipegesture.png + + \sa {Gestures Programming}, QPanGesture, QPinchGesture +*/ + +/*! + \enum QSwipeGesture::SwipeDirection + + This enum describes the possible directions for the gesture's motion + along the horizontal and vertical axes. + + \value NoDirection The gesture had no motion associated with it on a particular axis. + \value Left The gesture involved a horizontal motion to the left. + \value Right The gesture involved a horizontal motion to the right. + \value Up The gesture involved an upward vertical motion. + \value Down The gesture involved a downward vertical motion. +*/ + +/*! + \property QSwipeGesture::horizontalDirection + \brief the horizontal direction of the gesture + + If the gesture has a horizontal component, the horizontal direction + is either Left or Right; otherwise, it is NoDirection. + + \sa verticalDirection, swipeAngle +*/ + +/*! + \property QSwipeGesture::verticalDirection + \brief the vertical direction of the gesture + If the gesture has a vertical component, the vertical direction + is either Up or Down; otherwise, it is NoDirection. + + \sa horizontalDirection, swipeAngle +*/ + +/*! + \property QSwipeGesture::swipeAngle + \brief the angle of the motion associated with the gesture + + If the gesture has either a horizontal or vertical component, the + swipe angle describes the angle between the direction of motion and the + x-axis as defined using the standard widget + \l{The Coordinate System}{coordinate system}. + + \sa horizontalDirection, verticalDirection +*/ + +/*! + \internal +*/ QSwipeGesture::QSwipeGesture(QObject *parent) - : QGesture(*new QSwipeGesturePrivate, Qt::SwipeGesture, parent) + : QGesture(*new QSwipeGesturePrivate, parent) { + d_func()->gestureType = Qt::SwipeGesture; } QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const { - return d_func()->horizontalDirection; + Q_D(const QSwipeGesture); + if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270) + return QSwipeGesture::NoDirection; + else if (d->swipeAngle < 90 || d->swipeAngle > 270) + return QSwipeGesture::Right; + else + return QSwipeGesture::Left; } QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const { - return d_func()->verticalDirection; -} - -void QSwipeGesture::setHorizontalDirection(QSwipeGesture::SwipeDirection value) -{ - d_func()->horizontalDirection = value; -} - -void QSwipeGesture::setVerticalDirection(QSwipeGesture::SwipeDirection value) -{ - d_func()->verticalDirection = value; + Q_D(const QSwipeGesture); + if (d->swipeAngle <= 0 || d->swipeAngle == 180) + return QSwipeGesture::NoDirection; + else if (d->swipeAngle < 180) + return QSwipeGesture::Up; + else + return QSwipeGesture::Down; } qreal QSwipeGesture::swipeAngle() const diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index b37120f..02eb526 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -51,12 +51,12 @@ QT_BEGIN_HEADER +Q_DECLARE_METATYPE(Qt::GestureState) + QT_BEGIN_NAMESPACE QT_MODULE(Gui) -Q_DECLARE_METATYPE(Qt::GestureState) - class QGesturePrivate; class Q_GUI_EXPORT QGesture : public QObject { @@ -70,8 +70,7 @@ class Q_GUI_EXPORT QGesture : public QObject Q_PROPERTY(QObject* targetObject READ targetObject WRITE setTargetObject) public: - explicit QGesture(Qt::GestureType type = Qt::CustomGesture, QObject *parent = 0); - explicit QGesture(QObject *parent); + explicit QGesture(QObject *parent = 0); ~QGesture(); Qt::GestureType gestureType() const; @@ -87,7 +86,7 @@ public: void unsetHotSpot(); protected: - QGesture(QGesturePrivate &dd, Qt::GestureType type, QObject *parent); + QGesture(QGesturePrivate &dd, QObject *parent); private: friend class QGestureEvent; @@ -181,8 +180,12 @@ public: friend class QPinchGestureRecognizer; }; +QT_END_NAMESPACE + Q_DECLARE_METATYPE(QPinchGesture::WhatChanged) +QT_BEGIN_NAMESPACE + class QSwipeGesturePrivate; class Q_GUI_EXPORT QSwipeGesture : public QGesture { @@ -190,8 +193,8 @@ class Q_GUI_EXPORT QSwipeGesture : public QGesture Q_DECLARE_PRIVATE(QSwipeGesture) Q_ENUMS(SwipeDirection) - Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection WRITE setHorizontalDirection) - Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection WRITE setVerticalDirection) + Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false) + Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false) Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle) public: @@ -200,8 +203,6 @@ public: SwipeDirection horizontalDirection() const; SwipeDirection verticalDirection() const; - void setHorizontalDirection(SwipeDirection value); - void setVerticalDirection(SwipeDirection value); qreal swipeAngle() const; void setSwipeAngle(qreal value); diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 000f44f..0f0aef2 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -48,6 +48,10 @@ #include "qevent.h" #include "qgraphicsitem.h" +#ifdef Q_WS_MAC +#include "qmacgesturerecognizer_mac_p.h" +#endif + #include "qdebug.h" // #define GESTURE_DEBUG @@ -64,7 +68,15 @@ QGestureManager::QGestureManager(QObject *parent) { qRegisterMetaType<Qt::GestureState>(); +#if defined(Q_WS_MAC) + registerGestureRecognizer(new QMacSwipeGestureRecognizer); + registerGestureRecognizer(new QMacPinchGestureRecognizer); + #if defined(QT_MAC_USE_COCOA) + registerGestureRecognizer(new QMacPanGestureRecognizer); + #endif +#else registerGestureRecognizer(new QPanGestureRecognizer); +#endif } QGestureManager::~QGestureManager() @@ -279,8 +291,10 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) QSet<QGesture *> notStarted = finishedGestures - activeGestures; if (!notStarted.isEmpty()) { // there are some gestures that claim to be finished, but never started. - qWarning("QGestureManager::filterEvent: some gestures were finished even though they've never started"); - finishedGestures -= notStarted; + // probably those are "singleshot" gestures so we'll fake the started state. + foreach (QGesture *gesture, notStarted) + gesture->d_func()->state = Qt::GestureStarted; + deliverEvents(notStarted, receiver); } activeGestures += startedGestures; diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index 590f09e..9de3bcc 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -45,27 +45,156 @@ QT_BEGIN_NAMESPACE +/*! + \class QGestureRecognizer + \since 4.6 + \brief The QGestureRecognizer class provides the infrastructure for gesture recognition. + \ingroup gestures + + Gesture recognizers are responsible for creating and managing QGesture objects and + monitoring input events sent to QWidget and QGraphicsObject subclasses. + QGestureRecognizer is the base class for implementing custom gestures. + + Developers that only need to provide gesture recognition for standard gestures do not + need to use this class directly. Instances will be created behind the scenes by the + framework. + + \section1 Recognizing Gestures + + The process of recognizing gestures involves filtering input events sent to specific + objects, and modifying the associated QGesture objects to include relevant information + about the user's input. + + Gestures are created when the framework calls createGesture() to handle user input + for a particular instance of a QWidget or QGraphicsObject subclass. A QGesture object + is created for each widget or item that is configured to use gestures. + + Once a QGesture has been created for a target object, the gesture recognizer will + receive events for it in its filterEvent() handler function. + + When a gesture is canceled, the reset() function is called, giving the recognizer the + chance to update the appropriate properties in the corresponding QGesture object. + + \section1 Supporting New Gestures + + To add support for new gestures, you need to derive from QGestureRecognizer to create + a custom recognizer class, construct an instance of this class, and register it with + the application by calling QApplication::registerGestureRecognizer(). You can also + subclass QGesture to create a custom gesture class, or rely on dynamic properties + to express specific details of the gesture you want to handle. + + Your custom QGestureRecognizer subclass needs to reimplement the filterEvent() function + to handle and filter the incoming input events for QWidget and QGraphicsObject subclasses. + Although the logic for gesture recognition is implemented in this function, you can + store persistent information about the state of the recognition process in the QGesture + object supplied. The filterEvent() function must return a value of Qt::GestureState that + indicates the state of recognition for a given gesture and target object. This determines + whether or not a gesture event will be delivered to a target object. + + If you choose to represent a gesture by a custom QGesture subclass, you will need to + reimplement the createGesture() function to construct instances of your gesture class. + Similarly, you may need to reimplement the reset() function if your custom gesture + objects need to be specially handled when a gesture is canceled. + + \sa QGesture +*/ + +/*! + \enum QGestureRecognizer::ResultFlags + + This enum describes the result of the current event filtering step in + a gesture recognizer state machine. + + The result consists of a state value (one of Ignore, NotGesture, + MaybeGesture, GestureTriggered, GestureFinished) and an optional hint + (ConsumeEventHint). + + \value Ignore The event does not change the state of the recognizer. + + \value NotGesture The event made it clear that it is not a gesture. If the + gesture recognizer was in GestureTriggered state before, then the gesture + is canceled and the appropriate QGesture object will be delivered to the + target as a part of a QGestureEvent. + + \value MaybeGesture The event changed the internal state of the recognizer, + but it isn't clear yet if it is a gesture or not. The recognizer needs to + filter more events to decide. Gesture recognizers in the MaybeGesture state + may be reset automatically if they take too long to recognize gestures. + + \value GestureTriggered The gesture has been triggered and the appropriate + QGesture object will be delivered to the target as a part of a + QGestureEvent. + + \value GestureFinished The gesture has been finished successfully and the + appropriate QGesture object will be delivered to the target as a part of a + QGestureEvent. + + \value ConsumeEventHint This hint specifies that the gesture framework should + consume the filtered event and not deliver it to the receiver. + + \omitvalue ResultState_Mask + \omitvalue ResultHint_Mask + + \sa QGestureRecognizer::filterEvent() +*/ + +/*! + Constructs a new gesture recognizer object. +*/ QGestureRecognizer::QGestureRecognizer() { } +/*! + Destroys the gesture recognizer. +*/ QGestureRecognizer::~QGestureRecognizer() { } -QGesture *QGestureRecognizer::createGesture(QObject *) +/*! + This function is called by Qt to create a new QGesture object for the + given \a target (QWidget or QGraphicsObject). + + Reimplement this function to create a custom QGesture-derived gesture + object if necessary. +*/ +QGesture *QGestureRecognizer::createGesture(QObject *target) { + Q_UNUSED(target); return new QGesture; } -void QGestureRecognizer::reset(QGesture *state) +/*! + This function is called by the framework to reset a given \a gesture. + + Reimplement this function to implement additional requirements for custom QGesture + objects. This may be necessary if you implement a custom QGesture whose properties + need special handling when the gesture is reset. +*/ +void QGestureRecognizer::reset(QGesture *gesture) { - if (state) { - QGesturePrivate *d = state->d_func(); + if (gesture) { + QGesturePrivate *d = gesture->d_func(); d->state = Qt::NoGesture; d->hotSpot = QPointF(); d->targetObject = 0; } } +/*! + \fn QGestureRecognizer::filterEvent(QGesture *gesture, QObject *watched, QEvent *event) + + Handles the given \a event for the \a watched object, updating the state of the \a gesture + object as required, and returns a suitable Result for the current recognition step. + + This function is called by the framework to allow the recognizer to filter input events + dispatched to QWidget or QGraphicsObject instances that it is monitoring. + + The result reflects how much of the gesture has been recognized. The state of the + \a gesture object is set depending on the result. + + \sa Qt::GestureState +*/ + QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h index c85afd2..efd8565 100644 --- a/src/gui/kernel/qgesturerecognizer.h +++ b/src/gui/kernel/qgesturerecognizer.h @@ -42,7 +42,7 @@ #ifndef QGESTURERECOGNIZER_H #define QGESTURERECOGNIZER_H -#include "qglobal.h" +#include <QtCore/qglobal.h> QT_BEGIN_HEADER diff --git a/src/gui/kernel/qmacgesturerecognizer_mac.mm b/src/gui/kernel/qmacgesturerecognizer_mac.mm new file mode 100644 index 0000000..7b19a54 --- /dev/null +++ b/src/gui/kernel/qmacgesturerecognizer_mac.mm @@ -0,0 +1,267 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmacgesturerecognizer_mac_p.h" +#include "qgesture.h" +#include "qgesture_p.h" +#include "qevent.h" +#include "qevent_p.h" +#include "qwidget.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +QMacSwipeGestureRecognizer::QMacSwipeGestureRecognizer() +{ +} + +QGesture *QMacSwipeGestureRecognizer::createGesture(QObject * /*target*/) +{ + return new QSwipeGesture; +} + +QGestureRecognizer::Result +QMacSwipeGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) { + QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event); + switch (ev->gestureType) { + case QNativeGestureEvent::Swipe: { + QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture); + g->setSwipeAngle(ev->angle); + return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + break; } + default: + break; + } + } + + return QGestureRecognizer::Ignore; +} + +void QMacSwipeGestureRecognizer::reset(QGesture *gesture) +{ + QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture); + g->setSwipeAngle(0); + QGestureRecognizer::reset(gesture); +} + +//////////////////////////////////////////////////////////////////////// + +QMacPinchGestureRecognizer::QMacPinchGestureRecognizer() +{ +} + +QGesture *QMacPinchGestureRecognizer::createGesture(QObject * /*target*/) +{ + return new QPinchGesture; +} + +QGestureRecognizer::Result +QMacPinchGestureRecognizer::filterEvent(QGesture *gesture, QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) { + QPinchGesture *g = static_cast<QPinchGesture *>(gesture); + QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event); + switch(ev->gestureType) { + case QNativeGestureEvent::GestureBegin: + reset(gesture); + g->setStartCenterPoint(static_cast<QWidget*>(obj)->mapFromGlobal(ev->position)); + g->setCenterPoint(g->startCenterPoint()); + g->setWhatChanged(QPinchGesture::CenterPointChanged); + return QGestureRecognizer::MaybeGesture | QGestureRecognizer::ConsumeEventHint; + case QNativeGestureEvent::Rotate: { + g->setLastScaleFactor(g->scaleFactor()); + g->setLastRotationAngle(g->rotationAngle()); + g->setRotationAngle(g->rotationAngle() + ev->percentage); + g->setWhatChanged(QPinchGesture::RotationAngleChanged); + return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + break; + } + case QNativeGestureEvent::Zoom: + g->setLastScaleFactor(g->scaleFactor()); + g->setLastRotationAngle(g->rotationAngle()); + g->setScaleFactor(g->scaleFactor() + ev->percentage); + g->setWhatChanged(QPinchGesture::ScaleFactorChanged); + return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + break; + case QNativeGestureEvent::GestureEnd: + return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint; + break; + default: + break; + } + } + + return QGestureRecognizer::Ignore; +} + +void QMacPinchGestureRecognizer::reset(QGesture *gesture) +{ + QPinchGesture *g = static_cast<QPinchGesture *>(gesture); + g->setWhatChanged(0); + g->setScaleFactor(1.0f); + g->setTotalScaleFactor(1.0f); + g->setLastScaleFactor(1.0f); + g->setRotationAngle(0.0f); + g->setTotalRotationAngle(0.0f); + g->setLastRotationAngle(0.0f); + g->setCenterPoint(QPointF()); + g->setStartCenterPoint(QPointF()); + g->setLastCenterPoint(QPointF()); + QGestureRecognizer::reset(gesture); +} + +//////////////////////////////////////////////////////////////////////// + +#if defined(QT_MAC_USE_COCOA) + +QMacPanGestureRecognizer::QMacPanGestureRecognizer() : _panCanceled(true) +{ +} + +QGesture *QMacPanGestureRecognizer::createGesture(QObject *target) +{ + if (!target) + return new QPanGesture; + + if (QWidget *w = qobject_cast<QWidget *>(target)) { + w->setAttribute(Qt::WA_AcceptTouchEvents); + w->setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents); + return new QPanGesture; + } + return 0; +} + +QGestureRecognizer::Result +QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent *event) +{ + const int panBeginDelay = 300; + const int panBeginRadius = 3; + + QPanGesture *g = static_cast<QPanGesture *>(gesture); + + switch (event->type()) { + case QEvent::TouchBegin: { + const QTouchEvent *ev = static_cast<const QTouchEvent*>(event); + if (ev->touchPoints().size() == 1) { + reset(gesture); + _startPos = QCursor::pos(); + _lastPos = _startPos; + _panTimer.start(panBeginDelay, target); + _panCanceled = false; + return QGestureRecognizer::MaybeGesture; + } + break;} + case QEvent::TouchEnd: { + if (_panCanceled) + break; + + const QTouchEvent *ev = static_cast<const QTouchEvent*>(event); + if (ev->touchPoints().size() == 1) + return QGestureRecognizer::GestureFinished; + break;} + case QEvent::TouchUpdate: { + if (_panCanceled) + break; + + const QTouchEvent *ev = static_cast<const QTouchEvent*>(event); + if (ev->touchPoints().size() == 1) { + if (_panTimer.isActive()) { + // INVARIANT: Still in maybeGesture. Check if the user + // moved his finger so much that it makes sense to cancel the pan: + const QPointF p = QCursor::pos(); + if ((p - _startPos).manhattanLength() > panBeginRadius) { + _panCanceled = true; + _panTimer.stop(); + return QGestureRecognizer::NotGesture; + } + } else { + const QPointF p = QCursor::pos(); + const QPointF posOffset = p - _lastPos; + g->setLastOffset(g->offset()); + g->setOffset(QSizeF(posOffset.x(), posOffset.y())); + g->setTotalOffset(g->lastOffset() + g->offset()); + _lastPos = p; + return QGestureRecognizer::GestureTriggered; + } + } else if (_panTimer.isActive()) { + // I only want to cancel the pan if the user is pressing + // more than one finger, and the pan hasn't started yet: + _panCanceled = true; + _panTimer.stop(); + return QGestureRecognizer::NotGesture; + } + break;} + case QEvent::Timer: { + QTimerEvent *ev = static_cast<QTimerEvent *>(event); + if (ev->timerId() == _panTimer.timerId()) { + _panTimer.stop(); + if (_panCanceled) + break; + // Begin new pan session! + _startPos = QCursor::pos(); + _lastPos = _startPos; + return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; + } + break; } + default: + break; + } + + return QGestureRecognizer::Ignore; +} + +void QMacPanGestureRecognizer::reset(QGesture *gesture) +{ + QPanGesture *g = static_cast<QPanGesture *>(gesture); + _startPos = QPointF(); + _lastPos = QPointF(); + _panCanceled = true; + g->setOffset(QSizeF(0, 0)); + g->setLastOffset(QSizeF(0, 0)); + g->setTotalOffset(QSizeF(0, 0)); + g->setAcceleration(qreal(1)); + QGestureRecognizer::reset(gesture); +} +#endif // QT_MAC_USE_COCOA + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qmacgesturerecognizer_mac_p.h b/src/gui/kernel/qmacgesturerecognizer_mac_p.h new file mode 100644 index 0000000..bdc2e08 --- /dev/null +++ b/src/gui/kernel/qmacgesturerecognizer_mac_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMACSWIPEGESTURERECOGNIZER_MAC_P_H +#define QMACSWIPEGESTURERECOGNIZER_MAC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtimer.h" +#include "qpoint.h" +#include "qgesturerecognizer.h" + +QT_BEGIN_NAMESPACE + +class QMacSwipeGestureRecognizer : public QGestureRecognizer +{ +public: + QMacSwipeGestureRecognizer(); + + QGesture *createGesture(QObject *target); + QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + void reset(QGesture *gesture); +}; + +class QMacPinchGestureRecognizer : public QGestureRecognizer +{ +public: + QMacPinchGestureRecognizer(); + + QGesture *createGesture(QObject *target); + QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + void reset(QGesture *gesture); +}; + +#if defined(QT_MAC_USE_COCOA) + +class QMacPanGestureRecognizer : public QObject, public QGestureRecognizer +{ +public: + QMacPanGestureRecognizer(); + + QGesture *createGesture(QObject *target); + QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event); + void reset(QGesture *gesture); +private: + QPointF _startPos; + QPointF _lastPos; + QBasicTimer _panTimer; + bool _panCanceled; +}; + +#endif + +QT_END_NAMESPACE + +#endif // QMACSWIPEGESTURERECOGNIZER_MAC_P_H diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 1214f08..6116a5e 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -125,7 +125,6 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act break; } action->setSoftKeyRole(softKeyRole); - action->setEnabled(actionWidget->isEnabled()); return action; } @@ -210,7 +209,7 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys) for (int index = 0; index < softkeys.count(); index++) { const QAction* softKeyAction = softkeys.at(index); switch (softKeyAction->softKeyRole()) { - // Positive Actions go on LSK + // Positive Actions on the LSK case QAction::PositiveSoftKey: position = 0; break; @@ -253,7 +252,8 @@ bool QSoftKeyManager::handleCommand(int command) QAction *action = softKeys.at(i); if (action->softKeyRole() != QAction::NoSoftKey) { if (j == index) { - if (action->isEnabled()) { + QWidget *parent = action->parentWidget(); + if (parent && parent->isEnabled()) { action->activate(QAction::Trigger); return true; } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index bce06e0..8da415f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1502,6 +1502,8 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier mapper->remove(data.winid); } + const WId oldWinId = data.winid; + data.winid = id; #if defined(Q_WS_X11) hd = id; // X11: hd == ident @@ -1509,6 +1511,16 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier if (mapper && id && !userDesktopWidget) { mapper->insert(data.winid, q); } + + if(oldWinId != id) { + // Do not emit an event when the old winId is destroyed. This only + // happens (a) during widget destruction, and (b) immediately prior + // to creation of a new winId, for example as a result of re-parenting. + if(id != 0) { + QEvent e(QEvent::WinIdChange); + QCoreApplication::sendEvent(q, &e); + } + } } void QWidgetPrivate::createTLExtra() @@ -2227,8 +2239,8 @@ QWidget *QWidget::find(WId id) against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to an NSView. - \note We recommend that you do not store this value as it is likely to - change at run-time. + This value may change at run-time. An event with type QEvent::WinIdChange + will be sent to the widget following a change in window system identifier. \sa find() */ @@ -11672,10 +11684,16 @@ QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const Synonym for QList<QWidget *>. */ -void QWidget::grabGesture(Qt::GestureType type, Qt::GestureContext context) +/*! + Subscribes the widget to a given \a gesture with a \a context. + + \sa QGestureEvent + \since 4.6 +*/ +void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) { Q_D(QWidget); - d->gestureContext.insert(type, context); + d->gestureContext.insert(gesture, context); (void)QGestureManager::instance(); // create a gesture manager } @@ -11992,3 +12010,10 @@ void QWidget::clearMask() XRender extension is not supported on the X11 display, or if the handle could not be created. */ + +#ifdef Q_OS_SYMBIAN +void QWidgetPrivate::_q_delayedDestroy(WId winId) +{ + delete winId; +} +#endif diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 3501c6e..e603a1a 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -726,14 +726,11 @@ private: friend class QGLContext; friend class QGLWidget; friend class QGLWindowSurface; - friend class QGLWindowSurfaceGLPaintDevice; - friend class QVGWindowSurface; friend class QX11PaintEngine; friend class QWin32PaintEngine; friend class QShortcutPrivate; friend class QShortcutMap; friend class QWindowSurface; - friend class QD3DWindowSurface; friend class QGraphicsProxyWidget; friend class QGraphicsProxyWidgetPrivate; friend class QStyleSheetStyle; @@ -776,6 +773,9 @@ private: private: Q_DISABLE_COPY(QWidget) Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden()) +#ifdef Q_OS_SYMBIAN + Q_PRIVATE_SLOT(d_func(), void _q_delayedDestroy(WId winId)) +#endif QWidgetData *data; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index a549740..f7c2712 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -296,7 +296,8 @@ public: void setMask_sys(const QRegion &); #ifdef Q_OS_SYMBIAN void setSoftKeys_sys(const QList<QAction*> &softkeys); - void activateSymbianWindow(); + void activateSymbianWindow(WId wid = 0); + void _q_delayedDestroy(WId winId); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index b0d405a..8ce5001 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,6 +56,12 @@ #include <aknappui.h> #endif +// This is necessary in order to be able to perform delayed invokation on slots +// which take arguments of type WId. One example is +// QWidgetPrivate::_q_delayedDestroy, which is used to delay destruction of +// CCoeControl objects until after the CONE event handler has finished running. +Q_DECLARE_METATYPE(WId) + QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -318,8 +324,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de bool desktop = (type == Qt::Desktop); //bool tool = (type == Qt::Tool || type == Qt::Drawer); - WId id = 0; - if (popup) flags |= Qt::WindowStaysOnTopHint; // a popup stays on top @@ -341,13 +345,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de data.crect.setSize(QSize(width, height)); } - CCoeControl *destroyw = 0; + CCoeControl *const destroyw = destroyOldWindow ? data.winid : 0; createExtra(); if (window) { - if (destroyOldWindow) - destroyw = data.winid; - id = window; setWinId(window); TRect tr = window->Rect(); data.crect.setRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); @@ -355,10 +356,15 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } else if (topLevel) { if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen)) data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); - QSymbianControl *control= q_check_ptr(new QSymbianControl(q)); - id = (WId)control; - setWinId(id); - QT_TRAP_THROWING(control->ConstructL(true,desktop)); + + QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); + QT_TRAP_THROWING(control->ConstructL(true, desktop)); + + // Symbian windows are always created in an inactive state + // We perform this assignment for the case where the window is being re-created + // as aa result of a call to setParent_sys, on either this widget or one of its + // ancestors. + extra->activated = 0; if (!desktop) { TInt stackingFlags; @@ -368,7 +374,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } control->MakeVisible(false); - QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); + QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags)); // Avoid keyboard focus to a hidden window. control->setFocusSafely(false); @@ -391,11 +397,22 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); control->SetRect(TRect(TPoint(x, y), TSize(w, h))); + + // We wait until the control is fully constructed before calling setWinId, because + // this generates a WinIdChanged event. + setWinId(control.take()); + } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget - QSymbianControl *control = new QSymbianControl(q); - setWinId(control); + + QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); QT_TRAP_THROWING(control->ConstructL(!parentWidget)); + // Symbian windows are always created in an inactive state + // We perform this assignment for the case where the window is being re-created + // as aa result of a call to setParent_sys, on either this widget or one of its + // ancestors. + extra->activated = 0; + TInt stackingFlags; if ((q->windowType() & Qt::Popup) == Qt::Popup) { stackingFlags = ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus; @@ -403,7 +420,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } control->MakeVisible(false); - QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); + QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags)); // Avoid keyboard focus to a hidden window. control->setFocusSafely(false); @@ -418,12 +435,21 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de | EPointerFilterMove | EPointerFilterDrag, 0); if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) - activateSymbianWindow(); + activateSymbianWindow(control.data()); + + // We wait until the control is fully constructed before calling setWinId, because + // this generates a WinIdChanged event. + setWinId(control.take()); } if (destroyw) { destroyw->ControlEnv()->AppUi()->RemoveFromStack(destroyw); - CBase::Delete(destroyw); + + // Delay deletion of the control in case this function is called in the + // context of a CONE event handler such as + // CCoeControl::ProcessPointerEventL + QMetaObject::invokeMethod(q, "_q_delayedDestroy", + Qt::QueuedConnection, Q_ARG(WId, destroyw)); } if (q->testAttribute(Qt::WA_AcceptTouchEvents)) @@ -468,7 +494,7 @@ void QWidgetPrivate::show_sys() invalidateBuffer(q->rect()); } -void QWidgetPrivate::activateSymbianWindow() +void QWidgetPrivate::activateSymbianWindow(WId wid) { Q_Q(QWidget); @@ -476,8 +502,12 @@ void QWidgetPrivate::activateSymbianWindow() Q_ASSERT(q->testAttribute(Qt::WA_Mapped)); Q_ASSERT(!extra->activated); - WId id = q->internalWinId(); - QT_TRAP_THROWING(id->ActivateL()); + if(!wid) + wid = q->internalWinId(); + + Q_ASSERT(wid); + + QT_TRAP_THROWING(wid->ActivateL()); extra->activated = 1; } @@ -571,8 +601,14 @@ void QWidgetPrivate::reparentChildren() w->d_func()->invalidateBuffer(w->rect()); WId parent = q->effectiveWinId(); WId child = w->effectiveWinId(); - if (parent != child) - child->SetParent(parent); + if (parent != child) { + // Child widget is native. Because Symbian windows cannot be + // re-parented, we must re-create the window. + const WId window = 0; + const bool initializeWindow = false; + const bool destroyOldWindow = true; + w->d_func()->create_sys(window, initializeWindow, destroyOldWindow); + } // ### TODO: We probably also need to update the component array here w->d_func()->reparentChildren(); } else { diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 95c0b44..6114938 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -65,4 +65,9 @@ int QPaintDevice::metric(PaintDeviceMetric) const return 0; } +Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric) +{ + return device->metric(metric); +} + QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 92aa3cb..c8e86b8 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -137,6 +137,7 @@ public: friend class QPainter; friend class QFontEngineMac; friend class QX11PaintEngine; + friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric); }; #ifdef QT3_SUPPORT diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 6037bd5..240403d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4213,13 +4213,6 @@ void QRasterBuffer::prepare(QCustomRasterPaintDevice *device) drawHelper = qDrawHelper + format; } -class MetricAccessor : public QWidget { -public: - int metric(PaintDeviceMetric m) { - return QWidget::metric(m); - } -}; - int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const { switch (m) { @@ -4231,7 +4224,7 @@ int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const break; } - return (static_cast<MetricAccessor*>(widget)->metric(m)); + return qt_paint_device_metric(widget, m); } int QCustomRasterPaintDevice::bytesPerLine() const diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp index e17dba1..6f4f398 100644 --- a/src/gui/painting/qpaintengine_s60.cpp +++ b/src/gui/painting/qpaintengine_s60.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QS60PaintEnginePrivate : public QRasterPaintEnginePrivate { public: - QS60PaintEnginePrivate(QS60PaintEngine *engine) { } + QS60PaintEnginePrivate(QS60PaintEngine *engine) { Q_UNUSED(engine); } }; QS60PaintEngine::QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data) diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/gui/s60framework/qs60mainapplication.cpp index 2973c97..82e7743 100644 --- a/src/gui/s60framework/qs60mainapplication.cpp +++ b/src/gui/s60framework/qs60mainapplication.cpp @@ -60,27 +60,32 @@ CApaApplication *newS60Application() _LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main.rsc"); /*! - * \class QS60MainApplication - * \obsolete - * \since 4.6 - * \brief The QS60MainApplication class provides support for migration from S60. - * - * The QS60MainApplication provides a helper class for use in migrating from existing S60 based - * applications to Qt based applications. It is used in the exact same way as the - * \c CAknApplication class from Symbian, but internally provides extensions used by Qt. - * - * When modifying old S60 applications that rely on implementing functions in \c CAknApplication, - * the class should be modified to inherit from this class instead of \c CAknApplication. Then the - * application can choose to override only certain functions. To make Qt use the custom application - * objects, pass a factory function to - * QApplication::QApplication(QApplication::QS60MainApplicationFactory, int &, char **). - * - * For more information on \c CAknApplication, please see the S60 documentation. - * - * Unlike other Qt classes, QS60MainApplication behaves like an S60 class, and can throw Symbian - * leaves. - * - * \sa QS60MainDocument, QS60MainAppUi, QApplication::QS60MainApplicationFactory + \class QS60MainApplication + \since 4.6 + \brief The QS60MainApplication class provides support for migration from S60. + + \warning This class is provided only to get access to S60 specific + functionality in the application framework classes. It is not + portable. We strongly recommend against using it in new applications. + + The QS60MainApplication provides a helper class for use in migrating + from existing S60 based applications to Qt based applications. It is + used in the exact same way as the \c CAknApplication class from + Symbian, but internally provides extensions used by Qt. + + When modifying old S60 applications that rely on implementing + functions in \c CAknApplication, the class should be modified to + inherit from this class instead of \c CAknApplication. Then the + application can choose to override only certain functions. To make + Qt use the custom application objects, pass a factory function to + \c{QApplication::QApplication(QApplication::QS60MainApplicationFactory, int &, char **)}. + + For more information on \c CAknApplication, please see the S60 documentation. + + Unlike other Qt classes, QS60MainApplication behaves like an S60 class, and can throw Symbian + leaves. + + \sa QS60MainDocument, QS60MainAppUi, QApplication::QS60MainApplicationFactory */ /*! diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index d8181f8..e630253 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -58,25 +58,31 @@ QT_BEGIN_NAMESPACE /*! - * \class QS60MainAppUi - * \obsolete - * \since 4.6 - * \brief Helper class for S60 migration - * - * The QS60MainAppUi provides a helper class for use in migrating from existing S60 based - * applications to Qt based applications. It is used in the exact same way as the - * \c CAknAppUi class from Symbian, but internally provides extensions used by Qt. - * - * When modifying old S60 applications that rely on implementing functions in \c CAknAppUi, - * the class should be modified to inherit from this class instead of \c CAknAppUi. Then the - * application can choose to override only certain functions. - * - * For more information on \c CAknAppUi, please see the S60 documentation. - * - * Unlike other Qt classes, QS60MainAppUi behaves like an S60 class, and can throw Symbian - * leaves. - * - * \sa QS60MainDocument, QS60MainApplication + \class QS60MainAppUi + \since 4.6 + \brief The QS60MainAppUi class is a helper class for S60 migration. + + \warning This class is provided only to get access to S60 specific + functionality in the application framework classes. It is not + portable. We strongly recommend against using it in new applications. + + The QS60MainAppUi provides a helper class for use in migrating from + existing S60 based applications to Qt based applications. It is used + in the exact same way as the \c CAknAppUi class from Symbian, but + internally provides extensions used by Qt. + + When modifying old S60 applications that rely on implementing + functions in \c CAknAppUi, the class should be modified to inherit + from this class instead of \c CAknAppUi. Then the application can + choose to override only certain functions. + + For more information on \c CAknAppUi, please see the S60 + documentation. + + Unlike other Qt classes, QS60MainAppUi behaves like an S60 class, + and can throw Symbian leaves. + + \sa QS60MainDocument, QS60MainApplication */ /*! diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 52595db..7405784 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -47,25 +47,31 @@ QT_BEGIN_NAMESPACE /*! - * \class QS60MainDocument - * \obsolete - * \since 4.6 - * \brief Helper class for S60 migration - * - * The QS60MainDocument provides a helper class for use in migrating from existing S60 based - * applications to Qt based applications. It is used in the exact same way as the - * \c CAknDocument class from Symbian, but internally provides extensions used by Qt. - * - * When modifying old S60 applications that rely on implementing functions in \c CAknDocument, - * the class should be modified to inherit from this class instead of \c CAknDocument. Then the - * application can choose to override only certain functions. - * - * For more information on \c CAknDocument, please see the S60 documentation. - * - * Unlike other Qt classes, QS60MainDocument behaves like an S60 class, and can throw Symbian - * leaves. - * - * \sa QS60MainApplication, QS60MainAppUi + \class QS60MainDocument + \since 4.6 + \brief The QS60MainDocument class is a helper class for S60 migration. + + \warning This class is provided only to get access to S60 specific + functionality in the application framework classes. It is not + portable. We strongly recommend against using it in new applications. + + The QS60MainDocument provides a helper class for use in migrating + from existing S60 based applications to Qt based applications. It is + used in the exact same way as the \c CAknDocument class from + Symbian, but internally provides extensions used by Qt. + + When modifying old S60 applications that rely on implementing + functions in \c CAknDocument, the class should be modified to + inherit from this class instead of \c CAknDocument. Then the + application can choose to override only certain functions. + + For more information on \c CAknDocument, please see the S60 + documentation. + + Unlike other Qt classes, QS60MainDocument behaves like an S60 class, + and can throw Symbian leaves. + + \sa QS60MainApplication, QS60MainAppUi */ /*! diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e8f6d39..738e36a 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1354,6 +1354,7 @@ static void match(int script, const QFontDef &request, #ifdef Q_WS_X11 load(family_name, script, forceXLFD); #else + Q_UNUSED(forceXLFD); load(family_name, script); #endif diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp index ffc0eb4..ff3f628 100644 --- a/src/gui/text/qfontengine_x11.cpp +++ b/src/gui/text/qfontengine_x11.cpp @@ -491,7 +491,7 @@ glyph_metrics_t QFontEngineXLFD::boundingBox(const QGlyphLayout &glyphs) // XCharStruct::rbearing is defined as distance from left edge to rightmost pixel xmax = qMax(xmax, overall.xoff + glyphs.offsets[i].x + xcs->rbearing); ymax = qMax(ymax, y + xcs->ascent + xcs->descent); - overall.xoff += glyphs.advances_x[i]; + overall.xoff += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6); } else { QFixed size = _fs->ascent; overall.x = qMin(overall.x, overall.xoff); diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index db4c07c..ee8b751 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -505,9 +505,13 @@ void QTextControlPrivate::startDrag() drag->setMimeData(data); Qt::DropActions actions = Qt::CopyAction; - if (interactionFlags & Qt::TextEditable) + Qt::DropAction action; + if (interactionFlags & Qt::TextEditable) { actions |= Qt::MoveAction; - Qt::DropAction action = drag->exec(actions, Qt::MoveAction); + action = drag->exec(actions, Qt::MoveAction); + } else { + action = drag->exec(actions, Qt::CopyAction); + } if (action == Qt::MoveAction && drag->target() != contextWidget) cursor.removeSelectedText(); diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 3521ade..9b7e8de 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -550,9 +550,9 @@ void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFor } } if (format.hasProperty(QTextFormat::FontLetterSpacing)) - writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()) ); + writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing())); if (format.hasProperty(QTextFormat::FontWordSpacing)) - writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontWordSpacing()) ); + writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing())); if (format.hasProperty(QTextFormat::FontUnderline)) writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"), format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none")); diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index b606538..0e888d6 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2174,11 +2174,14 @@ void QComboBox::insertSeparator(int index) /*! Removes the item at the given \a index from the combobox. This will update the current index if the index is removed. + + This function does nothing if \a index is out of range. */ void QComboBox::removeItem(int index) { - Q_ASSERT(index >= 0 && index < count()); Q_D(QComboBox); + if (index < 0 || index >= count()) + return; d->model->removeRows(index, 1, d->root); } diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 280ca63..10f8db8 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -560,7 +560,7 @@ QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialog Q_Q(QDialogButtonBox); QAction::SoftKeyRole softkeyRole; - QAction *action = new QAction(button->text(), q); + QAction *action = new QAction(button->text(), button); switch (role) { case ApplyRole: @@ -581,7 +581,6 @@ QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialog } QObject::connect(action, SIGNAL(triggered()), button, SIGNAL(clicked())); action->setSoftKeyRole(softkeyRole); - action->setEnabled(button->isEnabled()); return action; } #endif diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 5930540..7f9ff82 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1290,7 +1290,7 @@ void QLineControl::setCursorBlinkPeriod(int msec) m_blinkStatus = 1; } else { m_blinkTimer = 0; - if (m_blinkStatus == 0) + if (m_blinkStatus == 1) emit updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); } m_blinkPeriod = msec; diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 0947e1b..501e62f 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -119,7 +119,7 @@ void QMainWindowPrivate::init() q->setAttribute(Qt::WA_Hover); #ifdef QT_SOFTKEYS_ENABLED menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q); - menuBarAction->setObjectName("_q_menuSoftKeyAction"); + menuBarAction->setObjectName(QLatin1String("_q_menuSoftKeyAction")); #endif } @@ -933,7 +933,7 @@ static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where) } #ifndef QT_NO_TABBAR -/*! +/*! \property QMainWindow::documentMode \brief whether the tab bar for tabbed dockwidgets is set to document mode. \since 4.5 @@ -954,7 +954,7 @@ void QMainWindow::setDocumentMode(bool enabled) #endif // QT_NO_TABBAR #ifndef QT_NO_TABWIDGET -/*! +/*! \property QMainWindow::tabShape \brief the tab shape used for tabbed dock widgets. \since 4.5 diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 4fc3d3d..cee38ee 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1425,7 +1425,7 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) SetMenuItemProperty(data.submenuHandle, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else NSMenu *subMenu = static_cast<NSMenu *>(action->action->menu()->macMenu()); - if ([subMenu supermenu] != nil) { + if ([subMenu supermenu] && [subMenu supermenu] != [item menu]) { // The menu is already a sub-menu of another one. Cocoa will throw an exception, // in such cases. For the time being, a new QMenu with same set of actions is the // only workaround. @@ -1718,7 +1718,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action) GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused); SetMenuItemProperty(submenu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else - if ([submenu supermenu] != nil) + if ([submenu supermenu] && [submenu supermenu] != [item menu]) return; else [item setSubmenu:submenu]; |