diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-01-19 13:49:52 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-01-21 11:10:14 +0100 |
commit | b6191b16d41459ed73cea738dfaf8e25e81ae22b (patch) | |
tree | 6ad0952af507bf1ab8df9612023d6e224db8d7e2 /src/widgets/dialogs | |
parent | b2883a6acc7a8d8372a815cc91dd1a8449f25723 (diff) | |
parent | 9087df6bd2dd5198ccf101a237aadee331e51ec3 (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/corelib/global/global.pri
src/corelib/global/qcompilerdetection.h
src/corelib/global/qglobal.h
src/corelib/tools/qdatetime.cpp
src/plugins/platforms/xcb/qxcbscreen.h
src/plugins/platforms/xcb/qxcbwindow.h
src/widgets/dialogs/qcolordialog.cpp
src/widgets/dialogs/qcolordialog_p.h
tools/configure/configureapp.cpp
Change-Id: Ie9d6e9df13e570da0a90a67745a0d05f46c532af
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 56 | ||||
-rw-r--r-- | src/widgets/dialogs/qcolordialog.h | 1 | ||||
-rw-r--r-- | src/widgets/dialogs/qcolordialog_p.h | 14 | ||||
-rw-r--r-- | src/widgets/dialogs/qprogressdialog.cpp | 4 |
4 files changed, 67 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index aa1b4b1023..5fffe61877 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -57,6 +57,7 @@ #include "qdialogbuttonbox.h" #include "qscreen.h" #include "qcursor.h" +#include "qtimer.h" #include <algorithm> @@ -1539,8 +1540,18 @@ void QColorDialogPrivate::_q_pickScreenColor() #else q->grabMouse(); #endif + +#ifdef Q_OS_WIN32 // excludes WinCE and WinRT + // On Windows mouse tracking doesn't work over other processes's windows + updateTimer->start(30); + + // HACK: Because mouse grabbing doesn't work across processes, we have to have a dummy, + // invisible window to catch the mouse click, otherwise we will click whatever we clicked + // and loose focus. + dummyTransparentWindow.show(); +#endif q->grabKeyboard(); - /* With setMouseTracking(true) the desired color can be more precisedly picked up, + /* With setMouseTracking(true) the desired color can be more precisely picked up, * and continuously pushing the mouse button is not necessary. */ q->setMouseTracking(true); @@ -1567,6 +1578,10 @@ void QColorDialogPrivate::releaseColorPicking() cp->setCrossVisible(true); q->removeEventFilter(colorPickingEventFilter); q->releaseMouse(); +#ifdef Q_OS_WIN32 + updateTimer->stop(); + dummyTransparentWindow.setVisible(false); +#endif q->releaseKeyboard(); q->setMouseTracking(false); lblScreenColorInfo->setText(QLatin1String("\n")); @@ -1593,6 +1608,10 @@ void QColorDialogPrivate::init(const QColor &initial) #ifdef Q_WS_MAC delegate = 0; #endif +#ifdef Q_OS_WIN32 + dummyTransparentWindow.resize(1, 1); + dummyTransparentWindow.setFlags(Qt::Tool | Qt::FramelessWindowHint); +#endif q->setCurrentColor(initial); } @@ -1733,6 +1752,10 @@ void QColorDialogPrivate::initWidgets() cancel = buttons->addButton(QDialogButtonBox::Cancel); QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject())); +#ifdef Q_OS_WIN32 + updateTimer = new QTimer(q); + QObject::connect(updateTimer, SIGNAL(timeout()), q, SLOT(_q_updateColorPicking())); +#endif retranslateStrings(); } @@ -2138,18 +2161,41 @@ void QColorDialog::changeEvent(QEvent *e) QDialog::changeEvent(e); } -bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) +void QColorDialogPrivate::_q_updateColorPicking() { - // If the cross is visible the grabbed color will be black most of the times - cp->setCrossVisible(!cp->geometry().contains(e->pos())); +#ifndef QT_NO_CURSOR + Q_Q(QColorDialog); + static QPoint lastGlobalPos; + QPoint newGlobalPos = QCursor::pos(); + if (lastGlobalPos == newGlobalPos) + return; + lastGlobalPos = newGlobalPos; - const QPoint globalPos = e->globalPos(); + if (!q->rect().contains(q->mapFromGlobal(newGlobalPos))) { // Inside the dialog mouse tracking works, handleColorPickingMouseMove will be called + updateColorPicking(newGlobalPos); +#ifdef Q_OS_WIN32 + dummyTransparentWindow.setPosition(newGlobalPos); +#endif + } +#endif // ! QT_NO_CURSOR +} + +void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos) +{ const QColor color = grabScreenColor(globalPos); // QTBUG-39792, do not change standard, custom color selectors while moving as // otherwise it is not possible to pre-select a custom cell for assignment. setCurrentColor(color, ShowColor); updateColorLabelText(globalPos); +} + +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())); + + updateColorPicking(e->globalPos()); return true; } diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index 22ff907e7a..87e62be81f 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -112,6 +112,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor()) + Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking()) friend class QColorShower; }; diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 7e6c8b1231..cf8bb33d94 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -49,6 +49,7 @@ #include "private/qdialog_p.h" #include "qcolordialog.h" #include "qsharedpointer.h" +#include "qwindow.h" #ifndef QT_NO_COLORDIALOG @@ -63,6 +64,7 @@ class QVBoxLayout; class QPushButton; class QWellArray; class QColorPickingEventFilter; +class QTimer; class QColorDialogPrivate : public QDialogPrivate { @@ -75,7 +77,11 @@ public: SetColorAll = ShowColor | SelectColor }; - QColorDialogPrivate() : options(new QColorDialogOptions) {} + QColorDialogPrivate() : options(new QColorDialogOptions) +#ifdef Q_OS_WIN32 + , updateTimer(0) +#endif + {} QPlatformColorDialogHelper *platformColorDialogHelper() const { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); } @@ -104,7 +110,9 @@ public: void _q_newCustom(int, int); void _q_newStandard(int, int); void _q_pickScreenColor(); + void _q_updateColorPicking(); void updateColorLabelText(const QPoint &); + void updateColorPicking(const QPoint &pos); void releaseColorPicking(); bool handleColorPickingMouseMove(QMouseEvent *e); bool handleColorPickingMouseButtonRelease(QMouseEvent *e); @@ -137,6 +145,10 @@ public: QPointer<QObject> receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; +#ifdef Q_OS_WIN32 + QTimer *updateTimer; + QWindow dummyTransparentWindow; +#endif #ifdef Q_WS_MAC void openCocoaColorPanel(const QColor &initial, diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index c6d1df04aa..3f178189b9 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -110,10 +110,10 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance { Q_Q(QProgressDialog); label = new QLabel(labelText, q); - int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); - label->setAlignment(Qt::Alignment(align)); bar = new QProgressBar(q); bar->setRange(min, max); + int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); + label->setAlignment(Qt::Alignment(align)); autoClose = true; autoReset = true; forceHide = false; |