diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 34 | ||||
-rw-r--r-- | src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp | 17 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsproxywidget.cpp | 1 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetbackingstore.cpp | 31 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 6 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 4 | ||||
-rw-r--r-- | src/widgets/util/qflickgesture.cpp | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 1 |
11 files changed, 68 insertions, 46 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 45cde3c966..d0040c0afe 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -627,6 +627,7 @@ public: QColorPicker(QWidget* parent); ~QColorPicker(); + void setCrossVisible(bool visible); public slots: void setCol(int h, int s); @@ -650,6 +651,7 @@ private: void setCol(const QPoint &pt); QPixmap pix; + bool crossVisible; }; static int pWidth = 220; @@ -805,6 +807,7 @@ void QColorPicker::setCol(const QPoint &pt) QColorPicker::QColorPicker(QWidget* parent) : QFrame(parent) + , crossVisible(true) { hue = 0; sat = 0; setCol(150, 255); @@ -817,6 +820,14 @@ QColorPicker::~QColorPicker() { } +void QColorPicker::setCrossVisible(bool visible) +{ + if (crossVisible != visible) { + crossVisible = visible; + update(); + } +} + QSize QColorPicker::sizeHint() const { return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth()); @@ -858,12 +869,13 @@ void QColorPicker::paintEvent(QPaintEvent* ) QRect r = contentsRect(); p.drawPixmap(r.topLeft(), pix); - QPoint pt = colPt() + r.topLeft(); - p.setPen(Qt::black); - - p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); - p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); + if (crossVisible) { + QPoint pt = colPt() + r.topLeft(); + p.setPen(Qt::black); + p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); + p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); + } } void QColorPicker::resizeEvent(QResizeEvent *ev) @@ -1477,8 +1489,8 @@ bool QColorDialogPrivate::selectColor(const QColor &col) const QRgb *match = std::find(standardColors, standardColorsEnd, color); if (match != standardColorsEnd) { const int index = int(match - standardColors); - const int row = index / standardColorRows; - const int column = index % standardColorRows; + const int column = index / standardColorRows; + const int row = index % standardColorRows; _q_newStandard(row, column); standard->setCurrent(row, column); standard->setSelected(row, column); @@ -1493,8 +1505,8 @@ bool QColorDialogPrivate::selectColor(const QColor &col) const QRgb *match = std::find(customColors, customColorsEnd, color); if (match != customColorsEnd) { const int index = int(match - customColors); - const int row = index / customColorRows; - const int column = index % customColorRows; + const int column = index / customColorRows; + const int row = index % customColorRows; _q_newCustom(row, column); custom->setCurrent(row, column); custom->setSelected(row, column); @@ -1578,6 +1590,7 @@ void QColorDialogPrivate::_q_pickScreenColor() void QColorDialogPrivate::releaseColorPicking() { Q_Q(QColorDialog); + cp->setCrossVisible(true); q->removeEventFilter(colorPickingEventFilter); q->releaseMouse(); q->releaseKeyboard(); @@ -2174,6 +2187,9 @@ void QColorDialog::changeEvent(QEvent *e) bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) { + // If the cross is visible the grabbed color will be black most of the times + cp->setCrossVisible(!cp->geometry().contains(e->pos())); + const QPoint globalPos = e->globalPos(); const QColor color = grabScreenColor(globalPos); // QTBUG-39792, do not change standard, custom color selectors while moving as diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index cef2552e75..37b4a00e8e 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -61,7 +61,7 @@ public: //! [1] class CustomItem : public QGraphicsItem { - ... +public: enum { Type = UserType + 1 }; int type() const @@ -245,21 +245,6 @@ scene->destroyItemGroup(group); //! [17] -//! [QGraphicsItem type] -class CustomItem : public QGraphicsItem -{ - ... - enum { Type = UserType + 1 }; - - int type() const - { - // Enable the use of qgraphicsitem_cast with this item. - return Type; - } - ... -}; -//! [QGraphicsItem type] - //! [18] class QGraphicsPathItem : public QAbstractGraphicsShapeItem { diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 03f22a270f..a543445244 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -6592,7 +6592,7 @@ void QGraphicsItem::setData(int key, const QVariant &value) For example: - \snippet code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type + \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1 \sa UserType */ diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 68bc2ae1fa..a56c671180 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -270,6 +270,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()), receiver->mapToGlobal(pos.toPoint()), event->button(), event->buttons(), event->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, event->source()); QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber; QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget, diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 75979e3986..68f43aa750 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -53,6 +53,7 @@ #include <qstyleditemdelegate.h> #include <private/qabstractitemview_p.h> #include <private/qabstractitemmodel_p.h> +#include <private/qguiapplication_p.h> #ifndef QT_NO_ACCESSIBILITY #include <qaccessible.h> #endif @@ -1885,6 +1886,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event) QMouseEvent me(QEvent::MouseButtonPress, event->localPos(), event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(&me, event->source()); mousePressEvent(&me); return; } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 738f017e89..50a8066a41 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -619,6 +619,8 @@ public: QOpenGLContext *shareContext() const; + virtual QObject *focusObject() { return 0; } + #ifndef QT_NO_OPENGL virtual GLuint textureId() const { return 0; } virtual QImage grabFramebuffer() { return QImage(); } diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 38f02b2ed9..68beb9afca 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -957,9 +957,12 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatformTextureList *widgetTextures) { QWidgetPrivate *wd = QWidgetPrivate::get(widget); - if (wd->renderToTexture) - widgetTextures->appendTexture(wd->textureId(), QRect(widget->mapTo(tlw, QPoint()), widget->size()), - widget->testAttribute(Qt::WA_AlwaysStackOnTop)); + if (wd->renderToTexture) { + QPlatformTextureList::Flags flags = 0; + if (widget->testAttribute(Qt::WA_AlwaysStackOnTop)) + flags |= QPlatformTextureList::StacksOnTop; + widgetTextures->appendTexture(widget, wd->textureId(), QRect(widget->mapTo(tlw, QPoint()), widget->size()), flags); + } for (int i = 0; i < wd->children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(wd->children.at(i)); @@ -1150,28 +1153,20 @@ void QWidgetBackingStore::doSync() } #ifndef QT_NO_OPENGL - // There is something other dirty than the renderToTexture widgets. - // Now it is time to include the renderToTexture ones among the others. if (widgetTextures && widgetTextures->count()) { for (int i = 0; i < widgetTextures->count(); ++i) { - const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already - dirty += rect; - toClean += rect; + QWidget *w = widgetTextures->widget(i); + if (dirtyRenderToTextureWidgets.contains(w)) { + const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already + dirty += rect; + toClean += rect; + } } } -#endif - - // The dirtyRenderToTextureWidgets list is useless here, so just reset. As - // unintuitive as it is, we need to send paint events to renderToTexture - // widgets always when something (any widget) needs to be updated, even if - // the renderToTexture widget itself is clean, i.e. there was no update() - // call for it. This is because changing any widget will cause a flush and - // so a potentially blocking buffer swap for the window, and skipping paints - // for the renderToTexture widgets would make it impossible to have smoothly - // animated content in them. for (int i = 0; i < dirtyRenderToTextureWidgets.count(); ++i) resetWidget(dirtyRenderToTextureWidgets.at(i)); dirtyRenderToTextureWidgets.clear(); +#endif #ifndef QT_NO_GRAPHICSVIEW if (tlw->d_func()->extra->proxyWidget) { diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index fa9138344a..f543086969 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -147,6 +147,12 @@ QObject *QWidgetWindow::focusObject() const if (!widget) widget = m_widget; + if (widget) { + QObject *focusObj = QWidgetPrivate::get(widget)->focusObject(); + if (focusObj) + return focusObj; + } + return widget; } diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 3918b874e6..6f573ab809 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -879,6 +879,10 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg gbi.size = sz == QAquaSizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal; if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) { int width = 0; +#ifndef QT_NO_MDIAREA + if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget())) + width = r.size.width; +#endif ret = QSize(width, r.size.height); } } diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 8c87d9b269..f7abd008b7 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -40,6 +40,7 @@ #include "qgraphicssceneevent.h" #include "qgraphicsview.h" #include "qscroller.h" +#include "private/qapplication_p.h" #include "private/qevent_p.h" #include "private/qflickgesture_p.h" #include "qdebug.h" @@ -65,7 +66,9 @@ static QMouseEvent *copyMouseEvent(QEvent *e) case QEvent::MouseButtonRelease: case QEvent::MouseMove: { QMouseEvent *me = static_cast<QMouseEvent *>(e); - return new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(cme, me->source()); + return cme; } #ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMousePress: @@ -75,7 +78,9 @@ static QMouseEvent *copyMouseEvent(QEvent *e) #if 1 QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress : (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove); - return new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(cme, me->source()); + return cme; #else QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type()); copy->setPos(me->pos()); @@ -113,6 +118,7 @@ private: , sendingEvent(false) , mouseButton(Qt::NoButton) , mouseTarget(0) + , mouseEventSource(Qt::MouseEventNotSynthesized) { } static PressDelayHandler *inst; @@ -148,6 +154,7 @@ public: pressDelayTimer = startTimer(delay); mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos()); mouseButton = pressDelayEvent->button(); + mouseEventSource = pressDelayEvent->source(); qFGDebug() << "QFG: consuming/delaying mouse press"; } else { qFGDebug() << "QFG: NOT consuming/delaying mouse press"; @@ -234,6 +241,7 @@ public: QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway, mouseButton, QApplication::mouseButtons() & ~mouseButton, QApplication::keyboardModifiers()); + QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource); sendMouseEvent(&re, RegrabMouseAfterwards); // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release! } @@ -284,6 +292,7 @@ protected: QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(), me->button(), me->buttons(), me->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(©, me->source()); qt_sendSpontaneousEvent(mouseTarget, ©); } @@ -309,6 +318,7 @@ private: bool sendingEvent; Qt::MouseButton mouseButton; QPointer<QWidget> mouseTarget; + Qt::MouseEventSource mouseEventSource; }; diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index c9e8ed8e48..7e70be0aed 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1111,6 +1111,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), e->button(), e->buttons(), e->modifiers()); + QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source()); QApplication::sendEvent(caused, &new_e); return true; } |