summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qlocale_p.h6
-rw-r--r--src/gui/image/qimage.cpp36
-rw-r--r--src/gui/image/qplatformpixmap.cpp1
-rw-r--r--src/gui/painting/qbrush.cpp12
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp30
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm9
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp9
8 files changed, 87 insertions, 21 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 98b6a31a46..70430beb00 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -254,10 +254,8 @@ public:
const float huge = std::numeric_limits<float>::infinity();
return d < 0 ? -huge : huge;
}
- if (std::fabs(d) >= std::numeric_limits<double>::min() // i.e. d != 0
- && std::fabs(d) < std::numeric_limits<float>::min()) {
- // Values smaller than std::numeric_limits<double>::min() have
- // failed already; match them.
+ if (d != 0 && float(d) == 0) {
+ // Values that underflow double already failed. Match them:
if (ok != 0)
*ok = false;
return 0;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 0463ef6a42..f3857259ed 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1091,15 +1091,31 @@ void QImage::detach()
}
-static void copyMetadata(QImageData *dst, const QImageData *src)
+static void copyPhysicalMetadata(QImageData *dst, const QImageData *src)
{
- // Doesn't copy colortable and alpha_clut, or offset.
dst->dpmx = src->dpmx;
dst->dpmy = src->dpmy;
dst->devicePixelRatio = src->devicePixelRatio;
+}
+
+static void copyMetadata(QImageData *dst, const QImageData *src)
+{
+ // Doesn't copy colortable and alpha_clut, or offset.
+ copyPhysicalMetadata(dst, src);
dst->text = src->text;
}
+static void copyMetadata(QImage *dst, const QImage &src)
+{
+ dst->setDotsPerMeterX(src.dotsPerMeterX());
+ dst->setDotsPerMeterY(src.dotsPerMeterY());
+ dst->setDevicePixelRatio(src.devicePixelRatio());
+ const auto textKeys = src.textKeys();
+ for (const auto &key: textKeys)
+ dst->setText(key, src.text(key));
+
+}
+
/*!
\fn QImage QImage::copy(int x, int y, int width, int height) const
\overload
@@ -2951,8 +2967,10 @@ QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags) const
}
QImage mask(d->width, d->height, Format_MonoLSB);
- if (!mask.isNull())
+ if (!mask.isNull()) {
dither_to_Mono(mask.d, d, flags, true);
+ copyPhysicalMetadata(mask.d, d);
+ }
return mask;
}
@@ -3070,6 +3088,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const
#undef PIX
+ copyPhysicalMetadata(m.d, d);
return m;
}
#endif //QT_NO_IMAGE_HEURISTIC_MASK
@@ -3113,6 +3132,8 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
}
if (mode == Qt::MaskOutColor)
maskImage.invertPixels();
+
+ copyPhysicalMetadata(maskImage.d, d);
return maskImage;
}
@@ -4684,8 +4705,7 @@ QImage QImage::smoothScaled(int w, int h) const {
static QImage rotated90(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
@@ -4713,8 +4733,7 @@ static QImage rotated180(const QImage &image)
return image.mirrored(true, true);
QImage out(image.width(), image.height(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
@@ -4726,8 +4745,7 @@ static QImage rotated180(const QImage &image)
static QImage rotated270(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
- out.setDotsPerMeterX(image.dotsPerMeterY());
- out.setDotsPerMeterY(image.dotsPerMeterX());
+ copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
int w = image.width();
diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp
index 2209c3de4d..a2e01147c4 100644
--- a/src/gui/image/qplatformpixmap.cpp
+++ b/src/gui/image/qplatformpixmap.cpp
@@ -178,6 +178,7 @@ QBitmap QPlatformPixmap::mask() const
if (mask.isNull()) // allocation failed
return QBitmap();
+ mask.setDevicePixelRatio(devicePixelRatio());
mask.setColorCount(2);
mask.setColor(0, QColor(Qt::color0).rgba());
mask.setColor(1, QColor(Qt::color1).rgba());
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index abfa8d41bb..ed575abf54 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -545,9 +545,11 @@ QBrush::QBrush(const QBrush &other)
*/
QBrush::QBrush(const QGradient &gradient)
{
- Q_ASSERT_X(gradient.type() != QGradient::NoGradient, "QBrush::QBrush",
- "QGradient should not be used directly, use the linear, radial\n"
- "or conical gradients instead");
+ if (Q_UNLIKELY(gradient.type() == QGradient::NoGradient)) {
+ d.reset(nullBrushInstance());
+ d->ref.ref();
+ return;
+ }
const Qt::BrushStyle enum_table[] = {
Qt::LinearGradientPattern,
@@ -1376,8 +1378,10 @@ QGradient::QGradient(Preset preset)
}();
const QJsonValue presetData = jsonPresets[preset - 1];
- if (!presetData.isObject())
+ if (!presetData.isObject()) {
+ qWarning("QGradient: Undefined preset %i", preset);
return;
+ }
m_type = LinearGradient;
setCoordinateMode(ObjectMode);
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index afb4613ba5..c71d82546a 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -446,6 +446,11 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
d_ptr->blitter->setRedBlueSwizzle(false);
}
+ // There is no way to tell if the OpenGL-rendered content is premultiplied or not.
+ // For compatibility, assume that it is not, and use normal alpha blend always.
+ if (d_ptr->premultiplied)
+ funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
+
// Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
for (int i = 0; i < textures->count(); ++i) {
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 78ef7760af..e4da207b00 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -1208,6 +1208,11 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
return handled;
}
+inline qreal scaleOneValuator(qreal normValue, qreal screenMin, qreal screenSize)
+{
+ return screenMin + normValue * screenSize;
+}
+
void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletData)
{
auto *ev = reinterpret_cast<const qt_xcb_input_device_event_t *>(event);
@@ -1220,6 +1225,17 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
QPointF global(fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y));
double pressure = 0, rotation = 0, tangentialPressure = 0;
int xTilt = 0, yTilt = 0;
+ static const bool useValuators = !qEnvironmentVariableIsSet("QT_XCB_TABLET_LEGACY_COORDINATES");
+
+ // Valuators' values are relative to the physical size of the current virtual
+ // screen. Therefore we cannot use QScreen/QWindow geometry and should use
+ // QPlatformWindow/QPlatformScreen instead.
+ QRect physicalScreenArea;
+ if (Q_LIKELY(useValuators)) {
+ const QList<QPlatformScreen *> siblings = window->screen()->handle()->virtualSiblings();
+ for (const QPlatformScreen *screen : siblings)
+ physicalScreenArea |= screen->geometry();
+ }
for (QHash<int, TabletData::ValuatorClassInfo>::iterator it = tabletData->valuatorInfo.begin(),
ite = tabletData->valuatorInfo.end(); it != ite; ++it) {
@@ -1228,6 +1244,20 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
xi2GetValuatorValueIfSet(event, classInfo.number, &classInfo.curVal);
double normalizedValue = (classInfo.curVal - classInfo.minVal) / (classInfo.maxVal - classInfo.minVal);
switch (valuator) {
+ case QXcbAtom::AbsX:
+ if (Q_LIKELY(useValuators)) {
+ const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width());
+ global.setX(value);
+ local.setX(value - window->handle()->geometry().x());
+ }
+ break;
+ case QXcbAtom::AbsY:
+ if (Q_LIKELY(useValuators)) {
+ qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height());
+ global.setY(value);
+ local.setY(value - window->handle()->geometry().y());
+ }
+ break;
case QXcbAtom::AbsPressure:
pressure = normalizedValue;
break;
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 5c2a839781..d0e05c1e20 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -3411,18 +3411,20 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
case PE_IndicatorTabClose: {
// Make close button visible only on the hovered tab.
QTabBar *tabBar = qobject_cast<QTabBar*>(w->parentWidget());
+ const QWidget *closeBtn = w;
if (!tabBar) {
// QStyleSheetStyle instead of CloseButton (which has
// a QTabBar as a parent widget) uses the QTabBar itself:
tabBar = qobject_cast<QTabBar *>(const_cast<QWidget*>(w));
+ closeBtn = decltype(closeBtn)(property("_q_styleSheetRealCloseButton").value<void *>());
}
if (tabBar) {
const bool documentMode = tabBar->documentMode();
const QTabBarPrivate *tabBarPrivate = static_cast<QTabBarPrivate *>(QObjectPrivate::get(tabBar));
const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex();
if (!documentMode ||
- (hoveredTabIndex != -1 && ((w == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) ||
- (w == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide))))) {
+ (hoveredTabIndex != -1 && ((closeBtn == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) ||
+ (closeBtn == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide))))) {
const bool hover = (opt->state & State_MouseOver);
const bool selected = (opt->state & State_Selected);
const bool pressed = (opt->state & State_Sunken);
@@ -4323,7 +4325,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
d->setupNSGraphicsContext(cgCtx, YES);
[s.toNSString() drawInRect:textRect
- withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c }];
+ withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c,
+ NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0]}];
d->restoreNSGraphicsContext(cgCtx);
} else {
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index c104ac2498..9a3d938d25 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4593,8 +4593,12 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
break;
#if QT_CONFIG(tabbar)
case PE_IndicatorTabClose:
- if (w)
+ if (w) {
+ // QMacStyle needs a real widget, not its parent - to implement
+ // 'document mode' properly, drawing nothing if a tab is not hovered.
+ baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant::fromValue((void *)w));
w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
+ }
pseudoElement = PseudoElement_TabBarTabCloseButton;
#endif
@@ -4612,6 +4616,9 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
} else {
baseStyle()->drawPrimitive(pe, opt, p, w);
}
+
+ if (baseStyle()->property("_q_styleSheetRealCloseButton").toBool())
+ baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant(QVariant::Invalid));
}
QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap,