summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
commitd3e6e732c70ebc2340d6376d727b3c623be23810 (patch)
tree18d469f02ac36edd04b87a9bfa4886ceef0490f0 /src/gui
parentfdfd63053ae6b10af06553be3c1b15de274bebf7 (diff)
parentba8d3430029d8c4342e9a47c110ee8c9879818f4 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: config.tests/unix/compile.test src/plugins/platforms/cocoa/qcocoahelpers.mm src/tools/qlalr/cppgenerator.cpp Change-Id: I0103ca076a9aca7118b2fd99f0fdaf81055998c3
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp9
-rw-r--r--src/gui/kernel/qguiapplication.cpp19
-rw-r--r--src/gui/kernel/qkeysequence.cpp17
-rw-r--r--src/gui/kernel/qkeysequence_p.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp6
-rw-r--r--src/gui/text/qfont.cpp7
-rw-r--r--src/gui/text/qfontdatabase.cpp66
-rw-r--r--src/gui/text/qfontengine.cpp2
8 files changed, 83 insertions, 47 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 739f2a1c61..4758d1b5d4 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -1765,15 +1765,8 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
return QAccessible::accessibleInterface(m_uniqueId);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object);
- if (!iface || !iface->isValid()) {
- static bool hasWarned = false;
- if (!iface && !hasWarned) {
- qWarning() << "Problem creating accessible interface for: " << m_object << endl
- << "Make sure to deploy Qt with accessibility plugins.";
- hasWarned = true;
- }
+ if (!iface || !iface->isValid())
return 0;
- }
if (m_child >= 0) {
QAccessibleInterface *child = iface->child(m_child);
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 58e2586024..f98b4236fe 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -960,15 +960,10 @@ QList<QScreen *> QGuiApplication::screens()
/*!
\property QGuiApplication::primaryScreen
- \brief the primary (or default) screen of the application, or null if there is none.
+ \brief the primary (or default) screen of the application.
This will be the screen where QWindows are initially shown, unless otherwise specified.
- On some platforms, it may be null when there are actually no screens connected.
- It is not possible to start a new QGuiApplication while there are no screens.
- Applications which were running at the time the primary screen was removed
- will stop rendering graphics until one or more screens are restored.
-
The primaryScreenChanged signal was introduced in Qt 5.6.
\sa screens()
@@ -1095,7 +1090,7 @@ static void init_platform(const QString &pluginArgument, const QString &platform
QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
QString fatalMessage
- = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\".\n\n").arg(name);
+ = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\"\nin \"%2\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath));
if (!keys.isEmpty()) {
fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg(
keys.join(QStringLiteral(", ")));
@@ -1999,6 +1994,16 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
window = QGuiApplication::focusWindow();
}
+#if !defined(Q_OS_OSX)
+ // FIXME: Include OS X in this code path by passing the key event through
+ // QPlatformInputContext::filterEvent().
+ if (e->keyType == QEvent::KeyPress && window) {
+ if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers,
+ e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount))
+ return;
+ }
+#endif
+
QKeyEvent ev(e->keyType, e->key, e->modifiers,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
e->unicode, e->repeat, e->repeatCount);
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 9fe7267607..38cc9506ee 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -146,6 +146,23 @@ static int qtkeyForMacSymbol(const QChar ch)
#else
static bool qt_sequence_no_mnemonics = false;
#endif
+
+/*!
+ \fn void qt_set_sequence_auto_mnemonic(bool b)
+ \relates QKeySequence
+
+ Specifies whether mnemonics for menu items, labels, etc., should
+ be honored or not. On Windows and X11, this feature is
+ on by default; on OS X, it is off. When this feature is off
+ (that is, when \a b is false), QKeySequence::mnemonic() always
+ returns an empty string.
+
+ \note This function is not declared in any of Qt's header files.
+ To use it in your application, declare the function prototype
+ before calling it.
+
+ \sa QShortcut
+*/
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
/*!
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index abe91df2ee..492546616b 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHORTCUT
-struct Q_AUTOTEST_EXPORT QKeyBinding
+struct QKeyBinding
{
QKeySequence::StandardKey standardKey;
uchar priority;
@@ -66,7 +66,7 @@ struct Q_AUTOTEST_EXPORT QKeyBinding
uint platform;
};
-class Q_AUTOTEST_EXPORT QKeySequencePrivate
+class QKeySequencePrivate
{
public:
enum { MaxKeyCount = 4 }; // also used in QKeySequenceEdit
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 7055b7947a..d17c9c08a8 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -255,8 +255,10 @@ bool QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Q
bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
{
+#if defined(Q_OS_OSX)
if (t == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(tlw, timestamp, k, mods, 0, 0, 0, text, autorep, count))
return true;
+#endif
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
@@ -281,10 +283,14 @@ bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
const QString& text, bool autorep,
ushort count, bool tryShortcutOverride)
{
+#if defined(Q_OS_OSX)
if (tryShortcutOverride && type == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(tlw,
timestamp, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count)) {
return true;
}
+#else
+ Q_UNUSED(tryShortcutOverride)
+#endif
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 16e88dad5f..089104665f 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2815,6 +2815,10 @@ QFontEngine *QFontCache::findEngine(const Key &key)
EngineCache::Iterator it = engineCache.find(key),
end = engineCache.end();
if (it == end) return 0;
+
+ Q_ASSERT(it.value().data != Q_NULLPTR);
+ Q_ASSERT(key.multi == (it.value().data->type() == QFontEngine::Multi));
+
// found... update the hitcount and timestamp
updateHitCountAndTimeStamp(it.value());
@@ -2835,6 +2839,9 @@ void QFontCache::updateHitCountAndTimeStamp(Engine &value)
void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMulti)
{
+ Q_ASSERT(engine != Q_NULLPTR);
+ Q_ASSERT(key.multi == (engine->type() == QFontEngine::Multi));
+
#ifdef QFONTCACHE_DEBUG
FC_DEBUG("QFontCache: inserting new engine %p, refcount %d", engine, engine->ref.load());
if (!insertMulti && engineCache.contains(key)) {
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 6c63f5c7ee..b680bb4717 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -927,23 +927,28 @@ QFontEngine *loadSingleEngine(int script,
QFontDef def = request;
def.pixelSize = pixelSize;
+ QFontCache *fontCache = QFontCache::instance();
+
QFontCache::Key key(def,script);
- QFontEngine *engine = QFontCache::instance()->findEngine(key);
+ QFontEngine *engine = fontCache->findEngine(key);
if (!engine) {
- if (script != QChar::Script_Common) {
+ const bool cacheForCommonScript = script != QChar::Script_Common
+ && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0;
+
+ if (Q_LIKELY(cacheForCommonScript)) {
// fast path: check if engine was loaded for another script
key.script = QChar::Script_Common;
- engine = QFontCache::instance()->findEngine(key);
+ engine = fontCache->findEngine(key);
key.script = script;
if (engine) {
- Q_ASSERT(engine->type() != QFontEngine::Multi);
// Also check for OpenType tables when using complex scripts
if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) {
qWarning(" OpenType support missing for script %d", script);
return 0;
}
- QFontCache::instance()->insertEngine(key, engine);
+ fontCache->insertEngine(key, engine);
+
return engine;
}
}
@@ -951,13 +956,13 @@ QFontEngine *loadSingleEngine(int script,
// If the font data's native stretch matches the requested stretch we need to set stretch to 100
// to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate
// the new stretch factor. This only done if not matched by styleName.
- bool styleNameMatch = !request.styleName.isEmpty() && request.styleName == style->styleName;
- if (!styleNameMatch && style->key.stretch != 0 && request.stretch != 0)
+ if (style->key.stretch != 0 && request.stretch != 0
+ && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
def.stretch = (request.stretch * 100 + 50) / style->key.stretch;
+ }
engine = pfdb->fontEngine(def, size->handle);
if (engine) {
- Q_ASSERT(engine->type() != QFontEngine::Multi);
// Also check for OpenType tables when using complex scripts
if (!engine->supportsScript(QChar::Script(script))) {
qWarning(" OpenType support missing for script %d", script);
@@ -966,13 +971,13 @@ QFontEngine *loadSingleEngine(int script,
return 0;
}
- QFontCache::instance()->insertEngine(key, engine);
+ fontCache->insertEngine(key, engine);
- if (!engine->symbol && script != QChar::Script_Common && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0) {
+ if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) {
// cache engine for Common script as well
key.script = QChar::Script_Common;
- if (!QFontCache::instance()->findEngine(key))
- QFontCache::instance()->insertEngine(key, engine);
+ if (!fontCache->findEngine(key))
+ fontCache->insertEngine(key, engine);
}
}
}
@@ -985,7 +990,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QtFontStyle *style, QtFontSize *size)
{
QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size);
- Q_ASSERT(!engine || engine->type() != QFontEngine::Multi);
+
if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));
@@ -2641,12 +2646,14 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
}
#endif
+ QFontCache *fontCache = QFontCache::instance();
+
// Until we specifically asked not to, try looking for Multi font engine
// first, the last '1' indicates that we want Multi font engine instead
// of single ones
bool multi = !(request.styleStrategy & QFont::NoFontMerging);
QFontCache::Key key(request, script, multi ? 1 : 0);
- engine = QFontCache::instance()->findEngine(key);
+ engine = fontCache->findEngine(key);
if (engine) {
FM_DEBUG("Cache hit level 1");
return engine;
@@ -2687,7 +2694,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QFontDef def = request;
def.family = fallbacks.at(i);
QFontCache::Key key(def, script, multi ? 1 : 0);
- engine = QFontCache::instance()->findEngine(key);
+ engine = fontCache->findEngine(key);
if (!engine) {
QtFontDesc desc;
do {
@@ -2731,13 +2738,21 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (req.stretch == 0)
req.stretch = 100;
+ // respect the fallback families that might be passed through the request
+ const QStringList fallBackFamilies = familyList(req);
+
if (!d->engineData) {
+ QFontCache *fontCache = QFontCache::instance();
// look for the requested font in the engine data cache
- d->engineData = QFontCache::instance()->findEngineData(req);
+ // note: fallBackFamilies are not respected in the EngineData cache key;
+ // join them with the primary selection family to avoid cache misses
+ req.family = fallBackFamilies.join(QLatin1Char(','));
+
+ d->engineData = fontCache->findEngineData(req);
if (!d->engineData) {
// create a new one
d->engineData = new QFontEngineData;
- QFontCache::instance()->insertEngineData(req, d->engineData);
+ fontCache->insertEngineData(req, d->engineData);
}
d->engineData->ref.ref();
}
@@ -2746,25 +2761,18 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (d->engineData->engines[script])
return;
- // Until we specifically asked not to, try looking for Multi font engine
- // first, the last '1' indicates that we want Multi font engine instead
- // of single ones
- bool multi = !(req.styleStrategy & QFont::NoFontMerging);
- QFontCache::Key key(req, script, multi ? 1 : 0);
+ QFontEngine *fe = Q_NULLPTR;
- QFontEngine *fe = QFontCache::instance()->findEngine(key);
+ req.fallBackFamilies = fallBackFamilies;
+ if (!req.fallBackFamilies.isEmpty())
+ req.family = req.fallBackFamilies.takeFirst();
// list of families to try
QStringList family_list;
if (!req.family.isEmpty()) {
- QStringList familiesForRequest = familyList(req);
-
// Add primary selection
- family_list << familiesForRequest.takeFirst();
-
- // Fallbacks requested in font request
- req.fallBackFamilies = familiesForRequest;
+ family_list << req.family;
// add the default family
QString defaultFamily = QGuiApplication::font().family();
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 26914b63d2..8924a7c4ae 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -2296,7 +2296,7 @@ QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script
}
if (!engine) {
engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QChar::Script(script));
- QFontCache::instance()->insertEngine(key, engine, /* insertMulti */ !faceIsLocal);
+ fc->insertEngine(key, engine, /* insertMulti */ !faceIsLocal);
}
Q_ASSERT(engine);
return engine;