From ab84aa53affd6215abcdbe6dc56a0ca021a49d6b Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 16 Mar 2012 17:02:49 -0700 Subject: QWidget: update documents of mouseDoubleClickEvent() Double click behavior has been changed. see SHA: b371f3f943703840d0dfbe30505018bcca06e260 Change-Id: Ibd921d01fb25b8c31f75105a4ff63c42bf00c335 Reviewed-by: Casper van Donderen Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a4bb205b76..5457c54f5d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -612,8 +612,9 @@ void QWidget::setAutoFillBackground(bool enabled) steals the mouse events. \li mouseDoubleClickEvent() is called when the user double-clicks in the widget. If the user double-clicks, the widget receives a mouse - press event, a mouse release event and finally this event instead - of a second mouse press event. (Some mouse move events may also be + press event, a mouse release event, (a mouse click event,) a second + mouse press, this event and finally a second mouse release event. + (Some mouse move events may also be received if the mouse is not held steady during this operation.) It is \e{not possible} to distinguish a click from a double-click until the second click arrives. (This is one reason why most GUI -- cgit v1.2.3 From 478658fd41dba6c0d94edfbe31086dc3cabff533 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Sat, 17 Mar 2012 22:59:10 -0700 Subject: QtWidgets: cleanup several Q3* items Change-Id: I0812cdd74f19b4c98336724ea722807d4c68cf7d Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 5457c54f5d..1bf3d3cff9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2708,7 +2708,7 @@ Qt::WindowStates QWidget::windowState() const The function sets the window state on child widgets similar to setWindowState(). The difference is that the window state changed event has the isOverride() flag set. It exists mainly to keep - Q3Workspace working. + QWorkspace working. */ void QWidget::overrideWindowState(Qt::WindowStates newstate) { -- cgit v1.2.3 From c2e8db58413207315474232697f12ddceb8310e7 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 12 Mar 2012 19:43:03 +0100 Subject: Remove QAccessibleEvent child parameter. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the api cleaner and generally the child should not be there. It is only sometimes more convenient not to create a QAccessibleInterface instance, so the functionallity is kept. Change-Id: I26018a6d3e0549f4d79856775b4167c5660e229d Reviewed-by: Jan-Arve Sæther --- src/widgets/kernel/qwhatsthis.cpp | 4 ++-- src/widgets/kernel/qwidget.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 114cde59e9..88c41a5fba 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -412,7 +412,7 @@ QWhatsThisPrivate::QWhatsThisPrivate() #endif } #ifndef QT_NO_ACCESSIBILITY - QAccessibleEvent event(QAccessible::ContextHelpStart, this); + QAccessibleEvent event(this, QAccessible::ContextHelpStart); QAccessible::updateAccessibility(&event); #endif } @@ -425,7 +425,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate() QApplication::restoreOverrideCursor(); #endif #ifndef QT_NO_ACCESSIBILITY - QAccessibleEvent event(QAccessible::ContextHelpEnd, this); + QAccessibleEvent event(this, QAccessible::ContextHelpEnd); QAccessible::updateAccessibility(&event); #endif instance = 0; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 1bf3d3cff9..6418ba63e1 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5967,7 +5967,7 @@ void QWidget::setFocus(Qt::FocusReason reason) if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) # endif { - QAccessibleEvent event(QAccessible::Focus, f); + QAccessibleEvent event(f, QAccessible::Focus); QAccessible::updateAccessibility(&event); } #endif @@ -6049,7 +6049,7 @@ void QWidget::clearFocus() #endif { #ifndef QT_NO_ACCESSIBILITY - QAccessibleEvent event(QAccessible::Focus, this); + QAccessibleEvent event(this, QAccessible::Focus); QAccessible::updateAccessibility(&event); #endif } @@ -7057,7 +7057,7 @@ void QWidgetPrivate::show_helper() #ifndef QT_NO_ACCESSIBILITY if (q->windowType() != Qt::ToolTip) { // Tooltips are read aloud twice in MS narrator. - QAccessibleEvent event(QAccessible::ObjectShow, q); + QAccessibleEvent event(q, QAccessible::ObjectShow); QAccessible::updateAccessibility(&event); } #endif @@ -7150,7 +7150,7 @@ void QWidgetPrivate::hide_helper() #ifndef QT_NO_ACCESSIBILITY if (wasVisible) { - QAccessibleEvent event(QAccessible::ObjectHide, q); + QAccessibleEvent event(q, QAccessible::ObjectHide); QAccessible::updateAccessibility(&event); } #endif @@ -7384,7 +7384,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) qApp->d_func()->sendSyntheticEnterLeave(widget); #ifndef QT_NO_ACCESSIBILITY if (!spontaneous) { - QAccessibleEvent event(QAccessible::ObjectHide, widget); + QAccessibleEvent event(widget, QAccessible::ObjectHide); QAccessible::updateAccessibility(&event); } #endif @@ -8261,7 +8261,7 @@ void QWidget::changeEvent(QEvent * event) #ifndef QT_NO_ACCESSIBILITY QAccessible::State s; s.disabled = true; - QAccessibleStateChangeEvent event(s, this); + QAccessibleStateChangeEvent event(this, s); QAccessible::updateAccessibility(&event); #endif break; @@ -10403,7 +10403,7 @@ void QWidget::setAccessibleName(const QString &name) { Q_D(QWidget); d->accessibleName = name; - QAccessibleEvent event(QAccessible::NameChanged, this); + QAccessibleEvent event(this, QAccessible::NameChanged); QAccessible::updateAccessibility(&event); } @@ -10426,7 +10426,7 @@ void QWidget::setAccessibleDescription(const QString &description) { Q_D(QWidget); d->accessibleDescription = description; - QAccessibleEvent event(QAccessible::DescriptionChanged, this); + QAccessibleEvent event(this, QAccessible::DescriptionChanged); QAccessible::updateAccessibility(&event); } -- cgit v1.2.3 From c4ac14fae1765cae9d5ab94c8af486e2d14dede7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 17 Mar 2012 19:46:33 +0100 Subject: Fix KDE palette. In QKdeTheme We want to load every color. Else, only the first color is loaded, and the rest of the palette is just black making the applications basicaly not usable. But KDE only put in its config files the colors that are different from the default colors. This is the reason why we need to resolve against the style's default palette. We need to make sure the resolve_mask is 0 for an empty palette, even before the application palette is set. This was not required in Qt4 because the system palette was initialized differently. I realize this will only work with QApplication (and not with a single QGuiApplication) but it was not working before either. Change-Id: Ifb3c2c1358ef6d83a1ca5aa8fac3d2d4ea712b94 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 348eb2f343..7441d55865 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -130,14 +130,17 @@ QApplicationPrivate *QApplicationPrivate::self = 0; static void initSystemPalette() { - if (!QApplicationPrivate::sys_pal) + if (!QApplicationPrivate::sys_pal) { + QPalette defaultPlatte; + if (QApplicationPrivate::app_style) + defaultPlatte = QApplicationPrivate::app_style->standardPalette(); if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) { - QApplicationPrivate::setSystemPalette(*themePalette); + QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte)); QApplicationPrivate::initializeWidgetPaletteHash(); + } else { + QApplicationPrivate::setSystemPalette(defaultPlatte); } - - if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style) - QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); + } } static void clearSystemPalette() -- cgit v1.2.3 From 7e90df7bf5aafd09ea5ed8bcc370db6a8912d173 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 1 Mar 2012 16:54:50 +0200 Subject: FocusAboutToChange event to be send before focus changes Focus change happen as: FocusAboutToChange event -> focus change -> FocusOut event -> FocusIn event. Input method need to have focus when calling commit(). Notification on focus about to be lost allows QWindow implementations to commit in time. Also changes QWidget documentation to match code reality. Change-Id: I17a8a374a33dd700909f79e370b42348869261a6 Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qapplication.cpp | 19 ++++----- src/widgets/kernel/qwidget.cpp | 72 ++++++++++++++++++++++++-------- src/widgets/kernel/qwidget_p.h | 1 + src/widgets/kernel/qwidgetwindow_qpa.cpp | 9 ++++ 4 files changed, 72 insertions(+), 29 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 7441d55865..ce57e2868d 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1760,16 +1760,6 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) } QWidget *prev = focus_widget; focus_widget = focus; -#ifndef QT_NO_IM - if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason - && prev->testAttribute(Qt::WA_InputMethodEnabled)) - // Do reset the input context, in case the new focus widget won't accept keyboard input - // or it is not created fully yet. - || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled) - || !focus_widget->testAttribute(Qt::WA_WState_Created))))) { - qApp->inputMethod()->reset(); - } -#endif //QT_NO_IM if(focus_widget) focus_widget->d_func()->setFocus_sys(); @@ -1798,7 +1788,6 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) QApplication::sendEvent(that->style(), &in); } emit qApp->focusChanged(prev, focus_widget); - emit qApp->focusObjectChanged(focus_widget); } } } @@ -2051,6 +2040,14 @@ void QApplication::setActiveWindow(QWidget* act) } } + if (QApplicationPrivate::focus_widget) { + if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) + qApp->inputMethod()->reset(); + + QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); + QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); + } + QApplicationPrivate::active_window = window; if (QApplicationPrivate::active_window) { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6418ba63e1..63eb2540ff 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5875,9 +5875,10 @@ bool QWidget::hasFocus() const If the window is not active, the widget will be given the focus when the window becomes active. - First, a focus out event is sent to the focus widget (if any) to - tell it that it is about to lose the focus. Then a focus in event - is sent to this widget to tell it that it just received the focus. + First, a focus about to change event is sent to the focus widget (if any) to + tell it that it is about to lose the focus. Then focus is changed, a + focus out event is sent to the previous focus item and a focus in event is sent + to the new item to tell it that it just received the focus. (Nothing happens if the focus in and focus out widgets are the same.) @@ -5930,23 +5931,11 @@ void QWidget::setFocus(Qt::FocusReason reason) } #endif - QWidget *w = f; - if (isHidden()) { - while (w && w->isHidden()) { - w->d_func()->focus_child = f; - w = w->isWindow() ? 0 : w->parentWidget(); - } - } else { - while (w) { - w->d_func()->focus_child = f; - w = w->isWindow() ? 0 : w->parentWidget(); - } - } - #ifndef QT_NO_GRAPHICSVIEW // Update proxy state if (QWExtra *topData = window()->d_func()->extra) { if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) { + f->d_func()->updateFocusChild(); topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1; topData->proxyWidget->setFocus(reason); topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0; @@ -5955,6 +5944,21 @@ void QWidget::setFocus(Qt::FocusReason reason) #endif if (f->isActiveWindow()) { + QWidget *prev = QApplicationPrivate::focus_widget; + if (prev) { + if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason + && prev->testAttribute(Qt::WA_InputMethodEnabled)) { + qApp->inputMethod()->reset(); + } + + if (reason != Qt::NoFocusReason) { + QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); + QApplication::sendEvent(prev, &focusAboutToChange); + } + } + + f->d_func()->updateFocusChild(); + QApplicationPrivate::setFocusWidget(f, reason); #ifndef QT_NO_ACCESSIBILITY # ifdef Q_OS_WIN @@ -5999,6 +6003,30 @@ void QWidget::setFocus(Qt::FocusReason reason) } } #endif + } else { + f->d_func()->updateFocusChild(); + } + + if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) + emit extra->window->focusObjectChanged(f); +} + +// updates focus_child on parent widgets to point into this widget +void QWidgetPrivate::updateFocusChild() +{ + Q_Q(QWidget); + + QWidget *w = q; + if (q->isHidden()) { + while (w && w->isHidden()) { + w->d_func()->focus_child = q; + w = w->isWindow() ? 0 : w->parentWidget(); + } + } else { + while (w) { + w->d_func()->focus_child = q; + w = w->isWindow() ? 0 : w->parentWidget(); + } } } @@ -6015,8 +6043,8 @@ void QWidget::setFocus(Qt::FocusReason reason) Takes keyboard input focus from the widget. If the widget has active focus, a \link focusOutEvent() focus out - event\endlink is sent to this widget to tell it that it is about - to lose the focus. + event\endlink is sent to this widget to tell it that it has + lost the focus. This widget must enable focus setting in order to get the keyboard input focus, i.e. it must call setFocusPolicy(). @@ -6027,6 +6055,14 @@ void QWidget::setFocus(Qt::FocusReason reason) void QWidget::clearFocus() { + if (hasFocus()) { + if (testAttribute(Qt::WA_InputMethodEnabled)) + qApp->inputMethod()->reset(); + + QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); + QApplication::sendEvent(this, &focusAboutToChange); + } + QWidget *w = this; while (w) { if (w->d_func()->focus_child == this) diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 38314c234b..8107b6ca74 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -336,6 +336,7 @@ public: void stackUnder_sys(QWidget *); void setFocus_sys(); + void updateFocusChild(); void updateFont(const QFont &); inline void setFont_helper(const QFont &font) { diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index f58dddb70f..7a13e2032e 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -99,6 +99,15 @@ bool QWidgetWindow::event(QEvent *event) case QEvent::FocusOut: return false; + case QEvent::FocusAboutToChange: + if (QApplicationPrivate::focus_widget) { + if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) + qApp->inputMethod()->commit(); + + QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event); + } + return true; + case QEvent::KeyPress: case QEvent::KeyRelease: handleKeyEvent(static_cast(event)); -- cgit v1.2.3 From 1a414cbc2664621431028593ea7b6de3e730d556 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Mar 2012 15:00:56 +0100 Subject: Fix QSysInfo::WindowsVersion checking (QSysInfo::WV_NT_based is a mask) Manual merge of the original fix 1ef309e9 in the Qt 4.8 repo. Task-number: QTBUG-20480 Change-Id: Id08500c2dd16965af3942e65cff1f4afa24180b0 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwhatsthis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 88c41a5fba..9d3493dc8a 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -291,7 +291,7 @@ void QWhatsThat::paintEvent(QPaintEvent*) bool drawShadow = true; #if defined(Q_WS_WIN) if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) + && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) { BOOL shadow; SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0); -- cgit v1.2.3 From 82c974f753e0081f8bedc356ea07a8cfa6fae583 Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Tue, 20 Mar 2012 11:38:59 +0000 Subject: Deprecate QApplication::setGraphicsSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QApplication::setGraphicsSystem() call is entirely vestigial after the QPA rearchitecting of Qt. Deprecate it to give people a heads up that their original intent no longer has any impact on their application. Change-Id: I21838431db1057f7f7858b4a434ae0eebd2317de Reviewed-by: Thiago Macieira Reviewed-by: Samuel Rødal Reviewed-by: Girish Ramakrishnan Reviewed-by: Lars Knoll --- src/widgets/kernel/qapplication.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 55ed6998fa..3e11db0863 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -111,8 +111,9 @@ public: enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; static int colorSpec(); static void setColorSpec(int); - // ### Qt4 compatibility, remove? - static inline void setGraphicsSystem(const QString &) {} +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {} +#endif using QGuiApplication::palette; static QPalette palette(const QWidget *); -- cgit v1.2.3