summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-12-08 07:09:26 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-12-08 07:09:47 +0100
commit3ec31ef9c5acd57a4a59c0d5f5e20b8d9a19bfa1 (patch)
tree8b55dd13dbc2a33fe7c857f622e10b817386bdb3 /src/gui
parent6f87f2d23fb50d8183ea173fe423b7e1a24c0e2e (diff)
parent4ad8798de428b44fe4c56e1ca111940068056c57 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp21
-rw-r--r--src/gui/image/qicon.cpp9
-rw-r--r--src/gui/image/qimage.cpp30
-rw-r--r--src/gui/image/qimage_conversions.cpp13
-rw-r--r--src/gui/image/qimage_p.h2
-rw-r--r--src/gui/kernel/qguiapplication.cpp10
-rw-r--r--src/gui/kernel/qinputmethod.cpp3
-rw-r--r--src/gui/kernel/qplatformwindow.cpp31
-rw-r--r--src/gui/kernel/qstylehints.cpp18
-rw-r--r--src/gui/kernel/qstylehints.h2
-rw-r--r--src/gui/painting/qdrawhelper.cpp17
-rw-r--r--src/gui/painting/qdrawhelper_p.h2
-rw-r--r--src/gui/text/qfontengine_ft.cpp8
-rw-r--r--src/gui/text/qtexttable.cpp4
14 files changed, 111 insertions, 59 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index e9995045b1..1a8d263f94 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -852,18 +852,17 @@ void QAccessible::updateAccessibility(QAccessibleEvent *event)
// during construction of widgets. If you see cases where the
// cache seems wrong, this call is "to blame", but the code that
// caches dynamic data should be updated to handle change events.
- if (!isActive() || !event->accessibleInterface())
- return;
-
- if (event->type() == QAccessible::TableModelChanged) {
- QAccessibleInterface *iface = event->accessibleInterface();
- if (iface && iface->tableInterface())
- iface->tableInterface()->modelChange(static_cast<QAccessibleTableModelChangeEvent*>(event));
- }
+ QAccessibleInterface *iface = event->accessibleInterface();
+ if (isActive() && iface) {
+ if (event->type() == QAccessible::TableModelChanged) {
+ if (iface->tableInterface())
+ iface->tableInterface()->modelChange(static_cast<QAccessibleTableModelChangeEvent*>(event));
+ }
- if (updateHandler) {
- updateHandler(event);
- return;
+ if (updateHandler) {
+ updateHandler(event);
+ return;
+ }
}
if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 6090f42ba7..ca77b73033 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -1420,15 +1421,15 @@ QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRati
if (disableNxImageLoading)
return baseFileName;
- QString atNx = QLatin1String("@%1x");
int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.'));
if (dotIndex == -1) /* no dot */
dotIndex = baseFileName.size(); /* append */
+ QString atNxfileName = baseFileName;
+ atNxfileName.insert(dotIndex, QLatin1String("@2x"));
// Check for @Nx, ..., @3x, @2x file versions,
- for (int n = qCeil(targetDevicePixelRatio); n > 1; --n) {
- QString atNxfileName = baseFileName;
- atNxfileName.insert(dotIndex, atNx.arg(n));
+ for (int n = qMin(qCeil(targetDevicePixelRatio), 9); n > 1; --n) {
+ atNxfileName[dotIndex + 1] = QLatin1Char('0' + n);
if (QFile::exists(atNxfileName)) {
if (sourceDevicePixelRatio)
*sourceDevicePixelRatio = n;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 798002224a..a992ad6fea 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2380,17 +2380,25 @@ QColor QImage::pixelColor(int x, int y) const
return QColor();
}
+ QRgba64 c;
const uchar * s = constScanLine(y);
switch (d->format) {
case Format_BGR30:
case Format_A2BGR30_Premultiplied:
- return QColor(qConvertA2rgb30ToRgb64<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]));
+ c = qConvertA2rgb30ToRgb64<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]);
+ break;
case Format_RGB30:
case Format_A2RGB30_Premultiplied:
- return QColor(qConvertA2rgb30ToRgb64<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]));
+ c = qConvertA2rgb30ToRgb64<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]);
+ break;
default:
- return QColor(pixel(x, y));
+ c = QRgba64::fromArgb32(pixel(x, y));
+ break;
}
+ // QColor is always unpremultiplied
+ if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied)
+ c = c.unpremultiplied();
+ return QColor(c);
}
/*!
@@ -2421,6 +2429,12 @@ void QImage::setPixelColor(int x, int y, const QColor &color)
qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y);
return;
}
+ // QColor is always unpremultiplied
+ QRgba64 c = color.rgba64();
+ if (!hasAlphaChannel())
+ c.setAlpha(65535);
+ else if (qPixelLayouts[d->format].premultiplied)
+ c = c.premultiplied();
// detach is called from within scanLine
uchar * s = scanLine(y);
switch (d->format) {
@@ -2430,19 +2444,19 @@ void QImage::setPixelColor(int x, int y, const QColor &color)
qWarning("QImage::setPixelColor: called on monochrome or indexed format");
return;
case Format_BGR30:
- ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64()) | 0xc0000000;
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(c) | 0xc0000000;
return;
case Format_A2BGR30_Premultiplied:
- ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64());
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(c);
return;
case Format_RGB30:
- ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64()) | 0xc0000000;
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(c) | 0xc0000000;
return;
case Format_A2RGB30_Premultiplied:
- ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64());
+ ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(c);
return;
default:
- setPixel(x, y, color.rgba());
+ setPixel(x, y, c.toArgb32());
return;
}
}
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index 7d1fb23b15..cbdcf49da7 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -2920,7 +2920,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
} // Format_Grayscale8
};
-void qInitImageConversions()
+static void qInitImageConversions()
{
#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSSE3)
if (qCpuHasFeature(SSSE3)) {
@@ -2967,4 +2967,15 @@ void qInitImageConversions()
#endif
}
+class QImageConversionsInitializer {
+public:
+ QImageConversionsInitializer()
+ {
+ qInitImageConversions();
+ }
+};
+
+// Ensure initialization if this object file is linked.
+static QImageConversionsInitializer qImageConversionsInitializer;
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index feeab60abd..3badda0864 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -111,8 +111,6 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im
void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha);
-void qInitImageConversions();
-
const uchar *qt_get_bitflip_array();
Q_GUI_EXPORT void qGamma_correct_back_to_linear_cs(QImage *image);
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 6a473b3836..6fa974829f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -194,9 +194,6 @@ extern void qRegisterGuiVariant();
#ifndef QT_NO_ANIMATION
extern void qRegisterGuiGetInterpolator();
#endif
-extern void qInitBlendFunctions();
-extern void qInitDrawhelperAsm();
-extern void qInitImageConversions();
static bool qt_detectRTLLanguage()
{
@@ -1359,13 +1356,6 @@ void QGuiApplicationPrivate::init()
if (platform_integration == 0)
createPlatformIntegration();
- // Set up blend function tables.
- qInitBlendFunctions();
- // Set up which span functions should be used in raster engine...
- qInitDrawhelperAsm();
- // and QImage conversion functions
- qInitImageConversions();
-
initPalette();
QFont::initialize();
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index 8d51be853a..2684c43518 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -147,6 +147,9 @@ QRectF QInputMethod::cursorRectangle() const
/*!
\property QInputMethod::keyboardRectangle
\brief Virtual keyboard's geometry in window coordinates.
+
+ This might be an empty rectangle if it is not possible to know the geometry
+ of the keyboard. This is the case for a floating keyboard on android.
*/
QRectF QInputMethod::keyboardRectangle() const
{
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 8757715c0d..aea029b7f5 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -581,6 +581,9 @@ void QPlatformWindow::invalidateSurface()
QRect QPlatformWindow::initialGeometry(const QWindow *w,
const QRect &initialGeometry, int defaultWidth, int defaultHeight)
{
+ const QScreen *screen = effectiveScreen(w);
+ if (!screen)
+ return initialGeometry;
QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
if (rect.width() == 0) {
const int minWidth = w->minimumWidth();
@@ -591,25 +594,23 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
rect.setHeight(minHeight > 0 ? minHeight : defaultHeight);
}
if (w->isTopLevel() && qt_window_private(const_cast<QWindow*>(w))->positionAutomatic
- && w->type() != Qt::Popup) {
- if (const QScreen *screen = effectiveScreen(w)) {
- const QRect availableGeometry = screen->availableGeometry();
- // Center unless the geometry ( + unknown window frame) is too large for the screen).
- if (rect.height() < (availableGeometry.height() * 8) / 9
+ && w->type() != Qt::Popup) {
+ const QRect availableGeometry = screen->availableGeometry();
+ // Center unless the geometry ( + unknown window frame) is too large for the screen).
+ if (rect.height() < (availableGeometry.height() * 8) / 9
&& rect.width() < (availableGeometry.width() * 8) / 9) {
- const QWindow *tp = w->transientParent();
- if (tp) {
- // A transient window should be centered w.r.t. its transient parent.
- rect.moveCenter(tp->geometry().center());
- } else {
- // Center the window on the screen. (Only applicable on platforms
- // which do not provide a better way.)
- rect.moveCenter(availableGeometry.center());
- }
+ const QWindow *tp = w->transientParent();
+ if (tp) {
+ // A transient window should be centered w.r.t. its transient parent.
+ rect.moveCenter(tp->geometry().center());
+ } else {
+ // Center the window on the screen. (Only applicable on platforms
+ // which do not provide a better way.)
+ rect.moveCenter(availableGeometry.center());
}
}
}
- return QHighDpi::toNativePixels(rect, w);
+ return QHighDpi::toNativePixels(rect, screen);
}
/*!
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 0ecd2e12e8..eea26c05ed 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -325,7 +325,7 @@ int QStyleHints::cursorFlashTime() const
\note The platform may still choose to show certain windows non-fullscreen,
such as popups or dialogs. This property only reports the default behavior.
- \sa QWindow::show()
+ \sa QWindow::show(), showIsMaximized()
*/
bool QStyleHints::showIsFullScreen() const
{
@@ -333,6 +333,22 @@ bool QStyleHints::showIsFullScreen() const
}
/*!
+ \property QStyleHints::showIsMaximized
+ \brief \c true if the platform defaults to windows being maximized,
+ otherwise \c false.
+
+ \note The platform may still choose to show certain windows non-maximized,
+ such as popups or dialogs. This property only reports the default behavior.
+
+ \sa QWindow::show(), showIsFullScreen()
+ \since 5.6
+*/
+bool QStyleHints::showIsMaximized() const
+{
+ return hint(QPlatformIntegration::ShowIsMaximized).toBool();
+}
+
+/*!
\property QStyleHints::passwordMaskDelay
\brief the time, in milliseconds, a typed letter is displayed unshrouded
in a text input field in password mode.
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index 5762482f35..7c46eaa746 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -56,6 +56,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL)
Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL)
Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen STORED false CONSTANT FINAL)
+ Q_PROPERTY(bool showIsMaximized READ showIsMaximized STORED false CONSTANT FINAL)
Q_PROPERTY(int startDragDistance READ startDragDistance NOTIFY startDragDistanceChanged FINAL)
Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL)
@@ -79,6 +80,7 @@ public:
void setCursorFlashTime(int cursorFlashTime);
int cursorFlashTime() const;
bool showIsFullScreen() const;
+ bool showIsMaximized() const;
int passwordMaskDelay() const;
QChar passwordMaskCharacter() const;
qreal fontSmoothingGamma() const;
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 5854008ea3..8f5eb4d095 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -6328,7 +6328,7 @@ void qt_memfill32(quint32 *dest, quint32 color, int count)
template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
#endif
-void qInitDrawhelperAsm()
+static void qInitDrawhelperFunctions()
{
#ifdef __SSE2__
qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2;
@@ -6523,4 +6523,19 @@ void qInitDrawhelperAsm()
#endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2
}
+extern void qInitBlendFunctions();
+class DrawHelperInitializer {
+public:
+ DrawHelperInitializer()
+ {
+ // Set up basic blend function tables.
+ qInitBlendFunctions();
+ // Set up architecture optimized methods for the current machine.
+ qInitDrawhelperFunctions();
+ }
+};
+
+// Ensure initialization if this object file is linked.
+static DrawHelperInitializer drawHelperInitializer;
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 1d70477051..1ff19f4e04 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -213,8 +213,6 @@ struct Operator
};
};
-void qInitDrawhelperAsm();
-
class QRasterPaintEngine;
struct QSolidData
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 8dfabd48ad..89bc72ae4f 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -717,8 +717,12 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
FT_Set_Transform(face, &matrix, 0);
freetype->matrix = matrix;
// fake bold
- if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face))
- embolden = true;
+ if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) {
+ if (const TT_OS2 *os2 = reinterpret_cast<const TT_OS2 *>(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) {
+ if (os2->usWeightClass < 750)
+ embolden = true;
+ }
+ }
// underline metrics
line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale));
underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale));
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index a75a1aae54..454d3440d6 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -986,8 +986,8 @@ void QTextTable::removeColumns(int pos, int num)
Merges the cell at the specified \a row and \a column with the adjacent cells
into one cell. The new cell will span \a numRows rows and \a numCols columns.
- If \a numRows or \a numCols is less than the current number of rows or columns
- the cell spans then this method does nothing.
+ This method does nothing if \a numRows or \a numCols is less than the current
+ number of rows or columns spanned by the cell.
\sa splitCell()
*/