summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp6
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp49
-rw-r--r--src/widgets/kernel/qshortcut.cpp27
-rw-r--r--src/widgets/kernel/qwidget.cpp18
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp4
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp2
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm23
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp2
10 files changed, 100 insertions, 35 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index e2f5950e4b..bf1af239df 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -1893,6 +1893,8 @@ void QColorDialog::setOptions(ColorDialogOptions options)
d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options)));
d->buttons->setVisible(!(options & NoButtons));
d->showAlpha(options & ShowAlphaChannel);
+ if (options & DontUseNativeDialog)
+ d->nativeDialogInUse = false;
}
QColorDialog::ColorDialogOptions QColorDialog::options() const
@@ -1911,8 +1913,8 @@ QColorDialog::ColorDialogOptions QColorDialog::options() const
\value ShowAlphaChannel Allow the user to select the alpha component of a color.
\value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".)
- \value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's
- native color panel.
+ \value DontUseNativeDialog Use Qt's standard color dialog instead of the operating system
+ native color dialog.
\sa options, setOption(), testOption(), windowModality()
*/
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 4ec828ac83..995d279e13 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1392,7 +1392,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
#if !defined(QT_NO_TEXTEDIT)
if (e == QKeySequence::Copy) {
- if (d->detailsText->isVisible() && d->detailsText->copy()) {
+ if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) {
e->setAccepted(true);
return;
}
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 3fabeb1445..adccee9426 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2842,6 +2842,37 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
}
+ switch (e->type()) {
+ case QEvent::KeyPress:
+ {
+ bool isWidget = receiver->isWidgetType();
+ bool isWindow = receiver->isWindowType();
+ bool isGraphicsWidget = false;
+#ifndef QT_NO_GRAPHICSVIEW
+ isGraphicsWidget = !isWidget && !isWindow && qobject_cast<QGraphicsWidget *>(receiver);
+#endif
+ if (!isWidget && !isGraphicsWidget && !isWindow) {
+ return d->notify_helper(receiver, e);
+ }
+
+ QKeyEvent* key = static_cast<QKeyEvent*>(e);
+#ifndef QT_NO_SHORTCUT
+ // Try looking for a Shortcut before sending key events
+ if (qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key))
+ return true;
+#endif
+ qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
+ || key->key() == Qt::Key_Tab
+ || key->key() == Qt::Key_Left
+ || key->key() == Qt::Key_Up
+ || key->key() == Qt::Key_Right
+ || key->key() == Qt::Key_Down);
+
+ }
+ default:
+ break;
+ }
+
bool res = false;
if (!receiver->isWidgetType()) {
res = d->notify_helper(receiver, e);
@@ -2855,25 +2886,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
#ifndef QT_NO_GRAPHICSVIEW
isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
#endif
- if (!isWidget && !isGraphicsWidget) {
- res = d->notify_helper(receiver, e);
- break;
- }
-
QKeyEvent* key = static_cast<QKeyEvent*>(e);
- if (key->type()==QEvent::KeyPress) {
-#ifndef QT_NO_SHORTCUT
- // Try looking for a Shortcut before sending key events
- if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
- return res;
-#endif
- qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
- || key->key() == Qt::Key_Tab
- || key->key() == Qt::Key_Left
- || key->key() == Qt::Key_Up
- || key->key() == Qt::Key_Right
- || key->key() == Qt::Key_Down);
- }
bool def = key->isAccepted();
QPointer<QObject> pr = receiver;
while (receiver) {
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index c5cdce3d60..471b054a99 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -51,6 +51,7 @@
#include <private/qapplication_p.h>
#include <private/qshortcutmap_p.h>
#include <private/qaction_p.h>
+#include <private/qwidgetwindow_qpa_p.h>
QT_BEGIN_NAMESPACE
@@ -86,6 +87,20 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
if (QApplication::activePopupWidget())
active_window = QApplication::activePopupWidget();
+ if (!active_window) {
+ QWindow *qwindow = QGuiApplication::focusWindow();
+ if (qwindow && qwindow->isActive()) {
+ while (qwindow) {
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widgetWindow) {
+ active_window = widgetWindow->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+ }
+
if (!active_window)
return false;
@@ -106,6 +121,18 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
w = s->parentWidget();
}
+ if (!w) {
+ QWindow *qwindow = qobject_cast<QWindow *>(object);
+ while (qwindow) {
+ QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widget_window) {
+ w = widget_window->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+
if (!w)
return false;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 3eb949f814..a0c723fa0d 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -104,6 +104,8 @@
#include "qtabwidget.h" // Needed in inTabWidget()
#endif // QT_KEYPAD_NAVIGATION
+#include "qwindowcontainer_p.h"
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
@@ -1549,10 +1551,11 @@ void QWidgetPrivate::createTLExtra()
x->inTopLevelResize = false;
x->inRepaint = false;
x->embedded = 0;
+ x->window = 0;
+ x->screenIndex = 0;
#ifdef Q_WS_MAC
x->wasMaximized = false;
#endif // Q_WS_MAC
- createTLSysExtra();
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
qDebug() << "tlextra" << ++count;
@@ -6252,6 +6255,17 @@ bool QWidget::isActiveWindow() const
}
}
+ // Check for an active window container
+ if (QWindow *ww = QGuiApplication::focusWindow()) {
+ while (ww) {
+ QWidgetWindow *qww = qobject_cast<QWidgetWindow *>(ww);
+ QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0;
+ if (qwc && qwc->topLevelWidget() == tlw)
+ return true;
+ ww = ww->parent();
+ }
+ }
+
// Check if platform adaptation thinks the window is active. This is necessary for
// example in case of ActiveQt servers that are embedded into another application.
// Those are separate processes that are not part of the parent application Qt window/widget
@@ -10112,6 +10126,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break; }
case Qt::WA_NativeWindow: {
d->createTLExtra();
+ if (on)
+ d->createTLSysExtra();
#ifndef QT_NO_IM
QWidget *focusWidget = d->effectiveFocusWidget();
if (on && !internalWinId() && hasFocus()
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 3b6c9ca448..dafe7dc42a 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -890,9 +890,7 @@ void QWidgetPrivate::deleteSysExtra()
void QWidgetPrivate::createTLSysExtra()
{
Q_Q(QWidget);
- extra->topextra->screenIndex = 0;
- extra->topextra->window = 0;
- if (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow()) {
+ if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) {
extra->topextra->window = new QWidgetWindow(q);
if (extra->minw || extra->minh)
extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh));
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index c19b617091..18dd3156c6 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -446,7 +446,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (!widget)
widget = m_widget;
- if (event->type() == QEvent::MouseButtonPress && !qt_button_down)
+ if (event->type() == QEvent::MouseButtonPress)
qt_button_down = widget;
QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index f8905b1b1a..dad4e57d13 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -1630,6 +1630,19 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti
}
}
+void QMacStylePrivate::setAutoDefaultButton(QObject *button) const
+{
+ if (autoDefaultButton != button) {
+ if (QStyleAnimation *anim = animation(autoDefaultButton)) {
+ anim->updateTarget();
+ stopAnimation(autoDefaultButton);
+ }
+ autoDefaultButton = button;
+ }
+ if (autoDefaultButton && !animation(autoDefaultButton))
+ startAnimation(new QStyleAnimation(autoDefaultButton));
+}
+
QMacStylePrivate::QMacStylePrivate()
: mouseDown(false)
{
@@ -3497,15 +3510,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// takes precedence over a normal default button
if (btn->features & QStyleOptionButton::AutoDefaultButton
&& opt->state & State_Active && opt->state & State_HasFocus) {
- d->autoDefaultButton = opt->styleObject;
- if (!d->animation(opt->styleObject))
- d->startAnimation(new QStyleAnimation(opt->styleObject));
+ d->setAutoDefaultButton(opt->styleObject);
} else if (d->autoDefaultButton == opt->styleObject) {
- if (QStyleAnimation *animation = d->animation(opt->styleObject)) {
- animation->updateTarget();
- d->stopAnimation(opt->styleObject);
- }
- d->autoDefaultButton = 0;
+ d->setAutoDefaultButton(0);
}
if (!d->autoDefaultButton) {
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index bf42087fcb..efeaa66e39 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -194,6 +194,8 @@ public:
HIThemeButtonDrawInfo *bdi) const;
QPixmap generateBackgroundPattern() const;
+ void setAutoDefaultButton(QObject *button) const;
+
public:
mutable QPointer<QObject> pressedButton;
mutable QPointer<QObject> defaultButton;
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index ae931deb16..7cd7172ef5 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -873,7 +873,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
QPoint pos = event->globalPos() - state->pressPos;
q->move(pos);
- if (!state->ctrlDrag)
+ if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos());
ret = true;