summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp56
-rw-r--r--src/widgets/dialogs/qcolordialog.h1
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h14
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc2
-rw-r--r--src/widgets/kernel/qwidget.cpp11
-rw-r--r--src/widgets/styles/qfusionstyle.cpp3
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp12
-rw-r--r--src/widgets/widgets/qdockwidget.cpp5
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp3
10 files changed, 84 insertions, 27 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;
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
index f581df4cb3..7e2e79fc5d 100644
--- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -219,7 +219,7 @@
\section1 Custom Widgets in Layouts
When you make your own widget class, you should also communicate its layout
- properties. If the widget has a one of Qt's layouts, this is already taken
+ properties. If the widget uses one of Qt's layouts, this is already taken
care of. If the widget does not have any child widgets, or uses manual
layout, you can change the behavior of the widget using any or all of the
following mechanisms:
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 7b7600fdc3..40ecc8d184 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -7233,7 +7233,7 @@ QByteArray QWidget::saveGeometry() const
/*!
\since 4.2
- Restores the geometry and state top-level widgets stored in the
+ Restores the geometry and state of top-level widgets stored in the
byte array \a geometry. Returns \c true on success; otherwise
returns \c false.
@@ -12390,10 +12390,9 @@ static void releaseMouseGrabOfWidget(QWidget *widget)
\note Only visible widgets can grab mouse input. If isVisible()
returns \c false for a widget, that widget cannot call grabMouse().
- \note \b{(Mac OS X developers)} For \e Cocoa, calling
- grabMouse() on a widget only works when the mouse is inside the
- frame of that widget. For \e Carbon, it works outside the widget's
- frame as well, like for Windows and X11.
+ \note On Windows, grabMouse() only works when the mouse is inside a window
+ owned by the process.
+ On OS X, grabMouse() only works when the mouse is inside the frame of that widget.
\sa releaseMouse(), grabKeyboard(), releaseKeyboard()
*/
@@ -12414,7 +12413,7 @@ void QWidget::grabMouse()
\warning Grabbing the mouse might lock the terminal.
- \note \b{(Mac OS X developers)} See the note in QWidget::grabMouse().
+ \note See the note in QWidget::grabMouse().
\sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
*/
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 94b6000436..6ae0bde20a 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -514,6 +514,9 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
break;
}
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
+ if (arrow.isNull())
+ break;
+
QRect rect = option->rect;
QRect arrowRect;
int imageMax = qMin(arrow.height(), arrow.width());
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 282416971b..ea51d4989e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3397,8 +3397,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
state = QIcon::On;
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int labelWidth = pixmap.width();
- int labelHeight = pixmap.height();
+ int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
+ int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
+ int labelWidth = pixmapWidth;
+ int labelHeight = pixmapHeight;
int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
if (!button->text.isEmpty())
@@ -3407,15 +3409,15 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
//Determine label alignment:
if (textAlignment & Qt::AlignLeft) { /*left*/
iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
} else if (textAlignment & Qt::AlignHCenter) { /* center */
iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
} else { /*right*/
iconRect = QRect(textRect.x() + textRect.width() - labelWidth,
textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
}
iconRect = visualRect(button->direction, textRect, iconRect);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 01a1f5046e..4121074e2e 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -930,12 +930,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
initDrag(event->pos(), true);
if (state == 0)
break;
-#ifdef Q_WS_WIN
- // On Windows, NCA mouse events don't contain modifier info
- state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
-#else
state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
-#endif
startDrag();
break;
case QEvent::NonClientAreaMouseMove:
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 72a556db7c..e56fd111e5 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -288,8 +288,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) {
QTextBlock block = changeStartBlock;
- int blockLineCount = block.layout()->lineCount();
- if (block.isValid() && blockLineCount) {
+ if (block.isValid() && block.length()) {
QRectF oldBr = blockBoundingRect(block);
layoutBlock(block);
QRectF newBr = blockBoundingRect(block);