summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qiconloader.cpp6
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp3
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp6
-rw-r--r--src/gui/kernel/qplatformgraphicsbufferhelper.cpp6
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory.cpp6
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp1
-rw-r--r--src/gui/opengl/qopengltexturecache.cpp2
-rw-r--r--src/gui/painting/qcolor.cpp88
-rw-r--r--src/gui/text/qfont.cpp2
-rw-r--r--src/gui/text/qtextdocument.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp21
-rw-r--r--src/gui/text/qtextengine.cpp21
-rw-r--r--src/gui/text/qtextformat.cpp3
-rw-r--r--src/gui/text/qtextlayout.cpp60
14 files changed, 148 insertions, 79 deletions
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 228de3adc3..a9adde8c8d 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -50,7 +50,9 @@
#include <QtCore/qmath.h>
#include <QtCore/QList>
#include <QtCore/QDir>
+#if QT_CONFIG(settings)
#include <QtCore/QSettings>
+#endif
#include <QtGui/QPainter>
#include <private/qhexstring_p.h>
@@ -348,7 +350,7 @@ QIconTheme::QIconTheme(const QString &themeName)
m_valid = true;
}
}
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
if (themeIndex.exists()) {
const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
const QStringList keys = indexReader.allKeys();
@@ -407,7 +409,7 @@ QIconTheme::QIconTheme(const QString &themeName)
if (!m_parents.contains(QLatin1String("hicolor")))
m_parents.append(QLatin1String("hicolor"));
}
-#endif //QT_NO_SETTINGS
+#endif // settings
}
QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index aa640f4d7e..81c60cdb6a 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -3018,6 +3018,9 @@ bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value
/*!
\since 5.12
Removes the data stored in all the roles for the given \a index.
+ Returns \c true if \a index is valid and data was cleared, \c false
+ otherwise.
+
\sa setData(), data()
*/
#endif
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 6a0adca9ca..8b3a2ad193 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -42,7 +42,9 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QVariant>
#include <QtCore/QSharedData>
+#if QT_CONFIG(settings)
#include <QtCore/QSettings>
+#endif
#include <QtCore/QUrl>
#include <QtCore/QVector>
#include <QtGui/QColor>
@@ -296,7 +298,7 @@ QColorDialogStaticData::QColorDialogStaticData() : customSet(false)
void QColorDialogStaticData::readSettings()
{
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
const QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
for (int i = 0; i < int(CustomColorCount); ++i) {
const QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
@@ -308,7 +310,7 @@ void QColorDialogStaticData::readSettings()
void QColorDialogStaticData::writeSettings() const
{
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
if (customSet) {
const_cast<QColorDialogStaticData*>(this)->customSet = false;
QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
index 924266997d..c98aead5c2 100644
--- a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
+++ b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
@@ -57,6 +57,12 @@
QT_BEGIN_NAMESPACE
/*!
+ \namespace QPlatformGraphicsBufferHelper
+ \inmodule QtGui
+ \internal
+*/
+
+/*!
Convenience function to both lock and bind the \a graphicsBuffer to a texture.
This function will first try to lock with texture read and texture write
access. If this succeeds it will use the bindToTexture function to bind the
diff --git a/src/gui/kernel/qplatforminputcontextfactory.cpp b/src/gui/kernel/qplatforminputcontextfactory.cpp
index c59d89fabe..df7b95d8df 100644
--- a/src/gui/kernel/qplatforminputcontextfactory.cpp
+++ b/src/gui/kernel/qplatforminputcontextfactory.cpp
@@ -48,14 +48,14 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformInputContextFactoryInterface_iid, QLatin1String("/platforminputcontexts"), Qt::CaseInsensitive))
#endif
QStringList QPlatformInputContextFactory::keys()
{
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
return loader()->keyMap().values();
#else
return QStringList();
@@ -70,7 +70,7 @@ QString QPlatformInputContextFactory::requested()
QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
{
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
if (!key.isEmpty()) {
QStringList paramList = key.split(QLatin1Char(':'));
const QString platform = paramList.takeFirst().toLower();
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index b4ff21f3fd..92770cb55f 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -142,6 +142,7 @@ void CLASS::init(QOpenGLContext *context) \
\value BlendColor glBlendColor() is available.
\value BlendEquation glBlendEquation() is available.
\value BlendEquationSeparate glBlendEquationSeparate() is available.
+ \value BlendEquationAdvanced Advanced blend equations are available.
\value BlendFuncSeparate glBlendFuncSeparate() is available.
\value BlendSubtract Blend subtract mode is available.
\value CompressedTextures Compressed texture functions are available.
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp
index 8de0b25fee..ef07dbe109 100644
--- a/src/gui/opengl/qopengltexturecache.cpp
+++ b/src/gui/opengl/qopengltexturecache.cpp
@@ -97,7 +97,7 @@ void QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData(QPlatformPixmap *p
QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx)
: QOpenGLSharedResource(ctx->shareGroup())
- , m_cache(64 * 1024) // 64 MB cache
+ , m_cache(256 * 1024) // 256 MB cache
{
}
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index ef3296a6d4..a504e35c37 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -54,77 +54,77 @@ QT_BEGIN_NAMESPACE
/*!
\internal
- If s[0..1] is a valid hex number, returns its integer value,
+ If s[0..n] is a valid hex number, returns its integer value,
otherwise returns -1.
*/
-static inline int hex2int(const char *s)
+static inline int hex2int(const char *s, int n)
{
- const int hi = QtMiscUtils::fromHex(s[0]);
- if (hi < 0)
+ if (n < 0)
return -1;
- const int lo = QtMiscUtils::fromHex(s[1]);
- if (lo < 0)
- return -1;
- return (hi << 4) | lo;
-}
-
-/*!
- \internal
- If s is a valid hex digit, returns its integer value,
- multiplied by 0x11, otherwise returns -1.
- */
-static inline int hex2int(char s)
-{
- const int h = QtMiscUtils::fromHex(s);
- return h < 0 ? h : (h << 4) | h;
+ int result = 0;
+ for (; n > 0; --n) {
+ result = result * 16;
+ const int h = QtMiscUtils::fromHex(*s++);
+ if (h < 0)
+ return -1;
+ result += h;
+ }
+ return result;
}
-static bool get_hex_rgb(const char *name, size_t len, QRgb *rgb)
+static bool get_hex_rgb(const char *name, size_t len, QRgba64 *rgb)
{
if (name[0] != '#')
return false;
name++;
--len;
int a, r, g, b;
- a = 255;
+ a = 65535;
if (len == 12) {
- r = hex2int(name);
- g = hex2int(name + 4);
- b = hex2int(name + 8);
+ r = hex2int(name + 0, 4);
+ g = hex2int(name + 4, 4);
+ b = hex2int(name + 8, 4);
} else if (len == 9) {
- r = hex2int(name);
- g = hex2int(name + 3);
- b = hex2int(name + 6);
+ r = hex2int(name + 0, 3);
+ g = hex2int(name + 3, 3);
+ b = hex2int(name + 6, 3);
+ r = (r << 4) | (r >> 8);
+ g = (g << 4) | (g >> 8);
+ b = (b << 4) | (b >> 8);
} else if (len == 8) {
- a = hex2int(name);
- r = hex2int(name + 2);
- g = hex2int(name + 4);
- b = hex2int(name + 6);
+ a = hex2int(name + 0, 2) * 0x101;
+ r = hex2int(name + 2, 2) * 0x101;
+ g = hex2int(name + 4, 2) * 0x101;
+ b = hex2int(name + 6, 2) * 0x101;
} else if (len == 6) {
- r = hex2int(name);
- g = hex2int(name + 2);
- b = hex2int(name + 4);
+ r = hex2int(name + 0, 2) * 0x101;
+ g = hex2int(name + 2, 2) * 0x101;
+ b = hex2int(name + 4, 2) * 0x101;
} else if (len == 3) {
- r = hex2int(name[0]);
- g = hex2int(name[1]);
- b = hex2int(name[2]);
+ r = hex2int(name + 0, 1) * 0x1111;
+ g = hex2int(name + 1, 1) * 0x1111;
+ b = hex2int(name + 2, 1) * 0x1111;
} else {
r = g = b = -1;
}
- if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
+ if ((uint)r > 65535 || (uint)g > 65535 || (uint)b > 65535 || (uint)a > 65535) {
*rgb = 0;
return false;
}
- *rgb = qRgba(r, g ,b, a);
+ *rgb = qRgba64(r, g ,b, a);
return true;
}
bool qt_get_hex_rgb(const char *name, QRgb *rgb)
{
- return get_hex_rgb(name, qstrlen(name), rgb);
+ QRgba64 rgba64;
+ if (!get_hex_rgb(name, qstrlen(name), &rgba64))
+ return false;
+ *rgb = rgba64.toArgb32();
+ return true;
}
-static bool get_hex_rgb(const QChar *str, size_t len, QRgb *rgb)
+static bool get_hex_rgb(const QChar *str, size_t len, QRgba64 *rgb)
{
if (len > 13)
return false;
@@ -948,9 +948,9 @@ bool QColor::setColorFromString(String name)
}
if (name[0] == QLatin1Char('#')) {
- QRgb rgba;
+ QRgba64 rgba;
if (get_hex_rgb(name.data(), name.size(), &rgba)) {
- setRgba(rgba);
+ setRgba64(rgba);
return true;
} else {
invalidate();
@@ -1366,7 +1366,7 @@ QRgba64 QColor::rgba64() const Q_DECL_NOTHROW
Sets the RGB64 value to \a rgba, including its alpha.
- \sa \setRgba(), rgba64()
+ \sa setRgba(), rgba64()
*/
void QColor::setRgba64(QRgba64 rgba) Q_DECL_NOTHROW
{
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 27d804a3b4..3654c28fc5 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1287,7 +1287,7 @@ QFont::StyleStrategy QFont::styleStrategy() const
/*!
Returns the StyleHint.
- The style hint affects the \l{#fontmatching}{font matching algorithm}.
+ The style hint affects the \l{QFont#fontmatching}{font matching algorithm}.
See \l QFont::StyleHint for the list of available hints.
\sa setStyleHint(), QFont::StyleStrategy, QFontInfo::styleHint()
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 008f695da0..4f187c6701 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -155,7 +155,7 @@ bool Qt::mightBeRichText(const QString& text)
This function is defined in the \c <QTextDocument> header file.
- \sa escape(), mightBeRichText()
+ \sa QString::toHtmlEscaped(), mightBeRichText()
*/
QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode)
{
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index a9227f0171..ebd7a7d69f 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2709,7 +2709,8 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
qreal(q->paintDevice()->logicalDpiY()) / qreal(qt_defaultDpi()) : 1;
getLineHeightParams(blockFormat, line, scaling, &lineAdjustment, &lineBreakHeight, &lineHeight, &lineBottom);
- if (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom) {
+ if (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom &&
+ layoutStruct->pageHeight >= lineBreakHeight) {
layoutStruct->newPage();
floatMargins(layoutStruct->y, layoutStruct, &left, &right);
@@ -3049,18 +3050,12 @@ void QTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDo
QSizeF inlineSize = (pos == QTextFrameFormat::InFlow ? intrinsic : QSizeF(0, 0));
item.setWidth(inlineSize.width());
- QFontMetrics m(f.font());
- switch (f.verticalAlignment())
- {
- case QTextCharFormat::AlignMiddle:
- item.setDescent(inlineSize.height() / 2);
- item.setAscent(inlineSize.height() / 2);
- break;
- case QTextCharFormat::AlignBaseline:
- item.setDescent(m.descent());
- item.setAscent(inlineSize.height() - m.descent());
- break;
- default:
+ if (f.verticalAlignment() == QTextCharFormat::AlignMiddle) {
+ QFontMetrics m(f.font());
+ qreal halfX = m.xHeight()/2.;
+ item.setAscent((inlineSize.height() + halfX) / 2.);
+ item.setDescent((inlineSize.height() - halfX) / 2.);
+ } else {
item.setDescent(0);
item.setAscent(inlineSize.height());
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 4e9b00f9c9..8de16038ad 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1962,19 +1962,24 @@ const QCharAttributes *QTextEngine::attributes() const
void QTextEngine::shape(int item) const
{
- if (layoutData->items.at(item).analysis.flags == QScriptAnalysis::Object) {
+ auto &li = layoutData->items[item];
+ if (li.analysis.flags == QScriptAnalysis::Object) {
ensureSpace(1);
if (block.docHandle()) {
docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)),
- layoutData->items[item].position + block.position(),
- format(&layoutData->items[item]));
+ li.position + block.position(),
+ format(&li));
}
- } else if (layoutData->items.at(item).analysis.flags == QScriptAnalysis::Tab) {
+ // fix log clusters to point to the previous glyph, as the object doesn't have a glyph of it's own.
+ // This is required so that all entries in the array get initialized and are ordered correctly.
+ ushort *lc = logClusters(&li);
+ *lc = item ? lc[-1] : 0;
+ } else if (li.analysis.flags == QScriptAnalysis::Tab) {
// set up at least the ascent/descent/leading of the script item for the tab
- fontEngine(layoutData->items[item],
- &layoutData->items[item].ascent,
- &layoutData->items[item].descent,
- &layoutData->items[item].leading);
+ fontEngine(li, &li.ascent, &li.descent, &li.leading);
+ // see the comment above
+ ushort *lc = logClusters(&li);
+ *lc = item ? lc[-1] : 0;
} else {
shapeText(item);
}
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 18de8408b5..e814f4f718 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -649,6 +649,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\value ImageName
\value ImageWidth
\value ImageHeight
+ \value ImageQuality
Selection properties
@@ -2274,7 +2275,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
\fn void QTextBlockFormat::setHeadingLevel(int level)
\since 5.12
- Sets the paragraph's heading level, where 1 is the highest-level heading
+ Sets the paragraph's heading \a level, where 1 is the highest-level heading
type (usually with the largest possible heading font size), and increasing
values are progressively deeper into the document (and usually with smaller
font sizes). For example when reading an HTML H1 tag, the heading level is
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index ec49406548..e85b408db9 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1834,6 +1834,9 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.logClusters = eng->layoutData->logClustersPtr;
lbh.previousGlyph = 0;
+ bool hasInlineObject = false;
+ QFixed maxInlineObjectHeight = 0;
+
while (newItem < eng->layoutData->items.size()) {
lbh.resetRightBearing();
lbh.softHyphenWidth = 0;
@@ -1862,8 +1865,11 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
current.leading + current.ascent) - qMax(lbh.tmpData.ascent,
current.ascent);
- lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
- lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
+ if (current.analysis.flags != QScriptAnalysis::Object) {
+ // objects need some special treatment as they can special alignment or be floating
+ lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
+ lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
+ }
if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) {
lbh.whiteSpaceOrObject = true;
@@ -1911,9 +1917,18 @@ void QTextLine::layout_helper(int maxGlyphs)
if (eng->block.docHandle()) {
QTextInlineObject inlineObject(item, eng);
- eng->docLayout()->positionInlineObject(inlineObject, eng->block.position() + current.position, inlineObject.format());
+ QTextFormat f = inlineObject.format();
+ eng->docLayout()->positionInlineObject(inlineObject, eng->block.position() + current.position, f);
+ QTextCharFormat::VerticalAlignment valign = f.toCharFormat().verticalAlignment();
+ if (valign != QTextCharFormat::AlignTop && valign != QTextCharFormat::AlignBottom) {
+ lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
+ lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
+ }
}
+ hasInlineObject = true;
+ maxInlineObjectHeight = qMax(maxInlineObjectHeight, current.ascent + current.descent);
+
lbh.tmpData.textWidth += current.width;
newItem = item + 1;
@@ -2049,6 +2064,43 @@ found:
line += lbh.tmpData;
}
+ if (hasInlineObject && eng->block.docHandle()) {
+ // position top/bottom aligned inline objects
+ if (maxInlineObjectHeight > line.ascent + line.descent) {
+ // extend line height if required
+ QFixed toAdd = (maxInlineObjectHeight - line.ascent - line.descent)/2;
+ line.ascent += toAdd;
+ line.descent = maxInlineObjectHeight - line.ascent;
+ }
+ int startItem = eng->findItem(line.from);
+ int endItem = eng->findItem(line.from + line.length);
+ if (endItem < 0)
+ endItem = eng->layoutData->items.size();
+ for (int item = startItem; item < endItem; ++item) {
+ QScriptItem &current = eng->layoutData->items[item];
+ if (current.analysis.flags == QScriptAnalysis::Object) {
+ QTextInlineObject inlineObject(item, eng);
+ QTextCharFormat::VerticalAlignment align = inlineObject.format().toCharFormat().verticalAlignment();
+ QFixed height = current.ascent + current.descent;
+ switch (align) {
+ case QTextCharFormat::AlignTop:
+ current.ascent = line.ascent;
+ current.descent = height - line.ascent;
+ break;
+ case QTextCharFormat::AlignBottom:
+ current.descent = line.descent;
+ current.ascent = height - line.descent;
+ break;
+ default:
+ break;
+ }
+ Q_ASSERT(line.ascent >= current.ascent);
+ Q_ASSERT(line.descent >= current.descent);
+ }
+ }
+ }
+
+
LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(),
line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal());
LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data());
@@ -2522,6 +2574,8 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
QFixed itemY = y - si.ascent;
if (format.verticalAlignment() == QTextCharFormat::AlignTop) {
itemY = y - lineBase;
+ } else if (format.verticalAlignment() == QTextCharFormat::AlignBottom) {
+ itemY = y + line.descent - si.ascent - si.descent;
}
QRectF itemRect(iterator.x.toReal(), itemY.toReal(), iterator.itemWidth.toReal(), si.height().toReal());