summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp4
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp9
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h2
-rw-r--r--src/gui/image/qicon.cpp4
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp13
-rw-r--r--src/gui/kernel/qguiapplication.cpp47
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp2
-rw-r--r--src/gui/kernel/qplatformthemefactory.cpp2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp5
-rw-r--r--src/gui/text/qfontengine_ft.cpp36
-rw-r--r--src/gui/text/qfontengine_ft_p.h4
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp12
-rw-r--r--src/gui/text/qtextimagehandler.cpp2
14 files changed, 79 insertions, 65 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 757543281c..e95315aea8 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -758,7 +758,7 @@ void QAccessible::deleteAccessibleInterface(Id id)
*/
QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
{
- Id id = QAccessibleCache::instance()->idToInterface.key(iface);
+ Id id = QAccessibleCache::instance()->idForInterface(iface);
if (!id)
id = registerAccessibleInterface(iface);
return id;
@@ -771,7 +771,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
- return QAccessibleCache::instance()->idToInterface.value(id);
+ return QAccessibleCache::instance()->interfaceForId(id);
}
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index 6fbe9b5582..43c4b15cb0 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -83,6 +83,11 @@ QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const
return idToInterface.value(id);
}
+QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const
+{
+ return interfaceToId.value(iface);
+}
+
QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const
{
Q_ASSERT(iface);
@@ -90,7 +95,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *
// object might be 0
Q_ASSERT(!objectToId.contains(object));
- Q_ASSERT_X(!idToInterface.values().contains(iface), "", "Accessible interface inserted into cache twice!");
+ Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!");
QAccessible::Id id = acquireId();
QObject *obj = iface->object();
@@ -100,6 +105,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *
connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed);
}
idToInterface.insert(id, iface);
+ interfaceToId.insert(iface, id);
return id;
}
@@ -115,6 +121,7 @@ void QAccessibleCache::objectDestroyed(QObject* obj)
void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
{
QAccessibleInterface *iface = idToInterface.take(id);
+ interfaceToId.take(iface);
if (!obj)
obj = iface->object();
if (obj)
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index 5f62f43b6a..f054ee9678 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -70,6 +70,7 @@ class Q_GUI_EXPORT QAccessibleCache :public QObject
public:
static QAccessibleCache *instance();
QAccessibleInterface *interfaceForId(QAccessible::Id id) const;
+ QAccessible::Id idForInterface(QAccessibleInterface *iface) const;
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const;
void deleteInterface(QAccessible::Id id, QObject *obj = 0);
@@ -85,6 +86,7 @@ private:
QAccessible::Id acquireId() const;
mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface;
+ mutable QHash<QAccessibleInterface *, QAccessible::Id> interfaceToId;
mutable QHash<QObject *, QAccessible::Id> objectToId;
#ifdef Q_OS_MAC
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 0dec4b512d..c65ac7f92d 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1227,8 +1227,8 @@ bool QIcon::hasThemeIcon(const QString &name)
/*!
\since 5.6
- Indicate that this icon is a mask image, and hence can potentially
- be modified based on where it's displayed.
+ Indicate that this icon is a mask image(boolean \a isMask), and hence can
+ potentially be modified based on where it's displayed.
\sa isMask()
*/
void QIcon::setIsMask(bool isMask)
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 3279880601..e965045524 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1796,11 +1796,12 @@ QStandardItem *QStandardItem::takeChild(int row, int column)
QList<QStandardItem*> QStandardItem::takeRow(int row)
{
Q_D(QStandardItem);
+ QList<QStandardItem*> items;
if ((row < 0) || (row >= rowCount()))
- return QList<QStandardItem*>();
+ return items;
if (d->model)
d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
- QList<QStandardItem*> items;
+
int index = d->childIndex(row, 0); // Will return -1 if there are no columns
if (index != -1) {
int col_count = d->columnCount();
@@ -1829,13 +1830,15 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
QList<QStandardItem*> QStandardItem::takeColumn(int column)
{
Q_D(QStandardItem);
+ QList<QStandardItem*> items;
if ((column < 0) || (column >= columnCount()))
- return QList<QStandardItem*>();
+ return items;
if (d->model)
d->model->d_func()->columnsAboutToBeRemoved(this, column, column);
- QList<QStandardItem*> items;
- for (int row = d->rowCount() - 1; row >= 0; --row) {
+ const int rowCount = d->rowCount();
+ items.reserve(rowCount);
+ for (int row = rowCount - 1; row >= 0; --row) {
int index = d->childIndex(row, column);
QStandardItem *ch = d->children.at(index);
if (ch)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7afeadcced..416c899270 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -3355,28 +3355,6 @@ bool QGuiApplication::isSavingSession() const
return d->is_saving_session;
}
-/*!
- \since 5.2
-
- Function that can be used to sync Qt state with the Window Systems state.
-
- This function will first empty Qts events by calling QCoreApplication::processEvents(),
- then the platform plugin will sync up with the windowsystem, and finally Qts events
- will be delived by another call to QCoreApplication::processEvents();
-
- This function is timeconsuming and its use is discouraged.
-*/
-void QGuiApplication::sync()
-{
- QCoreApplication::processEvents();
- if (QGuiApplicationPrivate::platform_integration
- && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
- QGuiApplicationPrivate::platform_integration->sync();
- QCoreApplication::processEvents();
- QWindowSystemInterface::flushWindowSystemEvents();
- }
-}
-
void QGuiApplicationPrivate::commitData()
{
Q_Q(QGuiApplication);
@@ -3402,6 +3380,28 @@ void QGuiApplicationPrivate::saveState()
#endif //QT_NO_SESSIONMANAGER
/*!
+ \since 5.2
+
+ Function that can be used to sync Qt state with the Window Systems state.
+
+ This function will first empty Qts events by calling QCoreApplication::processEvents(),
+ then the platform plugin will sync up with the windowsystem, and finally Qts events
+ will be delived by another call to QCoreApplication::processEvents();
+
+ This function is timeconsuming and its use is discouraged.
+*/
+void QGuiApplication::sync()
+{
+ QCoreApplication::processEvents();
+ if (QGuiApplicationPrivate::platform_integration
+ && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
+ QGuiApplicationPrivate::platform_integration->sync();
+ QCoreApplication::processEvents();
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
+}
+
+/*!
\property QGuiApplication::layoutDirection
\brief the default layout direction for this application
@@ -3647,7 +3647,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
void QGuiApplicationPrivate::notifyThemeChanged()
{
- if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) {
+ if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) &&
+ !QCoreApplication::testAttribute(Qt::AA_SetPalette)) {
clearPalette();
initPalette();
}
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 566d025b28..1e04a673eb 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -86,7 +86,7 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath);
list = directLoader()->keyMap().values();
if (!list.isEmpty()) {
- const QString postFix = QStringLiteral(" (from ")
+ const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp
index 40ba844e57..223d7344e3 100644
--- a/src/gui/kernel/qplatformthemefactory.cpp
+++ b/src/gui/kernel/qplatformthemefactory.cpp
@@ -88,7 +88,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath);
list += directLoader()->keyMap().values();
if (!list.isEmpty()) {
- const QString postFix = QStringLiteral(" (from ")
+ const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index bcc17457d3..3e82d5a649 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1284,6 +1284,7 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ
const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION));
// Blacklist GPU chipsets that have problems with their BGRA support.
+#ifndef Q_OS_IOS
const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0
&& ::strstr(ver, "1.3") != 0) ||
(qstrcmp(renderer, "Mali-T760") == 0
@@ -1291,7 +1292,9 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ
(qstrcmp(renderer, "Mali-T720") == 0
&& ::strstr(ver, "3.1") != 0) ||
qstrcmp(renderer, "PowerVR SGX 554") == 0;
-
+#else
+ const bool blackListed = true;
+#endif
const bool supports_bgra = has_bgra_ext && !blackListed;
if (supports_bgra) {
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index e89522f5af..26ed81a091 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -259,7 +259,6 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
newFreetype->ref.store(1);
newFreetype->xsize = 0;
newFreetype->ysize = 0;
- newFreetype->scalableBitmapScaleFactor = 1;
newFreetype->matrix.xx = 0x10000;
newFreetype->matrix.yy = 0x10000;
newFreetype->matrix.xy = 0;
@@ -335,10 +334,11 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
}
-void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing)
+void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor)
{
*ysize = qRound(fontDef.pixelSize * 64);
*xsize = *ysize * fontDef.stretch / 100;
+ *scalableBitmapScaleFactor = 1;
*outline_drawing = false;
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) {
@@ -376,7 +376,7 @@ void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize,
// to make sure we can select the desired bitmap strike index
if (FT_Select_Size(face, best) == 0) {
if (isScalableBitmap())
- scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height);
+ *scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height);
*xsize = face->available_sizes[best].x_ppem;
*ysize = face->available_sizes[best].y_ppem;
} else {
@@ -729,7 +729,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive));
}
- freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing);
+ freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing, &scalableBitmapScaleFactor);
FT_Face face = lockFace();
@@ -1294,24 +1294,24 @@ int QFontEngineFT::synthesized() const
QFixed QFontEngineFT::ascent() const
{
QFixed v = QFixed::fromFixed(metrics.ascender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
QFixed QFontEngineFT::descent() const
{
QFixed v = QFixed::fromFixed(-metrics.descender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
QFixed QFontEngineFT::leading() const
{
QFixed v = QFixed::fromFixed(metrics.height - metrics.ascender + metrics.descender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
@@ -1326,7 +1326,7 @@ QFixed QFontEngineFT::xHeight() const
return answer;
}
} else {
- return QFixed(freetype->face->size->metrics.y_ppem) * freetype->scalableBitmapScaleFactor;
+ return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor;
}
return QFontEngine::xHeight();
}
@@ -1352,8 +1352,8 @@ QFixed QFontEngineFT::averageCharWidth() const
qreal QFontEngineFT::maxCharWidth() const
{
QFixed max_advance = QFixed::fromFixed(metrics.max_advance);
- if (freetype->scalableBitmapScaleFactor != 1)
- max_advance *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ max_advance *= scalableBitmapScaleFactor;
return max_advance.toReal();
}
@@ -1639,7 +1639,7 @@ bool QFontEngineFT::shouldUseDesignMetrics(QFontEngine::ShaperFlags flags) const
QFixed QFontEngineFT::scaledBitmapMetrics(QFixed m) const
{
- return m * freetype->scalableBitmapScaleFactor;
+ return m * scalableBitmapScaleFactor;
}
glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m) const
@@ -1677,8 +1677,8 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag
delete g;
}
- if (freetype->scalableBitmapScaleFactor != 1)
- glyphs->advances[i] *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ glyphs->advances[i] *= scalableBitmapScaleFactor;
}
if (face)
unlockFace();
@@ -1981,9 +1981,9 @@ QImage QFontEngineFT::bitmapForGlyph(glyph_t g, QFixed subPixelPosition, const Q
else if (defaultFormat == GlyphFormat::Format_Mono)
img = QImage(glyph->data, glyph->width, glyph->height, QImage::Format_Mono).copy();
- if (!img.isNull() && (!t.isIdentity() || freetype->scalableBitmapScaleFactor != 1)) {
+ if (!img.isNull() && (!t.isIdentity() || scalableBitmapScaleFactor != 1)) {
QTransform trans(t);
- const qreal scaleFactor = freetype->scalableBitmapScaleFactor.toReal();
+ const qreal scaleFactor = scalableBitmapScaleFactor.toReal();
trans.scale(scaleFactor, scaleFactor);
img = img.transformed(trans, Qt::SmoothTransformation);
}
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 3f4bf84753..3cdf0cda47 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -75,7 +75,7 @@ class QFontconfigDatabase;
class QFreetypeFace
{
public:
- void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing);
+ void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor);
QFontEngine::Properties properties() const;
bool getSfntTable(uint tag, uchar *buffer, uint *length) const;
@@ -96,7 +96,6 @@ public:
FT_Face face;
int xsize; // 26.6
int ysize; // 26.6
- QFixed scalableBitmapScaleFactor;
FT_Matrix matrix;
FT_CharMap unicode_map;
FT_CharMap symbol_map;
@@ -340,6 +339,7 @@ private:
FT_Size_Metrics metrics;
mutable bool kerning_pairs_loaded;
+ QFixed scalableBitmapScaleFactor;
};
inline uint qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g)
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index a1a562c839..5727b34e86 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -428,7 +428,7 @@ QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html,
QString html = _html;
const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->"));
if (startFragmentPos != -1) {
- QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ const QLatin1String qt3RichTextHeader("<meta name=\"qrichtext\" content=\"1\" />");
// Hack for Qt3
const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 103a208c26..7bca50325c 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1418,16 +1418,16 @@ static bool setFloatAttribute(qreal *destination, const QString &value)
return ok;
}
-static void setWidthAttribute(QTextLength *width, QString value)
+static void setWidthAttribute(QTextLength *width, const QString &valueStr)
{
bool ok = false;
- qreal realVal = value.toDouble(&ok);
+ qreal realVal = valueStr.toDouble(&ok);
if (ok) {
*width = QTextLength(QTextLength::FixedLength, realVal);
} else {
- value = value.trimmed();
+ QStringRef value = QStringRef(&valueStr).trimmed();
if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) {
- value.chop(1);
+ value.truncate(value.size() - 1);
realVal = value.toDouble(&ok);
if (ok)
*width = QTextLength(QTextLength::PercentageLength, realVal);
@@ -1438,9 +1438,7 @@ static void setWidthAttribute(QTextLength *width, QString value)
#ifndef QT_NO_CSSPARSER
void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider)
{
- QString css = value;
- css.prepend(QLatin1String("* {"));
- css.append(QLatin1Char('}'));
+ const QString css = QLatin1String("* {") + value + QLatin1Char('}');
QCss::Parser parser(css);
QCss::StyleSheet sheet;
parser.parse(&sheet, Qt::CaseInsensitive);
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index acd18994ad..18311ed161 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -111,7 +111,7 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con
doc->addResource(QTextDocument::ImageResource, url, pm);
}
- if (name.contains(QStringLiteral("@2x")))
+ if (name.contains(QLatin1String("@2x")))
pm.setDevicePixelRatio(sourcePixelRatio);
return pm;