summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp28
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-thai.c15
-rw-r--r--src/3rdparty/rfc6234/sha-private.h28
-rw-r--r--src/3rdparty/rfc6234/sha.h357
-rw-r--r--src/3rdparty/rfc6234/sha224-256.c583
-rw-r--r--src/3rdparty/rfc6234/sha384-512.c1034
-rw-r--r--src/concurrent/qfuturewatcher.h6
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in64
-rw-r--r--src/corelib/Qt5CoreMacros.cmake2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp30
-rw-r--r--src/corelib/codecs/qtextcodec.h5
-rw-r--r--src/corelib/global/qcompilerdetection.h77
-rw-r--r--src/corelib/global/qglobal.h45
-rw-r--r--src/corelib/global/qlibraryinfo.cpp67
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc3
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp6
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp6
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp5
-rw-r--r--src/corelib/kernel/qeventloop.cpp41
-rw-r--r--src/corelib/kernel/qeventloop.h1
-rw-r--r--src/corelib/kernel/qmetatype.cpp20
-rw-r--r--src/corelib/kernel/qmetatype.h75
-rw-r--r--src/corelib/kernel/qmetatype_p.h47
-rw-r--r--src/corelib/kernel/qmetatypeswitcher_p.h31
-rw-r--r--src/corelib/kernel/qobject.cpp6
-rw-r--r--src/corelib/kernel/qobject_impl.h1
-rw-r--r--src/corelib/kernel/qobjectdefs.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp98
-rw-r--r--src/corelib/kernel/qvariant.h20
-rw-r--r--src/corelib/kernel/qvariant_p.h11
-rw-r--r--src/corelib/mimetypes/qmimemagicrule_p.h1
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp1
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp42
-rw-r--r--src/corelib/mimetypes/qmimetypeparser_p.h24
-rw-r--r--src/corelib/thread/qthread.cpp9
-rw-r--r--src/corelib/thread/qthread.h2
-rw-r--r--src/corelib/thread/qthread_p.h17
-rw-r--r--src/corelib/thread/qthread_win.cpp27
-rw-r--r--src/corelib/tools/qchar.cpp63
-rw-r--r--src/corelib/tools/qchar.h13
-rw-r--r--src/corelib/tools/qcryptographichash.cpp106
-rw-r--r--src/corelib/tools/qcryptographichash.h6
-rw-r--r--src/corelib/tools/qeasingcurve.cpp1
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qlocale.qdoc4
-rw-r--r--src/corelib/tools/qlocale_win.cpp2
-rw-r--r--src/corelib/tools/qregexp.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp76
-rw-r--r--src/corelib/tools/qstring.h13
-rw-r--r--src/corelib/tools/qstringbuilder.cpp29
-rw-r--r--src/corelib/tools/qstringbuilder.h44
-rw-r--r--src/dbus/qdbusargument.cpp6
-rw-r--r--src/gui/accessible/qaccessible.cpp6
-rw-r--r--src/gui/accessible/qaccessible.h8
-rw-r--r--src/gui/accessible/qaccessible2.cpp8
-rw-r--r--src/gui/accessible/qaccessiblebridge.cpp2
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp1
-rw-r--r--src/gui/accessible/qaccessibleplugin.cpp1
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp2
-rw-r--r--src/gui/kernel/qevent.cpp78
-rw-r--r--src/gui/kernel/qevent.h24
-rw-r--r--src/gui/kernel/qguiapplication.cpp330
-rw-r--r--src/gui/kernel/qguiapplication_p.h16
-rw-r--r--src/gui/kernel/qguivariant.cpp11
-rw-r--r--src/gui/kernel/qinputmethod.cpp4
-rw-r--r--src/gui/kernel/qkeysequence.cpp322
-rw-r--r--src/gui/kernel/qkeysequence_p.h1
-rw-r--r--src/gui/kernel/qopenglcontext.cpp276
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatforminputcontext_qpa.h2
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.cpp24
-rw-r--r--src/gui/kernel/qplatformtheme_qpa.h17
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp151
-rw-r--r--src/gui/kernel/qwindow.cpp596
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp49
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h3
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h12
-rw-r--r--src/gui/opengl/qopengl.cpp3
-rw-r--r--src/gui/opengl/qopenglbuffer.cpp44
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp22
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp2
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp6
-rw-r--r--src/gui/painting/qbrush.cpp6
-rw-r--r--src/gui/painting/qcolor.cpp6
-rw-r--r--src/gui/painting/qfixed_p.h139
-rw-r--r--src/gui/painting/qpen.cpp6
-rw-r--r--src/gui/painting/qpolygon.cpp12
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp2
-rw-r--r--src/gui/text/qcssparser.cpp40
-rw-r--r--src/gui/text/qcssparser_p.h21
-rw-r--r--src/gui/text/qtextengine.cpp17
-rw-r--r--src/network/ssl/qsslerror.cpp2
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp4
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/fontconfig.pri4
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp19
-rw-r--r--src/platformsupport/udev/qudevhelper_p.h1
-rw-r--r--src/platformsupport/udev/qudevicehelper.cpp235
-rw-r--r--src/platformsupport/udev/qudevicehelper_p.h98
-rw-r--r--src/platformsupport/udev/udev.pri4
-rw-r--r--src/plugins/accessible/widgets/main.cpp10
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp2
-rw-r--r--src/plugins/accessible/widgets/widgets.json52
-rw-r--r--src/plugins/bearer/connman/connman.json3
-rw-r--r--src/plugins/bearer/connman/connman.pro2
-rw-r--r--src/plugins/bearer/connman/main.cpp8
-rw-r--r--src/plugins/bearer/corewlan/corewlan.json3
-rw-r--r--src/plugins/bearer/corewlan/corewlan.pro2
-rw-r--r--src/plugins/bearer/corewlan/main.cpp8
-rw-r--r--src/plugins/bearer/generic/generic.json3
-rw-r--r--src/plugins/bearer/generic/generic.pro2
-rw-r--r--src/plugins/bearer/generic/main.cpp8
-rw-r--r--src/plugins/bearer/nativewifi/main.cpp8
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.json3
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.pro2
-rw-r--r--src/plugins/bearer/networkmanager/main.cpp8
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.json3
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.pro2
-rw-r--r--src/plugins/bearer/nla/main.cpp8
-rw-r--r--src/plugins/bearer/nla/nla.json3
-rw-r--r--src/plugins/bearer/nla/nla.pro4
-rw-r--r--src/plugins/generic/evdevkeyboard/evdevkeyboard.json3
-rw-r--r--src/plugins/generic/evdevkeyboard/evdevkeyboard.pro5
-rw-r--r--src/plugins/generic/evdevkeyboard/main.cpp7
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp188
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h21
-rw-r--r--src/plugins/generic/evdevmouse/evdevmouse.json3
-rw-r--r--src/plugins/generic/evdevmouse/evdevmouse.pro3
-rw-r--r--src/plugins/generic/evdevmouse/main.cpp7
-rw-r--r--src/plugins/generic/evdevtouch/evdevtouch.json3
-rw-r--r--src/plugins/generic/evdevtouch/evdevtouch.pro3
-rw-r--r--src/plugins/generic/evdevtouch/main.cpp7
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h2
-rw-r--r--src/plugins/platforminputcontexts/maliit/qmaliitplatforminputcontext.h2
-rw-r--r--src/plugins/platforms/blackberry/blackberry.pro71
-rw-r--r--src/plugins/platforms/blackberry/main.cpp72
-rw-r--r--src/plugins/platforms/blackberry/qbbbuffer.cpp165
-rw-r--r--src/plugins/platforms/blackberry/qbbbuffer.h74
-rw-r--r--src/plugins/platforms/blackberry/qbbclipboard.cpp132
-rw-r--r--src/plugins/platforms/blackberry/qbbclipboard.h67
-rw-r--r--src/plugins/platforms/blackberry/qbbeventthread.cpp559
-rw-r--r--src/plugins/platforms/blackberry/qbbeventthread.h90
-rw-r--r--src/plugins/platforms/blackberry/qbbglbackingstore.cpp189
-rw-r--r--src/plugins/platforms/blackberry/qbbglbackingstore.h95
-rw-r--r--src/plugins/platforms/blackberry/qbbglcontext.cpp356
-rw-r--r--src/plugins/platforms/blackberry/qbbglcontext.h93
-rw-r--r--src/plugins/platforms/blackberry/qbbinputcontext_imf.cpp1696
-rw-r--r--src/plugins/platforms/blackberry/qbbinputcontext_imf.h132
-rw-r--r--src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp187
-rw-r--r--src/plugins/platforms/blackberry/qbbinputcontext_noimf.h84
-rw-r--r--src/plugins/platforms/blackberry/qbbintegration.cpp293
-rw-r--r--src/plugins/platforms/blackberry/qbbintegration.h119
-rw-r--r--src/plugins/platforms/blackberry/qbbkeytranslator.h269
-rw-r--r--src/plugins/platforms/blackberry/qbbnavigatorthread.cpp279
-rw-r--r--src/plugins/platforms/blackberry/qbbnavigatorthread.h78
-rw-r--r--src/plugins/platforms/blackberry/qbbrasterbackingstore.cpp166
-rw-r--r--src/plugins/platforms/blackberry/qbbrasterbackingstore.h81
-rw-r--r--src/plugins/platforms/blackberry/qbbrootwindow.cpp257
-rw-r--r--src/plugins/platforms/blackberry/qbbrootwindow.h81
-rw-r--r--src/plugins/platforms/blackberry/qbbscreen.cpp315
-rw-r--r--src/plugins/platforms/blackberry/qbbscreen.h121
-rw-r--r--src/plugins/platforms/blackberry/qbbvirtualkeyboard.cpp500
-rw-r--r--src/plugins/platforms/blackberry/qbbvirtualkeyboard.h130
-rw-r--r--src/plugins/platforms/blackberry/qbbwindow.cpp665
-rw-r--r--src/plugins/platforms/blackberry/qbbwindow.h133
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm21
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm13
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm48
-rw-r--r--src/plugins/platforms/directfb/directfb.json3
-rw-r--r--src/plugins/platforms/directfb/directfb.pro2
-rw-r--r--src/plugins/platforms/directfb/main.cpp6
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.cpp62
-rw-r--r--src/plugins/platforms/platforms.pro4
-rw-r--r--src/plugins/platforms/vnc/qvncserver.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp179
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp181
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.h2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp18
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp7
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp24
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h1
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.cpp1
-rw-r--r--src/plugins/printsupport/windows/main.cpp4
-rw-r--r--src/plugins/printsupport/windows/windows.json3
-rw-r--r--src/plugins/printsupport/windows/windows.pro2
-rw-r--r--src/plugins/sqldrivers/db2/db2.json3
-rw-r--r--src/plugins/sqldrivers/db2/db2.pro1
-rw-r--r--src/plugins/sqldrivers/db2/main.cpp12
-rw-r--r--src/plugins/sqldrivers/ibase/ibase.json3
-rw-r--r--src/plugins/sqldrivers/ibase/ibase.pro1
-rw-r--r--src/plugins/sqldrivers/ibase/main.cpp12
-rw-r--r--src/plugins/sqldrivers/mysql/main.cpp8
-rw-r--r--src/plugins/sqldrivers/mysql/mysql.json3
-rw-r--r--src/plugins/sqldrivers/mysql/mysql.pro1
-rw-r--r--src/plugins/sqldrivers/oci/main.cpp8
-rw-r--r--src/plugins/sqldrivers/oci/oci.json3
-rw-r--r--src/plugins/sqldrivers/oci/oci.pro1
-rw-r--r--src/plugins/sqldrivers/odbc/main.cpp8
-rw-r--r--src/plugins/sqldrivers/odbc/odbc.json3
-rw-r--r--src/plugins/sqldrivers/odbc/odbc.pro1
-rw-r--r--src/plugins/sqldrivers/psql/main.cpp8
-rw-r--r--src/plugins/sqldrivers/psql/psql.json3
-rw-r--r--src/plugins/sqldrivers/psql/psql.pro1
-rw-r--r--src/plugins/sqldrivers/sqlite/smain.cpp12
-rw-r--r--src/plugins/sqldrivers/sqlite/sqlite.json3
-rw-r--r--src/plugins/sqldrivers/sqlite/sqlite.pro1
-rw-r--r--src/plugins/sqldrivers/sqlite2/smain.cpp12
-rw-r--r--src/plugins/sqldrivers/sqlite2/sqlite2.json3
-rw-r--r--src/plugins/sqldrivers/sqlite2/sqlite2.pro1
-rw-r--r--src/plugins/sqldrivers/tds/main.cpp8
-rw-r--r--src/plugins/sqldrivers/tds/tds.json3
-rw-r--r--src/plugins/sqldrivers/tds/tds.pro1
-rw-r--r--src/printsupport/kernel/qprinterinfo_unix.cpp1
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.cpp4
-rw-r--r--src/sql/kernel/qsqlfield.cpp6
-rw-r--r--src/sql/models/qsqltablemodel.cpp99
-rw-r--r--src/src.pro4
-rw-r--r--src/testlib/qplaintestlogger.cpp16
-rw-r--r--src/testlib/qtestcase.cpp8
-rw-r--r--src/testlib/testlib.pro1
-rw-r--r--src/tools/moc/generator.cpp12
-rw-r--r--src/tools/moc/outputrevision.h2
-rw-r--r--src/tools/moc/util/generate_keywords.pro8
-rw-r--r--src/tools/rcc/rcc.cpp2
-rw-r--r--src/tools/tools.pro4
-rw-r--r--src/tools/uic/driver.cpp1
-rw-r--r--src/tools/uic/uic.cpp1
-rw-r--r--src/widgets/Qt5WidgetsConfigExtras.cmake.in7
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp2
-rw-r--r--src/widgets/dialogs/qdialog.cpp10
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp10
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp6
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp2
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp8
-rw-r--r--src/widgets/itemviews/qheaderview.cpp20
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp3
-rw-r--r--src/widgets/itemviews/qstandarditemmodel.cpp3
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp3
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp3
-rw-r--r--src/widgets/kernel/qaction.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp664
-rw-r--r--src/widgets/kernel/qapplication.h52
-rw-r--r--src/widgets/kernel/qapplication_p.h4
-rw-r--r--src/widgets/kernel/qicon.cpp5
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp2
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp8
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp2
-rw-r--r--src/widgets/styles/qcommonstyle.cpp19
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp19
-rw-r--r--src/widgets/util/qcompleter.cpp3
-rw-r--r--src/widgets/util/qscrollerproperties.cpp2
-rw-r--r--src/widgets/util/qundoview.cpp3
-rw-r--r--src/widgets/widgets/qcombobox.cpp21
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp3
-rw-r--r--src/widgets/widgets/qlineedit.cpp3
-rw-r--r--src/widgets/widgets/qmenu.cpp46
-rw-r--r--src/widgets/widgets/qmenubar.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp49
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h3
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp4
-rw-r--r--src/widgets/widgets/qworkspace.cpp11
-rw-r--r--src/xml/dom/qdom.cpp12
269 files changed, 13079 insertions, 2624 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index 0734442fe0..af0ee52e9a 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -265,6 +265,34 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast)
//qreal offsetBase = (size - 4) / 4 + qMin<qreal>(size, 4) + 1;
// qDebug("offset = %f", offsetBase);
+ // To fix some Thai character heights check for two above glyphs
+ if (nmarks == 2 && (attributes[gfrom+1].combiningClass == HB_Combining_AboveRight ||
+ attributes[gfrom+1].combiningClass == HB_Combining_AboveLeft ||
+ attributes[gfrom+1].combiningClass == HB_Combining_Above))
+ if (attributes[gfrom+2].combiningClass == 23 ||
+ attributes[gfrom+2].combiningClass == 24 ||
+ attributes[gfrom+2].combiningClass == 25 ||
+ attributes[gfrom+2].combiningClass == 27 ||
+ attributes[gfrom+2].combiningClass == 28 ||
+ attributes[gfrom+2].combiningClass == 30 ||
+ attributes[gfrom+2].combiningClass == 31 ||
+ attributes[gfrom+2].combiningClass == 33 ||
+ attributes[gfrom+2].combiningClass == 34 ||
+ attributes[gfrom+2].combiningClass == 35 ||
+ attributes[gfrom+2].combiningClass == 36 ||
+ attributes[gfrom+2].combiningClass == 107 ||
+ attributes[gfrom+2].combiningClass == 122) {
+ // Two above glyphs, check total height
+ int markTotalHeight = baseMetrics.height;
+ HB_GlyphMetrics markMetrics;
+ item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom+1], &markMetrics);
+ markTotalHeight += markMetrics.height;
+ item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom+2], &markMetrics);
+ markTotalHeight += markMetrics.height;
+ if ((markTotalHeight + 2 * offsetBase) > (size * 10))
+ offsetBase = ((size * 10) - markTotalHeight) / 2; // Use offset that just fits
+ }
+
bool rightToLeft = item->item.bidiLevel % 2;
int i;
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
index deff61be7e..bf6c35b19c 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
@@ -74,10 +74,10 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr)
for (i = 0; i < len; ++i) {
if (string[i] <= 0xa0)
result[i] = (unsigned char)string[i];
- if (string[i] >= 0xe01 && string[i] <= 0xe5b)
+ else if (string[i] >= 0xe01 && string[i] <= 0xe5b)
result[i] = (unsigned char)(string[i] - 0xe00 + 0xa0);
else
- result[i] = '?';
+ result[i] = (unsigned char)~0; // Same encoding as libthai uses for invalid chars
}
result[len] = 0;
@@ -259,8 +259,13 @@ static HB_Bool HB_ThaiConvertStringToGlyphIndices (HB_ShaperItem *item)
for (int lgi = 0; lgi < lgn; lgi++) {
if ( rglyphs[lgi] == 0xdd/*TH_BLANK_BASE_GLYPH*/ ) {
glyphString[slen++] = C_DOTTED_CIRCLE;
- }
- else {
+ } else if (cstr[i] == (signed char)~0) {
+ // The only glyphs that should be passed to this function that cannot be mapped to
+ // tis620 are the ones of type Inherited class. Pass these glyphs untouched.
+ glyphString[slen++] = string[i];
+ if (string[i] == 0x200D || string[i] == 0x200C)
+ item->attributes[slen-1].dontPrint = true; // Hide ZWJ and ZWNJ characters
+ } else {
glyphString[slen++] = (HB_UChar16) thai_get_glyph_index (font_type, rglyphs[lgi]);
}
}
@@ -353,7 +358,7 @@ HB_Bool HB_ThaiShape (HB_ShaperItem *shaper_item)
const int availableGlyphs = shaper_item->num_glyphs;
if ( HB_SelectScript (shaper_item, thai_features) ) {
HB_OpenTypeShape (shaper_item, /*properties*/0);
- return HB_OpenTypePosition (shaper_item, availableGlyphs, /*doLogClusters*/false);
+ return HB_OpenTypePosition (shaper_item, availableGlyphs, /*doLogClusters*/true);
}
#endif
diff --git a/src/3rdparty/rfc6234/sha-private.h b/src/3rdparty/rfc6234/sha-private.h
new file mode 100644
index 0000000000..6e9c4520fb
--- /dev/null
+++ b/src/3rdparty/rfc6234/sha-private.h
@@ -0,0 +1,28 @@
+/************************ sha-private.h ************************/
+/***************** See RFC 6234 for details. *******************/
+#ifndef _SHA_PRIVATE__H
+#define _SHA_PRIVATE__H
+/*
+ * These definitions are defined in FIPS 180-3, section 4.1.
+ * Ch() and Maj() are defined identically in sections 4.1.1,
+ * 4.1.2, and 4.1.3.
+ *
+ * The definitions used in FIPS 180-3 are as follows:
+ */
+
+#ifndef USE_MODIFIED_MACROS
+#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+#else /* USE_MODIFIED_MACROS */
+/*
+ * The following definitions are equivalent and potentially faster.
+ */
+
+#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z))
+#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
+
+#endif /* USE_MODIFIED_MACROS */
+
+#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z))
+
+#endif /* _SHA_PRIVATE__H */
diff --git a/src/3rdparty/rfc6234/sha.h b/src/3rdparty/rfc6234/sha.h
new file mode 100644
index 0000000000..9c26f0253c
--- /dev/null
+++ b/src/3rdparty/rfc6234/sha.h
@@ -0,0 +1,357 @@
+/**************************** sha.h ****************************/
+/***************** See RFC 6234 for details. *******************/
+/*
+ Copyright (c) 2011 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ - Redistributions of source code must retain the above
+ copyright notice, this list of conditions and
+ the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ - Neither the name of Internet Society, IETF or IETF Trust, nor
+ the names of specific contributors, may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _SHA_H_
+#define _SHA_H_
+
+/*
+ * Description:
+ * This file implements the Secure Hash Algorithms
+ * as defined in the U.S. National Institute of Standards
+ * and Technology Federal Information Processing Standards
+ * Publication (FIPS PUB) 180-3 published in October 2008
+ * and formerly defined in its predecessors, FIPS PUB 180-1
+ * and FIP PUB 180-2.
+ *
+ * A combined document showing all algorithms is available at
+ * http://csrc.nist.gov/publications/fips/
+ * fips180-3/fips180-3_final.pdf
+ *
+ * The five hashes are defined in these sizes:
+ * SHA-1 20 byte / 160 bit
+ * SHA-224 28 byte / 224 bit
+ * SHA-256 32 byte / 256 bit
+ * SHA-384 48 byte / 384 bit
+ * SHA-512 64 byte / 512 bit
+ *
+ * Compilation Note:
+ * These files may be compiled with two options:
+ * USE_32BIT_ONLY - use 32-bit arithmetic only, for systems
+ * without 64-bit integers
+ *
+ * USE_MODIFIED_MACROS - use alternate form of the SHA_Ch()
+ * and SHA_Maj() macros that are equivalent
+ * and potentially faster on many systems
+ *
+ */
+
+// stdint.h include commented out by Nokia, it is not available on all platforms.
+// #include <stdint.h>
+/*
+ * If you do not have the ISO standard stdint.h header file, then you
+ * must typedef the following:
+ * name meaning
+ * uint64_t unsigned 64-bit integer
+ * uint32_t unsigned 32-bit integer
+ * uint8_t unsigned 8-bit integer (i.e., unsigned char)
+ * int_least16_t integer of >= 16 bits
+ *
+ * See stdint-example.h
+ */
+
+#ifndef _SHA_enum_
+#define _SHA_enum_
+/*
+ * All SHA functions return one of these values.
+ */
+enum {
+ shaSuccess = 0,
+ shaNull, /* Null pointer parameter */
+ shaInputTooLong, /* input data too long */
+ shaStateError, /* called Input after FinalBits or Result */
+ shaBadParam /* passed a bad parameter */
+};
+#endif /* _SHA_enum_ */
+
+/*
+ * These constants hold size information for each of the SHA
+ * hashing operations
+ */
+enum {
+ SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64,
+ SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128,
+ SHA512_Message_Block_Size = 128,
+ USHA_Max_Message_Block_Size = SHA512_Message_Block_Size,
+
+ SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32,
+ SHA384HashSize = 48, SHA512HashSize = 64,
+ USHAMaxHashSize = SHA512HashSize,
+
+ SHA1HashSizeBits = 160, SHA224HashSizeBits = 224,
+ SHA256HashSizeBits = 256, SHA384HashSizeBits = 384,
+ SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits
+};
+
+/*
+ * These constants are used in the USHA (Unified SHA) functions.
+ */
+typedef enum SHAversion {
+ SHA1, SHA224, SHA256, SHA384, SHA512
+} SHAversion;
+
+/*
+ * This structure will hold context information for the SHA-1
+ * hashing operation.
+ */
+typedef struct SHA1Context {
+ uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
+
+ uint32_t Length_High; /* Message length in bits */
+ uint32_t Length_Low; /* Message length in bits */
+
+ int_least16_t Message_Block_Index; /* Message_Block array index */
+ /* 512-bit message blocks */
+ uint8_t Message_Block[SHA1_Message_Block_Size];
+
+ int Computed; /* Is the hash computed? */
+ int Corrupted; /* Cumulative corruption code */
+} SHA1Context;
+
+/*
+ * This structure will hold context information for the SHA-256
+ * hashing operation.
+ */
+typedef struct SHA256Context {
+ uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */
+
+ uint32_t Length_High; /* Message length in bits */
+ uint32_t Length_Low; /* Message length in bits */
+
+ int_least16_t Message_Block_Index; /* Message_Block array index */
+ /* 512-bit message blocks */
+ uint8_t Message_Block[SHA256_Message_Block_Size];
+
+ int Computed; /* Is the hash computed? */
+ int Corrupted; /* Cumulative corruption code */
+} SHA256Context;
+
+/*
+ * This structure will hold context information for the SHA-512
+ * hashing operation.
+ */
+typedef struct SHA512Context {
+#ifdef USE_32BIT_ONLY
+ uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */
+ uint32_t Length[4]; /* Message length in bits */
+#else /* !USE_32BIT_ONLY */
+ uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */
+ uint64_t Length_High, Length_Low; /* Message length in bits */
+#endif /* USE_32BIT_ONLY */
+
+ int_least16_t Message_Block_Index; /* Message_Block array index */
+ /* 1024-bit message blocks */
+ uint8_t Message_Block[SHA512_Message_Block_Size];
+
+ int Computed; /* Is the hash computed?*/
+ int Corrupted; /* Cumulative corruption code */
+} SHA512Context;
+
+/*
+ * This structure will hold context information for the SHA-224
+ * hashing operation. It uses the SHA-256 structure for computation.
+ */
+typedef struct SHA256Context SHA224Context;
+
+/*
+ * This structure will hold context information for the SHA-384
+ * hashing operation. It uses the SHA-512 structure for computation.
+ */
+typedef struct SHA512Context SHA384Context;
+
+/*
+ * This structure holds context information for all SHA
+ * hashing operations.
+ */
+typedef struct USHAContext {
+ int whichSha; /* which SHA is being used */
+ union {
+ SHA1Context sha1Context;
+ SHA224Context sha224Context; SHA256Context sha256Context;
+ SHA384Context sha384Context; SHA512Context sha512Context;
+ } ctx;
+} USHAContext;
+
+/*
+ * This structure will hold context information for the HMAC
+ * keyed-hashing operation.
+ */
+typedef struct HMACContext {
+ int whichSha; /* which SHA is being used */
+ int hashSize; /* hash size of SHA being used */
+ int blockSize; /* block size of SHA being used */
+ USHAContext shaContext; /* SHA context */
+ unsigned char k_opad[USHA_Max_Message_Block_Size];
+ /* outer padding - key XORd with opad */
+ int Computed; /* Is the MAC computed? */
+ int Corrupted; /* Cumulative corruption code */
+
+} HMACContext;
+
+/*
+ * This structure will hold context information for the HKDF
+ * extract-and-expand Key Derivation Functions.
+ */
+typedef struct HKDFContext {
+ int whichSha; /* which SHA is being used */
+ HMACContext hmacContext;
+ int hashSize; /* hash size of SHA being used */
+ unsigned char prk[USHAMaxHashSize];
+ /* pseudo-random key - output of hkdfInput */
+ int Computed; /* Is the key material computed? */
+ int Corrupted; /* Cumulative corruption code */
+} HKDFContext;
+
+/*
+ * Function Prototypes
+ */
+
+/* SHA-1 */
+extern int SHA1Reset(SHA1Context *);
+extern int SHA1Input(SHA1Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA1FinalBits(SHA1Context *, uint8_t bits,
+ unsigned int bit_count);
+extern int SHA1Result(SHA1Context *,
+ uint8_t Message_Digest[SHA1HashSize]);
+
+/* SHA-224 */
+extern int SHA224Reset(SHA224Context *);
+extern int SHA224Input(SHA224Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA224FinalBits(SHA224Context *, uint8_t bits,
+ unsigned int bit_count);
+extern int SHA224Result(SHA224Context *,
+ uint8_t Message_Digest[SHA224HashSize]);
+
+/* SHA-256 */
+extern int SHA256Reset(SHA256Context *);
+extern int SHA256Input(SHA256Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA256FinalBits(SHA256Context *, uint8_t bits,
+ unsigned int bit_count);
+extern int SHA256Result(SHA256Context *,
+ uint8_t Message_Digest[SHA256HashSize]);
+
+/* SHA-384 */
+extern int SHA384Reset(SHA384Context *);
+extern int SHA384Input(SHA384Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA384FinalBits(SHA384Context *, uint8_t bits,
+ unsigned int bit_count);
+extern int SHA384Result(SHA384Context *,
+ uint8_t Message_Digest[SHA384HashSize]);
+
+/* SHA-512 */
+extern int SHA512Reset(SHA512Context *);
+extern int SHA512Input(SHA512Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA512FinalBits(SHA512Context *, uint8_t bits,
+ unsigned int bit_count);
+extern int SHA512Result(SHA512Context *,
+ uint8_t Message_Digest[SHA512HashSize]);
+
+/* Unified SHA functions, chosen by whichSha */
+extern int USHAReset(USHAContext *context, SHAversion whichSha);
+extern int USHAInput(USHAContext *context,
+ const uint8_t *bytes, unsigned int bytecount);
+extern int USHAFinalBits(USHAContext *context,
+ uint8_t bits, unsigned int bit_count);
+extern int USHAResult(USHAContext *context,
+ uint8_t Message_Digest[USHAMaxHashSize]);
+extern int USHABlockSize(enum SHAversion whichSha);
+extern int USHAHashSize(enum SHAversion whichSha);
+extern int USHAHashSizeBits(enum SHAversion whichSha);
+extern const char *USHAHashName(enum SHAversion whichSha);
+
+/*
+ * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
+ * for all SHAs.
+ * This interface allows a fixed-length text input to be used.
+ */
+extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
+ const unsigned char *text, /* pointer to data stream */
+ int text_len, /* length of data stream */
+ const unsigned char *key, /* pointer to authentication key */
+ int key_len, /* length of authentication key */
+ uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
+
+/*
+ * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
+ * for all SHAs.
+ * This interface allows any length of text input to be used.
+ */
+extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
+ const unsigned char *key, int key_len);
+extern int hmacInput(HMACContext *context, const unsigned char *text,
+ int text_len);
+extern int hmacFinalBits(HMACContext *context, uint8_t bits,
+ unsigned int bit_count);
+extern int hmacResult(HMACContext *context,
+ uint8_t digest[USHAMaxHashSize]);
+
+/*
+ * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
+ * RFC 5869, for all SHAs.
+ */
+extern int hkdf(SHAversion whichSha, const unsigned char *salt,
+ int salt_len, const unsigned char *ikm, int ikm_len,
+ const unsigned char *info, int info_len,
+ uint8_t okm[ ], int okm_len);
+extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
+ int salt_len, const unsigned char *ikm,
+ int ikm_len, uint8_t prk[USHAMaxHashSize]);
+extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
+ int prk_len, const unsigned char *info,
+ int info_len, uint8_t okm[ ], int okm_len);
+
+/*
+ * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
+ * RFC 5869, for all SHAs.
+ * This interface allows any length of text input to be used.
+ */
+extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
+ const unsigned char *salt, int salt_len);
+extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
+ int ikm_len);
+extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
+ unsigned int ikm_bit_count);
+extern int hkdfResult(HKDFContext *context,
+ uint8_t prk[USHAMaxHashSize],
+ const unsigned char *info, int info_len,
+ uint8_t okm[USHAMaxHashSize], int okm_len);
+#endif /* _SHA_H_ */
diff --git a/src/3rdparty/rfc6234/sha224-256.c b/src/3rdparty/rfc6234/sha224-256.c
new file mode 100644
index 0000000000..9546540ea5
--- /dev/null
+++ b/src/3rdparty/rfc6234/sha224-256.c
@@ -0,0 +1,583 @@
+/************************* sha224-256.c ************************/
+/***************** See RFC 6234 for details. *******************/
+/* Copyright (c) 2011 IETF Trust and the persons identified as */
+/* authors of the code. All rights reserved. */
+/* See sha.h for terms of use and redistribution. */
+
+/*
+ * Description:
+ * This file implements the Secure Hash Algorithms SHA-224 and
+ * SHA-256 as defined in the U.S. National Institute of Standards
+ * and Technology Federal Information Processing Standards
+ * Publication (FIPS PUB) 180-3 published in October 2008
+ * and formerly defined in its predecessors, FIPS PUB 180-1
+ * and FIP PUB 180-2.
+ *
+ * A combined document showing all algorithms is available at
+ * http://csrc.nist.gov/publications/fips/
+ * fips180-3/fips180-3_final.pdf
+ *
+ * The SHA-224 and SHA-256 algorithms produce 224-bit and 256-bit
+ * message digests for a given data stream. It should take about
+ * 2**n steps to find a message with the same digest as a given
+ * message and 2**(n/2) to find any two messages with the same
+ * digest, when n is the digest size in bits. Therefore, this
+ * algorithm can serve as a means of providing a
+ * "fingerprint" for a message.
+ *
+ * Portability Issues:
+ * SHA-224 and SHA-256 are defined in terms of 32-bit "words".
+ * This code uses <stdint.h> (included via "sha.h") to define 32-
+ * and 8-bit unsigned integer types. If your C compiler does not
+ * support 32-bit unsigned integers, this code is not
+ * appropriate.
+ *
+ * Caveats:
+ * SHA-224 and SHA-256 are designed to work with messages less
+ * than 2^64 bits long. This implementation uses SHA224/256Input()
+ * to hash the bits that are a multiple of the size of an 8-bit
+ * octet, and then optionally uses SHA224/256FinalBits()
+ * to hash the final few bits of the input.
+ */
+
+#include "sha.h"
+#include "sha-private.h"
+
+/* Define the SHA shift, rotate left, and rotate right macros */
+#define SHA256_SHR(bits,word) ((word) >> (bits))
+#define SHA256_ROTL(bits,word) \
+ (((word) << (bits)) | ((word) >> (32-(bits))))
+#define SHA256_ROTR(bits,word) \
+ (((word) >> (bits)) | ((word) << (32-(bits))))
+
+/* Define the SHA SIGMA and sigma macros */
+#define SHA256_SIGMA0(word) \
+ (SHA256_ROTR( 2,word) ^ SHA256_ROTR(13,word) ^ SHA256_ROTR(22,word))
+#define SHA256_SIGMA1(word) \
+ (SHA256_ROTR( 6,word) ^ SHA256_ROTR(11,word) ^ SHA256_ROTR(25,word))
+#define SHA256_sigma0(word) \
+ (SHA256_ROTR( 7,word) ^ SHA256_ROTR(18,word) ^ SHA256_SHR( 3,word))
+#define SHA256_sigma1(word) \
+ (SHA256_ROTR(17,word) ^ SHA256_ROTR(19,word) ^ SHA256_SHR(10,word))
+
+/*
+ * Add "length" to the length.
+ * Set Corrupted when overflow has occurred.
+ */
+/* addTemp commented out by Nokia, static variables are not thread-safe */
+/* static uint32_t addTemp; */
+/* 'M' appended to Macro name by Nokia */
+#define SHA224_256AddLengthM(context, length) \
+ (addTemp = (context)->Length_Low, (context)->Corrupted = \
+ (((context)->Length_Low += (length)) < addTemp) && \
+ (++(context)->Length_High == 0) ? shaInputTooLong : \
+ (context)->Corrupted )
+
+/* Local Function Prototypes */
+static int SHA224_256Reset(SHA256Context *context, uint32_t *H0);
+static void SHA224_256ProcessMessageBlock(SHA256Context *context);
+static void SHA224_256Finalize(SHA256Context *context,
+ uint8_t Pad_Byte);
+static void SHA224_256PadMessage(SHA256Context *context,
+ uint8_t Pad_Byte);
+static int SHA224_256ResultN(SHA256Context *context,
+ uint8_t Message_Digest[ ], int HashSize);
+
+/* Initial Hash Values: FIPS 180-3 section 5.3.2 */
+static uint32_t SHA224_H0[SHA256HashSize/4] = {
+ 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939,
+ 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4
+};
+
+/* Initial Hash Values: FIPS 180-3 section 5.3.3 */
+static uint32_t SHA256_H0[SHA256HashSize/4] = {
+ 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
+ 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
+};
+
+/*
+ * SHA224Reset
+ *
+ * Description:
+ * This function will initialize the SHA224Context in preparation
+ * for computing a new SHA224 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA224Reset(SHA224Context *context)
+{
+ return SHA224_256Reset(context, SHA224_H0);
+}
+
+/*
+ * SHA224Input
+ *
+ * Description:
+ * This function accepts an array of octets as the next portion
+ * of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_array[ ]: [in]
+ * An array of octets representing the next portion of
+ * the message.
+ * length: [in]
+ * The length of the message in message_array.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA224Input(SHA224Context *context, const uint8_t *message_array,
+ unsigned int length)
+{
+ return SHA256Input(context, message_array, length);
+}
+
+/*
+ * SHA224FinalBits
+ *
+ * Description:
+ * This function will add in any final bits of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_bits: [in]
+ * The final bits of the message, in the upper portion of the
+ * byte. (Use 0b###00000 instead of 0b00000### to input the
+ * three bits ###.)
+ * length: [in]
+ * The number of bits in message_bits, between 1 and 7.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA224FinalBits(SHA224Context *context,
+ uint8_t message_bits, unsigned int length)
+{
+ return SHA256FinalBits(context, message_bits, length);
+}
+
+/*
+ * SHA224Result
+ *
+ * Description:
+ * This function will return the 224-bit message digest
+ * into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 27.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA224Result(SHA224Context *context,
+ uint8_t Message_Digest[SHA224HashSize])
+{
+ return SHA224_256ResultN(context, Message_Digest, SHA224HashSize);
+}
+
+/*
+ * SHA256Reset
+ *
+ * Description:
+ * This function will initialize the SHA256Context in preparation
+ * for computing a new SHA256 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA256Reset(SHA256Context *context)
+{
+ return SHA224_256Reset(context, SHA256_H0);
+}
+
+/*
+ * SHA256Input
+ *
+ * Description:
+ * This function accepts an array of octets as the next portion
+ * of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_array[ ]: [in]
+ * An array of octets representing the next portion of
+ * the message.
+ * length: [in]
+ * The length of the message in message_array.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA256Input(SHA256Context *context, const uint8_t *message_array,
+ unsigned int length)
+{
+ if (!context) return shaNull;
+ if (!length) return shaSuccess;
+ if (!message_array) return shaNull;
+ if (context->Computed) return context->Corrupted = shaStateError;
+ if (context->Corrupted) return context->Corrupted;
+
+ while (length--) {
+ context->Message_Block[context->Message_Block_Index++] =
+ *message_array;
+
+ if ((SHA224_256AddLength(context, 8) == shaSuccess) &&
+ (context->Message_Block_Index == SHA256_Message_Block_Size))
+ SHA224_256ProcessMessageBlock(context);
+
+ message_array++;
+ }
+
+ return context->Corrupted;
+
+}
+
+/*
+ * SHA256FinalBits
+ *
+ * Description:
+ * This function will add in any final bits of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_bits: [in]
+ * The final bits of the message, in the upper portion of the
+ * byte. (Use 0b###00000 instead of 0b00000### to input the
+ * three bits ###.)
+ * length: [in]
+ * The number of bits in message_bits, between 1 and 7.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA256FinalBits(SHA256Context *context,
+ uint8_t message_bits, unsigned int length)
+{
+ static uint8_t masks[8] = {
+ /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80,
+ /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0,
+ /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8,
+ /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE
+ };
+ static uint8_t markbit[8] = {
+ /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40,
+ /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10,
+ /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04,
+ /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01
+ };
+
+ if (!context) return shaNull;
+ if (!length) return shaSuccess;
+ if (context->Corrupted) return context->Corrupted;
+ if (context->Computed) return context->Corrupted = shaStateError;
+ if (length >= 8) return context->Corrupted = shaBadParam;
+
+ SHA224_256AddLength(context, length);
+ SHA224_256Finalize(context, (uint8_t)
+ ((message_bits & masks[length]) | markbit[length]));
+
+ return context->Corrupted;
+}
+
+/*
+ * SHA256Result
+ *
+ * Description:
+ * This function will return the 256-bit message digest
+ * into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 31.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA256Result(SHA256Context *context,
+ uint8_t Message_Digest[SHA256HashSize])
+{
+ return SHA224_256ResultN(context, Message_Digest, SHA256HashSize);
+}
+
+/*
+ * SHA224_256Reset
+ *
+ * Description:
+ * This helper function will initialize the SHA256Context in
+ * preparation for computing a new SHA-224 or SHA-256 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ * H0[ ]: [in]
+ * The initial hash value array to use.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+static int SHA224_256Reset(SHA256Context *context, uint32_t *H0)
+{
+ if (!context) return shaNull;
+
+ context->Length_High = context->Length_Low = 0;
+ context->Message_Block_Index = 0;
+
+ context->Intermediate_Hash[0] = H0[0];
+ context->Intermediate_Hash[1] = H0[1];
+ context->Intermediate_Hash[2] = H0[2];
+ context->Intermediate_Hash[3] = H0[3];
+ context->Intermediate_Hash[4] = H0[4];
+ context->Intermediate_Hash[5] = H0[5];
+ context->Intermediate_Hash[6] = H0[6];
+ context->Intermediate_Hash[7] = H0[7];
+
+ context->Computed = 0;
+ context->Corrupted = shaSuccess;
+
+ return shaSuccess;
+}
+
+/*
+ * SHA224_256ProcessMessageBlock
+ *
+ * Description:
+ * This helper function will process the next 512 bits of the
+ * message stored in the Message_Block array.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ *
+ * Returns:
+ * Nothing.
+ *
+ * Comments:
+ * Many of the variable names in this code, especially the
+ * single character names, were used because those were the
+ * names used in the Secure Hash Standard.
+ */
+static void SHA224_256ProcessMessageBlock(SHA256Context *context)
+{
+ /* Constants defined in FIPS 180-3, section 4.2.2 */
+ static const uint32_t K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
+ 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
+ 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
+ 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
+ 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
+ 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
+ 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
+ 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
+ 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
+ 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
+ int t, t4; /* Loop counter */
+ uint32_t temp1, temp2; /* Temporary word value */
+ uint32_t W[64]; /* Word sequence */
+ uint32_t A, B, C, D, E, F, G, H; /* Word buffers */
+
+ /*
+ * Initialize the first 16 words in the array W
+ */
+ for (t = t4 = 0; t < 16; t++, t4 += 4)
+ W[t] = (((uint32_t)context->Message_Block[t4]) << 24) |
+ (((uint32_t)context->Message_Block[t4 + 1]) << 16) |
+ (((uint32_t)context->Message_Block[t4 + 2]) << 8) |
+ (((uint32_t)context->Message_Block[t4 + 3]));
+
+ for (t = 16; t < 64; t++)
+ W[t] = SHA256_sigma1(W[t-2]) + W[t-7] +
+ SHA256_sigma0(W[t-15]) + W[t-16];
+
+ A = context->Intermediate_Hash[0];
+ B = context->Intermediate_Hash[1];
+ C = context->Intermediate_Hash[2];
+ D = context->Intermediate_Hash[3];
+ E = context->Intermediate_Hash[4];
+ F = context->Intermediate_Hash[5];
+ G = context->Intermediate_Hash[6];
+ H = context->Intermediate_Hash[7];
+
+ for (t = 0; t < 64; t++) {
+ temp1 = H + SHA256_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t];
+ temp2 = SHA256_SIGMA0(A) + SHA_Maj(A,B,C);
+ H = G;
+ G = F;
+ F = E;
+ E = D + temp1;
+ D = C;
+ C = B;
+ B = A;
+ A = temp1 + temp2;
+ }
+
+ context->Intermediate_Hash[0] += A;
+ context->Intermediate_Hash[1] += B;
+ context->Intermediate_Hash[2] += C;
+ context->Intermediate_Hash[3] += D;
+ context->Intermediate_Hash[4] += E;
+ context->Intermediate_Hash[5] += F;
+ context->Intermediate_Hash[6] += G;
+ context->Intermediate_Hash[7] += H;
+
+ context->Message_Block_Index = 0;
+}
+
+/*
+ * SHA224_256Finalize
+ *
+ * Description:
+ * This helper function finishes off the digest calculations.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * Pad_Byte: [in]
+ * The last byte to add to the message block before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+static void SHA224_256Finalize(SHA256Context *context,
+ uint8_t Pad_Byte)
+{
+ int i;
+ SHA224_256PadMessage(context, Pad_Byte);
+ /* message may be sensitive, so clear it out */
+ for (i = 0; i < SHA256_Message_Block_Size; ++i)
+ context->Message_Block[i] = 0;
+ context->Length_High = 0; /* and clear length */
+ context->Length_Low = 0;
+ context->Computed = 1;
+}
+
+/*
+ * SHA224_256PadMessage
+ *
+ * Description:
+ * According to the standard, the message must be padded to the next
+ * even multiple of 512 bits. The first padding bit must be a '1'.
+ * The last 64 bits represent the length of the original message.
+ * All bits in between should be 0. This helper function will pad
+ * the message according to those rules by filling the
+ * Message_Block array accordingly. When it returns, it can be
+ * assumed that the message digest has been computed.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to pad.
+ * Pad_Byte: [in]
+ * The last byte to add to the message block before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * Nothing.
+ */
+static void SHA224_256PadMessage(SHA256Context *context,
+ uint8_t Pad_Byte)
+{
+ /*
+ * Check to see if the current message block is too small to hold
+ * the initial padding bits and length. If so, we will pad the
+ * block, process it, and then continue padding into a second
+ * block.
+ */
+ if (context->Message_Block_Index >= (SHA256_Message_Block_Size-8)) {
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+ while (context->Message_Block_Index < SHA256_Message_Block_Size)
+ context->Message_Block[context->Message_Block_Index++] = 0;
+ SHA224_256ProcessMessageBlock(context);
+ } else
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+
+ while (context->Message_Block_Index < (SHA256_Message_Block_Size-8))
+ context->Message_Block[context->Message_Block_Index++] = 0;
+
+ /*
+ * Store the message length as the last 8 octets
+ */
+ context->Message_Block[56] = (uint8_t)(context->Length_High >> 24);
+ context->Message_Block[57] = (uint8_t)(context->Length_High >> 16);
+ context->Message_Block[58] = (uint8_t)(context->Length_High >> 8);
+ context->Message_Block[59] = (uint8_t)(context->Length_High);
+ context->Message_Block[60] = (uint8_t)(context->Length_Low >> 24);
+ context->Message_Block[61] = (uint8_t)(context->Length_Low >> 16);
+ context->Message_Block[62] = (uint8_t)(context->Length_Low >> 8);
+ context->Message_Block[63] = (uint8_t)(context->Length_Low);
+
+ SHA224_256ProcessMessageBlock(context);
+}
+
+/*
+ * SHA224_256ResultN
+ *
+ * Description:
+ * This helper function will return the 224-bit or 256-bit message
+ * digest into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 27/31.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ * HashSize: [in]
+ * The size of the hash, either 28 or 32.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+static int SHA224_256ResultN(SHA256Context *context,
+ uint8_t Message_Digest[ ], int HashSize)
+{
+ int i;
+
+ if (!context) return shaNull;
+ if (!Message_Digest) return shaNull;
+ if (context->Corrupted) return context->Corrupted;
+
+ if (!context->Computed)
+ SHA224_256Finalize(context, 0x80);
+
+ for (i = 0; i < HashSize; ++i)
+ Message_Digest[i] = (uint8_t)
+ (context->Intermediate_Hash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) ));
+
+ return shaSuccess;
+}
diff --git a/src/3rdparty/rfc6234/sha384-512.c b/src/3rdparty/rfc6234/sha384-512.c
new file mode 100644
index 0000000000..7d9ba3fa52
--- /dev/null
+++ b/src/3rdparty/rfc6234/sha384-512.c
@@ -0,0 +1,1034 @@
+/************************* sha384-512.c ************************/
+/***************** See RFC 6234 for details. *******************/
+/* Copyright (c) 2011 IETF Trust and the persons identified as */
+/* authors of the code. All rights reserved. */
+/* See sha.h for terms of use and redistribution. */
+
+/*
+ * Description:
+ * This file implements the Secure Hash Algorithms SHA-384 and
+ * SHA-512 as defined in the U.S. National Institute of Standards
+ * and Technology Federal Information Processing Standards
+ * Publication (FIPS PUB) 180-3 published in October 2008
+ * and formerly defined in its predecessors, FIPS PUB 180-1
+ * and FIP PUB 180-2.
+ *
+ * A combined document showing all algorithms is available at
+ * http://csrc.nist.gov/publications/fips/
+ * fips180-3/fips180-3_final.pdf
+ *
+ * The SHA-384 and SHA-512 algorithms produce 384-bit and 512-bit
+ * message digests for a given data stream. It should take about
+ * 2**n steps to find a message with the same digest as a given
+ * message and 2**(n/2) to find any two messages with the same
+ * digest, when n is the digest size in bits. Therefore, this
+ * algorithm can serve as a means of providing a
+ * "fingerprint" for a message.
+ *
+ * Portability Issues:
+ * SHA-384 and SHA-512 are defined in terms of 64-bit "words",
+ * but if USE_32BIT_ONLY is #defined, this code is implemented in
+ * terms of 32-bit "words". This code uses <stdint.h> (included
+ * via "sha.h") to define the 64-, 32- and 8-bit unsigned integer
+ * types. If your C compiler does not support 64-bit unsigned
+ * integers and you do not #define USE_32BIT_ONLY, this code is
+ * not appropriate.
+ *
+ * Caveats:
+ * SHA-384 and SHA-512 are designed to work with messages less
+ * than 2^128 bits long. This implementation uses SHA384/512Input()
+ * to hash the bits that are a multiple of the size of an 8-bit
+ * octet, and then optionally uses SHA384/256FinalBits()
+ * to hash the final few bits of the input.
+ *
+ */
+
+#include "sha.h"
+
+#ifdef USE_32BIT_ONLY
+/*
+ * Define 64-bit arithmetic in terms of 32-bit arithmetic.
+ * Each 64-bit number is represented in a 2-word array.
+ * All macros are defined such that the result is the last parameter.
+ */
+
+/*
+ * Define shift, rotate left, and rotate right functions
+ */
+#define SHA512_SHR(bits, word, ret) ( \
+ /* (((uint64_t)((word))) >> (bits)) */ \
+ (ret)[0] = (((bits) < 32) && ((bits) >= 0)) ? \
+ ((word)[0] >> (bits)) : 0, \
+ (ret)[1] = ((bits) > 32) ? ((word)[0] >> ((bits) - 32)) : \
+ ((bits) == 32) ? (word)[0] : \
+ ((bits) >= 0) ? \
+ (((word)[0] << (32 - (bits))) | \
+ ((word)[1] >> (bits))) : 0 )
+
+#define SHA512_SHL(bits, word, ret) ( \
+ /* (((uint64_t)(word)) << (bits)) */ \
+ (ret)[0] = ((bits) > 32) ? ((word)[1] << ((bits) - 32)) : \
+ ((bits) == 32) ? (word)[1] : \
+ ((bits) >= 0) ? \
+ (((word)[0] << (bits)) | \
+ ((word)[1] >> (32 - (bits)))) : \
+ 0, \
+ (ret)[1] = (((bits) < 32) && ((bits) >= 0)) ? \
+ ((word)[1] << (bits)) : 0 )
+
+/*
+ * Define 64-bit OR
+ */
+#define SHA512_OR(word1, word2, ret) ( \
+ (ret)[0] = (word1)[0] | (word2)[0], \
+ (ret)[1] = (word1)[1] | (word2)[1] )
+
+/*
+ * Define 64-bit XOR
+ */
+#define SHA512_XOR(word1, word2, ret) ( \
+ (ret)[0] = (word1)[0] ^ (word2)[0], \
+ (ret)[1] = (word1)[1] ^ (word2)[1] )
+
+/*
+ * Define 64-bit AND
+ */
+#define SHA512_AND(word1, word2, ret) ( \
+ (ret)[0] = (word1)[0] & (word2)[0], \
+ (ret)[1] = (word1)[1] & (word2)[1] )
+
+/*
+ * Define 64-bit TILDA
+ */
+#define SHA512_TILDA(word, ret) \
+ ( (ret)[0] = ~(word)[0], (ret)[1] = ~(word)[1] )
+
+/*
+ * Define 64-bit ADD
+ */
+#define SHA512_ADD(word1, word2, ret) ( \
+ (ret)[1] = (word1)[1], (ret)[1] += (word2)[1], \
+ (ret)[0] = (word1)[0] + (word2)[0] + ((ret)[1] < (word1)[1]) )
+
+/*
+ * Add the 4word value in word2 to word1.
+ */
+static uint32_t ADDTO4_temp, ADDTO4_temp2;
+#define SHA512_ADDTO4(word1, word2) ( \
+ ADDTO4_temp = (word1)[3], \
+ (word1)[3] += (word2)[3], \
+ ADDTO4_temp2 = (word1)[2], \
+ (word1)[2] += (word2)[2] + ((word1)[3] < ADDTO4_temp), \
+ ADDTO4_temp = (word1)[1], \
+ (word1)[1] += (word2)[1] + ((word1)[2] < ADDTO4_temp2), \
+ (word1)[0] += (word2)[0] + ((word1)[1] < ADDTO4_temp) )
+
+/*
+ * Add the 2word value in word2 to word1.
+ */
+static uint32_t ADDTO2_temp;
+#define SHA512_ADDTO2(word1, word2) ( \
+ ADDTO2_temp = (word1)[1], \
+ (word1)[1] += (word2)[1], \
+ (word1)[0] += (word2)[0] + ((word1)[1] < ADDTO2_temp) )
+
+/*
+ * SHA rotate ((word >> bits) | (word << (64-bits)))
+ */
+static uint32_t ROTR_temp1[2], ROTR_temp2[2];
+#define SHA512_ROTR(bits, word, ret) ( \
+ SHA512_SHR((bits), (word), ROTR_temp1), \
+ SHA512_SHL(64-(bits), (word), ROTR_temp2), \
+ SHA512_OR(ROTR_temp1, ROTR_temp2, (ret)) )
+
+/*
+ * Define the SHA SIGMA and sigma macros
+ *
+ * SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word)
+ */
+static uint32_t SIGMA0_temp1[2], SIGMA0_temp2[2],
+ SIGMA0_temp3[2], SIGMA0_temp4[2];
+#define SHA512_SIGMA0(word, ret) ( \
+ SHA512_ROTR(28, (word), SIGMA0_temp1), \
+ SHA512_ROTR(34, (word), SIGMA0_temp2), \
+ SHA512_ROTR(39, (word), SIGMA0_temp3), \
+ SHA512_XOR(SIGMA0_temp2, SIGMA0_temp3, SIGMA0_temp4), \
+ SHA512_XOR(SIGMA0_temp1, SIGMA0_temp4, (ret)) )
+
+/*
+ * SHA512_ROTR(14,word) ^ SHA512_ROTR(18,word) ^ SHA512_ROTR(41,word)
+ */
+static uint32_t SIGMA1_temp1[2], SIGMA1_temp2[2],
+ SIGMA1_temp3[2], SIGMA1_temp4[2];
+#define SHA512_SIGMA1(word, ret) ( \
+ SHA512_ROTR(14, (word), SIGMA1_temp1), \
+ SHA512_ROTR(18, (word), SIGMA1_temp2), \
+ SHA512_ROTR(41, (word), SIGMA1_temp3), \
+ SHA512_XOR(SIGMA1_temp2, SIGMA1_temp3, SIGMA1_temp4), \
+ SHA512_XOR(SIGMA1_temp1, SIGMA1_temp4, (ret)) )
+
+/*
+ * (SHA512_ROTR( 1,word) ^ SHA512_ROTR( 8,word) ^ SHA512_SHR( 7,word))
+ */
+static uint32_t sigma0_temp1[2], sigma0_temp2[2],
+ sigma0_temp3[2], sigma0_temp4[2];
+#define SHA512_sigma0(word, ret) ( \
+ SHA512_ROTR( 1, (word), sigma0_temp1), \
+ SHA512_ROTR( 8, (word), sigma0_temp2), \
+ SHA512_SHR( 7, (word), sigma0_temp3), \
+ SHA512_XOR(sigma0_temp2, sigma0_temp3, sigma0_temp4), \
+ SHA512_XOR(sigma0_temp1, sigma0_temp4, (ret)) )
+
+/*
+ * (SHA512_ROTR(19,word) ^ SHA512_ROTR(61,word) ^ SHA512_SHR( 6,word))
+ */
+static uint32_t sigma1_temp1[2], sigma1_temp2[2],
+ sigma1_temp3[2], sigma1_temp4[2];
+#define SHA512_sigma1(word, ret) ( \
+ SHA512_ROTR(19, (word), sigma1_temp1), \
+ SHA512_ROTR(61, (word), sigma1_temp2), \
+ SHA512_SHR( 6, (word), sigma1_temp3), \
+ SHA512_XOR(sigma1_temp2, sigma1_temp3, sigma1_temp4), \
+ SHA512_XOR(sigma1_temp1, sigma1_temp4, (ret)) )
+
+#ifndef USE_MODIFIED_MACROS
+/*
+ * These definitions are the ones used in FIPS 180-3, section 4.1.3
+ * Ch(x,y,z) ((x & y) ^ (~x & z))
+ */
+static uint32_t Ch_temp1[2], Ch_temp2[2], Ch_temp3[2];
+#define SHA_Ch(x, y, z, ret) ( \
+ SHA512_AND(x, y, Ch_temp1), \
+ SHA512_TILDA(x, Ch_temp2), \
+ SHA512_AND(Ch_temp2, z, Ch_temp3), \
+ SHA512_XOR(Ch_temp1, Ch_temp3, (ret)) )
+
+/*
+ * Maj(x,y,z) (((x)&(y)) ^ ((x)&(z)) ^ ((y)&(z)))
+ */
+static uint32_t Maj_temp1[2], Maj_temp2[2],
+ Maj_temp3[2], Maj_temp4[2];
+#define SHA_Maj(x, y, z, ret) ( \
+ SHA512_AND(x, y, Maj_temp1), \
+ SHA512_AND(x, z, Maj_temp2), \
+ SHA512_AND(y, z, Maj_temp3), \
+ SHA512_XOR(Maj_temp2, Maj_temp3, Maj_temp4), \
+ SHA512_XOR(Maj_temp1, Maj_temp4, (ret)) )
+#else /* !USE_MODIFIED_MACROS */
+/*
+ * These definitions are potentially faster equivalents for the ones
+ * used in FIPS 180-3, section 4.1.3.
+ * ((x & y) ^ (~x & z)) becomes
+ * ((x & (y ^ z)) ^ z)
+ */
+#define SHA_Ch(x, y, z, ret) ( \
+ (ret)[0] = (((x)[0] & ((y)[0] ^ (z)[0])) ^ (z)[0]), \
+ (ret)[1] = (((x)[1] & ((y)[1] ^ (z)[1])) ^ (z)[1]) )
+
+/*
+ * ((x & y) ^ (x & z) ^ (y & z)) becomes
+ * ((x & (y | z)) | (y & z))
+ */
+#define SHA_Maj(x, y, z, ret) ( \
+ ret[0] = (((x)[0] & ((y)[0] | (z)[0])) | ((y)[0] & (z)[0])), \
+ ret[1] = (((x)[1] & ((y)[1] | (z)[1])) | ((y)[1] & (z)[1])) )
+#endif /* USE_MODIFIED_MACROS */
+
+/*
+ * Add "length" to the length.
+ * Set Corrupted when overflow has occurred.
+ */
+static uint32_t addTemp[4] = { 0, 0, 0, 0 };
+#define SHA384_512AddLength(context, length) ( \
+ addTemp[3] = (length), SHA512_ADDTO4((context)->Length, addTemp), \
+ (context)->Corrupted = (((context)->Length[3] < (length)) && \
+ ((context)->Length[2] == 0) && ((context)->Length[1] == 0) && \
+ ((context)->Length[0] == 0)) ? shaInputTooLong : \
+ (context)->Corrupted )
+
+/* Local Function Prototypes */
+static int SHA384_512Reset(SHA512Context *context,
+ uint32_t H0[SHA512HashSize/4]);
+static void SHA384_512ProcessMessageBlock(SHA512Context *context);
+static void SHA384_512Finalize(SHA512Context *context,
+ uint8_t Pad_Byte);
+static void SHA384_512PadMessage(SHA512Context *context,
+ uint8_t Pad_Byte);
+static int SHA384_512ResultN( SHA512Context *context,
+ uint8_t Message_Digest[ ], int HashSize);
+
+/* Initial Hash Values: FIPS 180-3 sections 5.3.4 and 5.3.5 */
+static uint32_t SHA384_H0[SHA512HashSize/4] = {
+ 0xCBBB9D5D, 0xC1059ED8, 0x629A292A, 0x367CD507, 0x9159015A,
+ 0x3070DD17, 0x152FECD8, 0xF70E5939, 0x67332667, 0xFFC00B31,
+ 0x8EB44A87, 0x68581511, 0xDB0C2E0D, 0x64F98FA7, 0x47B5481D,
+ 0xBEFA4FA4
+};
+static uint32_t SHA512_H0[SHA512HashSize/4] = {
+ 0x6A09E667, 0xF3BCC908, 0xBB67AE85, 0x84CAA73B, 0x3C6EF372,
+ 0xFE94F82B, 0xA54FF53A, 0x5F1D36F1, 0x510E527F, 0xADE682D1,
+ 0x9B05688C, 0x2B3E6C1F, 0x1F83D9AB, 0xFB41BD6B, 0x5BE0CD19,
+ 0x137E2179
+};
+
+#else /* !USE_32BIT_ONLY */
+
+#include "sha-private.h"
+
+/* Define the SHA shift, rotate left and rotate right macros */
+#define SHA512_SHR(bits,word) (((uint64_t)(word)) >> (bits))
+#define SHA512_ROTR(bits,word) ((((uint64_t)(word)) >> (bits)) | \
+ (((uint64_t)(word)) << (64-(bits))))
+
+/*
+ * Define the SHA SIGMA and sigma macros
+ *
+ * SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word)
+ */
+#define SHA512_SIGMA0(word) \
+ (SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word))
+#define SHA512_SIGMA1(word) \
+ (SHA512_ROTR(14,word) ^ SHA512_ROTR(18,word) ^ SHA512_ROTR(41,word))
+#define SHA512_sigma0(word) \
+ (SHA512_ROTR( 1,word) ^ SHA512_ROTR( 8,word) ^ SHA512_SHR( 7,word))
+#define SHA512_sigma1(word) \
+ (SHA512_ROTR(19,word) ^ SHA512_ROTR(61,word) ^ SHA512_SHR( 6,word))
+
+/*
+ * Add "length" to the length.
+ * Set Corrupted when overflow has occurred.
+ */
+/* addTemp commented out by Nokia, static variables are not thread-safe */
+/* static uint64_t addTemp; */
+/* 'M' appended to Macro name by Nokia */
+#define SHA384_512AddLengthM(context, length) \
+ (addTemp = context->Length_Low, context->Corrupted = \
+ ((context->Length_Low += length) < addTemp) && \
+ (++context->Length_High == 0) ? shaInputTooLong : \
+ (context)->Corrupted)
+
+/* Local Function Prototypes */
+static int SHA384_512Reset(SHA512Context *context,
+ uint64_t H0[SHA512HashSize/8]);
+static void SHA384_512ProcessMessageBlock(SHA512Context *context);
+static void SHA384_512Finalize(SHA512Context *context,
+ uint8_t Pad_Byte);
+static void SHA384_512PadMessage(SHA512Context *context,
+ uint8_t Pad_Byte);
+static int SHA384_512ResultN(SHA512Context *context,
+ uint8_t Message_Digest[ ], int HashSize);
+
+/* Initial Hash Values: FIPS 180-3 sections 5.3.4 and 5.3.5 */
+static uint64_t SHA384_H0[ ] = {
+ 0xCBBB9D5DC1059ED8ll, 0x629A292A367CD507ll, 0x9159015A3070DD17ll,
+ 0x152FECD8F70E5939ll, 0x67332667FFC00B31ll, 0x8EB44A8768581511ll,
+ 0xDB0C2E0D64F98FA7ll, 0x47B5481DBEFA4FA4ll
+};
+static uint64_t SHA512_H0[ ] = {
+ 0x6A09E667F3BCC908ll, 0xBB67AE8584CAA73Bll, 0x3C6EF372FE94F82Bll,
+ 0xA54FF53A5F1D36F1ll, 0x510E527FADE682D1ll, 0x9B05688C2B3E6C1Fll,
+ 0x1F83D9ABFB41BD6Bll, 0x5BE0CD19137E2179ll
+};
+
+#endif /* USE_32BIT_ONLY */
+
+/*
+ * SHA384Reset
+ *
+ * Description:
+ * This function will initialize the SHA384Context in preparation
+ * for computing a new SHA384 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA384Reset(SHA384Context *context)
+{
+ return SHA384_512Reset(context, SHA384_H0);
+}
+
+/*
+ * SHA384Input
+ *
+ * Description:
+ * This function accepts an array of octets as the next portion
+ * of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_array[ ]: [in]
+ * An array of octets representing the next portion of
+ * the message.
+ * length: [in]
+ * The length of the message in message_array.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA384Input(SHA384Context *context,
+ const uint8_t *message_array, unsigned int length)
+{
+ return SHA512Input(context, message_array, length);
+}
+
+/*
+ * SHA384FinalBits
+ *
+ * Description:
+ * This function will add in any final bits of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_bits: [in]
+ * The final bits of the message, in the upper portion of the
+ * byte. (Use 0b###00000 instead of 0b00000### to input the
+ * three bits ###.)
+ * length: [in]
+ * The number of bits in message_bits, between 1 and 7.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA384FinalBits(SHA384Context *context,
+ uint8_t message_bits, unsigned int length)
+{
+ return SHA512FinalBits(context, message_bits, length);
+}
+
+/*
+ * SHA384Result
+ *
+ * Description:
+ * This function will return the 384-bit message digest
+ * into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 47.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA384Result(SHA384Context *context,
+ uint8_t Message_Digest[SHA384HashSize])
+{
+ return SHA384_512ResultN(context, Message_Digest, SHA384HashSize);
+}
+
+/*
+ * SHA512Reset
+ *
+ * Description:
+ * This function will initialize the SHA512Context in preparation
+ * for computing a new SHA512 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA512Reset(SHA512Context *context)
+{
+ return SHA384_512Reset(context, SHA512_H0);
+}
+
+/*
+ * SHA512Input
+ *
+ * Description:
+ * This function accepts an array of octets as the next portion
+ * of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_array[ ]: [in]
+ * An array of octets representing the next portion of
+ * the message.
+ * length: [in]
+ * The length of the message in message_array.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA512Input(SHA512Context *context,
+ const uint8_t *message_array,
+ unsigned int length)
+{
+ if (!context) return shaNull;
+ if (!length) return shaSuccess;
+ if (!message_array) return shaNull;
+ if (context->Computed) return context->Corrupted = shaStateError;
+ if (context->Corrupted) return context->Corrupted;
+
+ while (length--) {
+ context->Message_Block[context->Message_Block_Index++] =
+ *message_array;
+
+ if ((SHA384_512AddLength(context, 8) == shaSuccess) &&
+ (context->Message_Block_Index == SHA512_Message_Block_Size))
+ SHA384_512ProcessMessageBlock(context);
+
+ message_array++;
+ }
+
+ return context->Corrupted;
+}
+
+/*
+ * SHA512FinalBits
+ *
+ * Description:
+ * This function will add in any final bits of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * message_bits: [in]
+ * The final bits of the message, in the upper portion of the
+ * byte. (Use 0b###00000 instead of 0b00000### to input the
+ * three bits ###.)
+ * length: [in]
+ * The number of bits in message_bits, between 1 and 7.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA512FinalBits(SHA512Context *context,
+ uint8_t message_bits, unsigned int length)
+{
+ static uint8_t masks[8] = {
+ /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80,
+ /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0,
+ /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8,
+ /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE
+ };
+ static uint8_t markbit[8] = {
+ /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40,
+ /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10,
+ /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04,
+ /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01
+ };
+
+ if (!context) return shaNull;
+ if (!length) return shaSuccess;
+ if (context->Corrupted) return context->Corrupted;
+ if (context->Computed) return context->Corrupted = shaStateError;
+ if (length >= 8) return context->Corrupted = shaBadParam;
+
+ SHA384_512AddLength(context, length);
+ SHA384_512Finalize(context, (uint8_t)
+ ((message_bits & masks[length]) | markbit[length]));
+
+ return context->Corrupted;
+}
+
+/*
+ * SHA512Result
+ *
+ * Description:
+ * This function will return the 512-bit message digest
+ * into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 63.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int SHA512Result(SHA512Context *context,
+ uint8_t Message_Digest[SHA512HashSize])
+{
+ return SHA384_512ResultN(context, Message_Digest, SHA512HashSize);
+}
+
+/*
+ * SHA384_512Reset
+ *
+ * Description:
+ * This helper function will initialize the SHA512Context in
+ * preparation for computing a new SHA384 or SHA512 message
+ * digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ * H0[ ]: [in]
+ * The initial hash value array to use.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+#ifdef USE_32BIT_ONLY
+static int SHA384_512Reset(SHA512Context *context,
+ uint32_t H0[SHA512HashSize/4])
+#else /* !USE_32BIT_ONLY */
+static int SHA384_512Reset(SHA512Context *context,
+ uint64_t H0[SHA512HashSize/8])
+#endif /* USE_32BIT_ONLY */
+{
+ int i;
+ if (!context) return shaNull;
+
+ context->Message_Block_Index = 0;
+
+#ifdef USE_32BIT_ONLY
+ context->Length[0] = context->Length[1] =
+ context->Length[2] = context->Length[3] = 0;
+
+ for (i = 0; i < SHA512HashSize/4; i++)
+ context->Intermediate_Hash[i] = H0[i];
+#else /* !USE_32BIT_ONLY */
+ context->Length_High = context->Length_Low = 0;
+
+ for (i = 0; i < SHA512HashSize/8; i++)
+ context->Intermediate_Hash[i] = H0[i];
+#endif /* USE_32BIT_ONLY */
+
+ context->Computed = 0;
+ context->Corrupted = shaSuccess;
+
+ return shaSuccess;
+}
+
+/*
+ * SHA384_512ProcessMessageBlock
+ *
+ * Description:
+ * This helper function will process the next 1024 bits of the
+ * message stored in the Message_Block array.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ *
+ * Returns:
+ * Nothing.
+ *
+ * Comments:
+ * Many of the variable names in this code, especially the
+ * single character names, were used because those were the
+ * names used in the Secure Hash Standard.
+ *
+ *
+ */
+static void SHA384_512ProcessMessageBlock(SHA512Context *context)
+{
+#ifdef USE_32BIT_ONLY
+ /* Constants defined in FIPS 180-3, section 4.2.3 */
+ static const uint32_t K[80*2] = {
+ 0x428A2F98, 0xD728AE22, 0x71374491, 0x23EF65CD, 0xB5C0FBCF,
+ 0xEC4D3B2F, 0xE9B5DBA5, 0x8189DBBC, 0x3956C25B, 0xF348B538,
+ 0x59F111F1, 0xB605D019, 0x923F82A4, 0xAF194F9B, 0xAB1C5ED5,
+ 0xDA6D8118, 0xD807AA98, 0xA3030242, 0x12835B01, 0x45706FBE,
+ 0x243185BE, 0x4EE4B28C, 0x550C7DC3, 0xD5FFB4E2, 0x72BE5D74,
+ 0xF27B896F, 0x80DEB1FE, 0x3B1696B1, 0x9BDC06A7, 0x25C71235,
+ 0xC19BF174, 0xCF692694, 0xE49B69C1, 0x9EF14AD2, 0xEFBE4786,
+ 0x384F25E3, 0x0FC19DC6, 0x8B8CD5B5, 0x240CA1CC, 0x77AC9C65,
+ 0x2DE92C6F, 0x592B0275, 0x4A7484AA, 0x6EA6E483, 0x5CB0A9DC,
+ 0xBD41FBD4, 0x76F988DA, 0x831153B5, 0x983E5152, 0xEE66DFAB,
+ 0xA831C66D, 0x2DB43210, 0xB00327C8, 0x98FB213F, 0xBF597FC7,
+ 0xBEEF0EE4, 0xC6E00BF3, 0x3DA88FC2, 0xD5A79147, 0x930AA725,
+ 0x06CA6351, 0xE003826F, 0x14292967, 0x0A0E6E70, 0x27B70A85,
+ 0x46D22FFC, 0x2E1B2138, 0x5C26C926, 0x4D2C6DFC, 0x5AC42AED,
+ 0x53380D13, 0x9D95B3DF, 0x650A7354, 0x8BAF63DE, 0x766A0ABB,
+ 0x3C77B2A8, 0x81C2C92E, 0x47EDAEE6, 0x92722C85, 0x1482353B,
+ 0xA2BFE8A1, 0x4CF10364, 0xA81A664B, 0xBC423001, 0xC24B8B70,
+ 0xD0F89791, 0xC76C51A3, 0x0654BE30, 0xD192E819, 0xD6EF5218,
+ 0xD6990624, 0x5565A910, 0xF40E3585, 0x5771202A, 0x106AA070,
+ 0x32BBD1B8, 0x19A4C116, 0xB8D2D0C8, 0x1E376C08, 0x5141AB53,
+ 0x2748774C, 0xDF8EEB99, 0x34B0BCB5, 0xE19B48A8, 0x391C0CB3,
+ 0xC5C95A63, 0x4ED8AA4A, 0xE3418ACB, 0x5B9CCA4F, 0x7763E373,
+ 0x682E6FF3, 0xD6B2B8A3, 0x748F82EE, 0x5DEFB2FC, 0x78A5636F,
+ 0x43172F60, 0x84C87814, 0xA1F0AB72, 0x8CC70208, 0x1A6439EC,
+ 0x90BEFFFA, 0x23631E28, 0xA4506CEB, 0xDE82BDE9, 0xBEF9A3F7,
+ 0xB2C67915, 0xC67178F2, 0xE372532B, 0xCA273ECE, 0xEA26619C,
+ 0xD186B8C7, 0x21C0C207, 0xEADA7DD6, 0xCDE0EB1E, 0xF57D4F7F,
+ 0xEE6ED178, 0x06F067AA, 0x72176FBA, 0x0A637DC5, 0xA2C898A6,
+ 0x113F9804, 0xBEF90DAE, 0x1B710B35, 0x131C471B, 0x28DB77F5,
+ 0x23047D84, 0x32CAAB7B, 0x40C72493, 0x3C9EBE0A, 0x15C9BEBC,
+ 0x431D67C4, 0x9C100D4C, 0x4CC5D4BE, 0xCB3E42B6, 0x597F299C,
+ 0xFC657E2A, 0x5FCB6FAB, 0x3AD6FAEC, 0x6C44198C, 0x4A475817
+ };
+ int t, t2, t8; /* Loop counter */
+ uint32_t temp1[2], temp2[2], /* Temporary word values */
+ temp3[2], temp4[2], temp5[2];
+ uint32_t W[2*80]; /* Word sequence */
+ uint32_t A[2], B[2], C[2], D[2], /* Word buffers */
+ E[2], F[2], G[2], H[2];
+
+ /* Initialize the first 16 words in the array W */
+ for (t = t2 = t8 = 0; t < 16; t++, t8 += 8) {
+ W[t2++] = ((((uint32_t)context->Message_Block[t8 ])) << 24) |
+ ((((uint32_t)context->Message_Block[t8 + 1])) << 16) |
+ ((((uint32_t)context->Message_Block[t8 + 2])) << 8) |
+ ((((uint32_t)context->Message_Block[t8 + 3])));
+ W[t2++] = ((((uint32_t)context->Message_Block[t8 + 4])) << 24) |
+ ((((uint32_t)context->Message_Block[t8 + 5])) << 16) |
+ ((((uint32_t)context->Message_Block[t8 + 6])) << 8) |
+ ((((uint32_t)context->Message_Block[t8 + 7])));
+ }
+
+ for (t = 16; t < 80; t++, t2 += 2) {
+ /* W[t] = SHA512_sigma1(W[t-2]) + W[t-7] +
+ SHA512_sigma0(W[t-15]) + W[t-16]; */
+ uint32_t *Wt2 = &W[t2-2*2];
+ uint32_t *Wt7 = &W[t2-7*2];
+ uint32_t *Wt15 = &W[t2-15*2];
+ uint32_t *Wt16 = &W[t2-16*2];
+ SHA512_sigma1(Wt2, temp1);
+ SHA512_ADD(temp1, Wt7, temp2);
+ SHA512_sigma0(Wt15, temp1);
+ SHA512_ADD(temp1, Wt16, temp3);
+ SHA512_ADD(temp2, temp3, &W[t2]);
+ }
+
+ A[0] = context->Intermediate_Hash[0];
+ A[1] = context->Intermediate_Hash[1];
+ B[0] = context->Intermediate_Hash[2];
+ B[1] = context->Intermediate_Hash[3];
+ C[0] = context->Intermediate_Hash[4];
+ C[1] = context->Intermediate_Hash[5];
+ D[0] = context->Intermediate_Hash[6];
+ D[1] = context->Intermediate_Hash[7];
+ E[0] = context->Intermediate_Hash[8];
+ E[1] = context->Intermediate_Hash[9];
+ F[0] = context->Intermediate_Hash[10];
+ F[1] = context->Intermediate_Hash[11];
+ G[0] = context->Intermediate_Hash[12];
+ G[1] = context->Intermediate_Hash[13];
+ H[0] = context->Intermediate_Hash[14];
+ H[1] = context->Intermediate_Hash[15];
+
+ for (t = t2 = 0; t < 80; t++, t2 += 2) {
+ /*
+ * temp1 = H + SHA512_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t];
+ */
+ SHA512_SIGMA1(E,temp1);
+ SHA512_ADD(H, temp1, temp2);
+ SHA_Ch(E,F,G,temp3);
+ SHA512_ADD(temp2, temp3, temp4);
+ SHA512_ADD(&K[t2], &W[t2], temp5);
+ SHA512_ADD(temp4, temp5, temp1);
+ /*
+ * temp2 = SHA512_SIGMA0(A) + SHA_Maj(A,B,C);
+ */
+ SHA512_SIGMA0(A,temp3);
+ SHA_Maj(A,B,C,temp4);
+ SHA512_ADD(temp3, temp4, temp2);
+ H[0] = G[0]; H[1] = G[1];
+ G[0] = F[0]; G[1] = F[1];
+ F[0] = E[0]; F[1] = E[1];
+ SHA512_ADD(D, temp1, E);
+ D[0] = C[0]; D[1] = C[1];
+ C[0] = B[0]; C[1] = B[1];
+ B[0] = A[0]; B[1] = A[1];
+ SHA512_ADD(temp1, temp2, A);
+ }
+
+ SHA512_ADDTO2(&context->Intermediate_Hash[0], A);
+ SHA512_ADDTO2(&context->Intermediate_Hash[2], B);
+ SHA512_ADDTO2(&context->Intermediate_Hash[4], C);
+ SHA512_ADDTO2(&context->Intermediate_Hash[6], D);
+ SHA512_ADDTO2(&context->Intermediate_Hash[8], E);
+ SHA512_ADDTO2(&context->Intermediate_Hash[10], F);
+ SHA512_ADDTO2(&context->Intermediate_Hash[12], G);
+ SHA512_ADDTO2(&context->Intermediate_Hash[14], H);
+
+#else /* !USE_32BIT_ONLY */
+ /* Constants defined in FIPS 180-3, section 4.2.3 */
+ static const uint64_t K[80] = {
+ 0x428A2F98D728AE22ll, 0x7137449123EF65CDll, 0xB5C0FBCFEC4D3B2Fll,
+ 0xE9B5DBA58189DBBCll, 0x3956C25BF348B538ll, 0x59F111F1B605D019ll,
+ 0x923F82A4AF194F9Bll, 0xAB1C5ED5DA6D8118ll, 0xD807AA98A3030242ll,
+ 0x12835B0145706FBEll, 0x243185BE4EE4B28Cll, 0x550C7DC3D5FFB4E2ll,
+ 0x72BE5D74F27B896Fll, 0x80DEB1FE3B1696B1ll, 0x9BDC06A725C71235ll,
+ 0xC19BF174CF692694ll, 0xE49B69C19EF14AD2ll, 0xEFBE4786384F25E3ll,
+ 0x0FC19DC68B8CD5B5ll, 0x240CA1CC77AC9C65ll, 0x2DE92C6F592B0275ll,
+ 0x4A7484AA6EA6E483ll, 0x5CB0A9DCBD41FBD4ll, 0x76F988DA831153B5ll,
+ 0x983E5152EE66DFABll, 0xA831C66D2DB43210ll, 0xB00327C898FB213Fll,
+ 0xBF597FC7BEEF0EE4ll, 0xC6E00BF33DA88FC2ll, 0xD5A79147930AA725ll,
+ 0x06CA6351E003826Fll, 0x142929670A0E6E70ll, 0x27B70A8546D22FFCll,
+ 0x2E1B21385C26C926ll, 0x4D2C6DFC5AC42AEDll, 0x53380D139D95B3DFll,
+ 0x650A73548BAF63DEll, 0x766A0ABB3C77B2A8ll, 0x81C2C92E47EDAEE6ll,
+ 0x92722C851482353Bll, 0xA2BFE8A14CF10364ll, 0xA81A664BBC423001ll,
+ 0xC24B8B70D0F89791ll, 0xC76C51A30654BE30ll, 0xD192E819D6EF5218ll,
+ 0xD69906245565A910ll, 0xF40E35855771202All, 0x106AA07032BBD1B8ll,
+ 0x19A4C116B8D2D0C8ll, 0x1E376C085141AB53ll, 0x2748774CDF8EEB99ll,
+ 0x34B0BCB5E19B48A8ll, 0x391C0CB3C5C95A63ll, 0x4ED8AA4AE3418ACBll,
+ 0x5B9CCA4F7763E373ll, 0x682E6FF3D6B2B8A3ll, 0x748F82EE5DEFB2FCll,
+ 0x78A5636F43172F60ll, 0x84C87814A1F0AB72ll, 0x8CC702081A6439ECll,
+ 0x90BEFFFA23631E28ll, 0xA4506CEBDE82BDE9ll, 0xBEF9A3F7B2C67915ll,
+ 0xC67178F2E372532Bll, 0xCA273ECEEA26619Cll, 0xD186B8C721C0C207ll,
+ 0xEADA7DD6CDE0EB1Ell, 0xF57D4F7FEE6ED178ll, 0x06F067AA72176FBAll,
+ 0x0A637DC5A2C898A6ll, 0x113F9804BEF90DAEll, 0x1B710B35131C471Bll,
+ 0x28DB77F523047D84ll, 0x32CAAB7B40C72493ll, 0x3C9EBE0A15C9BEBCll,
+ 0x431D67C49C100D4Cll, 0x4CC5D4BECB3E42B6ll, 0x597F299CFC657E2All,
+ 0x5FCB6FAB3AD6FAECll, 0x6C44198C4A475817ll
+ };
+ int t, t8; /* Loop counter */
+ uint64_t temp1, temp2; /* Temporary word value */
+ uint64_t W[80]; /* Word sequence */
+ uint64_t A, B, C, D, E, F, G, H; /* Word buffers */
+
+ /*
+ * Initialize the first 16 words in the array W
+ */
+ for (t = t8 = 0; t < 16; t++, t8 += 8)
+ W[t] = ((uint64_t)(context->Message_Block[t8 ]) << 56) |
+ ((uint64_t)(context->Message_Block[t8 + 1]) << 48) |
+ ((uint64_t)(context->Message_Block[t8 + 2]) << 40) |
+ ((uint64_t)(context->Message_Block[t8 + 3]) << 32) |
+ ((uint64_t)(context->Message_Block[t8 + 4]) << 24) |
+ ((uint64_t)(context->Message_Block[t8 + 5]) << 16) |
+ ((uint64_t)(context->Message_Block[t8 + 6]) << 8) |
+ ((uint64_t)(context->Message_Block[t8 + 7]));
+
+ for (t = 16; t < 80; t++)
+ W[t] = SHA512_sigma1(W[t-2]) + W[t-7] +
+ SHA512_sigma0(W[t-15]) + W[t-16];
+ A = context->Intermediate_Hash[0];
+ B = context->Intermediate_Hash[1];
+ C = context->Intermediate_Hash[2];
+ D = context->Intermediate_Hash[3];
+ E = context->Intermediate_Hash[4];
+ F = context->Intermediate_Hash[5];
+ G = context->Intermediate_Hash[6];
+ H = context->Intermediate_Hash[7];
+
+ for (t = 0; t < 80; t++) {
+ temp1 = H + SHA512_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t];
+ temp2 = SHA512_SIGMA0(A) + SHA_Maj(A,B,C);
+ H = G;
+ G = F;
+ F = E;
+ E = D + temp1;
+ D = C;
+ C = B;
+ B = A;
+ A = temp1 + temp2;
+ }
+
+ context->Intermediate_Hash[0] += A;
+ context->Intermediate_Hash[1] += B;
+ context->Intermediate_Hash[2] += C;
+ context->Intermediate_Hash[3] += D;
+ context->Intermediate_Hash[4] += E;
+ context->Intermediate_Hash[5] += F;
+ context->Intermediate_Hash[6] += G;
+ context->Intermediate_Hash[7] += H;
+#endif /* USE_32BIT_ONLY */
+
+ context->Message_Block_Index = 0;
+}
+
+/*
+ * SHA384_512Finalize
+ *
+ * Description:
+ * This helper function finishes off the digest calculations.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update.
+ * Pad_Byte: [in]
+ * The last byte to add to the message block before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+static void SHA384_512Finalize(SHA512Context *context,
+ uint8_t Pad_Byte)
+{
+ int_least16_t i;
+ SHA384_512PadMessage(context, Pad_Byte);
+ /* message may be sensitive, clear it out */
+ for (i = 0; i < SHA512_Message_Block_Size; ++i)
+ context->Message_Block[i] = 0;
+#ifdef USE_32BIT_ONLY /* and clear length */
+ context->Length[0] = context->Length[1] = 0;
+ context->Length[2] = context->Length[3] = 0;
+#else /* !USE_32BIT_ONLY */
+ context->Length_High = context->Length_Low = 0;
+#endif /* USE_32BIT_ONLY */
+ context->Computed = 1;
+}
+
+/*
+ * SHA384_512PadMessage
+ *
+ * Description:
+ * According to the standard, the message must be padded to the next
+ * even multiple of 1024 bits. The first padding bit must be a '1'.
+ * The last 128 bits represent the length of the original message.
+ * All bits in between should be 0. This helper function will
+ * pad the message according to those rules by filling the
+ * Message_Block array accordingly. When it returns, it can be
+ * assumed that the message digest has been computed.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to pad.
+ * Pad_Byte: [in]
+ * The last byte to add to the message block before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * Nothing.
+ *
+ */
+static void SHA384_512PadMessage(SHA512Context *context,
+ uint8_t Pad_Byte)
+{
+ /*
+ * Check to see if the current message block is too small to hold
+ * the initial padding bits and length. If so, we will pad the
+ * block, process it, and then continue padding into a second
+ * block.
+ */
+ if (context->Message_Block_Index >= (SHA512_Message_Block_Size-16)) {
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+ while (context->Message_Block_Index < SHA512_Message_Block_Size)
+ context->Message_Block[context->Message_Block_Index++] = 0;
+
+ SHA384_512ProcessMessageBlock(context);
+ } else
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+
+ while (context->Message_Block_Index < (SHA512_Message_Block_Size-16))
+ context->Message_Block[context->Message_Block_Index++] = 0;
+
+ /*
+ * Store the message length as the last 16 octets
+ */
+#ifdef USE_32BIT_ONLY
+ context->Message_Block[112] = (uint8_t)(context->Length[0] >> 24);
+ context->Message_Block[113] = (uint8_t)(context->Length[0] >> 16);
+ context->Message_Block[114] = (uint8_t)(context->Length[0] >> 8);
+ context->Message_Block[115] = (uint8_t)(context->Length[0]);
+ context->Message_Block[116] = (uint8_t)(context->Length[1] >> 24);
+ context->Message_Block[117] = (uint8_t)(context->Length[1] >> 16);
+ context->Message_Block[118] = (uint8_t)(context->Length[1] >> 8);
+ context->Message_Block[119] = (uint8_t)(context->Length[1]);
+
+ context->Message_Block[120] = (uint8_t)(context->Length[2] >> 24);
+ context->Message_Block[121] = (uint8_t)(context->Length[2] >> 16);
+ context->Message_Block[122] = (uint8_t)(context->Length[2] >> 8);
+ context->Message_Block[123] = (uint8_t)(context->Length[2]);
+ context->Message_Block[124] = (uint8_t)(context->Length[3] >> 24);
+ context->Message_Block[125] = (uint8_t)(context->Length[3] >> 16);
+ context->Message_Block[126] = (uint8_t)(context->Length[3] >> 8);
+ context->Message_Block[127] = (uint8_t)(context->Length[3]);
+#else /* !USE_32BIT_ONLY */
+ context->Message_Block[112] = (uint8_t)(context->Length_High >> 56);
+ context->Message_Block[113] = (uint8_t)(context->Length_High >> 48);
+ context->Message_Block[114] = (uint8_t)(context->Length_High >> 40);
+ context->Message_Block[115] = (uint8_t)(context->Length_High >> 32);
+ context->Message_Block[116] = (uint8_t)(context->Length_High >> 24);
+ context->Message_Block[117] = (uint8_t)(context->Length_High >> 16);
+ context->Message_Block[118] = (uint8_t)(context->Length_High >> 8);
+ context->Message_Block[119] = (uint8_t)(context->Length_High);
+
+ context->Message_Block[120] = (uint8_t)(context->Length_Low >> 56);
+ context->Message_Block[121] = (uint8_t)(context->Length_Low >> 48);
+ context->Message_Block[122] = (uint8_t)(context->Length_Low >> 40);
+ context->Message_Block[123] = (uint8_t)(context->Length_Low >> 32);
+ context->Message_Block[124] = (uint8_t)(context->Length_Low >> 24);
+ context->Message_Block[125] = (uint8_t)(context->Length_Low >> 16);
+ context->Message_Block[126] = (uint8_t)(context->Length_Low >> 8);
+ context->Message_Block[127] = (uint8_t)(context->Length_Low);
+#endif /* USE_32BIT_ONLY */
+
+ SHA384_512ProcessMessageBlock(context);
+}
+
+/*
+ * SHA384_512ResultN
+ *
+ * Description:
+ * This helper function will return the 384-bit or 512-bit message
+ * digest into the Message_Digest array provided by the caller.
+ * NOTE:
+ * The first octet of hash is stored in the element with index 0,
+ * the last octet of hash in the element with index 47/63.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA hash.
+ * Message_Digest[ ]: [out]
+ * Where the digest is returned.
+ * HashSize: [in]
+ * The size of the hash, either 48 or 64.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+static int SHA384_512ResultN(SHA512Context *context,
+ uint8_t Message_Digest[ ], int HashSize)
+{
+ int i;
+#ifdef USE_32BIT_ONLY
+ int i2;
+#endif /* USE_32BIT_ONLY */
+
+ if (!context) return shaNull;
+ if (!Message_Digest) return shaNull;
+ if (context->Corrupted) return context->Corrupted;
+
+ if (!context->Computed)
+ SHA384_512Finalize(context, 0x80);
+
+#ifdef USE_32BIT_ONLY
+ for (i = i2 = 0; i < HashSize; ) {
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>24);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>16);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>8);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2++]);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>24);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>16);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>8);
+ Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2++]);
+ }
+#else /* !USE_32BIT_ONLY */
+ for (i = 0; i < HashSize; ++i)
+ Message_Digest[i] = (uint8_t)
+ (context->Intermediate_Hash[i>>3] >> 8 * ( 7 - ( i % 8 ) ));
+#endif /* USE_32BIT_ONLY */
+
+ return shaSuccess;
+}
diff --git a/src/concurrent/qfuturewatcher.h b/src/concurrent/qfuturewatcher.h
index 11dab42174..439a25d844 100644
--- a/src/concurrent/qfuturewatcher.h
+++ b/src/concurrent/qfuturewatcher.h
@@ -63,7 +63,7 @@ class Q_CONCURRENT_EXPORT QFutureWatcherBase : public QObject
Q_DECLARE_PRIVATE(QFutureWatcherBase)
public:
- QFutureWatcherBase(QObject *parent = 0);
+ explicit QFutureWatcherBase(QObject *parent = 0);
int progressValue() const;
int progressMinimum() const;
@@ -119,7 +119,7 @@ template <typename T>
class QFutureWatcher : public QFutureWatcherBase
{
public:
- QFutureWatcher(QObject *_parent = 0)
+ explicit QFutureWatcher(QObject *_parent = 0)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
@@ -189,7 +189,7 @@ template <>
class QFutureWatcher<void> : public QFutureWatcherBase
{
public:
- QFutureWatcher(QObject *_parent = 0)
+ explicit QFutureWatcher(QObject *_parent = 0)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 37af42d6bd..67598f4f70 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -1,18 +1,62 @@
get_filename_component(_qt5_corelib_install_prefix ${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR} ABSOLUTE)
-# Required by default:
-set(QT_QMAKE_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/qmake$$CMAKE_BIN_SUFFIX\")
-set(QT_MOC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/moc$$CMAKE_BIN_SUFFIX\")
-set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/rcc$$CMAKE_BIN_SUFFIX\")
+!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+set(QT_QMAKE_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+set(QT_MOC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+!!ELSE
+set(QT_QMAKE_EXECUTABLE \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+set(QT_MOC_EXECUTABLE \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+set(QT_RCC_EXECUTABLE \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+!!ENDIF
+!!IF isEmpty(CMAKE_DATA_DIR_IS_ABSOLUTE)
list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/mkspecs/default\")
+!!ELSE
+list(APPEND Qt5Core_INCLUDE_DIRS \"$${CMAKE_DATA_DIR}mkspecs/default\")
+!!ENDIF
-if (NOT \"$${CMAKE_ADD_FPIE_FLAGS}\" STREQUAL \"\")
- set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE")
-endif()
+!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS)
+set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE")
+!!ENDIF
+
+!!IF !isEmpty(QT_NAMESPACE)
+list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
+list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
+!!ENDIF
+
+!!IF !isEmpty(QT_LIBINFIX)
+set(QT_LIBINFIX \"$${QT_LIBINFIX}\")
+!!ENDIF
-if (NOT \"$$QT_NAMESPACE\" STREQUAL \"\")
- list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
- list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
+!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+set(Qt5Core_QTMAIN_LIBRARIES Qt5::WinMain)
+
+if (NOT _Qt5WinMain_target)
+ set(_Qt5WinMain_target 1)
+ add_library(Qt5::WinMain STATIC IMPORTED)
endif()
+
+!!IF !isEmpty(debug_type)
+set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+set_target_properties(Qt5::WinMain PROPERTIES
+!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ IMPORTED_LOCATION_DEBUG "${_qt5_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}"
+!!ELSE
+ IMPORTED_LOCATION_DEBUG "$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}"
+!!ENDIF
+)
+!!ENDIF
+
+!!IF !isEmpty(release_type)
+set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Qt5::WinMain PROPERTIES
+!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ IMPORTED_LOCATION_RELEASE \"${_qt5_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
+!!ELSE
+ IMPORTED_LOCATION_RELEASE \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
+!!ENDIF
+)
+!!ENDIF
+!!ENDIF
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index abfe49ec84..4a10fad9eb 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -83,7 +83,7 @@ macro(QT5_GET_MOC_FLAGS _moc_flags)
set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
endforeach()
- if(Q_WS_WIN)
+ if(WIN32)
set(${_moc_flags} ${${_moc_flags}} -DWIN32)
endif()
endmacro()
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index e49ebfb844..3119c4f661 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1495,35 +1495,7 @@ QString QTextDecoder::toUnicode(const QByteArray &ba)
files to be loaded. For details of internationalization, see
\l{Internationalization with Qt}.
- \sa codecForTr(), setCodecForCStrings()
-*/
-
-
-/*!
- \fn QTextCodec* QTextCodec::codecForCStrings()
-
- Returns the codec used by QString to convert to and from \c{const
- char *} and QByteArrays. If this function returns 0 (the default),
- QString assumes Latin-1.
-
- \sa setCodecForCStrings()
-*/
-
-/*!
- \fn void QTextCodec::setCodecForCStrings(QTextCodec *codec)
- \nonreentrant
-
- Sets the codec used by QString to convert to and from \c{const
- char *} and QByteArrays. If the \a codec is 0 (the default),
- QString assumes Latin-1.
-
- \warning Some codecs do not preserve the characters in the ASCII
- range (0x00 to 0x7F). For example, the Japanese Shift-JIS
- encoding maps the backslash character (0x5A) to the Yen
- character. To avoid undesirable side-effects, we recommend
- avoiding such codecs with setCodecsForCString().
-
- \sa codecForCStrings(), setCodecForTr()
+ \sa codecForTr()
*/
/*!
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index 9e46863964..ad37005e92 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -75,9 +75,6 @@ public:
static QTextCodec* codecForTr();
static void setCodecForTr(QTextCodec *c);
- static QTextCodec* codecForCStrings();
- static void setCodecForCStrings(QTextCodec *c);
-
static QTextCodec *codecForHtml(const QByteArray &ba);
static QTextCodec *codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec);
@@ -139,8 +136,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTextCodec::ConversionFlags)
inline QTextCodec* QTextCodec::codecForTr() { return validCodecs() ? cftr : 0; }
inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; }
-inline QTextCodec* QTextCodec::codecForCStrings() { return validCodecs() ? QString::codecForCStrings : 0; }
-inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { QString::codecForCStrings = c; }
class Q_CORE_EXPORT QTextEncoder {
Q_DISABLE_COPY(QTextEncoder)
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 5ab79092d2..b3787261be 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -76,14 +76,13 @@
# define Q_CC_SYM
/* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */
# if defined(__SC__) && __SC__ < 0x750
-# define Q_NO_EXPLICIT_KEYWORD
+# error "Compiler not supported"
# endif
# define Q_NO_USING_KEYWORD
#elif defined(_MSC_VER)
# define Q_CC_MSVC
# define Q_CC_MSVC_NET
-# define Q_CANNOT_DELETE_CONSTANT
# define Q_OUTOFLINE_TEMPLATE inline
# define Q_NO_TEMPLATE_FRIENDS
# define Q_ALIGNOF(type) __alignof(type)
@@ -114,8 +113,7 @@
# define Q_CC_BOR
# define Q_INLINE_TEMPLATE
# if __BORLANDC__ < 0x502
-# define Q_NO_BOOL_TYPE
-# define Q_NO_EXPLICIT_KEYWORD
+# error "Compiler not supported"
# endif
# define Q_NO_USING_KEYWORD
@@ -140,45 +138,19 @@
# define Q_CC_MINGW
# endif
# if defined(__INTEL_COMPILER)
-/* Intel C++ also masquerades as GCC 3.2.0 */
+/* Intel C++ also masquerades as GCC */
# define Q_CC_INTEL
# endif
# if defined(__clang__)
-/* Clang also masquerades as GCC 4.2.1 */
+/* Clang also masquerades as GCC */
# define Q_CC_CLANG
# endif
-# ifdef __APPLE__
-# define Q_NO_DEPRECATED_CONSTRUCTORS
-# endif
-# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
-# define Q_FULL_TEMPLATE_INSTANTIATION
-# endif
-/* GCC 2.95 knows "using" but does not support it correctly */
-# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
-# define Q_NO_USING_KEYWORD
-# endif
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-# define Q_ALIGNOF(type) __alignof__(type)
-# define Q_TYPEOF(expr) __typeof__(expr)
-# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
-# endif
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
-# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
-# endif
-/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
-# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
-# define Q_WRONG_SB_CTYPE_MACROS
-# endif
-/* GCC <= 3.3 cannot handle template friends */
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
-# define Q_NO_TEMPLATE_FRIENDS
-# endif
-/* Apple's GCC 3.1 chokes on our streaming qDebug() */
-# if defined(Q_OS_DARWIN) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 3)
-# define Q_BROKEN_DEBUG_STREAM
-# endif
-# if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP)
+# define Q_ALIGNOF(type) __alignof__(type)
+# define Q_TYPEOF(expr) __typeof__(expr)
+# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
+# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
+# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
+# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# define Q_NO_PACKED_REFERENCE
# ifndef __ARM_EABI__
@@ -251,12 +223,7 @@
# define Q_CC_XLC
# define Q_FULL_TEMPLATE_INSTANTIATION
# if __xlC__ < 0x400
-# define Q_NO_BOOL_TYPE
-# define Q_NO_EXPLICIT_KEYWORD
-# define Q_NO_USING_KEYWORD
-# define Q_OUTOFLINE_TEMPLATE inline
-# define Q_BROKEN_TEMPLATE_SPECIALIZATION
-# define Q_CANNOT_DELETE_CONSTANT
+# error "Compiler not supported"
# elif __xlC__ >= 0x0600
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)
@@ -280,7 +247,7 @@
- observed on Compaq C++ V6.3-002.
In any case versions prior to Compaq C++ V6.0-005 do not have bool. */
# if !defined(_BOOL_EXISTS)
-# define Q_NO_BOOL_TYPE
+# error "Compiler not supported"
# endif
/* Spurious (?) error messages observed on Compaq C++ V6.5-014. */
# define Q_NO_USING_KEYWORD
@@ -288,7 +255,6 @@
DEC C++ V5.5-004. */
# if __DECCXX_VER < 60060000
# define Q_BROKEN_TEMPLATE_SPECIALIZATION
-# define Q_CANNOT_DELETE_CONSTANT
# endif
/* avoid undefined symbol problems with out-of-line template members */
# define Q_OUTOFLINE_TEMPLATE inline
@@ -315,7 +281,7 @@
__BOOL_DEFINED
Defined in Microsoft C++ mode when bool is a keyword. */
# if !defined(_BOOL) && !defined(__BOOL_DEFINED)
-# define Q_NO_BOOL_TYPE
+# error "Compiler not supported"
# endif
/* The Comeau compiler is based on EDG and does define __EDG__ */
@@ -341,9 +307,8 @@
# elif defined(__DCC__)
# define Q_CC_DIAB
-# undef Q_NO_BOOL_TYPE
# if !defined(__bool)
-# define Q_NO_BOOL_TYPE
+# error "Compiler not supported"
# endif
/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */
@@ -407,7 +372,7 @@
# define Q_NO_TEMPLATE_FRIENDS
# endif
# if !defined(_BOOL)
-# define Q_NO_BOOL_TYPE
+# error "Compiler not supported"
# endif
# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4)
# define Q_NO_USING_KEYWORD
@@ -415,9 +380,7 @@
# define Q_C_CALLBACKS
/* 4.2 compiler or older */
# else
-# define Q_NO_BOOL_TYPE
-# define Q_NO_EXPLICIT_KEYWORD
-# define Q_NO_USING_KEYWORD
+# error "Compiler not supported"
# endif
/* CDS++ does not seem to define __EDG__ or __EDG according to Reliant
@@ -426,7 +389,7 @@
# define Q_CC_EDG
# define Q_CC_CDS
# if !defined(_BOOL)
-# define Q_NO_BOOL_TYPE
+# error "Compiler not supported"
# endif
# define Q_BROKEN_TEMPLATE_SPECIALIZATION
@@ -449,11 +412,7 @@
# define Q_DECL_IMPORT Q_DECL_EXPORT
# endif
# else
-# define Q_CC_HP
-# define Q_NO_BOOL_TYPE
-# define Q_FULL_TEMPLATE_INSTANTIATION
-# define Q_BROKEN_TEMPLATE_SPECIALIZATION
-# define Q_NO_EXPLICIT_KEYWORD
+# error "Compiler not supported"
# endif
# define Q_NO_USING_KEYWORD /* ### check "using" status */
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index fb6eaeb452..99328d52ac 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -191,7 +191,7 @@ namespace QT_NAMESPACE {}
#endif
#ifndef Q_REQUIRED_RESULT
-# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+# if defined(Q_CC_GNU)
# define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
# else
# define Q_REQUIRED_RESULT
@@ -275,11 +275,6 @@ typedef unsigned int uint;
typedef unsigned long ulong;
QT_END_INCLUDE_NAMESPACE
-#if defined(Q_NO_BOOL_TYPE)
-#error "Compiler doesn't support the bool type"
-#endif
-
-
/*
Constant bool values
*/
@@ -315,9 +310,7 @@ QT_END_INCLUDE_NAMESPACE
/*
Warnings and errors when using deprecated methods
*/
-#if defined(Q_MOC_RUN)
-# define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
-#elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
+#if defined(Q_CC_GNU) || defined(Q_CC_RVCT)
# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
#elif defined(Q_CC_MSVC)
# define Q_DECL_DEPRECATED __declspec(deprecated)
@@ -331,15 +324,6 @@ QT_END_INCLUDE_NAMESPACE
#ifndef Q_DECL_VARIABLE_DEPRECATED
# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
#endif
-#ifndef Q_DECL_CONSTRUCTOR_DEPRECATED
-# if defined(Q_MOC_RUN)
-# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED
-# elif defined(Q_NO_DEPRECATED_CONSTRUCTORS)
-# define Q_DECL_CONSTRUCTOR_DEPRECATED
-# else
-# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED
-# endif
-#endif
#if defined(QT_NO_DEPRECATED)
# undef QT_DEPRECATED
@@ -394,24 +378,13 @@ QT_END_INCLUDE_NAMESPACE
#ifdef QT_ASCII_CAST_WARNINGS
# define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
-# if defined(Q_CC_GNU) && __GNUC__ < 4
- /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */
-# define QT_ASCII_CAST_WARN_CONSTRUCTOR
-# else
-# define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
-# endif
#else
# define QT_ASCII_CAST_WARN
-# define QT_ASCII_CAST_WARN_CONSTRUCTOR
#endif
#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
# if defined(Q_CC_GNU)
-#if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
# define QT_FASTCALL __attribute__((regparm(3)))
-#else
-# define QT_FASTCALL
-#endif
# elif defined(Q_CC_MSVC)
# define QT_FASTCALL __fastcall
# else
@@ -512,17 +485,12 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
class QDataStream;
-#if !defined(QT_NO_COP)
-# define QT_NO_COP
-#endif
-
#if defined(Q_OS_VXWORKS)
# define QT_NO_CRASHHANDLER // no popen
# define QT_NO_PROCESS // no exec*, no fork
# define QT_NO_LPR
# define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end...
# define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
-# define QT_NO_QWS_MULTIPROCESS // no processes
#endif
# include <QtCore/qfeatures.h>
@@ -1237,12 +1205,15 @@ class QFlags
int i;
public:
typedef Enum enum_type;
- Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {}
+ // compiler-generated copy/move ctor/assignment operators are fine!
+#ifdef qdoc
+ inline QFlags(const QFlags &other);
+ inline QFlags &operator=(const QFlags &other);
+#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
inline QFlags(QFlag f) : i(f) {}
- inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
inline QFlags &operator&=(int mask) { i &= mask; return *this; }
inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
@@ -1463,8 +1434,6 @@ Q_CORE_EXPORT int qrand();
#ifdef Q_OS_QNX
// QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
// shared fonts and QSystemSemaphore + QSharedMemory are not available
-# define QT_NO_QWS_MULTIPROCESS
-# define QT_NO_QWS_SHARE_FONTS
# define QT_NO_SYSTEMSEMAPHORE
# define QT_NO_SHAREDMEMORY
#endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 61c750acaf..c871675334 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -348,71 +348,8 @@ QLibraryInfo::location(LibraryLocation loc)
QSettings *config = QLibraryInfoPrivate::configuration();
config->beginGroup(QLatin1String("Paths"));
- QString subKey;
- {
- /*
- find the child group whose version number is closest
- to the library version. for example and we have the
- following groups:
-
- Paths
- Paths/4.0
- Paths/4.1.2
- Paths/4.2.5
- Paths/5
-
- if QT_VERSION is 4.0.1, then we use 'Paths/4.0'
- if QT_VERSION is 4.1.5, then we use 'Paths/4.1.2'
- if QT_VERSION is 4.6.3, then we use 'Paths/4.2.5'
- if QT_VERSION is 6.0.2, then we use 'Paths/5'
-
- note: any of the trailing version numbers may be
- omitted (in which case, they default to zero),
- i.e. 4 == 4.0.0, 4.1 == 4.1.0, and so on
- */
- enum {
- QT_MAJOR = ((QT_VERSION >> 16) & 0xFF),
- QT_MINOR = ((QT_VERSION >> 8) & 0xFF),
- QT_PATCH = (QT_VERSION & 0xFF)
- };
- int maj = 0, min = 0, pat = 0;
- QStringList children = config->childGroups();
- for(int child = 0; child < children.size(); ++child) {
- QString cver = children.at(child);
- QStringList cver_list = cver.split(QLatin1Char('.'));
- if(cver_list.size() > 0 && cver_list.size() < 4) {
- bool ok;
- int cmaj = -1, cmin = -1, cpat = -1;
- cmaj = cver_list[0].toInt(&ok);
- if(!ok || cmaj < 0)
- continue;
- if(cver_list.size() >= 2) {
- cmin = cver_list[1].toInt(&ok);
- if(!ok)
- continue;
- if(cmin < 0)
- cmin = -1;
- }
- if(cver_list.size() >= 3) {
- cpat = cver_list[2].toInt(&ok);
- if(!ok)
- continue;
- if(cpat < 0)
- cpat = -1;
- }
- if((cmaj >= maj && cmaj <= QT_MAJOR) &&
- (cmin == -1 || (cmin >= min && cmin <= QT_MINOR)) &&
- (cpat == -1 || (cpat >= pat && cpat <= QT_PATCH)) &&
- config->contains(cver + QLatin1Char('/') + key)) {
- subKey = cver + QLatin1Char('/');
- maj = cmaj;
- min = cmin;
- pat = cpat;
- }
- }
- }
- }
- ret = config->value(subKey + key, defaultValue).toString();
+ ret = config->value(key, defaultValue).toString();
+
// expand environment variables in the form $(ENVVAR)
int rep;
QRegExp reg_var(QLatin1String("\\$\\(.*\\)"));
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 2087d763de..4ea62c77a6 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -293,6 +293,7 @@ public:
WindowStaysOnTopHint = 0x00040000,
WindowTransparentForInput = 0x00080000,
WindowOverridesSystemGestures = 0x00100000,
+ WindowDoesNotAcceptFocus = 0x00200000,
CustomizeWindowHint = 0x02000000,
WindowStaysOnBottomHint = 0x04000000,
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index d50960f68b..895feb7f53 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2112,6 +2112,9 @@
implements its own set of gestures and that system level gestures, like for
instance three-finger desktop switching, should be disabled.
+ \value WindowDoesNotAcceptFocus Informs the window system that this window should
+ not receive the input focus.
+
\value WindowType_Mask A mask for extracting the window type
part of the window flags.
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index f4f285bae4..534c377102 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -66,7 +66,9 @@
QT_BEGIN_NAMESPACE
+#ifndef Q_OS_WIN
#define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
+#endif
// used in testing framework
#define QSETTINGS_P_H_VERSION 3
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index e31337d0fd..aa3745237b 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -67,7 +67,7 @@ QWindowsPipeWriter::~QWindowsPipeWriter()
quitNow = true;
waitCondition.wakeOne();
lock.unlock();
- if (!wait(100))
+ if (!wait(30000))
terminate();
#if !defined(Q_OS_WINCE) || (_WIN32_WCE >= 0x600)
CloseHandle(writePipe);
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 1d6610af05..a8c3921f45 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -431,15 +431,9 @@ bool QPersistentModelIndex::isValid() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QModelIndex &idx)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QModelIndex(" << idx.row() << ',' << idx.column()
<< ',' << idx.internalPointer() << ',' << idx.model() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QModelIndex to QDebug");
- return dbg;
- Q_UNUSED(idx);
-#endif
}
QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx)
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 7f31128770..c6c1f6f3cf 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1622,15 +1622,9 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QItemSelectionRange &range)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QItemSelectionRange(" << range.topLeft()
<< ',' << range.bottomRight() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QItemSelectionRange to QDebug");
- return dbg;
- Q_UNUSED(range);
-#endif
}
#endif
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index ebd1ce2a70..b7ef69423f 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -883,9 +883,10 @@ void QSortFilterProxyModelPrivate::source_items_removed(
if (proxy_count > source_to_proxy.size()) {
// mapping is in an inconsistent state -- redo the whole mapping
qWarning("QSortFilterProxyModel: inconsistent changes reported by source model");
- remove_from_mapping(source_parent);
Q_Q(QSortFilterProxyModel);
- q->reset();
+ q->beginResetModel();
+ remove_from_mapping(source_parent);
+ q->endResetModel();
return;
}
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 8b0ec85679..dfdd178c35 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -322,28 +322,51 @@ class QEventLoopLockerPrivate
{
public:
explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop)
- : loop(loop), app(0)
+ : loop(loop), type(EventLoop)
{
loop->ref();
}
+ explicit QEventLoopLockerPrivate(QThreadPrivate *thread)
+ : thread(thread), type(Thread)
+ {
+ thread->ref();
+ }
+
explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app)
- : loop(0), app(app)
+ : app(app), type(Application)
{
app->ref();
}
~QEventLoopLockerPrivate()
{
- if (loop)
+ switch (type)
+ {
+ case EventLoop:
loop->deref();
- else
+ break;
+ case Thread:
+ thread->deref();
+ break;
+ default:
app->deref();
+ break;
+ }
}
private:
- QEventLoopPrivate *loop;
- QCoreApplicationPrivate *app;
+ union {
+ QEventLoopPrivate * loop;
+ QThreadPrivate * thread;
+ QCoreApplicationPrivate * app;
+ };
+ enum Type {
+ EventLoop,
+ Thread,
+ Application
+ };
+ const Type type;
};
/*!
@@ -390,6 +413,12 @@ QEventLoopLocker::QEventLoopLocker(QEventLoop *loop)
}
+QEventLoopLocker::QEventLoopLocker(QThread *thread)
+ : d_ptr(new QEventLoopLockerPrivate(static_cast<QThreadPrivate*>(QObjectPrivate::get(thread))))
+{
+
+}
+
/*!
Destroys this event loop locker object
*/
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index 0e7195d6a7..ba082d7d9d 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -96,6 +96,7 @@ class Q_CORE_EXPORT QEventLoopLocker
public:
QEventLoopLocker();
explicit QEventLoopLocker(QEventLoop *loop);
+ explicit QEventLoopLocker(QThread *thread);
~QEventLoopLocker();
private:
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index a1baf28f10..003ad1c32d 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1290,7 +1290,7 @@ namespace {
class TypeDestroyer {
template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct DestroyerImpl {
- static void Destroy(const int /* type */, T *where) { delete where; }
+ static void Destroy(const int /* type */, void *where) { qMetaTypeDeleteHelper<T>(where); }
};
template<typename T>
struct DestroyerImpl<T, /* IsAcceptedType = */ false> {
@@ -1318,7 +1318,7 @@ public:
template<typename T>
void delegate(const T *where) { DestroyerImpl<T>::Destroy(m_type, const_cast<T*>(where)); }
void delegate(const void *) {}
- void delegate(const QMetaTypeSwitcher::UnknownType *where) { customTypeDestroyer(m_type, (void*)where); }
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) { customTypeDestroyer(m_type, (void*)where); }
private:
static void customTypeDestroyer(const int type, void *where)
@@ -1354,11 +1354,11 @@ namespace {
class TypeConstructor {
template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct ConstructorImpl {
- static void *Construct(const int /*type*/, void *where, const T *copy) { return qMetaTypeConstructHelper(where, copy); }
+ static void *Construct(const int /*type*/, void *where, const void *copy) { return qMetaTypeConstructHelper<T>(where, copy); }
};
template<typename T>
struct ConstructorImpl<T, /* IsAcceptedType = */ false> {
- static void *Construct(const int type, void *where, const T *copy)
+ static void *Construct(const int type, void *where, const void *copy)
{
if (QTypeModuleInfo<T>::IsGui)
return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) : 0;
@@ -1380,7 +1380,7 @@ public:
template<typename T>
void *delegate(const T *copy) { return ConstructorImpl<T>::Construct(m_type, m_where, copy); }
void *delegate(const void *) { return m_where; }
- void *delegate(const QMetaTypeSwitcher::UnknownType *copy) { return customTypeConstructor(m_type, m_where, copy); }
+ void *delegate(const QMetaTypeSwitcher::NotBuiltinType *copy) { return customTypeConstructor(m_type, m_where, copy); }
private:
static void *customTypeConstructor(const int type, void *where, const void *copy)
@@ -1440,7 +1440,7 @@ namespace {
class TypeDestructor {
template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct DestructorImpl {
- static void Destruct(const int /* type */, T *where) { qMetaTypeDestructHelper(where); }
+ static void Destruct(const int /* type */, void *where) { qMetaTypeDestructHelper<T>(where); }
};
template<typename T>
struct DestructorImpl<T, /* IsAcceptedType = */ false> {
@@ -1468,7 +1468,7 @@ public:
template<typename T>
void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); }
void delegate(const void *) {}
- void delegate(const QMetaTypeSwitcher::UnknownType *where) { customTypeDestructor(m_type, (void*)where); }
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) { customTypeDestructor(m_type, (void*)where); }
private:
static void customTypeDestructor(const int type, void *where)
@@ -1536,7 +1536,7 @@ public:
template<typename T>
int delegate(const T*) { return SizeOfImpl<T>::Size(m_type); }
- int delegate(const QMetaTypeSwitcher::UnknownType*) { return customTypeSizeOf(m_type); }
+ int delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeSizeOf(m_type); }
private:
static int customTypeSizeOf(const int type)
{
@@ -1606,7 +1606,7 @@ public:
template<typename T>
quint32 delegate(const T*) { return FlagsImpl<T>::Flags(m_type); }
quint32 delegate(const void*) { return 0; }
- quint32 delegate(const QMetaTypeSwitcher::UnknownType*) { return customTypeFlags(m_type); }
+ quint32 delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeFlags(m_type); }
private:
const int m_type;
static quint32 customTypeFlags(const int type)
@@ -1793,7 +1793,7 @@ public:
template<typename T>
void delegate(const T*) { TypeInfoImpl<T>(m_type, info); }
void delegate(const void*) {}
- void delegate(const QMetaTypeSwitcher::UnknownType*) { customTypeInfo(m_type); }
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { customTypeInfo(m_type); }
private:
void customTypeInfo(const uint type)
{
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 4af77fcedc..beb7294abd 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -200,14 +200,7 @@ public:
LastWidgetsType = QSizePolicy,
HighestInternalId = LastWidgetsType,
-// This logic must match the one in qglobal.h
-#if defined(QT_COORD_TYPE)
- QReal = 0,
-#elif defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE)
- QReal = Float,
-#else
- QReal = Double,
-#endif
+ QReal = sizeof(qreal) == sizeof(double) ? Double : Float,
User = 256
};
@@ -318,46 +311,57 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
template <typename T>
-void qMetaTypeDeleteHelper(T *t)
+void qMetaTypeDeleteHelper(void *t)
{
- delete t;
+ delete static_cast<T*>(t);
}
+template <> inline void qMetaTypeDeleteHelper<void>(void *) {}
template <typename T>
-void *qMetaTypeCreateHelper(const T *t)
+void *qMetaTypeCreateHelper(const void *t)
{
if (t)
return new T(*static_cast<const T*>(t));
return new T();
}
+template <> inline void *qMetaTypeCreateHelper<void>(const void *) { return 0; }
+
template <typename T>
-void qMetaTypeDestructHelper(T *t)
+void qMetaTypeDestructHelper(void *t)
{
Q_UNUSED(t) // Silence MSVC that warns for POD types.
- t->~T();
+ static_cast<T*>(t)->~T();
}
+template <> inline void qMetaTypeDestructHelper<void>(void *) {}
+
template <typename T>
-void *qMetaTypeConstructHelper(void *where, const T *t)
+void *qMetaTypeConstructHelper(void *where, const void *t)
{
if (t)
return new (where) T(*static_cast<const T*>(t));
return new (where) T;
}
+template <> inline void *qMetaTypeConstructHelper<void>(void *, const void *) { return 0; }
+
#ifndef QT_NO_DATASTREAM
template <typename T>
-void qMetaTypeSaveHelper(QDataStream &stream, const T *t)
+void qMetaTypeSaveHelper(QDataStream &stream, const void *t)
{
- stream << *t;
+ stream << *static_cast<const T*>(t);
}
+template <> inline void qMetaTypeSaveHelper<void>(QDataStream &, const void *) {}
+
template <typename T>
-void qMetaTypeLoadHelper(QDataStream &stream, T *t)
+void qMetaTypeLoadHelper(QDataStream &stream, void *t)
{
- stream >> *t;
+ stream >> *static_cast<T*>(t);
}
+
+template <> inline void qMetaTypeLoadHelper<void>(QDataStream &, void *) {}
#endif // QT_NO_DATASTREAM
template <typename T>
@@ -442,15 +446,6 @@ int qRegisterMetaType(const char *typeName
if (typedefOf != -1)
return QMetaType::registerTypedef(typeName, typedefOf);
- typedef void*(*CreatePtr)(const T*);
- CreatePtr cptr = qMetaTypeCreateHelper<T>;
- typedef void(*DeletePtr)(T*);
- DeletePtr dptr = qMetaTypeDeleteHelper<T>;
- typedef void*(*ConstructPtr)(void *, const T*);
- ConstructPtr ipcptr = qMetaTypeConstructHelper<T>;
- typedef void(*DestructPtr)(T*);
- DestructPtr ipdptr = qMetaTypeDestructHelper<T>;
-
QMetaType::TypeFlags flags;
if (!QTypeInfo<T>::isStatic)
flags |= QMetaType::MovableType;
@@ -461,10 +456,10 @@ int qRegisterMetaType(const char *typeName
if (QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value)
flags |= QMetaType::PointerToQObject;
- return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Deleter>(dptr),
- reinterpret_cast<QMetaType::Creator>(cptr),
- reinterpret_cast<QMetaType::Destructor>(ipdptr),
- reinterpret_cast<QMetaType::Constructor>(ipcptr),
+ return QMetaType::registerType(typeName, qMetaTypeDeleteHelper<T>,
+ qMetaTypeCreateHelper<T>,
+ qMetaTypeDestructHelper<T>,
+ qMetaTypeConstructHelper<T>,
sizeof(T),
flags);
}
@@ -477,14 +472,8 @@ void qRegisterMetaTypeStreamOperators(const char *typeName
#endif
)
{
- typedef void(*SavePtr)(QDataStream &, const T *);
- typedef void(*LoadPtr)(QDataStream &, T *);
- SavePtr sptr = qMetaTypeSaveHelper<T>;
- LoadPtr lptr = qMetaTypeLoadHelper<T>;
-
qRegisterMetaType<T>(typeName);
- QMetaType::registerStreamOperators(typeName, reinterpret_cast<QMetaType::SaveOperator>(sptr),
- reinterpret_cast<QMetaType::LoadOperator>(lptr));
+ QMetaType::registerStreamOperators(typeName, qMetaTypeSaveHelper<T>, qMetaTypeLoadHelper<T>);
}
#endif // QT_NO_DATASTREAM
@@ -516,16 +505,8 @@ inline int qRegisterMetaType(
template <typename T>
inline int qRegisterMetaTypeStreamOperators()
{
- typedef void(*SavePtr)(QDataStream &, const T *);
- typedef void(*LoadPtr)(QDataStream &, T *);
- SavePtr sptr = qMetaTypeSaveHelper<T>;
- LoadPtr lptr = qMetaTypeLoadHelper<T>;
-
register int id = qMetaTypeId<T>();
- QMetaType::registerStreamOperators(id,
- reinterpret_cast<QMetaType::SaveOperator>(sptr),
- reinterpret_cast<QMetaType::LoadOperator>(lptr));
-
+ QMetaType::registerStreamOperators(id, qMetaTypeSaveHelper<T>, qMetaTypeLoadHelper<T>);
return id;
}
#endif
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index e48c5d3033..b50521c7a6 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -122,31 +122,6 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_DECLARE_WIDGETS_MODULE_TYPES_ITER)
class QMetaTypeInterface
{
public:
- template<typename T>
- struct Impl {
- static void *creator(const T *t)
- {
- if (t)
- return new T(*t);
- return new T();
- }
-
- static void deleter(T *t) { delete t; }
- static void saver(QDataStream &stream, const T *t) { stream << *t; }
- static void loader(QDataStream &stream, T *t) { stream >> *t; }
- static void destructor(T *t)
- {
- Q_UNUSED(t) // Silence MSVC that warns for POD types.
- t->~T();
- }
- static void *constructor(void *where, const T *t)
- {
- if (t)
- return new (where) T(*static_cast<const T*>(t));
- return new (where) T;
- }
- };
-
QMetaType::Creator creator;
QMetaType::Deleter deleter;
QMetaType::SaveOperator saveOp;
@@ -157,20 +132,10 @@ public:
quint32 flags; // same as QMetaType::TypeFlags
};
-template<>
-struct QMetaTypeInterface::Impl<void> {
- static void *creator(const void *) { return 0; }
- static void deleter(void *) {}
- static void saver(QDataStream &, const void *) {}
- static void loader(QDataStream &, void *) {}
- static void destructor(void *){}
- static void *constructor(void *, const void *) { return 0; }
-};
-
#ifndef QT_NO_DATASTREAM
# define QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type) \
- /*saveOp*/(reinterpret_cast<QMetaType::SaveOperator>(QMetaTypeInterface::Impl<Type>::saver)), \
- /*loadOp*/(reinterpret_cast<QMetaType::LoadOperator>(QMetaTypeInterface::Impl<Type>::loader)),
+ /*saveOp*/(qMetaTypeSaveHelper<Type>), \
+ /*loadOp*/(qMetaTypeLoadHelper<Type>),
# define QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(Type) \
/*saveOp*/ 0, \
/*loadOp*/ 0,
@@ -184,11 +149,11 @@ struct QMetaTypeInterface::Impl<void> {
#define QT_METATYPE_INTERFACE_INIT_IMPL(Type, DATASTREAM_DELEGATE) \
{ \
- /*creator*/(reinterpret_cast<QMetaType::Creator>(QMetaTypeInterface::Impl<Type>::creator)), \
- /*deleter*/(reinterpret_cast<QMetaType::Deleter>(QMetaTypeInterface::Impl<Type>::deleter)), \
+ /*creator*/(qMetaTypeCreateHelper<Type>), \
+ /*deleter*/(qMetaTypeDeleteHelper<Type>), \
DATASTREAM_DELEGATE(Type) \
- /*constructor*/(reinterpret_cast<QMetaType::Constructor>(QMetaTypeInterface::Impl<Type>::constructor)), \
- /*destructor*/(reinterpret_cast<QMetaType::Destructor>(QMetaTypeInterface::Impl<Type>::destructor)), \
+ /*constructor*/(qMetaTypeConstructHelper<Type>), \
+ /*destructor*/(qMetaTypeDestructHelper<Type>), \
/*size*/(QTypeInfo<Type>::sizeOf), \
/*flags*/(!QTypeInfo<Type>::isStatic * QMetaType::MovableType) \
| (QTypeInfo<Type>::isComplex * QMetaType::NeedsConstruction) \
diff --git a/src/corelib/kernel/qmetatypeswitcher_p.h b/src/corelib/kernel/qmetatypeswitcher_p.h
index c1cccfca63..e9c15ea214 100644
--- a/src/corelib/kernel/qmetatypeswitcher_p.h
+++ b/src/corelib/kernel/qmetatypeswitcher_p.h
@@ -59,46 +59,27 @@ QT_BEGIN_NAMESPACE
class QMetaTypeSwitcher {
public:
-
- typedef void *UnknownType;
+ class NotBuiltinType;
template<class ReturnType, class DelegateObject>
static ReturnType switcher(DelegateObject &logic, int type, const void *data);
};
-#define QT_METATYPE_SWICHER_CASE_PRIMITIVE(TypeName, TypeId, Name)\
- case QMetaType::TypeName: return logic.delegate(static_cast<const Name *>(data));
-
-#define QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER(TypeName, TypeId, Name)\
- case QMetaType::TypeName: return logic.delegate(static_cast< Name * const *>(data));
-
-#define QT_METATYPE_SWICHER_CASE_POINTER(TypeName, TypeId, Name)\
- case QMetaType::TypeName: return logic.delegate(static_cast< QT_PREPEND_NAMESPACE(Name) * const *>(data));
-
-#define QT_METATYPE_SWICHER_CASE_QCLASS(TypeName, TypeId, Name)\
- case QMetaType::TypeName: return logic.delegate(static_cast<const QT_PREPEND_NAMESPACE(Name) *>(data));
+#define QT_METATYPE_SWICHER_CASE(TypeName, TypeId, Name)\
+ case QMetaType::TypeName: return logic.delegate(static_cast<Name const *>(data));
template<class ReturnType, class DelegateObject>
ReturnType QMetaTypeSwitcher::switcher(DelegateObject &logic, int type, const void *data)
{
switch (QMetaType::Type(type)) {
- QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QT_METATYPE_SWICHER_CASE_PRIMITIVE)
- QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER)
- QT_FOR_EACH_STATIC_CORE_POINTER(QT_METATYPE_SWICHER_CASE_POINTER)
- QT_FOR_EACH_STATIC_CORE_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS)
- QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_METATYPE_SWICHER_CASE_QCLASS)
- QT_FOR_EACH_STATIC_GUI_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS)
- QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS)
+ QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_SWICHER_CASE)
default:
- return logic.delegate(static_cast<const UnknownType *>(data));
+ return logic.delegate(static_cast<NotBuiltinType const *>(data));
}
}
-#undef QT_METATYPE_SWICHER_CASE_PRIMITIVE
-#undef QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER
-#undef QT_METATYPE_SWICHER_CASE_QCLASS
-#undef QT_METATYPE_SWICHER_CASE_POINTER
+#undef QT_METATYPE_SWICHER_CASE
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 252a713872..8fa5dcdcff 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -3617,7 +3617,6 @@ QObjectUserData* QObject::userData(uint id) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QObject *o) {
-#ifndef Q_BROKEN_DEBUG_STREAM
if (!o)
return dbg << "QObject(0x0) ";
dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
@@ -3625,11 +3624,6 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
dbg << ", name = " << o->objectName();
dbg << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QObject to QDebug");
- return dbg;
- Q_UNUSED(o);
-#endif
}
#endif
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 5adffb708f..419fcc1dd4 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
namespace QtPrivate {
template <typename T> struct RemoveRef { typedef T Type; };
- template <typename T> struct RemoveRef<const T&> { typedef T Type; };
template <typename T> struct RemoveRef<T&> { typedef T Type; };
template <typename T> struct RemoveConstRef { typedef T Type; };
template <typename T> struct RemoveConstRef<const T&> { typedef T Type; };
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 45ef8ab3ca..fa0226917f 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -54,7 +54,7 @@ class QByteArray;
class QString;
#ifndef Q_MOC_OUTPUT_REVISION
-#define Q_MOC_OUTPUT_REVISION 63
+#define Q_MOC_OUTPUT_REVISION 64
#endif
// The following macros are our "extensions" to C++
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 2f67ae9287..5eaa93c7b0 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -279,7 +279,7 @@ inline bool qt_convertToBool(const QVariant::Private *const d)
Converts \a d to type \a t, which is placed in \a result.
*/
-static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, bool *ok)
+static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
{
Q_ASSERT(d->type != uint(t));
Q_ASSERT(result);
@@ -732,7 +732,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
return true;
}
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
static void streamDebug(QDebug dbg, const QVariant &v)
{
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
@@ -752,7 +752,7 @@ const QVariant::Handler qt_kernel_variant_handler = {
compare,
convert,
0,
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
streamDebug
#else
0
@@ -763,8 +763,8 @@ static void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false
static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); }
static bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; }
static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; }
-static bool dummyConvert(const QVariant::Private *, QVariant::Type , void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+static bool dummyConvert(const QVariant::Private *, int, void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }
+#if !defined(QT_NO_DEBUG_STREAM)
static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); }
#endif
const QVariant::Handler qt_dummy_variant_handler = {
@@ -778,7 +778,7 @@ const QVariant::Handler qt_dummy_variant_handler = {
dummyCompare,
dummyConvert,
0,
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
dummyStreamDebug
#else
0
@@ -840,14 +840,14 @@ static bool customCompare(const QVariant::Private *a, const QVariant::Private *b
return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type));
}
-static bool customConvert(const QVariant::Private *, QVariant::Type, void *, bool *ok)
+static bool customConvert(const QVariant::Private *, int, void *, bool *ok)
{
if (ok)
*ok = false;
return false;
}
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
static void customStreamDebug(QDebug, const QVariant &) {}
#endif
@@ -862,7 +862,7 @@ const QVariant::Handler qt_custom_variant_handler = {
customCompare,
customConvert,
0,
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
customStreamDebug
#else
0
@@ -1062,9 +1062,9 @@ Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Name
/*!
- \fn QVariant::QVariant(int typeOrUserType, const void *copy)
+ \fn QVariant::QVariant(int typeId, const void *copy)
- Constructs variant of type \a typeOrUserType, and initializes with
+ Constructs variant of type \a typeId, and initializes with
\a copy if \a copy is not 0.
Note that you have to pass the address of the variable you want stored.
@@ -1162,17 +1162,15 @@ QVariant::QVariant(QDataStream &s)
\fn QVariant::QVariant(const char *val)
Constructs a new variant with a string value of \a val.
- The variant creates a deep copy of \a val, using the encoding
- set by QTextCodec::setCodecForCStrings().
+ The variant creates a deep copy of \a val into a QString assuming
+ UTF-8 encoding on the input \a val.
Note that \a val is converted to a QString for storing in the
- variant and QVariant::type() will return QMetaType::QString for
+ variant and QVariant::userType() will return QMetaType::QString for
the variant.
You can disable this operator by defining \c
QT_NO_CAST_FROM_ASCII when you compile your applications.
-
- \sa QTextCodec::setCodecForCStrings()
*/
#ifndef QT_NO_CAST_FROM_ASCII
@@ -1375,19 +1373,19 @@ QVariant::QVariant(const char *val)
QVariant::QVariant(Type type)
{ create(type, 0); }
-QVariant::QVariant(int typeOrUserType, const void *copy)
-{ create(typeOrUserType, copy); d.is_null = false; }
+QVariant::QVariant(int typeId, const void *copy)
+{ create(typeId, copy); d.is_null = false; }
/*! \internal
flags is true if it is a pointer type
*/
-QVariant::QVariant(int typeOrUserType, const void *copy, uint flags)
+QVariant::QVariant(int typeId, const void *copy, uint flags)
{
if (flags) { //type is a pointer type
- d.type = typeOrUserType;
+ d.type = typeId;
d.data.ptr = *reinterpret_cast<void *const*>(copy);
} else {
- create(typeOrUserType, copy);
+ create(typeId, copy);
}
d.is_null = false;
}
@@ -1565,7 +1563,7 @@ void QVariant::detach()
*/
const char *QVariant::typeName() const
{
- return typeToName(Type(d.type));
+ return typeToName(d.type);
}
/*!
@@ -1582,17 +1580,17 @@ void QVariant::clear()
}
/*!
- Converts the enum representation of the storage type, \a typ, to
+ Converts the int representation of the storage type, \a typeId, to
its string representation.
Returns a null pointer if the type is QVariant::Invalid or doesn't exist.
*/
-const char *QVariant::typeToName(Type typ)
+const char *QVariant::typeToName(int typeId)
{
- if (typ == Invalid)
+ if (typeId == Invalid)
return 0;
- return QMetaType::typeName(typ);
+ return QMetaType::typeName(typeId);
}
@@ -1842,7 +1840,7 @@ QDataStream& operator<<(QDataStream &s, const QVariant::Type p)
template <typename T>
inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager)
{
- const QVariant::Type targetType = static_cast<const QVariant::Type>(qMetaTypeId<T>());
+ const uint targetType = qMetaTypeId<T>();
if (d.type == targetType)
return *v_cast<T>(&d);
@@ -2163,7 +2161,7 @@ inline T qNumVariantToHelper(const QVariant::Private &d,
return val;
T ret = 0;
- if (!handlerManager[d.type]->convert(&d, QVariant::Type(t), &ret, ok) && ok)
+ if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok)
*ok = false;
return ret;
}
@@ -2407,7 +2405,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*!
Returns true if the variant's type can be cast to the requested
- type, \a t. Such casting is done automatically when calling the
+ type, \a targetTypeId. Such casting is done automatically when calling the
toInt(), toBool(), ... methods.
The following casts are done automatically:
@@ -2439,18 +2437,18 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
\sa convert()
*/
-bool QVariant::canConvert(Type t) const
+bool QVariant::canConvert(int targetTypeId) const
{
// TODO Reimplement this function, currently it works but it is a historical mess.
const uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type);
- if (uint(t) == uint(QMetaType::Float)) t = QVariant::Double;
+ if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double;
- if (currentType == uint(t))
+ if (currentType == uint(targetTypeId))
return true;
// FIXME It should be LastCoreType intead of Uuid
- if (currentType > QVariant::Uuid || t > QVariant::Uuid) {
- switch (uint(t)) {
+ if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
+ switch (uint(targetTypeId)) {
case QVariant::Int:
return currentType == QVariant::KeySequence
|| currentType == QMetaType::ULong
@@ -2492,14 +2490,14 @@ bool QVariant::canConvert(Type t) const
}
}
- if(t == String && currentType == StringList)
+ if (targetTypeId == String && currentType == StringList)
return v_cast<QStringList>(&d)->count() == 1;
else
- return qCanConvertMatrix[t] & (1 << currentType);
+ return qCanConvertMatrix[targetTypeId] & (1 << currentType);
}
/*!
- Casts the variant to the requested type, \a t. If the cast cannot be
+ Casts the variant to the requested type, \a targetTypeId. If the cast cannot be
done, the variant is cleared. Returns true if the current type of
the variant was successfully cast; otherwise returns false.
@@ -2510,23 +2508,23 @@ bool QVariant::canConvert(Type t) const
\sa canConvert(), clear()
*/
-bool QVariant::convert(Type t)
+bool QVariant::convert(int targetTypeId)
{
- if (d.type == uint(t))
+ if (d.type == uint(targetTypeId))
return true;
QVariant oldValue = *this;
clear();
- if (!oldValue.canConvert(t))
+ if (!oldValue.canConvert(targetTypeId))
return false;
- create(t, 0);
+ create(targetTypeId, 0);
if (oldValue.isNull())
return false;
bool isOk = true;
- if (!handlerManager[d.type]->convert(&oldValue.d, t, data(), &isOk))
+ if (!handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk))
isOk = false;
d.is_null = !isOk;
return isOk;
@@ -2540,7 +2538,7 @@ bool QVariant::convert(Type t)
bool QVariant::convert(const int type, void *ptr) const
{
Q_ASSERT(type < int(QMetaType::User));
- return handlerManager[type]->convert(&d, QVariant::Type(type), ptr, 0);
+ return handlerManager[type]->convert(&d, type, ptr, 0);
}
@@ -2607,7 +2605,7 @@ bool QVariant::cmp(const QVariant &v) const
else
return toLongLong() == v.toLongLong();
}
- if (!v2.canConvert(Type(d.type)) || !v2.convert(Type(d.type)))
+ if (!v2.canConvert(d.type) || !v2.convert(d.type))
return false;
}
return handlerManager[d.type]->compare(&d, &v2.d);
@@ -2646,28 +2644,16 @@ bool QVariant::isNull() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QVariant &v)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QVariant(" << QMetaType::typeName(v.userType()) << ", ";
handlerManager[v.d.type]->debugStream(dbg, v);
dbg.nospace() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QVariant to QDebug");
- return dbg;
- Q_UNUSED(v);
-#endif
}
QDebug operator<<(QDebug dbg, const QVariant::Type p)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QVariant::" << QMetaType::typeName(p);
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QVariant::Type to QDebug");
- return dbg;
- Q_UNUSED(p);
-#endif
}
#endif
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 5fcfe3e696..5da482d5cd 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -194,8 +194,8 @@ class Q_CORE_EXPORT QVariant
inline QVariant();
~QVariant();
QVariant(Type type);
- QVariant(int typeOrUserType, const void *copy);
- QVariant(int typeOrUserType, const void *copy, uint flags);
+ QVariant(int typeId, const void *copy);
+ QVariant(int typeId, const void *copy, uint flags);
QVariant(const QVariant &other);
#ifndef QT_NO_DATASTREAM
@@ -210,7 +210,7 @@ class Q_CORE_EXPORT QVariant
QVariant(double d);
QVariant(float f) { d.is_null = false; d.type = QMetaType::Float; d.data.f = f; }
#ifndef QT_NO_CAST_FROM_ASCII
- QT_ASCII_CAST_WARN_CONSTRUCTOR QVariant(const char *str);
+ QT_ASCII_CAST_WARN QVariant(const char *str);
#endif
QVariant(const QByteArray &bytearray);
@@ -257,8 +257,8 @@ class Q_CORE_EXPORT QVariant
int userType() const;
const char *typeName() const;
- bool canConvert(Type t) const;
- bool convert(Type t);
+ bool canConvert(int targetTypeId) const;
+ bool convert(int targetTypeId);
inline bool isValid() const;
bool isNull() const;
@@ -311,7 +311,7 @@ class Q_CORE_EXPORT QVariant
void load(QDataStream &ds);
void save(QDataStream &ds) const;
#endif
- static const char *typeToName(Type type);
+ static const char *typeToName(int typeId);
static Type nameToType(const char *name);
void *data();
@@ -331,7 +331,7 @@ class Q_CORE_EXPORT QVariant
template<typename T>
bool canConvert() const
- { return canConvert(Type(qMetaTypeId<T>())); }
+ { return canConvert(qMetaTypeId<T>()); }
public:
#ifndef qdoc
@@ -381,8 +381,8 @@ class Q_CORE_EXPORT QVariant
typedef void (*f_save)(const Private *, QDataStream &);
#endif
typedef bool (*f_compare)(const Private *, const Private *);
- typedef bool (*f_convert)(const QVariant::Private *d, Type t, void *, bool *);
- typedef bool (*f_canConvert)(const QVariant::Private *d, Type t);
+ typedef bool (*f_convert)(const QVariant::Private *d, int t, void *, bool *);
+ typedef bool (*f_canConvert)(const QVariant::Private *d, int t);
typedef void (*f_debugStream)(QDebug, const QVariant &);
struct Handler {
f_construct construct;
@@ -527,7 +527,7 @@ namespace QtPrivate {
return *reinterpret_cast<const T *>(v.constData());
if (vid < int(QMetaType::User)) {
T t;
- if (v.convert(QVariant::Type(vid), &t))
+ if (v.convert(vid, &t))
return t;
}
return T();
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index cdae8997a7..a754bc4363 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -188,7 +188,7 @@ public:
}
bool delegate(const void*) { return true; }
-
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return false; }
protected:
const QVariant::Private *m_a;
const QVariant::Private *m_b;
@@ -282,6 +282,7 @@ public:
}
// we need that as sizof(void) is undefined and it is needed in HasIsNullMethod
bool delegate(const void *) { return m_d->is_null; }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *) { return m_d->is_null; }
protected:
const QVariant::Private *m_d;
};
@@ -345,7 +346,7 @@ public:
FilteredConstructor<T>(*this);
}
- void delegate(const QMetaTypeSwitcher::UnknownType*)
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type);
m_x->type = QVariant::Invalid;
@@ -395,7 +396,7 @@ public:
FilteredDestructor<T> cleaner(m_d);
}
- void delegate(const QMetaTypeSwitcher::UnknownType*)
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
qWarning("Trying to destruct an instance of an invalid type, type id: %i", m_d->type);
}
@@ -410,7 +411,7 @@ Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QV
Q_CORE_EXPORT void unregisterHandler(const int /* Modules::Names */ name);
}
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
template<class Filter>
class QVariantDebugStream
{
@@ -441,7 +442,7 @@ public:
Filtered<T> streamIt(m_debugStream, m_d);
}
- void delegate(const QMetaTypeSwitcher::UnknownType*)
+ void delegate(const QMetaTypeSwitcher::NotBuiltinType*)
{
qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type);
}
diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h
index 655ca365fa..e35c1923f9 100644
--- a/src/corelib/mimetypes/qmimemagicrule_p.h
+++ b/src/corelib/mimetypes/qmimemagicrule_p.h
@@ -83,6 +83,7 @@ public:
private:
const QScopedPointer<QMimeMagicRulePrivate> d;
};
+Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 77592880a0..4099487f9b 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -300,7 +300,6 @@ QString QMimeType::name() const
Returns the description of the MIME type to be displayed on user interfaces.
The system language (QLocale::system().name()) is used to select the appropriate translation.
- Another language can be specified by setting the \a localeName argument.
*/
QString QMimeType::comment() const
{
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 23f57367e3..4a2ec0a0b2 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -58,29 +58,29 @@
QT_BEGIN_NAMESPACE
// XML tags in MIME files
-const char *const mimeInfoTagC = "mime-info";
-const char *const mimeTypeTagC = "mime-type";
-const char *const mimeTypeAttributeC = "type";
-const char *const subClassTagC = "sub-class-of";
-const char *const commentTagC = "comment";
-const char *const genericIconTagC = "generic-icon";
-const char *const iconTagC = "icon";
-const char *const nameAttributeC = "name";
-const char *const globTagC = "glob";
-const char *const aliasTagC = "alias";
-const char *const patternAttributeC = "pattern";
-const char *const weightAttributeC = "weight";
-const char *const caseSensitiveAttributeC = "case-sensitive";
-const char *const localeAttributeC = "xml:lang";
+static const char mimeInfoTagC[] = "mime-info";
+static const char mimeTypeTagC[] = "mime-type";
+static const char mimeTypeAttributeC[] = "type";
+static const char subClassTagC[] = "sub-class-of";
+static const char commentTagC[] = "comment";
+static const char genericIconTagC[] = "generic-icon";
+static const char iconTagC[] = "icon";
+static const char nameAttributeC[] = "name";
+static const char globTagC[] = "glob";
+static const char aliasTagC[] = "alias";
+static const char patternAttributeC[] = "pattern";
+static const char weightAttributeC[] = "weight";
+static const char caseSensitiveAttributeC[] = "case-sensitive";
+static const char localeAttributeC[] = "xml:lang";
-const char *const magicTagC = "magic";
-const char *const priorityAttributeC = "priority";
+static const char magicTagC[] = "magic";
+static const char priorityAttributeC[] = "priority";
-const char *const matchTagC = "match";
-const char *const matchValueAttributeC = "value";
-const char *const matchTypeAttributeC = "type";
-const char *const matchOffsetAttributeC = "offset";
-const char *const matchMaskAttributeC = "mask";
+static const char matchTagC[] = "match";
+static const char matchValueAttributeC[] = "value";
+static const char matchTypeAttributeC[] = "type";
+static const char matchOffsetAttributeC[] = "offset";
+static const char matchMaskAttributeC[] = "mask";
/*!
\class QMimeTypeParser
diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h
index 455c07063c..af01e1641a 100644
--- a/src/corelib/mimetypes/qmimetypeparser_p.h
+++ b/src/corelib/mimetypes/qmimetypeparser_p.h
@@ -50,30 +50,6 @@ QT_BEGIN_NAMESPACE
class QIODevice;
-// XML tags in MIME files
-extern const char *const mimeInfoTagC;
-extern const char *const mimeTypeTagC;
-extern const char *const mimeTypeAttributeC;
-extern const char *const subClassTagC;
-extern const char *const commentTagC;
-extern const char *const genericIconTagC;
-extern const char *const nameAttributeC;
-extern const char *const globTagC;
-extern const char *const aliasTagC;
-extern const char *const patternAttributeC;
-extern const char *const weightAttributeC;
-extern const char *const caseSensitiveAttributeC;
-extern const char *const localeAttributeC;
-
-extern const char *const magicTagC;
-extern const char *const priorityAttributeC;
-
-extern const char *const matchTagC;
-extern const char *const matchValueAttributeC;
-extern const char *const matchTypeAttributeC;
-extern const char *const matchOffsetAttributeC;
-extern const char *const matchMaskAttributeC;
-
class QMimeTypeParserBase
{
Q_DISABLE_COPY(QMimeTypeParserBase)
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index be0a98d3b5..a071463178 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -763,5 +763,14 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher)
}
}
+bool QThread::event(QEvent *event)
+{
+ if (event->type() == QEvent::Quit) {
+ quit();
+ return true;
+ } else {
+ return QObject::event(event);
+ }
+}
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 719f4afbbb..ba119afb5d 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -95,6 +95,8 @@ public:
QAbstractEventDispatcher *eventDispatcher() const;
void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
+ bool event(QEvent *event);
+
public Q_SLOTS:
void start(Priority = InheritPriority);
void terminate();
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index d8374e9805..6597b56893 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -60,6 +60,7 @@
#include "QtCore/qstack.h"
#include "QtCore/qwaitcondition.h"
#include "QtCore/qmap.h"
+#include "QtCore/qcoreapplication.h"
#include "private/qobject_p.h"
@@ -144,6 +145,7 @@ public:
~QThreadPrivate();
mutable QMutex mutex;
+ QAtomicInt quitLockRef;
bool running;
bool finished;
@@ -179,6 +181,18 @@ public:
QThreadData *data;
static void createEventDispatcher(QThreadData *data);
+
+ void ref()
+ {
+ quitLockRef.ref();
+ }
+
+ void deref()
+ {
+ if (!quitLockRef.deref() && running) {
+ QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+ }
+ }
};
#else // QT_NO_THREAD
@@ -195,6 +209,9 @@ public:
static QThread *threadForId(int) { return QThread::currentThread(); }
static void createEventDispatcher(QThreadData *data);
+ void ref() {}
+ void deref() {}
+
Q_DECLARE_PUBLIC(QThread)
};
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index afcfb2c949..38fb6ef8dd 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -72,7 +72,7 @@
QT_BEGIN_NAMESPACE
void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread);
-void qt_adopted_thread_watcher_function(void *);
+DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID);
static DWORD qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES;
void qt_create_tls()
@@ -147,7 +147,7 @@ void QAdoptedThread::init()
static QVector<HANDLE> qt_adopted_thread_handles;
static QVector<QThread *> qt_adopted_qthreads;
static QMutex qt_adopted_thread_watcher_mutex;
-static HANDLE qt_adopted_thread_watcher_handle = 0;
+static DWORD qt_adopted_thread_watcher_id = 0;
static HANDLE qt_adopted_thread_wakeup = 0;
/*! \internal
@@ -158,18 +158,25 @@ static HANDLE qt_adopted_thread_wakeup = 0;
void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
{
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
+
+ if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
+#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
+ CloseHandle(adoptedThreadHandle);
+#endif
+ return;
+ }
+
qt_adopted_thread_handles.append(adoptedThreadHandle);
qt_adopted_qthreads.append(qthread);
// Start watcher thread if it is not already running.
- if (qt_adopted_thread_watcher_handle == 0) {
+ if (qt_adopted_thread_watcher_id == 0) {
if (qt_adopted_thread_wakeup == 0) {
qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0);
qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
}
- qt_adopted_thread_watcher_handle =
- (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL);
+ CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id);
} else {
SetEvent(qt_adopted_thread_wakeup);
}
@@ -180,13 +187,13 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
When this happens it derefs the QThreadData for the adopted thread
to make sure it gets cleaned up properly.
*/
-void qt_adopted_thread_watcher_function(void *)
+DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
{
forever {
qt_adopted_thread_watcher_mutex.lock();
if (qt_adopted_thread_handles.count() == 1) {
- qt_adopted_thread_watcher_handle = 0;
+ qt_adopted_thread_watcher_id = 0;
qt_adopted_thread_watcher_mutex.unlock();
break;
}
@@ -244,6 +251,12 @@ void qt_adopted_thread_watcher_function(void *)
qt_adopted_qthreads.remove(qthreadIndex);
}
}
+
+ QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
+ if (threadData)
+ threadData->deref();
+
+ return 0;
}
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 01241dce6b..0261843a3a 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -413,33 +413,16 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QChar::QChar(char ch)
+
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
*/
-QChar::QChar(char ch)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- ucs = QTextCodec::codecForCStrings()->toUnicode(&ch, 1).at(0).unicode();
- else
-#endif
- ucs = uchar(ch);
-}
/*!
+ \fn QChar::QChar(uchar ch)
+
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch.
*/
-QChar::QChar(uchar ch)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings()) {
- // #####
- char c = char(ch);
- ucs = QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
- } else
-#endif
- ucs = ch;
-}
/*!
\fn QChar::QChar(uchar cell, uchar row)
@@ -1256,49 +1239,35 @@ ushort QChar::toCaseFolded(ushort ucs2)
Returns the Latin-1 character equivalent to the QChar, or 0. This
is mainly useful for non-internationalized software.
- \sa toAscii(), unicode(), QTextCodec::codecForCStrings()
+ \sa toAscii(), unicode()
*/
/*!
- Returns the character value of the QChar obtained using the current
- codec used to read C strings, or 0 if the character is not representable
- using this codec. The default codec handles Latin-1 encoded text,
- but this can be changed to assist developers writing source code using
- other encodings.
+ \fn char QChar::toAscii() const
+
+ Returns the Latin-1 character value of the QChar, or 0 if the character is not
+ representable.
The main purpose of this function is to preserve ASCII characters used
in C strings. This is mainly useful for developers of non-internationalized
software.
- \sa toLatin1(), unicode(), QTextCodec::codecForCStrings()
+ \note It is not possible to distinguish a non-Latin 1 character from an ASCII 0
+ (NUL) character. Prefer to use unicode(), which does not have this ambiguity.
+
+ \sa toLatin1(), unicode()
*/
-char QChar::toAscii() const
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0);
-#endif
- return ucs > 0xff ? 0 : char(ucs);
-}
/*!
+ \fn QChar QChar::fromAscii(char)
+
Converts the ASCII character \a c to it's equivalent QChar. This
is mainly useful for non-internationalized software.
An alternative is to use QLatin1Char.
- \sa fromLatin1(), unicode(), QTextCodec::codecForCStrings()
+ \sa fromLatin1(), unicode()
*/
-QChar QChar::fromAscii(char c)
-{
-#ifndef QT_NO_CODEC_FOR_C_STRINGS
- if (QTextCodec::codecForCStrings())
- // #####
- return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode();
-#endif
- return QChar(ushort((uchar)c));
-}
#ifndef QT_NO_DATASTREAM
/*!
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index df3d7eac33..3209ffb0f2 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -86,9 +86,8 @@ public:
Q_DECL_CONSTEXPR QChar(QLatin1Char ch) : ucs(ch.unicode()) {} // implicit
#ifndef QT_NO_CAST_FROM_ASCII
- // these two constructors are NOT inline const_expr!
- QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(char c);
- QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(uchar c);
+ QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { }
+ QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { }
#endif
// Unicode information
@@ -222,13 +221,13 @@ public:
UnicodeVersion unicodeVersion() const;
- char toAscii() const;
+ inline char toAscii() const;
inline char toLatin1() const;
inline ushort unicode() const { return ucs; }
inline ushort &unicode() { return ucs; }
- static QChar fromAscii(char c);
- static QChar fromLatin1(char c);
+ static inline QChar fromAscii(char c);
+ static inline QChar fromLatin1(char c);
inline bool isNull() const { return ucs == 0; }
bool isPrint() const;
@@ -344,8 +343,10 @@ private:
Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
+inline char QChar::toAscii() const { return ucs > 0xff ? 0 : char(ucs); }
inline char QChar::toLatin1() const { return ucs > 0xff ? '\0' : char(ucs); }
inline QChar QChar::fromLatin1(char c) { return QChar(ushort(uchar(c))); }
+inline QChar QChar::fromAscii(char c) { return QChar(ushort(uchar(c))); }
inline void QChar::setCell(uchar acell)
{ ucs = ushort((ucs & 0xff00) + acell); }
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 164660f818..31a0fdc5e6 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -46,8 +46,53 @@
#include "../../3rdparty/md4/md4.h"
#include "../../3rdparty/md4/md4.cpp"
#include "../../3rdparty/sha1/sha1.cpp"
+
+/*
+ These typedefs are needed by the RFC6234 code. Normally they would come
+ from from stdint.h, but since this header is not available on all platforms
+ (MSVC 2008, for example), we need to define them ourselves.
+*/
+typedef QT_PREPEND_NAMESPACE(quint64) uint64_t;
+typedef QT_PREPEND_NAMESPACE(quint32) uint32_t;
+typedef QT_PREPEND_NAMESPACE(quint8) uint8_t;
+typedef QT_PREPEND_NAMESPACE(qint16) int_least16_t;
+// Header from rfc6234 with 1 modification:
+// sha1.h - commented out '#include <stdint.h>' on line 74
+#include "../../3rdparty/rfc6234/sha.h"
+
+/*
+ These 2 functions replace macros of the same name in sha224-256.c and
+ sha384-512.c. Originally, these macros relied on a global static 'addTemp'
+ variable. We do not want this for 2 reasons:
+
+ 1. since we are including the sources directly, the declaration of the 2 conflict
+
+ 2. static variables are not thread-safe, we do not want multiple threads
+ computing a hash to corrupt one another
+*/
+static int SHA224_256AddLength(SHA256Context *context, unsigned int length);
+static int SHA384_512AddLength(SHA512Context *context, unsigned int length);
+
+// Sources from rfc6234, with 4 modifications:
+// sha224-256.c - commented out 'static uint32_t addTemp;' on line 68
+// sha224-256.c - appended 'M' to the SHA224_256AddLength macro on line 70
+#include "../../3rdparty/rfc6234/sha224-256.c"
+// sha384-512.c - commented out 'static uint64_t addTemp;' on line 302
+// sha384-512.c - appended 'M' to the SHA224_256AddLength macro on line 304
+#include "../../3rdparty/rfc6234/sha384-512.c"
+
#include <qiodevice.h>
+static inline int SHA224_256AddLength(SHA256Context *context, unsigned int length)
+{
+ uint32_t addTemp;
+ return SHA224_256AddLengthM(context, length);
+}
+static inline int SHA384_512AddLength(SHA512Context *context, unsigned int length)
+{
+ uint64_t addTemp;
+ return SHA384_512AddLengthM(context, length);
+}
QT_BEGIN_NAMESPACE
@@ -59,6 +104,10 @@ public:
MD5Context md5Context;
md4_context md4Context;
Sha1State sha1Context;
+ SHA224Context sha224Context;
+ SHA256Context sha256Context;
+ SHA384Context sha384Context;
+ SHA512Context sha512Context;
};
QByteArray result;
};
@@ -75,7 +124,7 @@ public:
QCryptographicHash can be used to generate cryptographic hashes of binary or text data.
- Currently MD4, MD5, and SHA-1 are supported.
+ Currently MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 are supported.
*/
/*!
@@ -83,7 +132,11 @@ public:
\value Md4 Generate an MD4 hash sum
\value Md5 Generate an MD5 hash sum
- \value Sha1 Generate an SHA1 hash sum
+ \value Sha1 Generate an SHA-1 hash sum
+ \value Sha224 Generate an SHA-224 hash sum
+ \value Sha256 Generate an SHA-256 hash sum
+ \value Sha384 Generate an SHA-384 hash sum
+ \value Sha512 Generate an SHA-512 hash sum
*/
/*!
@@ -119,6 +172,18 @@ void QCryptographicHash::reset()
case Sha1:
sha1InitState(&d->sha1Context);
break;
+ case Sha224:
+ SHA224Reset(&d->sha224Context);
+ break;
+ case Sha256:
+ SHA256Reset(&d->sha256Context);
+ break;
+ case Sha384:
+ SHA384Reset(&d->sha384Context);
+ break;
+ case Sha512:
+ SHA512Reset(&d->sha512Context);
+ break;
}
d->result.clear();
}
@@ -139,6 +204,18 @@ void QCryptographicHash::addData(const char *data, int length)
case Sha1:
sha1Update(&d->sha1Context, (const unsigned char *)data, length);
break;
+ case Sha224:
+ SHA224Input(&d->sha224Context, reinterpret_cast<const unsigned char *>(data), length);
+ break;
+ case Sha256:
+ SHA256Input(&d->sha256Context, reinterpret_cast<const unsigned char *>(data), length);
+ break;
+ case Sha384:
+ SHA384Input(&d->sha384Context, reinterpret_cast<const unsigned char *>(data), length);
+ break;
+ case Sha512:
+ SHA512Input(&d->sha512Context, reinterpret_cast<const unsigned char *>(data), length);
+ break;
}
d->result.clear();
}
@@ -201,6 +278,31 @@ QByteArray QCryptographicHash::result() const
d->result.resize(20);
sha1FinalizeState(&copy);
sha1ToHash(&copy, (unsigned char *)d->result.data());
+ break;
+ }
+ case Sha224: {
+ SHA224Context copy = d->sha224Context;
+ d->result.resize(SHA224HashSize);
+ SHA224Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
+ break;
+ }
+ case Sha256:{
+ SHA256Context copy = d->sha256Context;
+ d->result.resize(SHA256HashSize);
+ SHA256Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
+ break;
+ }
+ case Sha384:{
+ SHA384Context copy = d->sha384Context;
+ d->result.resize(SHA384HashSize);
+ SHA384Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
+ break;
+ }
+ case Sha512:{
+ SHA512Context copy = d->sha512Context;
+ d->result.resize(SHA512HashSize);
+ SHA512Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
+ break;
}
}
return d->result;
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index 59314e1963..2bfc03373a 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -58,7 +58,11 @@ public:
enum Algorithm {
Md4,
Md5,
- Sha1
+ Sha1,
+ Sha224,
+ Sha256,
+ Sha384,
+ Sha512
};
QCryptographicHash(Algorithm method);
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 1ca9a55d72..81778f908f 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -1110,6 +1110,7 @@ QEasingCurve::~QEasingCurve()
Swaps curve \a other with this curve. This operation is very
fast and never fails.
+*/
/*!
Compare this easing curve with \a other and returns true if they are
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 8f36e5c2ae..bf6933732c 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -402,7 +402,7 @@ Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src)
}
} else {
if (src != from && to - from > 0)
- memcpy(from, src, (to - from) * sizeof(Node *));
+ memcpy(from, src, (to - from) * sizeof(Node));
}
}
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 2fff58333d..3a386c17d6 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -89,7 +89,7 @@
pair; it does not use the system locale database.
\note For the current keyboard input locale take a look at
- QInputPanel::locale().
+ QInputMethod::locale().
QLocale's data is based on Common Locale Data Repository v1.8.1.
@@ -114,7 +114,7 @@
California, Berkeley and its contributors.
\sa QString::arg(), QString::toInt(), QString::toDouble(),
- QInputPanel::locale()
+ QInputMethod::locale()
*/
/*!
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index cd9fffc7a5..e787f2fa2a 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -525,7 +525,7 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- typedef BOOL (*GetUserPreferredUILanguagesFunc) (
+ typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
DWORD dwFlags,
PULONG pulNumLanguages,
PWSTR pwszLanguagesBuffer,
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index e8c0d4eccc..d7bcd0edbc 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -3934,6 +3934,7 @@ static void invalidateEngine(QRegExpPrivate *priv)
QRegExp::QRegExp()
{
priv = new QRegExpPrivate;
+ prepareEngine(priv);
}
/*!
@@ -3949,6 +3950,7 @@ QRegExp::QRegExp()
QRegExp::QRegExp(const QString &pattern, Qt::CaseSensitivity cs, PatternSyntax syntax)
{
priv = new QRegExpPrivate(QRegExpEngineKey(pattern, syntax, cs));
+ prepareEngine(priv);
}
/*!
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index d0c5506228..e73c52980f 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -96,10 +96,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_TEXTCODEC
-QTextCodec *QString::codecForCStrings;
-#endif
-
#ifdef QT_USE_ICU
// qlocale_icu.cpp
extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
@@ -471,9 +467,8 @@ const QString::Null QString::null = { };
\snippet doc/src/snippets/qstring/main.cpp 0
QString converts the \c{const char *} data into Unicode using the
- fromAscii() function. By default, fromAscii() treats character
- above 128 as Latin-1 characters, but this can be changed by
- calling QTextCodec::setCodecForCStrings().
+ fromAscii() function. fromAscii() treats ordinals above 128 as Latin-1
+ characters.
In all of the QString functions that take \c{const char *}
parameters, the \c{const char *} is interpreted as a classic
@@ -611,9 +606,7 @@ const QString::Null QString::null = { };
toLatin1(), toUtf8(), and toLocal8Bit().
\list
- \o toAscii() returns an 8-bit string encoded using the codec
- specified by QTextCodec::codecForCStrings (by default, that is
- Latin 1).
+ \o toAscii() returns a Latin-1 (ISO 8859-1) encoded 8-bit string.
\o toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string.
\o toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a
superset of US-ASCII (ANSI X3.4-1986) that supports the entire
@@ -721,11 +714,11 @@ const QString::Null QString::null = { };
\section1 More Efficient String Construction
Many strings are known at compile time. But the trivial
- constructor QString("Hello"), will convert the string literal
- to a QString using the codecForCStrings(). To avoid this one
- can use the QStringLiteral macro to directly create the required
- data at compile time. Constructing a QString out of the literal
- does then not cause any overhead at runtime.
+ constructor QString("Hello"), will copy the contents of the string,
+ treating the contents as Latin-1. To avoid this one can use the
+ QStringLiteral macro to directly create the required data at compile
+ time. Constructing a QString out of the literal does then not cause
+ any overhead at runtime.
A slightly less efficient way is to use QLatin1String. This class wraps
a C string literal, precalculates it length at compile time and can
@@ -3658,9 +3651,7 @@ QByteArray QString::toLatin1() const
/*!
Returns an 8-bit representation of the string as a QByteArray.
- If a codec has been set using QTextCodec::setCodecForCStrings(),
- it is used to convert Unicode to 8-bit char; otherwise this
- function does the same as toLatin1().
+ This function does the same as toLatin1().
Note that, despite the name, this function does not necessarily return an US-ASCII
(ANSI X3.4-1986) string and its result may not be US-ASCII compatible.
@@ -3669,10 +3660,6 @@ QByteArray QString::toLatin1() const
*/
QByteArray QString::toAscii() const
{
-#ifndef QT_NO_TEXTCODEC
- if (codecForCStrings)
- return codecForCStrings->fromUnicode(*this);
-#endif // QT_NO_TEXTCODEC
return toLatin1();
}
@@ -3806,23 +3793,6 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
QString::Data *QString::fromAscii_helper(const char *str, int size)
{
-#ifndef QT_NO_TEXTCODEC
- if (codecForCStrings) {
- Data *d;
- if (!str) {
- d = const_cast<Data *>(&shared_null.str);
- } else if (size == 0 || (!*str && size < 0)) {
- d = const_cast<Data *>(&shared_empty.str);
- } else {
- if (size < 0)
- size = qstrlen(str);
- QString s = codecForCStrings->toUnicode(str, size);
- d = s.d;
- d->ref.ref();
- }
- return d;
- }
-#endif
return fromLatin1_helper(str, size);
}
@@ -3871,11 +3841,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size)
If \a size is -1 (default), it is taken to be strlen(\a
str).
- Note that, despite the name, this function actually uses the codec
- defined by QTextCodec::setCodecForCStrings() to convert \a str to
- Unicode. Depending on the codec, it may not accept valid US-ASCII (ANSI
- X3.4-1986) input. If no codec has been set, this function does the same
- as fromLatin1().
+ This function does the same as fromLatin1().
\sa toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit()
*/
@@ -5144,19 +5110,8 @@ QString &QString::vsprintf(const char* cformat, va_list ap)
const char *c = cformat;
for (;;) {
// Copy non-escape chars to result
-#ifndef QT_NO_TEXTCODEC
- int i = 0;
- while (*(c + i) != '\0' && *(c + i) != '%')
- ++i;
- if (codecForCStrings)
- result.append(codecForCStrings->toUnicode(c, i));
- else
- result.append(fromLatin1(c, i));
- c += i;
-#else
while (*c != '\0' && *c != '%')
result.append(QLatin1Char(*c++));
-#endif
if (*c == '\0')
break;
@@ -7068,8 +7023,7 @@ bool QString::isRightToLeft() const
This operator is mostly useful to pass a QString to a function
that accepts a std::string object.
- If the QString contains Unicode characters that the
- QTextCodec::codecForCStrings() codec cannot handle, using this operator
+ If the QString contains non-Latin1 Unicode characters, using this
can lead to loss of information.
This operator is only available if Qt is configured with STL
@@ -8742,9 +8696,7 @@ QByteArray QStringRef::toLatin1() const
Returns an 8-bit representation of the string as a QByteArray.
- If a codec has been set using QTextCodec::setCodecForCStrings(),
- it is used to convert Unicode to 8-bit char; otherwise this
- function does the same as toLatin1().
+ This function does the same as toLatin1().
Note that, despite the name, this function does not necessarily return an US-ASCII
(ANSI X3.4-1986) string and its result may not be US-ASCII compatible.
@@ -8753,10 +8705,6 @@ QByteArray QStringRef::toLatin1() const
*/
QByteArray QStringRef::toAscii() const
{
-#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings)
- return QString::codecForCStrings->fromUnicode(unicode(), length());
-#endif // QT_NO_TEXTCODEC
return toLatin1();
}
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index bdadba8bd4..6fc86fc04b 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -502,10 +502,10 @@ public:
// ASCII compatibility
#ifndef QT_NO_CAST_FROM_ASCII
- inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch)
+ inline QT_ASCII_CAST_WARN QString(const char *ch)
: d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1))
{}
- inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const QByteArray &a)
+ inline QT_ASCII_CAST_WARN QString(const QByteArray &a)
: d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size())))
{}
inline QT_ASCII_CAST_WARN QString &operator=(const char *ch)
@@ -609,9 +609,6 @@ private:
Data *d;
inline QString(Data *dd, int /*dummy*/) : d(dd) {}
-#ifndef QT_NO_TEXTCODEC
- static QTextCodec *codecForCStrings;
-#endif
static int grow(int);
static void free(Data *);
void realloc();
@@ -931,9 +928,6 @@ inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); }
#ifndef QT_NO_CAST_FROM_ASCII
inline bool qStringComparisonHelper(const QString &s1, const char *s2)
{
-# ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1));
-# endif
return (s1 == QLatin1String(s2));
}
inline bool QString::operator==(const char *s) const
@@ -1220,9 +1214,6 @@ inline bool operator>=(const QStringRef &s1, const QStringRef &s2)
inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2)
{
-# ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1));
-# endif
return (s1 == QLatin1String(s2));
}
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 3d6b0eb709..6999972172 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -105,14 +105,6 @@ QT_BEGIN_NAMESPACE
*/
void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
{
-#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings && len) {
- QString tmp = QString::fromAscii(a, len > 0 ? len : -1);
- memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
- out += tmp.length();
- return;
- }
-#endif
if (len == -1) {
if (!a)
return;
@@ -124,25 +116,4 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out
}
}
-/*! \internal */
-void QAbstractConcatenable::convertToAscii(const QChar* a, int len, char*& out)
-{
-#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) {
- QByteArray tmp = QString::codecForCStrings->fromUnicode(a, len);
- memcpy(out, tmp.constData(), tmp.size());
- out += tmp.length();
- return;
- }
-#endif
- if (len == -1) {
- while (a->unicode())
- convertToLatin1(*a++, out);
- } else {
- for (int i = 0; i < len; ++i)
- convertToLatin1(a[i], out);
- }
-}
-
-
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 5a4c27d22a..4c963185ad 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -62,30 +62,9 @@ struct Q_CORE_EXPORT QAbstractConcatenable
{
protected:
static void convertFromAscii(const char *a, int len, QChar *&out);
- static void convertToAscii(const QChar *a, int len, char *&out);
static inline void convertFromAscii(char a, QChar *&out)
{
-#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings)
- *out++ = QChar::fromAscii(a);
- else
-#endif
- *out++ = QLatin1Char(a);
- }
-
- static inline void convertToAscii(QChar a, char *&out)
- {
-#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings)
- *out++ = a.toAscii(); //###
- else
-#endif
- convertToLatin1(a, out);
- }
-
- static inline void convertToLatin1(QChar a, char *&out)
- {
- *out++ = a.unicode() > 0xff ? '?' : char(a.unicode());
+ *out++ = QLatin1Char(a);
}
};
@@ -192,10 +171,6 @@ template <> struct QConcatenable<QChar> : private QAbstractConcatenable
static int size(const QChar) { return 1; }
static inline void appendTo(const QChar c, QChar *&out)
{ *out++ = c; }
-#ifndef QT_NO_CAST_TO_ASCII
- static inline QT_ASCII_CAST_WARN void appendTo(const QChar c, char *&out)
- { convertToAscii(c, out); }
-#endif
};
template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable
@@ -206,10 +181,6 @@ template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable
static int size(const QCharRef &) { return 1; }
static inline void appendTo(const QCharRef &c, QChar *&out)
{ *out++ = QChar(c); }
-#ifndef QT_NO_CAST_TO_ASCII
- static inline QT_ASCII_CAST_WARN void appendTo(const QCharRef &c, char *&out)
- { convertToAscii(c, out); }
-#endif
};
template <> struct QConcatenable<QLatin1String>
@@ -242,10 +213,6 @@ template <> struct QConcatenable<QString> : private QAbstractConcatenable
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n);
out += n;
}
-#ifndef QT_NO_CAST_TO_ASCII
- static inline QT_ASCII_CAST_WARN void appendTo(const QString &a, char *&out)
- { convertToAscii(a.constData(), a.length(), out); }
-#endif
};
template <int N> struct QConcatenable<QConstStringDataPtr<N> > : private QAbstractConcatenable
@@ -259,10 +226,6 @@ template <int N> struct QConcatenable<QConstStringDataPtr<N> > : private QAbstra
memcpy(out, reinterpret_cast<const char*>(a.ptr->data), sizeof(QChar) * N);
out += N;
}
-#ifndef QT_NO_CAST_TO_ASCII
- static inline QT_ASCII_CAST_WARN void appendTo(const type &a, char *&out)
- { convertToAscii(a.ptr->data, N, out); }
-#endif
};
template <> struct QConcatenable<QStringRef> : private QAbstractConcatenable
@@ -277,11 +240,6 @@ template <> struct QConcatenable<QStringRef> : private QAbstractConcatenable
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n);
out += n;
}
-#ifndef QT_NO_CAST_TO_ASCII
- static inline QT_ASCII_CAST_WARN void appendTo(const QStringRef &a, char *&out)
- { convertToAscii(a.constData(), a.length(), out); }
-#endif
-
};
template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable
diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp
index 1c2cb6f0f0..6e6e676dae 100644
--- a/src/dbus/qdbusargument.cpp
+++ b/src/dbus/qdbusargument.cpp
@@ -89,7 +89,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id)
if (signature.isEmpty() || !ok || !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))) {
qWarning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' "
"(Did you forget to call beginStructure() ?)",
- QVariant::typeToName( QVariant::Type(id) ),
+ QMetaType::typeName(id),
signature.isEmpty() ? "<empty>" : signature.constData());
return "";
} else if ((signature.at(0) != DBUS_TYPE_ARRAY && signature.at(0) != DBUS_STRUCT_BEGIN_CHAR) ||
@@ -97,9 +97,9 @@ QByteArray QDBusArgumentPrivate::createSignature(int id)
signature.at(1) == DBUS_TYPE_STRING))) {
qWarning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) "
"(Did you forget to call beginStructure() ?)",
- QVariant::typeToName( QVariant::Type(id) ),
+ QMetaType::typeName(id),
signature.constData(),
- QVariant::typeToName( QVariant::Type(QDBusMetaType::signatureToType(signature))) );
+ QMetaType::typeName(QDBusMetaType::signatureToType(signature)));
return "";
}
return signature;
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 0d00df2a17..37e7a1dbb4 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
\class QAccessible
\brief The QAccessible class provides enums and static functions
related to accessibility.
+ \internal
\ingroup accessibility
\inmodule QtWidgets
@@ -364,6 +365,8 @@ QT_BEGIN_NAMESPACE
\value Labelled The first object is labelled by the second object.
\value Controller The first object controls the second object.
\value Controlled The first object is controlled by the second object.
+ \value AllRelations Used as a mask to specify that we are interesting in information
+ about all relations
Implementations of relations() return a combination of these flags.
Some values are mutually exclusive.
@@ -690,6 +693,7 @@ void QAccessible::updateAccessibility(const QAccessibleEvent &event)
\class QAccessibleEvent
\brief The QAccessibleEvent is use to notify about changes that are
relevant for accessibility in the application.
+ \internal
\ingroup accessibility
\inmodule QtGui
@@ -725,6 +729,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
\class QAccessibleInterface
\brief The QAccessibleInterface class defines an interface that exposes information
about accessible objects.
+ \internal
\ingroup accessibility
\inmodule QtGui
@@ -1170,6 +1175,7 @@ const char *qAccessibleEventString(QAccessible::Event event)
return QAccessible::staticMetaObject.enumerator(eventEnum).valueToKey(event);
}
+/*! \internal */
bool operator==(const QAccessible::State &first, const QAccessible::State &second)
{
return memcmp(&first, &second, sizeof(QAccessible::State)) == 0;
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index e57033d9bf..a72b91a90f 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -306,10 +306,10 @@ public:
};
enum RelationFlag {
- Label = 0x00020000,
- Labelled = 0x00040000,
- Controller = 0x00080000,
- Controlled = 0x00100000,
+ Label = 0x00000001,
+ Labelled = 0x00000002,
+ Controller = 0x00000004,
+ Controlled = 0x00000008,
AllRelations = 0xffffffff
};
Q_DECLARE_FLAGS(Relation, RelationFlag)
diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp
index 0f854c6158..db3028b371 100644
--- a/src/gui/accessible/qaccessible2.cpp
+++ b/src/gui/accessible/qaccessible2.cpp
@@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE
/*!
\namespace QAccessible2
\ingroup accessibility
+ \internal
\brief The QAccessible2 namespace defines constants relating to
IAccessible2-based interfaces
@@ -60,6 +61,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleTextInterface
+ \internal
\ingroup accessibility
@@ -180,6 +182,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleEditableTextInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleEditableTextInterface class implements support for objects with editable text.
@@ -247,6 +250,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleSimpleEditableTextInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleSimpleEditableTextInterface class is a convenience class for
text-based widgets. It can be inherited instead of \l QAccessibleEditableTextInterface.
@@ -259,6 +263,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleValueInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleValueInterface class implements support for objects that manipulate a value.
@@ -323,6 +328,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleTableCellInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleTableCellInterface class implements support for
the IAccessibleTable2 Cell interface.
@@ -333,6 +339,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleTableInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleTableInterface class implements support for
the IAccessibleTable2 interface.
@@ -344,6 +351,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QAccessibleActionInterface
\ingroup accessibility
+ \internal
\brief The QAccessibleActionInterface class implements support for
invocable actions in the interface.
diff --git a/src/gui/accessible/qaccessiblebridge.cpp b/src/gui/accessible/qaccessiblebridge.cpp
index 8fcf0474a1..d6d0796701 100644
--- a/src/gui/accessible/qaccessiblebridge.cpp
+++ b/src/gui/accessible/qaccessiblebridge.cpp
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
\class QAccessibleBridge
\brief The QAccessibleBridge class is the base class for
accessibility back-ends.
+ \internal
\ingroup accessibility
\inmodule QtWidgets
@@ -100,6 +101,7 @@ QT_BEGIN_NAMESPACE
\class QAccessibleBridgePlugin
\brief The QAccessibleBridgePlugin class provides an abstract
base for accessibility bridge plugins.
+ \internal
\ingroup plugins
\ingroup accessibility
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index d277f39c43..e587ad077c 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -92,6 +92,7 @@ QList<QByteArray> QAccessibleObjectPrivate::actionList() const
\class QAccessibleObject
\brief The QAccessibleObject class implements parts of the
QAccessibleInterface for QObjects.
+ \internal
\ingroup accessibility
\inmodule QtWidgets
diff --git a/src/gui/accessible/qaccessibleplugin.cpp b/src/gui/accessible/qaccessibleplugin.cpp
index 8823d63b79..c2fe9c7a7a 100644
--- a/src/gui/accessible/qaccessibleplugin.cpp
+++ b/src/gui/accessible/qaccessibleplugin.cpp
@@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE
\class QAccessiblePlugin
\brief The QAccessiblePlugin class provides an abstract base for
accessibility plugins.
+ \internal
\ingroup plugins
\ingroup accessibility
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
index b33ccd42a2..0d97fdd0be 100644
--- a/src/gui/kernel/qclipboard_qpa.cpp
+++ b/src/gui/kernel/qclipboard_qpa.cpp
@@ -76,8 +76,6 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
if (!clipboard->supportsMode(mode)) return;
clipboard->setMimeData(src,mode);
-
- emitChanged(mode);
}
bool QClipboard::supportsMode(Mode mode) const
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c3a6be692b..281d4f61bc 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -453,7 +453,13 @@ QHoverEvent::~QHoverEvent()
Wheel events are sent to the widget under the mouse cursor, but
if that widget does not handle the event they are sent to the
- focus widget. The rotation distance is provided by delta().
+ focus widget. Wheel events are generated for both mouse wheels
+ and trackpad scroll gestures. There are two ways to read the
+ wheel event delta: angleDelta() returns the delta in wheel
+ degrees. This value is always provided. pixelDelta() returns
+ the delta in screen pixels and is available on platforms that
+ have high-resolution trackpads, such as Mac OS X.
+
The functions pos() and globalPos() return the mouse cursor's
location at the time of the event.
@@ -483,8 +489,11 @@ QHoverEvent::~QHoverEvent()
*/
/*!
+ \obsolete
Constructs a wheel event object.
+ Use the QPoint-based constructor instead.
+
The position, \a pos, is the location of the mouse cursor within
the widget. The globalPos() is initialized to QCursor::pos()
which is usually, but not always, correct.
@@ -496,13 +505,13 @@ QHoverEvent::~QHoverEvent()
\a modifiers holds the keyboard modifier flags at the time of the
event, and \a orient holds the wheel's orientation.
- \sa pos() delta() state()
+ \sa pos() pixelDelta() angleDelta() state()
*/
#ifndef QT_NO_WHEELEVENT
QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
+ : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
{
g = QCursor::pos();
}
@@ -515,26 +524,69 @@ QWheelEvent::~QWheelEvent()
}
/*!
+ \obsolete
Constructs a wheel event object.
+ Use the QPoint-based constructor instead.
+
The \a pos provides the location of the mouse cursor
within the widget. The position in global coordinates is specified
by \a globalPos. \a delta contains the rotation distance, \a modifiers
holds the keyboard modifier flags at the time of the event, and
\a orient holds the wheel's orientation.
- \sa pos() globalPos() delta() state()
+
+ \sa pos() pixelDelta() angleDelta() state()
*/
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
+{}
+
+/*!
+ Constructs a wheel event object.
+
+ The \a pos provides the location of the mouse cursor
+ within the window. The position in global coordinates is specified
+ by \a globalPos. \pixelDelta contains the scrolling distance
+ in pixels on screen, \a angleDelta contains the wheel rotation distance.
+ \pixelDelta is optional and can be null.
+
+ \a modifiers holds the keyboard modifier flags at the time of the event.
+
+ \a pixelDelta contains the scrolling delta in pixels,
+ \a angleDelta contains the rotation distance, and
+ \a orient holds the wheel's orientation.
+
+ \sa pos() globalPos() delta() state()
+*/
+
+QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+ QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
+ angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
{}
+
#endif // QT_NO_WHEELEVENT
/*!
- \fn int QWheelEvent::delta() const
+ \fn QPoint QWheelEvent::pixelDelta() const
+
+ Returns the scrolling distance in pixels on screen. This value is
+ provided on platforms that support high-resolution pixel-based
+ delta values, such as Mac OS X. The value should be used directly
+ to scroll content on screen.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
+*/
+
+/*!
+ \fn QPoint QWheelEvent::angleDelta() const
Returns the distance that the wheel is rotated, in eighths of a
degree. A positive value indicates that the wheel was rotated
@@ -556,6 +608,12 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
*/
/*!
+ \fn int QWheelEvent::delta() const
+
+ This function has been deprecated, use pixelDelta() or angleDelta() instead.
+*/
+
+/*!
\fn const QPoint &QWheelEvent::pos() const
Returns the position of the mouse cursor relative to the widget
@@ -833,7 +891,7 @@ Qt::KeyboardModifiers QKeyEvent::modifiers() const
bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
{
uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
- uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+ const uint platform = QKeySequencePrivate::currentKeyPlatforms();
uint N = QKeySequencePrivate::numberOfKeyBindings;
@@ -2887,7 +2945,6 @@ QShortcutEvent::~QShortcutEvent()
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QEvent *e) {
-#ifndef Q_BROKEN_DEBUG_STREAM
// More useful event output could be added here
if (!e)
return dbg << "QEvent(this = 0x0)";
@@ -3168,11 +3225,6 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QEvent to QDebug");
- return dbg;
- Q_UNUSED(e);
-#endif
}
#endif
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 93dea41de9..ca93095a94 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -148,9 +148,21 @@ public:
QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient = Qt::Vertical);
+ QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+ QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+
~QWheelEvent();
- inline int delta() const { return d; }
+
+ inline QPoint pixelDelta() const { return pixelD; }
+ inline QPoint angleDelta() const { return angleD; }
+
+#if QT_DEPRECATED_SINCE(5, 0)
+ inline QT_DEPRECATED int delta() const { return qt4D; }
+ inline QT_DEPRECATED Qt::Orientation orientation() const { return qt4O; }
+#endif
+
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
inline QPoint pos() const { return p.toPoint(); }
inline QPoint globalPos() const { return g.toPoint(); }
@@ -163,15 +175,15 @@ public:
inline const QPointF &globalPosF() const { return g; }
inline Qt::MouseButtons buttons() const { return mouseState; }
- Qt::Orientation orientation() const { return o; }
-
-
protected:
QPointF p;
QPointF g;
- int d;
+ QPoint pixelD;
+ QPoint angleD;
+ int qt4D;
+ Qt::Orientation qt4O;
Qt::MouseButtons mouseState;
- Qt::Orientation o;
+ int reserved;
};
#endif
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7cb3d4b488..1cd448a6bb 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -99,6 +99,14 @@ QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0;
QList<QObject *> QGuiApplicationPrivate::generic_plugin_list;
+enum ApplicationResourceFlags
+{
+ ApplicationPaletteExplicitlySet = 0x1,
+ ApplicationFontExplicitlySet = 0x2
+};
+
+static unsigned applicationResourceFlags = 0;
+
bool QGuiApplicationPrivate::app_do_modal = false;
QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
@@ -144,7 +152,169 @@ static bool qt_detectRTLLanguage()
" and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
}
+static void initPalette()
+{
+ if (!QGuiApplicationPrivate::app_pal)
+ if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
+ QGuiApplicationPrivate::app_pal = new QPalette(*themePalette);
+ if (!QGuiApplicationPrivate::app_pal)
+ QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
+}
+
+static inline void clearPalette()
+{
+ delete QGuiApplicationPrivate::app_pal;
+ QGuiApplicationPrivate::app_pal = 0;
+}
+
+static void initFontUnlocked()
+{
+ if (!QGuiApplicationPrivate::app_font)
+ QGuiApplicationPrivate::app_font =
+ new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont());
+}
+
+static inline void clearFontUnlocked()
+{
+ delete QGuiApplicationPrivate::app_font;
+ QGuiApplicationPrivate::app_font = 0;
+}
+
+/*!
+ \class QGuiApplication
+ \brief The QGuiApplication class manages the GUI application's control
+ flow and main settings.
+
+ \inmodule QtGui
+
+ QGuiApplication contains the main event loop, where all events from the window
+ system and other sources are processed and dispatched. It also handles the
+ application's initialization and finalization. In addition, QGuiApplication handles
+ most of the system-wide and application-wide settings.
+
+ For any GUI application using Qt, there is precisely \bold one QGuiApplication
+ object no matter whether the application has 0, 1, 2 or more windows at
+ any given time. For non-GUI Qt applications, use QCoreApplication instead,
+ as it does not depend on the \l QtGui library.
+
+ The QGuiApplication object is accessible through the instance() function, which
+ returns a pointer equivalent to the global \l qApp pointer.
+
+ QGuiApplication's main areas of responsibility are:
+ \list
+ \o It initializes the application with the user's desktop settings,
+ such as palette(), font() and styleHints(). It keeps
+ track of these properties in case the user changes the desktop
+ globally, for example, through some kind of control panel.
+
+ \o It performs event handling, meaning that it receives events
+ from the underlying window system and dispatches them to the
+ relevant widgets. You can send your own events to windows by
+ using sendEvent() and postEvent().
+
+ \o It parses common command line arguments and sets its internal
+ state accordingly. See the \l{QGuiApplication::QGuiApplication()}
+ {constructor documentation} below for more details.
+
+ \o It provides localization of strings that are visible to the
+ user via translate().
+
+ \o It provides some magical objects like the clipboard().
+
+ \o It knows about the application's windows. You can ask which
+ window is at a certain position using topLevelAt(), get a list of
+ topLevelWindows(), etc.
+
+ \o It manages the application's mouse cursor handling, see
+ setOverrideCursor()
+ \endlist
+
+ Since the QGuiApplication object does so much initialization, it \e{must} be
+ created before any other objects related to the user interface are created.
+ QGuiApplication also deals with common command line arguments. Hence, it is
+ usually a good idea to create it \e before any interpretation or
+ modification of \c argv is done in the application itself.
+
+ \table
+ \header
+ \o{2,1} Groups of functions
+
+ \row
+ \o System settings
+ \o desktopSettingsAware(),
+ setDesktopSettingsAware(),
+ styleHints(),
+ palette(),
+ setPalette(),
+ font(),
+ setFont().
+
+ \row
+ \o Event handling
+ \o exec(),
+ processEvents(),
+ exit(),
+ quit().
+ sendEvent(),
+ postEvent(),
+ sendPostedEvents(),
+ removePostedEvents(),
+ hasPendingEvents(),
+ notify().
+
+ \row
+ \o Windows
+ \o allWindows(),
+ topLevelWindows(),
+ focusWindow(),
+ clipboard(),
+ topLevelAt().
+
+ \row
+ \o Advanced cursor handling
+ \o overrideCursor(),
+ setOverrideCursor(),
+ restoreOverrideCursor().
+
+ \row
+ \o Miscellaneous
+ \o startingUp(),
+ closingDown(),
+ type().
+ \endtable
+
+ \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop
+*/
+
+/*!
+ Initializes the window system and constructs an application object with
+ \a argc command line arguments in \a argv.
+
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QGuiApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
+
+ The global \c qApp pointer refers to this application object. Only one
+ application object should be created.
+
+ This application object must be constructed before any \l{QPaintDevice}
+ {paint devices} (including pixmaps, bitmaps etc.).
+
+ \note \a argc and \a argv might be changed as Qt removes command line
+ arguments that it recognizes.
+ All Qt programs automatically support the following command line options:
+ \list
+ \o -reverse, sets the application's layout direction to
+ Qt::RightToLeft
+ \o -qmljsdebugger=, activates the QML/JS debugger with a specified port.
+ The value must be of format port:1234[,block], where block is optional
+ and will make the application wait until a debugger connects to it.
+ \endlist
+
+ \sa arguments()
+*/
QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
: QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
{
@@ -159,6 +329,9 @@ QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p)
d_func()->init();
}
+/*!
+ Destructs the application.
+*/
QGuiApplication::~QGuiApplication()
{
Q_D(QGuiApplication);
@@ -174,8 +347,7 @@ QGuiApplication::~QGuiApplication()
delete QGuiApplicationPrivate::qt_clipboard;
QGuiApplicationPrivate::qt_clipboard = 0;
- delete QGuiApplicationPrivate::app_pal;
- QGuiApplicationPrivate::app_pal = 0;
+ clearPalette();
qUnregisterGuiVariant();
@@ -194,6 +366,10 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
application_type = QCoreApplication::GuiClient;
}
+/*!
+ Returns the QWindow that receives events tied to focus,
+ such as key events.
+*/
QWindow *QGuiApplication::focusWindow()
{
return QGuiApplicationPrivate::focus_window;
@@ -208,7 +384,7 @@ QWindow *QGuiApplication::focusWindow()
/*!
Returns the QObject in currently active window that will be final receiver of events
- tied focus, such as key events.
+ tied to focus, such as key events.
*/
QObject *QGuiApplication::focusObject()
{
@@ -249,6 +425,11 @@ QWindowList QGuiApplication::topLevelWindows()
return topLevelWindows;
}
+/*!
+ Returns the primary (or default) screen of the application.
+
+ This will be the screen where QWindows are shown, unless otherwise specified.
+*/
QScreen *QGuiApplication::primaryScreen()
{
if (QGuiApplicationPrivate::screen_list.isEmpty())
@@ -256,11 +437,18 @@ QScreen *QGuiApplication::primaryScreen()
return QGuiApplicationPrivate::screen_list.at(0);
}
+/*!
+ Returns a list of all the screens associated with the
+ windowing system the application is connected to.
+*/
QList<QScreen *> QGuiApplication::screens()
{
return QGuiApplicationPrivate::screen_list;
}
+/*!
+ Returns the top level window at the given position, if any.
+*/
QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
{
QList<QScreen *> screens = QGuiApplication::screens();
@@ -517,8 +705,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
delete generic_plugin_list.at(i);
generic_plugin_list.clear();
- delete app_font;
- app_font = 0;
+ clearFontUnlocked();
+
QFont::cleanup();
#ifndef QT_NO_CURSOR
@@ -557,27 +745,62 @@ static QClipboard *clipboard();
#endif
#endif
+/*!
+ Returns the currently held keyboard modifiers.
+*/
Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
{
return QGuiApplicationPrivate::modifier_buttons;
}
+/*!
+ Returns the currently held mouse buttons.
+*/
Qt::MouseButtons QGuiApplication::mouseButtons()
{
return QGuiApplicationPrivate::mouse_buttons;
}
+/*!
+ Returns the platform's native interface, for platform specific
+ functionality.
+*/
QPlatformNativeInterface *QGuiApplication::platformNativeInterface()
{
QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
return pi->nativeInterface();
}
+/*!
+ Enters the main event loop and waits until exit() is called, and then
+ returns the value that was set to exit() (which is 0 if exit() is called
+ via quit()).
+
+ It is necessary to call this function to start event handling. The main
+ event loop receives events from the window system and dispatches these to
+ the application widgets.
+
+ Generally, no user interaction can take place before calling exec().
+
+ To make your application perform idle processing, e.g., executing a special
+ function whenever there are no pending events, use a QTimer with 0 timeout.
+ More advanced idle processing schemes can be achieved using processEvents().
+
+ We recommend that you connect clean-up code to the
+ \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
+ application's \c{main()} function. This is because, on some platforms, the
+ QApplication::exec() call may not return.
+
+ \sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
+ QCoreApplication::exec()
+*/
int QGuiApplication::exec()
{
return QCoreApplication::exec();
}
+/*! \reimp
+*/
bool QGuiApplication::notify(QObject *object, QEvent *event)
{
#ifndef QT_NO_SHORTCUT
@@ -595,6 +818,8 @@ bool QGuiApplication::notify(QObject *object, QEvent *event)
return QCoreApplication::notify(object, event);
}
+/*! \reimp
+*/
bool QGuiApplication::event(QEvent *e)
{
if(e->type() == QEvent::LanguageChange) {
@@ -603,6 +828,9 @@ bool QGuiApplication::event(QEvent *e)
return QCoreApplication::event(e);
}
+/*!
+ \internal
+*/
bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
{
return QCoreApplication::compressEvent(event, receiver, postedEvents);
@@ -804,8 +1032,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
QWindow *window = e->window.data();
if (window) {
- QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, e->modifiers,
- e->orient);
+ QWheelEvent ev(e->localPos, e->globalPos, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &ev);
return;
@@ -896,6 +1123,8 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
{
+ if (self)
+ self->notifyThemeChanged();
if (QWindow *window = tce->window.data()) {
QEvent e(QEvent::ThemeChange);
QGuiApplication::sendSpontaneousEvent(window, &e);
@@ -1364,6 +1593,9 @@ Qt::DropAction QGuiApplicationPrivate::processDrop(QWindow *w, QMimeData *dropDa
}
#ifndef QT_NO_CLIPBOARD
+/*!
+ Returns the object for interacting with the clipboard.
+*/
QClipboard * QGuiApplication::clipboard()
{
if (QGuiApplicationPrivate::qt_clipboard == 0) {
@@ -1378,20 +1610,22 @@ QClipboard * QGuiApplication::clipboard()
#endif
/*!
- Returns the application palette.
+ Returns the default application palette.
- \sa setPalette(), QWidget::palette()
+ \sa setPalette()
*/
+
QPalette QGuiApplication::palette()
{
- if (!QGuiApplicationPrivate::app_pal)
- if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
- QGuiApplicationPrivate::app_pal = new QPalette(*themePalette);
- if (!QGuiApplicationPrivate::app_pal)
- QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
+ initPalette();
return *QGuiApplicationPrivate::app_pal;
}
+/*!
+ Changes the default application palette to \a palette.
+
+ \sa palette()
+*/
void QGuiApplication::setPalette(const QPalette &pal)
{
if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal))
@@ -1400,17 +1634,26 @@ void QGuiApplication::setPalette(const QPalette &pal)
QGuiApplicationPrivate::app_pal = new QPalette(pal);
else
*QGuiApplicationPrivate::app_pal = pal;
+ applicationResourceFlags |= ApplicationPaletteExplicitlySet;
}
+/*!
+ Returns the default application font.
+
+ \sa setFont()
+*/
QFont QGuiApplication::font()
{
QMutexLocker locker(&applicationFontMutex);
- if (!QGuiApplicationPrivate::app_font)
- QGuiApplicationPrivate::app_font =
- new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont());
+ initFontUnlocked();
return *QGuiApplicationPrivate::app_font;
}
+/*!
+ Changes the default application font to \a font.
+
+ \sa font()
+*/
void QGuiApplication::setFont(const QFont &font)
{
QMutexLocker locker(&applicationFontMutex);
@@ -1418,6 +1661,7 @@ void QGuiApplication::setFont(const QFont &font)
QGuiApplicationPrivate::app_font = new QFont(font);
else
*QGuiApplicationPrivate::app_font = font;
+ applicationResourceFlags |= ApplicationFontExplicitlySet;
}
/*!
@@ -1631,7 +1875,7 @@ void QGuiApplication::restoreOverrideCursor()
/*!
\since 5.0
- returns the style hints.
+ Returns the application's style hints.
The style hints encapsulate a set of platform dependent properties
such as double click intervals, full width selection and others.
@@ -1675,6 +1919,14 @@ bool QGuiApplication::desktopSettingsAware()
return QGuiApplicationPrivate::obey_desktop_settings;
}
+QInputMethod *QGuiApplication::inputMethod() const
+{
+ Q_D(const QGuiApplication);
+ if (!d->inputMethod)
+ const_cast<QGuiApplicationPrivate *>(d)->inputMethod = new QInputMethod();
+ return d->inputMethod;
+}
+
/*!
\since 5.0
@@ -1686,40 +1938,11 @@ bool QGuiApplication::desktopSettingsAware()
\sa QInputPanel
*/
-QInputMethod *QGuiApplication::inputMethod() const
-{
- Q_D(const QGuiApplication);
- if (!d->inputMethod)
- const_cast<QGuiApplicationPrivate *>(d)->inputMethod = new QInputMethod();
- return d->inputMethod;
-}
-
QInputPanel *QGuiApplication::inputPanel() const
{
return inputMethod();
}
-
-// Returns the current platform used by keyBindings
-uint QGuiApplicationPrivate::currentKeyPlatform()
-{
- uint platform = KB_Win;
-#ifdef Q_OS_MAC
- platform = KB_Mac;
-#elif defined Q_WS_X11 // ## TODO: detect these
- platform = KB_X11;
-#if 0
- if (X11->desktopEnvironment == DE_KDE)
- platform |= KB_KDE;
- if (X11->desktopEnvironment == DE_GNOME)
- platform |= KB_Gnome;
- if (X11->desktopEnvironment == DE_CDE)
- platform |= KB_CDE;
-#endif
-#endif
- return platform;
-}
-
/*!
\since 4.5
\fn void QGuiApplication::fontDatabaseChanged()
@@ -1843,4 +2066,17 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
return QPixmap();
}
+void QGuiApplicationPrivate::notifyThemeChanged()
+{
+ if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) {
+ clearPalette();
+ initPalette();
+ }
+ if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) {
+ QMutexLocker locker(&applicationFontMutex);
+ clearFontUnlocked();
+ initFontUnlocked();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 7e6e0aa8c7..68546ce0cf 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -89,19 +89,6 @@ public:
static QPlatformTheme *platformTheme()
{ return platform_theme; }
-
- enum KeyPlatform {
- KB_Win = 1,
- KB_Mac = 2,
- KB_X11 = 4,
- KB_KDE = 8,
- KB_Gnome = 16,
- KB_CDE = 32,
- KB_All = 0xffff
- };
-
- static uint currentKeyPlatform();
-
static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
{ return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
@@ -213,6 +200,9 @@ public:
};
QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
+protected:
+ virtual void notifyThemeChanged();
+
private:
void init();
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
index 8378650dcb..50d3f0b7d1 100644
--- a/src/gui/kernel/qguivariant.cpp
+++ b/src/gui/kernel/qguivariant.cpp
@@ -221,7 +221,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);
}
-static bool convert(const QVariant::Private *d, QVariant::Type t,
+static bool convert(const QVariant::Private *d, int t,
void *result, bool *ok)
{
switch (t) {
@@ -236,7 +236,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t,
switch (d->type) {
#ifndef QT_NO_SHORTCUT
case QVariant::KeySequence:
- *str = QString(*v_cast<QKeySequence>(d));
+ *str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText);
return true;
#endif
case QVariant::Font:
@@ -285,7 +285,8 @@ static bool convert(const QVariant::Private *d, QVariant::Type t,
#ifndef QT_NO_SHORTCUT
case QVariant::Int:
if (d->type == QVariant::KeySequence) {
- *static_cast<int *>(result) = (int)(*(v_cast<QKeySequence>(d)));
+ const QKeySequence &seq = *v_cast<QKeySequence>(d);
+ *static_cast<int *>(result) = seq.isEmpty() ? 0 : seq[0];
return true;
}
break;
@@ -342,7 +343,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t,
return qcoreVariantHandler()->convert(d, t, result, ok);
}
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
static void streamDebug(QDebug dbg, const QVariant &v)
{
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
@@ -362,7 +363,7 @@ const QVariant::Handler qt_gui_variant_handler = {
compare,
convert,
0,
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_STREAM)
streamDebug
#else
0
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index de00396e40..9e724446ff 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -154,9 +154,9 @@ QRectF QInputMethod::cursorRectangle() const
QInputMethodQueryEvent query(Qt::ImCursorRectangle);
QGuiApplication::sendEvent(d->inputItem.data(), &query);
- QRect r = query.value(Qt::ImCursorRectangle).toRect();
+ QRectF r = query.value(Qt::ImCursorRectangle).toRectF();
if (!r.isValid())
- return QRect();
+ return QRectF();
return d->inputItemTransform.mapRect(r);
}
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 021135b6fe..7053f01196 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -41,6 +41,7 @@
#include "qkeysequence.h"
#include "qkeysequence_p.h"
+#include "qplatformtheme_qpa.h"
#include "private/qguiapplication_p.h"
#ifndef QT_NO_SHORTCUT
@@ -640,153 +641,163 @@ static const struct {
//Table of key bindings. It must be sorted on key sequence.
//A priority of 1 indicates that this is the primary key binding when multiple are defined.
+enum KeyPlatform {
+ KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme),
+ KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme),
+ KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme),
+ KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme),
+ KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme),
+ KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme),
+ KB_All = 0xffff
+};
+
const QKeyBinding QKeySequencePrivate::keyBindings[] = {
// StandardKey Priority Key Sequence Platforms
- {QKeySequence::Back, 0, Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, QGuiApplicationPrivate::KB_All},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Delete, 1, Qt::Key_Delete, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
- {QKeySequence::HelpContents, 0, Qt::Key_F1, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::FindNext, 0, Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
- {QKeySequence::FindNext, 1, Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Refresh, 0, Qt::Key_F5, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::Undo, 0, Qt::Key_F14, QGuiApplicationPrivate::KB_X11}, //Undo on sun keyboards
- {QKeySequence::Copy, 0, Qt::Key_F16, QGuiApplicationPrivate::KB_X11}, //Copy on sun keyboards
- {QKeySequence::Paste, 0, Qt::Key_F18, QGuiApplicationPrivate::KB_X11}, //Paste on sun keyboards
- {QKeySequence::Cut, 0, Qt::Key_F20, QGuiApplicationPrivate::KB_X11}, //Cut on sun keyboards
- {QKeySequence::PreviousChild, 0, Qt::Key_Back, QGuiApplicationPrivate::KB_All},
- {QKeySequence::NextChild, 0, Qt::Key_Forward, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QGuiApplicationPrivate::KB_All},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, //## Check if this should work on mac
- {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_All},
- {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_All},
- {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_All},
- {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_All},
- {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
- {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
- {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QGuiApplicationPrivate::KB_All},
- {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
- {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QGuiApplicationPrivate::KB_All},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_KDE},
- {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QGuiApplicationPrivate::KB_All},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QGuiApplicationPrivate::KB_KDE},
- {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
- {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QGuiApplicationPrivate::KB_All},
- {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Gnome},
- {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QGuiApplicationPrivate::KB_All},
- {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
- {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_KDE | QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_KDE},
- {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QGuiApplicationPrivate::KB_All},
- {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QGuiApplicationPrivate::KB_All},
- {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Mac}, //different priority from above
- {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
- {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QGuiApplicationPrivate::KB_KDE},
- {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Mac },//different priority from above
- {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
- {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac },
- {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QGuiApplicationPrivate::KB_Win},
- {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}
+ {QKeySequence::Back, 0, Qt::Key_Backspace, KB_Win},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, KB_All},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, KB_All},
+ {QKeySequence::Delete, 1, Qt::Key_Delete, KB_All},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, KB_Mac},
+ {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, KB_All},
+ {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, KB_All},
+ {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, KB_All},
+ {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, KB_All},
+ {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, KB_All},
+ {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All},
+ {QKeySequence::HelpContents, 0, Qt::Key_F1, KB_Win | KB_X11},
+ {QKeySequence::FindNext, 0, Qt::Key_F3, KB_X11},
+ {QKeySequence::FindNext, 1, Qt::Key_F3, KB_Win},
+ {QKeySequence::Refresh, 0, Qt::Key_F5, KB_Win | KB_X11},
+ {QKeySequence::Undo, 0, Qt::Key_F14, KB_X11}, //Undo on sun keyboards
+ {QKeySequence::Copy, 0, Qt::Key_F16, KB_X11}, //Copy on sun keyboards
+ {QKeySequence::Paste, 0, Qt::Key_F18, KB_X11}, //Paste on sun keyboards
+ {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11}, //Cut on sun keyboards
+ {QKeySequence::PreviousChild, 0, Qt::Key_Back, KB_All},
+ {QKeySequence::NextChild, 0, Qt::Key_Forward, KB_All},
+ {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, KB_Win},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
+ {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11},
+ {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11}, //## Check if this should work on mac
+ {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, KB_Mac},
+ {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, KB_All},
+ {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, KB_All},
+ {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, KB_All},
+ {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, KB_All},
+ {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, KB_All},
+ {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, KB_All},
+ {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, KB_All},
+ {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, KB_X11},
+ {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, KB_Win},
+ {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, KB_All},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, KB_KDE},
+ {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
+ {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, KB_All},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, KB_KDE},
+ {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, KB_Mac},
+ {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, KB_All},
+ {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All},
+ {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All},
+ {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11}, //emacs (line edit only)
+ {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, KB_All},
+ {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, KB_Gnome | KB_Mac},
+ {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Gnome},
+ {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All},
+ {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, KB_X11}, //emacs (line edit only)
+ {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All},
+ {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, KB_All},
+ {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, KB_All},
+ {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac},
+ {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, KB_Gnome | KB_Mac},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, KB_KDE},
+ {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All},
+ {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, KB_All},
+ {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All},
+ {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, KB_Mac},
+ {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All},
+ {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, KB_Win},
+ {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All},
+ {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, KB_Mac},
+ {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, KB_Win | KB_X11},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, KB_Mac}, //different priority from above
+ {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, KB_X11 | KB_Win},
+ {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, KB_X11 | KB_Win},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, KB_Mac},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, KB_Mac },
+ {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac},
+ {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, KB_Mac },
+ {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, KB_Mac},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, KB_Win},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win},
+ {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac},
+ {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win},
+ {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, KB_KDE},
+ {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Win | KB_X11},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },//different priority from above
+ {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, KB_X11},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Mac },
+ {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac},
+ {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac },
+ {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, KB_Mac},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, KB_Win},
+ {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win},
+ {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, KB_Mac},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, KB_Mac},
+ {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac},
+ {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only
+ {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, KB_Mac },
+ {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac },
+ {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,KB_Win},
+ {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac},
+ {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, KB_Mac},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac},
+ {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac}
};
const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding));
@@ -991,7 +1002,7 @@ static inline int maybeSwapShortcut(int shortcut)
*/
QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
{
- uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+ const uint platform = QKeySequencePrivate::currentKeyPlatforms();
QList <QKeySequence> list;
for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
@@ -1330,6 +1341,19 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
return ret;
}
+unsigned QKeySequencePrivate::currentKeyPlatforms()
+{
+ int keyboardScheme = QPlatformTheme::WindowsKeyboardScheme;
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
+ unsigned result = 1u << keyboardScheme;
+ if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
+ || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
+ || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
+ result |= KB_X11;
+ return result;
+}
+
/*!
Creates a shortcut string for \a key. For example,
Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
@@ -1711,14 +1735,8 @@ QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QKeySequence &p)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QKeySequence(" << p.toString() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QKeySequence to QDebug");
- return dbg;
- Q_UNUSED(p);
-#endif
}
#endif
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index 68cbb8778b..4481557121 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -88,6 +88,7 @@ public:
static const QKeyBinding keyBindings[];
static const uint numberOfKeyBindings;
+ static unsigned currentKeyPlatforms();
};
#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index ba51653fcf..f9ebf8820c 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -74,6 +74,76 @@ QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker;
QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
#endif
+/*!
+ \class QOpenGLContext
+ \brief The QOpenGLContext represents a native OpenGL context, enabling
+ OpenGL rendering on a QSurface.
+
+ QOpenGLContext represents the OpenGL state of an underlying OpenGL context.
+ To set up a context, set its screen and format such that they match those
+ of the surface or surfaces with which the context is meant to be used, if
+ necessary make it share resources with other contexts with
+ setShareContext(), and finally call create(). Use isValid() to check if the
+ context was successfully initialized.
+
+ A context can be made current against a given surface by calling
+ makeCurrent(). When OpenGL rendering is done, call swapBuffers() to swap
+ the front and back buffers of the surface, so that the newly rendered
+ content becomes visible. To be able to support certain platforms,
+ QOpenGLContext requires that you call makeCurrent() again before starting
+ rendering a new frame, after calling swapBuffers().
+
+ If the context is temporarily not needed, such as when the application is
+ not rendering, it can be useful to call destroy() to free resources.
+ However, if you do so you will need to call create() again before the
+ context can be used, and you might need to recreate any OpenGL resources
+ and reinitialize the OpenGL state. You can connect to the
+ aboutToBeDestroyed() signal to clean up any resources that have been
+ allocated with different ownership from the QOpenGLContext itself.
+
+ Once a QOpenGLContext has been made current, you can render to it in a
+ platform independent way by using Qt's OpenGL enablers such as
+ QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, and
+ QOpenGLFramebufferObject. It is also possible to use the platform's OpenGL
+ API directly, without using the Qt enablers, although potentially at the
+ cost of portability. The latter is necessary when wanting to use OpenGL 1.x
+ or OpenGL ES 1.x.
+
+ For more information about the OpenGL API, refer to the official
+ \l{OpenGL documentation}.
+
+ \section1 Thread affinity
+
+ QOpenGLContext can be moved to a different thread with moveToThread(). Do
+ not call makeCurrent() from a different thread than the one to which the
+ QOpenGLContext object belongs. A context can only be current in one thread
+ and against one surface at a time, and a thread only has one context
+ current at a time.
+
+ \section1 Context resource sharing
+
+ Resources, such as framebuffer objects, textures, and vertex buffer objects
+ can be shared between contexts. Use setShareContext() before calling
+ create() to specify that the contexts should share these resources.
+ QOpenGLContext internally keeps track of a QOpenGLContextGroup object which
+ can be accessed with shareGroup(), and which can be used to find all the
+ contexts in a given share group. A share group consists of all contexts that
+ have been succesfully initialized and are sharing with an existing context in
+ the share group. A non-sharing context has a share group consisting of a
+ single context.
+
+ \section1 Default framebuffer
+
+ On certain platforms, a framebuffer other than 0 might be the default frame
+ buffer depending on the current surface. Instead of calling
+ glBindFramebuffer(0), it is recommended that you use
+ glBindFramebuffer(ctx->defaultFramebufferObject()), to ensure that your
+ application is portable between different platforms. However, if you use
+ QOpenGLFunctions::glBindFramebuffer(), this is done automatically for you.
+
+ \sa QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, QOpenGLFramebufferObject
+*/
+
void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context)
{
QGuiGLThreadContext *threadContext = qwindow_context_storage.localData();
@@ -89,7 +159,8 @@ void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context)
}
/*!
- Returns the last context which called makeCurrent. This function is thread aware.
+ Returns the last context which called makeCurrent in the current thread,
+ or 0, if no context is current.
*/
QOpenGLContext* QOpenGLContext::currentContext()
{
@@ -100,17 +171,31 @@ QOpenGLContext* QOpenGLContext::currentContext()
return 0;
}
+/*!
+ Returns true if the two contexts are sharing OpenGL resources.
+*/
bool QOpenGLContext::areSharing(QOpenGLContext *first, QOpenGLContext *second)
{
return first->shareGroup() == second->shareGroup();
}
+/*!
+ Returns the underlying platform context.
+
+ \internal
+*/
QPlatformOpenGLContext *QOpenGLContext::handle() const
{
Q_D(const QOpenGLContext);
return d->platformGLContext;
}
+/*!
+ Returns the underlying platform context with which this context is sharing.
+
+ \internal
+*/
+
QPlatformOpenGLContext *QOpenGLContext::shareHandle() const
{
Q_D(const QOpenGLContext);
@@ -120,7 +205,11 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const
}
/*!
- Creates a new GL context instance, you need to call create() before it can be used.
+ Creates a new OpenGL context instance.
+
+ Before it can be used you need to set the proper format and call create().
+
+ \sa create(), makeCurrent()
*/
QOpenGLContext::QOpenGLContext(QObject *parent)
: QObject(*new QOpenGLContextPrivate(), parent)
@@ -130,7 +219,8 @@ QOpenGLContext::QOpenGLContext(QObject *parent)
}
/*!
- Sets the format the GL context should be compatible with. You need to call create() before it takes effect.
+ Sets the \a format the OpenGL context should be compatible with. You need
+ to call create() before it takes effect.
*/
void QOpenGLContext::setFormat(const QSurfaceFormat &format)
{
@@ -139,7 +229,8 @@ void QOpenGLContext::setFormat(const QSurfaceFormat &format)
}
/*!
- Sets the context to share textures, shaders, and other GL resources with. You need to call create() before it takes effect.
+ Sets the context to share textures, shaders, and other OpenGL resources
+ with. You need to call create() before it takes effect.
*/
void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)
{
@@ -148,7 +239,8 @@ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)
}
/*!
- Sets the screen the GL context should be valid for. You need to call create() before it takes effect.
+ Sets the \a screen the OpenGL context should be valid for. You need to call
+ create() before it takes effect.
*/
void QOpenGLContext::setScreen(QScreen *screen)
{
@@ -159,9 +251,15 @@ void QOpenGLContext::setScreen(QScreen *screen)
}
/*!
- Attempts to create the GL context with the desired parameters.
+ Attempts to create the OpenGL context with the current configuration.
+
+ The current configuration includes the format, the share context, and the
+ screen.
- Returns true if the native context was successfully created and is ready to be used.
+ Returns true if the native context was successfully created and is ready to
+ be used with makeCurrent(), swapBuffers(), etc.
+
+ \sa makeCurrent(), destroy()
*/
bool QOpenGLContext::create()
{
@@ -179,6 +277,22 @@ bool QOpenGLContext::create()
return d->platformGLContext;
}
+/*!
+ Destroy the underlying platform context associated with this context.
+
+ If any other context is directly or indirectly sharing resources with this
+ context, the shared resources, which includes vertex buffer objects, shader
+ objects, textures, and framebuffer objects, are not freed. However,
+ destroying the underlying platform context frees any state associated with
+ the context.
+
+ After destroy() has been called, you must call create() if you wish to
+ use the context again.
+
+ \note This implicitly calls doneCurrent() if the context is current.
+
+ \sa create()
+*/
void QOpenGLContext::destroy()
{
Q_D(QOpenGLContext);
@@ -199,15 +313,20 @@ void QOpenGLContext::destroy()
\fn void QOpenGLContext::aboutToBeDestroyed()
This signal is emitted before the underlying native OpenGL context is
- destroyed, such that users may clean up OpenGL resources that might otherwise
- be left dangling in the case of shared OpenGL contexts.
+ destroyed, such that users may clean up OpenGL resources that might
+ otherwise be left dangling in the case of shared OpenGL contexts.
- If you wish to make the context current in order to do clean-up, make sure to
- only connect to the signal using a direct connection.
+ If you wish to make the context current in order to do clean-up, make sure
+ to only connect to the signal using a direct connection.
*/
/*!
- If this is the current context for the thread, doneCurrent is called
+ Destroys the QOpenGLContext object.
+
+ This implicitly calls destroy(), so if this is the current context for the
+ thread, doneCurrent() is also called.
+
+ \sa destroy()
*/
QOpenGLContext::~QOpenGLContext()
{
@@ -219,7 +338,9 @@ QOpenGLContext::~QOpenGLContext()
}
/*!
- Returns if this context is valid, i.e. has been successfully created.
+ Returns if this context is valid, i.e. has been successfully created.
+
+ \sa create()
*/
bool QOpenGLContext::isValid() const
{
@@ -228,11 +349,13 @@ bool QOpenGLContext::isValid() const
}
/*!
- Get the QOpenGLFunctions instance for this context.
+ Get the QOpenGLFunctions instance for this context.
- The context or a sharing context must be current.
-*/
+ QOpenGLContext offers this as a convenient way to access QOpenGLFunctions
+ without having to manage it manually.
+ The context or a sharing context must be current.
+*/
QOpenGLFunctions *QOpenGLContext::functions() const
{
Q_D(const QOpenGLContext);
@@ -242,15 +365,17 @@ QOpenGLFunctions *QOpenGLContext::functions() const
}
/*!
- Call this to get the default framebuffer object for the current surface.
+ Call this to get the default framebuffer object for the current surface.
- On some platforms the default framebuffer object depends on the surface being rendered to,
- and might be different from 0. Thus, instead of calling glBindFramebuffer(0), you should
- call glBindFramebuffer(ctx->defaultFramebufferObject()) if you want your application to
- work across different Qt platforms.
+ On some platforms the default framebuffer object depends on the surface
+ being rendered to, and might be different from 0. Thus, instead of calling
+ glBindFramebuffer(0), you should call
+ glBindFramebuffer(ctx->defaultFramebufferObject()) if you want your
+ application to work across different Qt platforms.
- If you use the glBindFramebuffer() in QOpenGLFunctions you do not have to worry about this,
- as it automatically binds the current context's defaultFramebufferObject() when 0 is passed.
+ If you use the glBindFramebuffer() in QOpenGLFunctions you do not have to
+ worry about this, as it automatically binds the current context's
+ defaultFramebufferObject() when 0 is passed.
*/
GLuint QOpenGLContext::defaultFramebufferObject() const
{
@@ -265,12 +390,18 @@ GLuint QOpenGLContext::defaultFramebufferObject() const
}
/*!
- If surface is 0 this is equivalent to calling doneCurrent().
+ Makes the context current in the current thread, against the given
+ \a surface.
+
+ If \a surface is 0 this is equivalent to calling doneCurrent().
- Do not call this function from a different thread than the one the QOpenGLContext instance lives in. If
- you wish to use QOpenGLContext from a different thread you should first call make sure it's not current
- in the current thread, by calling doneCurrent() if necessary. Then call moveToThread(otherThread)
- before using it in the other thread.
+ Do not call this function from a different thread than the one the
+ QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a
+ different thread you should first call make sure it's not current in the
+ current thread, by calling doneCurrent() if necessary. Then call
+ moveToThread(otherThread) before using it in the other thread.
+
+ \sa functions(), doneCurrent()
*/
bool QOpenGLContext::makeCurrent(QSurface *surface)
{
@@ -313,6 +444,10 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
/*!
Convenience function for calling makeCurrent with a 0 surface.
+
+ This results in no context being current in the current thread.
+
+ \sa makeCurrent(), currentContext()
*/
void QOpenGLContext::doneCurrent()
{
@@ -330,7 +465,9 @@ void QOpenGLContext::doneCurrent()
}
/*!
- Returns the surface the context is current for.
+ Returns the surface the context has been made current with.
+
+ This is the surface passed as an argument to makeCurrent().
*/
QSurface *QOpenGLContext::surface() const
{
@@ -391,6 +528,11 @@ void QOpenGLContext::swapBuffers(QSurface *surface)
d->platformGLContext->swapBuffers(surfaceHandle);
}
+/*!
+ Resolves the function pointer to an OpenGL extension function, identified by \a procName
+
+ Returns 0 if no such function can be found.
+*/
QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName)
{
Q_D(QOpenGLContext);
@@ -399,6 +541,11 @@ QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName)
return d->platformGLContext->getProcAddress(procName);
}
+/*!
+ Returns the format of the underlying platform context, if create() has been called.
+
+ Otherwise, returns the requested format.
+*/
QSurfaceFormat QOpenGLContext::format() const
{
Q_D(const QOpenGLContext);
@@ -407,27 +554,41 @@ QSurfaceFormat QOpenGLContext::format() const
return d->platformGLContext->format();
}
+/*!
+ Returns the share group this context belongs to.
+*/
QOpenGLContextGroup *QOpenGLContext::shareGroup() const
{
Q_D(const QOpenGLContext);
return d->shareGroup;
}
+/*!
+ Returns the share context this context was created with.
+
+ If the underlying platform was not able to support the requested
+ sharing, this will return 0.
+*/
QOpenGLContext *QOpenGLContext::shareContext() const
{
Q_D(const QOpenGLContext);
return d->shareContext;
}
+/*!
+ Returns the screen the context was created for.
+*/
QScreen *QOpenGLContext::screen() const
{
Q_D(const QOpenGLContext);
return d->screen;
}
-/*
- internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
- have any type information.
+/*!
+ internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
+ have any type information.
+
+ \internal
*/
void *QOpenGLContext::qGLContextHandle() const
{
@@ -435,6 +596,9 @@ void *QOpenGLContext::qGLContextHandle() const
return d->qGLContextHandle;
}
+/*!
+ \internal
+*/
void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))
{
Q_D(QOpenGLContext);
@@ -442,6 +606,9 @@ void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFun
d->qGLContextDeleteFunction = qGLContextDeleteFunction;
}
+/*!
+ \internal
+*/
void QOpenGLContext::deleteQGLContext()
{
Q_D(QOpenGLContext);
@@ -452,23 +619,45 @@ void QOpenGLContext::deleteQGLContext()
}
}
+/*!
+ \class QOpenGLContextGroup
+ \brief The QOpenGLContextGroup represents a group of contexts sharing
+ OpenGL resources.
+
+ QOpenGLContextGroup is automatically created and managed by QOpenGLContext
+ instances. Its purpose is to identify all the contexts that are sharing
+ resources.
+
+ \sa QOpenGLContext::shareGroup()
+*/
QOpenGLContextGroup::QOpenGLContextGroup()
: QObject(*new QOpenGLContextGroupPrivate())
{
}
+/*!
+ \internal
+*/
QOpenGLContextGroup::~QOpenGLContextGroup()
{
Q_D(QOpenGLContextGroup);
d->cleanup();
}
+/*!
+ Returns all the QOpenGLContext objects in this share group.
+*/
QList<QOpenGLContext *> QOpenGLContextGroup::shares() const
{
Q_D(const QOpenGLContextGroup);
return d->m_shares;
}
+/*!
+ Returns the QOpenGLContextGroup corresponding to the current context.
+
+ \sa QOpenGLContext::currentContext()
+*/
QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup()
{
QOpenGLContext *current = QOpenGLContext::currentContext();
@@ -544,9 +733,10 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)
\class QOpenGLSharedResource
\internal
\since 5.0
- \brief The QOpenGLSharedResource class is used to keep track of resources that
- are shared between OpenGL contexts (like textures, framebuffer objects, shader
- programs, etc), and clean them up in a safe way when they're no longer needed.
+ \brief The QOpenGLSharedResource class is used to keep track of resources
+ that are shared between OpenGL contexts (like textures, framebuffer
+ objects, shader programs, etc), and clean them up in a safe way when
+ they're no longer needed.
The QOpenGLSharedResource instance should never be deleted, instead free()
should be called when it's no longer needed. Thus it will be put on a queue
@@ -556,11 +746,11 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)
The sub-class needs to implement two pure virtual functions. The first,
freeResource() must be implemented to actually do the freeing, for example
call glDeleteTextures() on a texture id. Qt makes sure a valid context in
- the resource's share group is current at the time. The other, invalidateResource(),
- is called by Qt in the circumstance when the last context in the share group is
- destroyed before free() has been called. The implementation of invalidateResource()
- should set any identifiers to 0 or set a flag to prevent them from being used
- later on.
+ the resource's share group is current at the time. The other,
+ invalidateResource(), is called by Qt in the circumstance when the last
+ context in the share group is destroyed before free() has been called. The
+ implementation of invalidateResource() should set any identifiers to 0 or
+ set a flag to prevent them from being used later on.
*/
QOpenGLSharedResource::QOpenGLSharedResource(QOpenGLContextGroup *group)
: m_group(group)
@@ -616,9 +806,9 @@ void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context)
\since 5.0
\brief The QOpenGLMultiGroupSharedResource keeps track of a shared resource
that might be needed from multiple contexts, like a glyph cache or gradient
- cache. One instance of the object is created for each group when
- necessary. The shared resource instance should have a constructor that
- takes a QOpenGLContext *. To get an instance for a given context one calls
+ cache. One instance of the object is created for each group when necessary.
+ The shared resource instance should have a constructor that takes a
+ QOpenGLContext *. To get an instance for a given context one calls
T *QOpenGLMultiGroupSharedResource::value<T>(context), where T is a sub-class
of QOpenGLSharedResource.
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
index 9e0c60b3f6..bc08a73a7f 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.cpp
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -96,6 +96,8 @@ void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
//we know its clipboard
Q_UNUSED(mode);
q_clipboardData()->setSource(data);
+
+ emitChanged(mode);
}
bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
diff --git a/src/gui/kernel/qplatforminputcontext_qpa.h b/src/gui/kernel/qplatforminputcontext_qpa.h
index 77c3811d95..c7d823d662 100644
--- a/src/gui/kernel/qplatforminputcontext_qpa.h
+++ b/src/gui/kernel/qplatforminputcontext_qpa.h
@@ -64,7 +64,7 @@ public:
virtual void reset();
virtual void commit();
virtual void update(Qt::InputMethodQueries);
- virtual void invokeAction(QInputPanel::Action, int cursorPosition);
+ virtual void invokeAction(QInputMethod::Action, int cursorPosition);
virtual bool filterEvent(const QEvent *event);
virtual QRectF keyboardRect() const;
void emitKeyboardRectChanged();
diff --git a/src/gui/kernel/qplatformtheme_qpa.cpp b/src/gui/kernel/qplatformtheme_qpa.cpp
index aec465f0ff..3f6b69b902 100644
--- a/src/gui/kernel/qplatformtheme_qpa.cpp
+++ b/src/gui/kernel/qplatformtheme_qpa.cpp
@@ -84,6 +84,20 @@ QT_BEGIN_NAMESPACE
\value StyleNames (QStringList) A list of preferred style names.
+ \value WindowAutoPlacement (bool) A boolean value indicating whether Windows
+ (particularly dialogs) are placed by the system
+ (see _NET_WM_FULL_PLACEMENT in X11).
+
+ \value DialogButtonBoxLayout (int) An integer representing a
+ QDialogButtonBox::ButtonLayout value.
+
+ \value DialogButtonBoxButtonsHaveIcons (bool) A boolean value indicating whether
+ the buttons of a QDialogButtonBox should have icons.
+
+ \value UseFullScreenForPopupMenu (bool) Pop menus can cover the full screen including task bar.
+
+ \value KeyboardScheme (int) An integer value (enum KeyboardSchemes) specifying the
+ keyboard scheme.
\sa themeHint(), QStyle::pixelMetric()
*/
@@ -121,6 +135,14 @@ const QPalette *QPlatformTheme::palette(Palette type) const
QVariant QPlatformTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::UseFullScreenForPopupMenu:
+ return QVariant(false);
+ case QPlatformTheme::WindowAutoPlacement:
+ return QVariant(false);
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(int(0));
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(false);
case QPlatformTheme::ItemViewActivateItemOnSingleClick:
return QVariant(false);
case QPlatformTheme::ToolButtonStyle:
@@ -140,6 +162,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QVariant(false);
case MaximumScrollBarDragDistance:
return QVariant(-1);
+ case KeyboardScheme:
+ return QVariant(int(WindowsKeyboardScheme));
}
return QVariant();
}
diff --git a/src/gui/kernel/qplatformtheme_qpa.h b/src/gui/kernel/qplatformtheme_qpa.h
index 036432054e..31a52a9391 100644
--- a/src/gui/kernel/qplatformtheme_qpa.h
+++ b/src/gui/kernel/qplatformtheme_qpa.h
@@ -69,7 +69,12 @@ public:
SystemIconThemeName,
SystemIconFallbackThemeName,
IconThemeSearchPaths,
- StyleNames
+ StyleNames,
+ WindowAutoPlacement,
+ DialogButtonBoxLayout,
+ DialogButtonBoxButtonsHaveIcons,
+ UseFullScreenForPopupMenu,
+ KeyboardScheme
};
enum DialogType {
@@ -84,6 +89,16 @@ public:
NPalettes
};
+ enum KeyboardSchemes
+ {
+ WindowsKeyboardScheme,
+ MacKeyboardScheme,
+ X11KeyboardScheme,
+ KdeKeyboardScheme,
+ GnomeKeyboardScheme,
+ CdeKeyboardScheme
+ };
+
virtual QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const;
virtual QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const;
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index b97852dc1d..9021d82e20 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -106,10 +106,86 @@ public:
int minor;
};
+/*!
+ \class QSurfaceFormat
+ \brief The QSurfaceFormat class represents the format of a QSurface.
+
+ The format includes the size of the color buffers, red, green, and blue;
+ the size of the alpha buffer; the size of the depth and stencil buffers;
+ and number of samples per pixel for multisampling. In addition, the format
+ contains surface configuration parameters such as OpenGL profile and
+ version for rendering, whether or not enable stereo buffers, and swap
+ behaviour.
+*/
+
+/*!
+ \enum QSurfaceFormat::FormatOption
+
+ This enum contains format options for use with QSurfaceFormat.
+
+ \value StereoBuffers Used to request stereo buffers in the surface format.
+ \value DebugContext Used to request a debug context with extra debugging information.
+ This requires OpenGL version 3.0 or higher.
+ \value DeprecatedFunctions Used to request that deprecated functions be included
+ in the OpenGL context profile. If not specified, you should get a forward compatible context
+ without support functionality marked as deprecated. This requires OpenGL version 3.0 or higher.
+*/
+
+/*!
+ \enum QSurfaceFormat::SwapBehavior
+
+ This enum is used by QSurfaceFormat to specify the swap behaviour of a surface. The swap behaviour
+ is mostly transparent to the application, but it affects factors such as rendering latency and
+ throughput.
+
+ \value DefaultSwapBehavior The default, unspecified swap behaviour of the platform.
+ \value SingleBuffer Used to request single buffering, which might result in flickering
+ when OpenGL rendering is done directly to screen without an intermediate offscreen
+ buffer.
+ \value DoubleBuffer This is typically the default swap behaviour on desktop platforms,
+ consisting of one back buffer and one front buffer. Rendering is done to the back
+ buffer, and then the back buffer and front buffer are swapped, or the contents of
+ the back buffer are copied to the front buffer, depending on the implementation.
+ \value TripleBuffer This swap behaviour is sometimes used in order to decrease the
+ risk of skipping a frame when the rendering rate is just barely keeping up with
+ the screen refresh rate. Depending on the platform it might also lead to slightly
+ more efficient use of the GPU due to improved pipelining behaviour. Triple buffering
+ comes at the cost of an extra frame of memory usage and latency, and might not be
+ supported depending on the underlying platform.
+*/
+
+/*!
+ \enum QSurfaceFormat::OpenGLContextProfile
+
+ This enum is used to specify the OpenGL context profile, in
+ conjunction with QSurfaceFormat::setMajorVersion() and
+ QSurfaceFormat::setMinorVersion().
+
+ Profiles are exposed in OpenGL 3.2 and above, and are used
+ to choose between a restricted core profile, and a compatibility
+ profile which might contain deprecated support functionality.
+
+ Note that the core profile might still contain functionality that
+ is deprecated and scheduled for removal in a higher version. To
+ get access to the deprecated functionality for the core profile
+ in the set OpenGL version you can use the QSurfaceFormat format option
+ QSurfaceFormat::DeprecatedFunctions.
+
+ \value NoProfile OpenGL version is lower than 3.2.
+ \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available.
+ \value CompatibilityProfile Functionality from earlier OpenGL versions is available.
+*/
+
+/*!
+ Constructs a default initialized QSurfaceFormat.
+*/
QSurfaceFormat::QSurfaceFormat() : d(new QSurfaceFormatPrivate)
{
}
+/*!
+ Constructs a QSurfaceFormat with the given format \a options.
+*/
QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
d(new QSurfaceFormatPrivate(options))
{
@@ -131,7 +207,6 @@ void QSurfaceFormat::detach()
/*!
Constructs a copy of \a other.
*/
-
QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other)
{
d = other.d;
@@ -141,7 +216,6 @@ QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other)
/*!
Assigns \a other to this object.
*/
-
QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other)
{
if (d != other.d) {
@@ -182,7 +256,6 @@ QSurfaceFormat::~QSurfaceFormat()
\sa stereo()
*/
-
void QSurfaceFormat::setStereo(bool enable)
{
QSurfaceFormat::FormatOptions newOptions = d->opts;
@@ -199,8 +272,7 @@ void QSurfaceFormat::setStereo(bool enable)
/*!
Returns the number of samples per pixel when multisampling is
- enabled. By default, the highest number of samples that is
- available is used.
+ enabled. By default, multisampling is disabled.
\sa setSampleBuffers(), sampleBuffers(), setSamples()
*/
@@ -211,8 +283,7 @@ int QSurfaceFormat::samples() const
/*!
Set the preferred number of samples per pixel when multisampling
- is enabled to \a numSamples. By default, the highest number of
- samples available is used.
+ is enabled to \a numSamples. By default, multisampling is disabled.
\sa setSampleBuffers(), sampleBuffers(), samples()
*/
@@ -229,7 +300,6 @@ void QSurfaceFormat::setSamples(int numSamples)
\sa testOption()
*/
-
void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt)
{
const QSurfaceFormat::FormatOptions newOptions = d->opts | opt;
@@ -244,7 +314,6 @@ void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt)
\sa setOption()
*/
-
bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const
{
return d->opts & opt;
@@ -273,6 +342,13 @@ int QSurfaceFormat::depthBufferSize() const
return d->depthSize;
}
+/*!
+ Set the swap behaviour of the surface.
+
+ The swap behaviour specifies whether single, double, or triple
+ buffering is desired. The default, SwapBehavior::DefaultSwapBehavior,
+ gives the default swap behavior of the platform.
+*/
void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
{
if (d->swapBehavior != behavior) {
@@ -281,19 +357,29 @@ void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior)
}
}
+/*!
+ Returns the configured swap behaviour.
+ \sa setSwapBehavior()
+*/
QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const
{
return d->swapBehavior;
}
+/*!
+ Returns true if the alpha buffer size is greater than zero.
+
+ This means that the surface might be used with per pixel
+ translucency effects.
+*/
bool QSurfaceFormat::hasAlpha() const
{
return d->alphaBufferSize > 0;
}
/*!
- Set the preferred stencil buffer size to \a size.
+ Set the preferred stencil buffer size to \a size bits.
\sa stencilBufferSize(), setStencil(), stencil()
*/
@@ -306,7 +392,7 @@ void QSurfaceFormat::setStencilBufferSize(int size)
}
/*!
- Returns the stencil buffer size.
+ Returns the stencil buffer size in bits.
\sa stencil(), setStencil(), setStencilBufferSize()
*/
@@ -315,26 +401,41 @@ int QSurfaceFormat::stencilBufferSize() const
return d->stencilSize;
}
+/*!
+ Get the size in bits of the red channel of the color buffer.
+*/
int QSurfaceFormat::redBufferSize() const
{
return d->redBufferSize;
}
+/*!
+ Get the size in bits of the green channel of the color buffer.
+*/
int QSurfaceFormat::greenBufferSize() const
{
return d->greenBufferSize;
}
+/*!
+ Get the size in bits of the blue channel of the color buffer.
+*/
int QSurfaceFormat::blueBufferSize() const
{
return d->blueBufferSize;
}
+/*!
+ Get the size in bits of the alpha channel of the color buffer.
+*/
int QSurfaceFormat::alphaBufferSize() const
{
return d->alphaBufferSize;
}
+/*!
+ Set the desired size in bits of the red channel of the color buffer.
+*/
void QSurfaceFormat::setRedBufferSize(int size)
{
if (d->redBufferSize != size) {
@@ -343,6 +444,9 @@ void QSurfaceFormat::setRedBufferSize(int size)
}
}
+/*!
+ Set the desired size in bits of the green channel of the color buffer.
+*/
void QSurfaceFormat::setGreenBufferSize(int size)
{
if (d->greenBufferSize != size) {
@@ -351,6 +455,9 @@ void QSurfaceFormat::setGreenBufferSize(int size)
}
}
+/*!
+ Set the desired size in bits of the blue channel of the color buffer.
+*/
void QSurfaceFormat::setBlueBufferSize(int size)
{
if (d->blueBufferSize != size) {
@@ -359,6 +466,9 @@ void QSurfaceFormat::setBlueBufferSize(int size)
}
}
+/*!
+ Set the desired size in bits of the alpha channel of the color buffer.
+*/
void QSurfaceFormat::setAlphaBufferSize(int size)
{
if (d->alphaBufferSize != size) {
@@ -368,10 +478,10 @@ void QSurfaceFormat::setAlphaBufferSize(int size)
}
/*!
- Sets the desired OpenGL context profile.
+ Sets the desired OpenGL context profile.
- This setting is ignored if the requested OpenGL version is
- less than 3.2.
+ This setting is ignored if the requested OpenGL version is
+ less than 3.2.
*/
void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
{
@@ -381,6 +491,12 @@ void QSurfaceFormat::setProfile(OpenGLContextProfile profile)
}
}
+/*!
+ Get the configured OpenGL context profile.
+
+ This setting is ignored if the requested OpenGL version is
+ less than 3.2.
+*/
QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile() const
{
return d->profile;
@@ -428,6 +544,12 @@ int QSurfaceFormat::minorVersion() const
return d->minor;
}
+/*!
+ Returns true if all the options of the two QSurfaceFormat objects
+ are equal.
+
+ \relates QSurfaceFormat
+*/
bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b)
{
return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
@@ -450,7 +572,6 @@ bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b)
\relates QSurfaceFormat
*/
-
bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b)
{
return !(a == b);
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 9c6b6c4bf7..04c2617838 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -63,15 +63,17 @@ QT_BEGIN_NAMESPACE
/*!
\class QWindow
- \brief The QWindow class encapsulates an independent window in a Windowing System.
+ \brief The QWindow class represents a window in the underlying windowing system.
- A window that is supplied a parent become a native child window of
+ A window that is supplied a parent becomes a native child window of
their parent window.
+ \section1 Resource management
+
Windows can potentially use a lot of memory. A usual measurement is
- width * height * depth. A window might also include multiple buffers
- to support double and triple buffering. To release a windows memory
- resources, the destroy() function.
+ width times height times color depth. A window might also include multiple
+ buffers to support double and triple buffering, as well as depth and stencil
+ buffers. To release a window's memory resources, the destroy() function.
\section1 Window and content orientation
@@ -90,6 +92,29 @@ QT_BEGIN_NAMESPACE
the contents instead, especially when doing rotation animations
between different orientations. The windowing system might use this
value to determine the layout of system popups or dialogs.
+
+ \section1 Visibility and Windowing system exposure.
+
+ By default, the window is not visible, and you must call setVisible(true),
+ or show() or similar to make it visible. To make a window hidden again,
+ call setVisible(false) or hide(). The visible property describes the state
+ the application wants the window to be in. Depending on the underlying
+ system, a visible window might still not be shown on the screen. It could,
+ for instance, be covered by other opaque windows or moved outside the
+ physical area of the screen. On windowing systems that have exposure
+ notifications, the isExposed() accessor describes whether the window should
+ be treated as directly visible on screen. The exposeEvent() function is
+ called whenever the windows exposure in the windowing system changes. On
+ windowing systems that do not make this information visible to the
+ application, isExposed() will simply return the same value as isVisible().
+*/
+
+/*!
+ Creates a window as a top level on the given screen.
+
+ The window is not shown until setVisible(true), show(), or similar is called.
+
+ \sa setScreen()
*/
QWindow::QWindow(QScreen *targetScreen)
: QObject(*new QWindowPrivate(), 0)
@@ -108,6 +133,15 @@ QWindow::QWindow(QScreen *targetScreen)
QGuiApplicationPrivate::window_list.prepend(this);
}
+/*!
+ Creates a window as a child of the given \a parent window.
+
+ The window will be embedded inside the parent window, its coordinates relative to the parent.
+
+ The screen is inherited from the parent.
+
+ \sa setParent()
+*/
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate(), parent)
, QSurface(QSurface::Window)
@@ -134,6 +168,9 @@ QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)
QGuiApplicationPrivate::window_list.prepend(this);
}
+/*!
+ Destroys the window.
+*/
QWindow::~QWindow()
{
if (QGuiApplicationPrivate::focus_window == this)
@@ -146,18 +183,43 @@ QSurface::~QSurface()
{
}
+/*!
+ Set the \a surfaceType of the window.
+
+ Specifies whether the window is meant for raster rendering with
+ QBackingStore, or OpenGL rendering with QOpenGLContext.
+
+ \sa QBackingStore, QOpenGLContext
+*/
void QWindow::setSurfaceType(SurfaceType surfaceType)
{
Q_D(QWindow);
d->surfaceType = surfaceType;
}
+/*!
+ Returns the surface type of the window.
+
+ \sa setSurfaceType()
+*/
QWindow::SurfaceType QWindow::surfaceType() const
{
Q_D(const QWindow);
return d->surfaceType;
}
+/*!
+ \property QWindow::visible
+ \brief whether the window is visible or not
+ \since 5.0
+
+ This property controls the visibility of the window in the windowing system.
+
+ By default, the window is not visible, you must call setVisible(true), or
+ show() or similar to make it visible.
+
+ \sa show()
+*/
void QWindow::setVisible(bool visible)
{
Q_D(QWindow);
@@ -186,7 +248,10 @@ void QWindow::setVisible(bool visible)
}
}
-
+/*!
+ Returns true if the window is set to visible.
+ \obsolete
+*/
bool QWindow::visible() const
{
return isVisible();
@@ -199,6 +264,20 @@ bool QWindow::isVisible() const
return d->visible;
}
+/*!
+ Allocates the platform resources associated with the window.
+
+ It is at this point that the surface format set using setFormat() gets resolved
+ into an actual native surface. However, the window remains hidden until setVisible() is called.
+
+ Note that it is not usually necessary to call this function directly, as it will be implicitly
+ called by show(), setVisible(), and other functions that require access to the platform
+ resources.
+
+ Call destroy() to free the platform resources if necessary.
+
+ \sa destroy()
+*/
void QWindow::create()
{
Q_D(QWindow);
@@ -216,6 +295,14 @@ void QWindow::create()
}
}
+/*!
+ Returns the window's platform id.
+
+ For platforms where this id might be useful, the value returned
+ will uniquely represent the window inside the corresponding screen.
+
+ \sa screen()
+*/
WId QWindow::winId() const
{
Q_D(const QWindow);
@@ -228,16 +315,22 @@ WId QWindow::winId() const
return id;
}
+/*!
+ Returns the parent window, if any.
+
+ A window without a parent is known as a top level window.
+*/
QWindow *QWindow::parent() const
{
Q_D(const QWindow);
return d->parentWindow;
}
-/**
- Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window.
- Setting parent to be 0(NULL) means map it as a top level window. If the parent window has grabbed its window system resources, then the current window will also grab its window system resources.
- **/
+/*!
+ Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window.
+
+ Setting parent to be 0 will make the window become a top level window.
+*/
void QWindow::setParent(QWindow *parent)
{
@@ -257,46 +350,66 @@ void QWindow::setParent(QWindow *parent)
}
/*!
- Returns whether the window is top level, i.e. has no parent window.
- */
+ Returns whether the window is top level, i.e. has no parent window.
+*/
bool QWindow::isTopLevel() const
{
Q_D(const QWindow);
return d->parentWindow == 0;
}
+/*!
+ Returns whether the window is modal.
+
+ A modal window prevents other windows from getting any input.
+*/
bool QWindow::isModal() const
{
Q_D(const QWindow);
return d->modality != Qt::NonModal;
}
+/*!
+ Returns the window's modality.
+
+ \sa setWindowModality()
+*/
Qt::WindowModality QWindow::windowModality() const
{
Q_D(const QWindow);
return d->modality;
}
+/*!
+ Sets the window's modality to \a windowModality.
+*/
void QWindow::setWindowModality(Qt::WindowModality windowModality)
{
Q_D(QWindow);
d->modality = windowModality;
}
+/*!
+ Sets the window's surface \a format.
+
+ The format determines properties such as color depth, alpha,
+ depth and stencil buffer size, etc.
+*/
void QWindow::setFormat(const QSurfaceFormat &format)
{
Q_D(QWindow);
d->requestedFormat = format;
}
-
/*!
Returns the requested surfaceformat of this window.
If the requested format was not supported by the platform implementation,
the requestedFormat will differ from the actual window format.
- \sa format.
+ This is the value set with setFormat().
+
+ \sa setFormat(), format()
*/
QSurfaceFormat QWindow::requestedFormat() const
{
@@ -304,6 +417,15 @@ QSurfaceFormat QWindow::requestedFormat() const
return d->requestedFormat;
}
+/*!
+ Returns the actual format of this window.
+
+ After the window has been created, this function will return the actual surface format
+ of the window. It might differ from the requested format if the requested format could
+ not be fulfilled by the platform.
+
+ \sa create(), requestedFormat()
+*/
QSurfaceFormat QWindow::format() const
{
Q_D(const QWindow);
@@ -312,6 +434,15 @@ QSurfaceFormat QWindow::format() const
return d->requestedFormat;
}
+/*!
+ Sets the window flags of the window to \a flags.
+
+ The window flags control the window's appearance in the windowing system,
+ whether it's a dialog, popup, or a regular window, and whether it should
+ have a title bar, etc.
+
+ \sa windowFlags()
+*/
void QWindow::setWindowFlags(Qt::WindowFlags flags)
{
Q_D(QWindow);
@@ -321,18 +452,46 @@ void QWindow::setWindowFlags(Qt::WindowFlags flags)
d->windowFlags = flags;
}
+/*!
+ Returns the window flags of the window.
+
+ This might differ from the flags set with setWindowFlags() if the
+ requested flags could not be fulfilled.
+
+ \sa setWindowFlags()
+*/
Qt::WindowFlags QWindow::windowFlags() const
{
Q_D(const QWindow);
return d->windowFlags;
}
+/*!
+ Returns the type of the window.
+
+ This returns the part of the window flags that represents
+ whether the window is a dialog, tooltip, popup, regular window, etc.
+
+ \sa windowFlags(), setWindowFlags()
+*/
Qt::WindowType QWindow::windowType() const
{
Q_D(const QWindow);
return static_cast<Qt::WindowType>(int(d->windowFlags & Qt::WindowType_Mask));
}
+/*!
+ \property QWindow::windowTitle
+ \brief the window's title in the windowing system
+ \since 5.0
+
+ The window title might appear in the title area of the window decorations,
+ depending on the windowing system and the window flags. It might also
+ be used by the windowing system to identify the window in other contexts,
+ such as in the task switcher.
+
+ \sa windowFlags()
+*/
void QWindow::setWindowTitle(const QString &title)
{
Q_D(QWindow);
@@ -348,6 +507,11 @@ QString QWindow::windowTitle() const
return d->windowTitle;
}
+/*!
+ Raise the window in the windowing system.
+
+ Requests that the window be raised to appear above other windows.
+*/
void QWindow::raise()
{
Q_D(QWindow);
@@ -356,6 +520,11 @@ void QWindow::raise()
}
}
+/*!
+ Lower the window in the windowing system.
+
+ Requests that the window be lowered to appear below other windows.
+*/
void QWindow::lower()
{
Q_D(QWindow);
@@ -364,6 +533,16 @@ void QWindow::lower()
}
}
+/*!
+ Sets the window's opacity in the windowing system to \a level.
+
+ If the windowing system supports window opacity, this can be used to fade the
+ window in and out, or to make it semitransparent.
+
+ A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below
+ is treated as fully transparent. Values inbetween represent varying levels of
+ translucency between the two extremes.
+*/
void QWindow::setOpacity(qreal level)
{
Q_D(QWindow);
@@ -372,6 +551,11 @@ void QWindow::setOpacity(qreal level)
}
}
+/*!
+ Requests the window to be activated, i.e. receive keyboard focus.
+
+ \sa isActive(), QGuiApplication::focusWindow()
+*/
void QWindow::requestActivateWindow()
{
Q_D(QWindow);
@@ -379,7 +563,6 @@ void QWindow::requestActivateWindow()
d->platformWindow->requestActivateWindow();
}
-
/*!
Returns if this window is exposed in the windowing system.
@@ -388,8 +571,9 @@ void QWindow::requestActivateWindow()
should minimize rendering and other graphical activities.
An exposeEvent() is sent every time this value changes.
- */
+ \sa exposeEvent()
+*/
bool QWindow::isExposed() const
{
Q_D(const QWindow);
@@ -424,22 +608,26 @@ bool QWindow::isActive() const
}
/*!
- Reports that the orientation of the window's contents have changed.
+ \property QWindow::contentOrientation
+ \since 5.0
+ \brief the orientation of the window's contents
+
+ This is a hint to the window manager in case it needs to display
+ additional content like popups, dialogs, status bars, or similar
+ in relation to the window.
- This is a hint to the window manager in case it needs to display
- additional content like popups, dialogs, status bars, or similar
- in relation to the window.
+ The recommended orientation is QScreen::orientation() but
+ an application doesn't have to support all possible orientations,
+ and thus can opt to ignore the current screen orientation.
- The recommended orientation is QScreen::orientation() but
- an application doesn't have to support all possible orientations,
- and thus can opt to ignore the current screen orientation.
+ The difference between the window and the content orientation
+ determines how much to rotate the content by. QScreen::angleBetween(),
+ QScreen::transformBetween(), and QScreen::mapBetween() can be used
+ to compute the necessary transform.
- The difference between the window and the content orientation
- determines how much to rotate the content by. QScreen::angleBetween(),
- QScreen::transformBetween(), and QScreen::mapBetween() can be used
- to compute the necessary transform.
+ The default value is Qt::PrimaryOrientation
- \sa requestWindowOrientation(), QScreen::orientation()
+ \sa requestWindowOrientation(), QScreen::orientation()
*/
void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
{
@@ -454,12 +642,6 @@ void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
emit contentOrientationChanged(orientation);
}
-/*!
- Returns the actual content orientation.
-
- This is the last value set with reportContentOrientationChange(). It defaults
- to Qt::PrimaryOrientation.
-*/
Qt::ScreenOrientation QWindow::contentOrientation() const
{
Q_D(const QWindow);
@@ -506,12 +688,27 @@ Qt::ScreenOrientation QWindow::windowOrientation() const
return d->windowOrientation;
}
+/*!
+ Returns the window state.
+
+ \sa setWindowState()
+*/
Qt::WindowState QWindow::windowState() const
{
Q_D(const QWindow);
return d->windowState;
}
+/*!
+ Sets the desired window \a state.
+
+ The window state represents whether the window appears in the
+ windowing system as maximized, minimized, fullscreen, or normal.
+
+ The enum value Qt::WindowActive is not an accepted parameter.
+
+ \sa windowState(), showNormal(), showFullScreen(), showMinimized(), showMaximized()
+*/
void QWindow::setWindowState(Qt::WindowState state)
{
if (state == Qt::WindowActive) {
@@ -527,7 +724,11 @@ void QWindow::setWindowState(Qt::WindowState state)
}
/*!
- Sets the transient parent, which is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
+ Sets the transient parent
+
+ This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
+
+ \sa transientParent(), parent()
*/
void QWindow::setTransientParent(QWindow *parent)
{
@@ -538,6 +739,11 @@ void QWindow::setTransientParent(QWindow *parent)
d->transientParent = parent;
}
+/*!
+ Returns the transient parent of the window.
+
+ \sa setTransientParent(), parent()
+*/
QWindow *QWindow::transientParent() const
{
Q_D(const QWindow);
@@ -555,8 +761,8 @@ QWindow *QWindow::transientParent() const
*/
/*!
- Returns true if the window is an ancestor of the given child. If mode is
- IncludeTransients transient parents are also considered ancestors.
+ Returns true if the window is an ancestor of the given child. If mode is
+ IncludeTransients transient parents are also considered ancestors.
*/
bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const
{
@@ -567,30 +773,57 @@ bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const
|| (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));
}
+/*!
+ Returns the minimum size of the window.
+
+ \sa setMinimumSize()
+*/
QSize QWindow::minimumSize() const
{
Q_D(const QWindow);
return d->minimumSize;
}
+/*!
+ Returns the maximum size of the window.
+
+ \sa setMaximumSize()
+*/
QSize QWindow::maximumSize() const
{
Q_D(const QWindow);
return d->maximumSize;
}
+/*!
+ Returns the base size of the window.
+
+ \sa setBaseSize()
+*/
QSize QWindow::baseSize() const
{
Q_D(const QWindow);
return d->baseSize;
}
+/*!
+ Returns the size increment of the window.
+
+ \sa setSizeIncrement()
+*/
QSize QWindow::sizeIncrement() const
{
Q_D(const QWindow);
return d->sizeIncrement;
}
+/*!
+ Sets the minimum size of the window.
+
+ This is a hint to the window manager to prevent resizing below the specified \a size.
+
+ \sa setMaximumSize(), minimumSize()
+*/
void QWindow::setMinimumSize(const QSize &size)
{
Q_D(QWindow);
@@ -602,6 +835,13 @@ void QWindow::setMinimumSize(const QSize &size)
d->platformWindow->propagateSizeHints();
}
+/*!
+ Sets the maximum size of the window.
+
+ This is a hint to the window manager to prevent resizing above the specified \a size.
+
+ \sa setMinimumSize(), maximumSize()
+*/
void QWindow::setMaximumSize(const QSize &size)
{
Q_D(QWindow);
@@ -613,6 +853,14 @@ void QWindow::setMaximumSize(const QSize &size)
d->platformWindow->propagateSizeHints();
}
+/*!
+ Sets the base size of the window.
+
+ The base size is used to calculate a proper window size if the
+ window defines sizeIncrement().
+
+ \sa setMinimumSize(), setMaximumSize(), setSizeIncrement(), baseSize()
+*/
void QWindow::setBaseSize(const QSize &size)
{
Q_D(QWindow);
@@ -623,6 +871,20 @@ void QWindow::setBaseSize(const QSize &size)
d->platformWindow->propagateSizeHints();
}
+/*!
+ Sets the size increment of the window.
+
+ When the user resizes the window, the size will move in steps of
+ sizeIncrement().width() pixels horizontally and
+ sizeIncrement().height() pixels vertically, with baseSize() as the
+ basis.
+
+ By default, this property contains a size with zero width and height.
+
+ The windowing system might not support size increments.
+
+ \sa setBaseSize(), setMinimumSize(), setMaximumSize()
+*/
void QWindow::setSizeIncrement(const QSize &size)
{
Q_D(QWindow);
@@ -634,7 +896,12 @@ void QWindow::setSizeIncrement(const QSize &size)
}
/*!
- Sets the geometry of the window excluding its window frame.
+ Sets the geometry of the window, excluding its window frame, to \a rect.
+
+ To make sure the window is visible, make sure the geometry is within
+ the virtual geometry of its screen.
+
+ \sa geometry(), screen(), QScreen::virtualGeometry()
*/
void QWindow::setGeometry(const QRect &rect)
{
@@ -661,7 +928,33 @@ void QWindow::setGeometry(const QRect &rect)
}
/*!
- Returns the geometry of the window excluding its window frame.
+ \property QWindow::x
+ \since 5.0
+ \brief the x position of the window's geometry
+*/
+
+/*!
+ \property QWindow::y
+ \since 5.0
+ \brief the y position of the window's geometry
+*/
+
+/*!
+ \property QWindow::width
+ \since 5.0
+ \brief the width of the window's geometry
+*/
+
+/*!
+ \property QWindow::height
+ \since 5.0
+ \brief the height of the window's geometry
+*/
+
+/*!
+ Returns the geometry of the window, excluding its window frame.
+
+ \sa frameMargins(), frameGeometry()
*/
QRect QWindow::geometry() const
{
@@ -673,6 +966,8 @@ QRect QWindow::geometry() const
/*!
Returns the window frame margins surrounding the window.
+
+ \sa geometry(), frameGeometry()
*/
QMargins QWindow::frameMargins() const
{
@@ -683,7 +978,9 @@ QMargins QWindow::frameMargins() const
}
/*!
- Returns the geometry of the window including its window frame.
+ Returns the geometry of the window, including its window frame.
+
+ \sa geometry(), frameMargins()
*/
QRect QWindow::frameGeometry() const
{
@@ -696,7 +993,11 @@ QRect QWindow::frameGeometry() const
}
/*!
- Returns the top left position of the window including its window frame.
+ Returns the top left position of the window, including its window frame.
+
+ This returns the same value as frameGeometry().topLeft().
+
+ \sa geometry(), frameGeometry()
*/
QPoint QWindow::framePos() const
{
@@ -710,6 +1011,8 @@ QPoint QWindow::framePos() const
/*!
Sets the upper left position of the window including its window frame.
+
+ \sa setGeometry(), frameGeometry()
*/
void QWindow::setFramePos(const QPoint &point)
{
@@ -722,6 +1025,11 @@ void QWindow::setFramePos(const QPoint &point)
}
}
+/*!
+ Sets the size of the window to be \a newSize.
+
+ \sa setGeometry()
+*/
void QWindow::resize(const QSize &newSize)
{
Q_D(QWindow);
@@ -732,18 +1040,23 @@ void QWindow::resize(const QSize &newSize)
}
}
+/*!
+ Sets the window icon to the given \a icon image.
+
+ The window icon might be used by the windowing system for example to decorate the window,
+ or in the task switcher.
+*/
void QWindow::setWindowIcon(const QImage &icon) const
{
Q_UNUSED(icon);
qDebug() << "unimplemented:" << __FILE__ << __LINE__;
}
-
-
/*!
Releases the native platform resources associated with this window.
- */
+ \sa create()
+*/
void QWindow::destroy()
{
Q_D(QWindow);
@@ -761,18 +1074,37 @@ void QWindow::destroy()
d->platformWindow = 0;
}
+/*!
+ Returns the platform window corresponding to the window.
+
+ \internal
+*/
QPlatformWindow *QWindow::handle() const
{
Q_D(const QWindow);
return d->platformWindow;
}
+/*!
+ Returns the platform surface corresponding to the window.
+
+ \internal
+*/
QPlatformSurface *QWindow::surfaceHandle() const
{
Q_D(const QWindow);
return d->platformWindow;
}
+/*!
+ Set whether keyboard grab should be enabled or not.
+
+ If the return value is true, the window receives all key events until setKeyboardGrabEnabled(false) is
+ called; other windows get no key events at all. Mouse events are not affected.
+ Use setMouseGrabEnabled() if you want to grab that.
+
+ \sa setMouseGrabEnabled()
+*/
bool QWindow::setKeyboardGrabEnabled(bool grab)
{
Q_D(QWindow);
@@ -781,6 +1113,15 @@ bool QWindow::setKeyboardGrabEnabled(bool grab)
return false;
}
+/*!
+ Sets whether mouse grab should be enabled or not.
+
+ If the return value is true, the window receives all mouse events until setMouseGrabEnabled(false) is
+ called; other windows get no mouse events at all. Keyboard events are not affected.
+ Use setKeyboardGrabEnabled() if you want to grab that.
+
+ \sa setKeyboardGrabEnabled()
+*/
bool QWindow::setMouseGrabEnabled(bool grab)
{
Q_D(QWindow);
@@ -789,12 +1130,30 @@ bool QWindow::setMouseGrabEnabled(bool grab)
return false;
}
+/*!
+ Returns the screen on which the window is shown.
+
+ The value returned will not change when the window is moved
+ between virtual screens (as returned by QScreen::virtualSiblings()).
+
+ \sa setScreen(), QScreen::virtualSiblings()
+*/
QScreen *QWindow::screen() const
{
Q_D(const QWindow);
return d->screen;
}
+/*!
+ Sets the screen on which the window should be shown.
+
+ If the window has been created, it will be recreated on the new screen.
+
+ Note that if the screen is part of a virtual desktop of multiple screens,
+ the window can appear on any of the screens returned by QScreen::virtualSiblings().
+
+ \sa screen(), QScreen::virtualSiblings()
+*/
void QWindow::setScreen(QScreen *newScreen)
{
Q_D(QWindow);
@@ -833,7 +1192,7 @@ void QWindow::screenDestroyed(QObject *object)
/*!
Returns the accessibility interface for the object that the window represents
- \preliminary
+ \internal
\sa QAccessible
*/
QAccessibleInterface *QWindow::accessibleRoot() const
@@ -849,14 +1208,22 @@ QAccessibleInterface *QWindow::accessibleRoot() const
*/
/*!
- Returns the QObject that will be the final receiver of events tied focus, such
- as key events.
+ Returns the QObject that will be the final receiver of events tied focus, such
+ as key events.
*/
QObject *QWindow::focusObject() const
{
return const_cast<QWindow *>(this);
}
+/*!
+ Shows the window.
+
+ This equivalent to calling showFullScreen() or showNormal(), depending
+ on whether the platform defaults to windows being fullscreen or not.
+
+ \sa showFullScreen(), showNormal(), hide(), QStyleHints::showIsFullScreen()
+*/
void QWindow::show()
{
if (qApp->styleHints()->showIsFullScreen())
@@ -865,23 +1232,54 @@ void QWindow::show()
showNormal();
}
+/*!
+ Hides the window.
+
+ Equivalent to calling setVisible(false).
+
+ \sa show(), setVisible()
+*/
void QWindow::hide()
{
setVisible(false);
}
+/*!
+ Shows the window as minimized.
+
+ Equivalent to calling setWindowState(Qt::WindowMinimized) and then
+ setVisible(true).
+
+ \sa setWindowState(), setVisible()
+*/
void QWindow::showMinimized()
{
setWindowState(Qt::WindowMinimized);
setVisible(true);
}
+/*!
+ Shows the window as maximized.
+
+ Equivalent to calling setWindowState(Qt::WindowMaximized) and then
+ setVisible(true).
+
+ \sa setWindowState(), setVisible()
+*/
void QWindow::showMaximized()
{
setWindowState(Qt::WindowMaximized);
setVisible(true);
}
+/*!
+ Shows the window as fullscreen.
+
+ Equivalent to calling setWindowState(Qt::WindowFullScreen) and then
+ setVisible(true).
+
+ \sa setWindowState(), setVisible()
+*/
void QWindow::showFullScreen()
{
setWindowState(Qt::WindowFullScreen);
@@ -889,12 +1287,28 @@ void QWindow::showFullScreen()
requestActivateWindow();
}
+/*!
+ Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
+
+ Equivalent to calling setWindowState(Qt::WindowNoState) and then
+ setVisible(true).
+
+ \sa setWindowState(), setVisible()
+*/
void QWindow::showNormal()
{
setWindowState(Qt::WindowNoState);
setVisible(true);
}
+/*!
+ Close the window.
+
+ This closes the window, effectively calling destroy(), and
+ potentially quitting the application
+
+ \sa destroy(), QGuiApplication::quitOnLastWindowClosed()
+*/
bool QWindow::close()
{
Q_D(QWindow);
@@ -912,8 +1326,6 @@ bool QWindow::close()
return true;
}
-
-
/*!
The expose event is sent by the window system whenever the window's
exposure on screen changes.
@@ -923,33 +1335,60 @@ bool QWindow::close()
value of isExposed() might change to false. When this happens,
an application should stop its rendering as it is no longer visible
to the user.
- */
+ \sa isExposed()
+*/
void QWindow::exposeEvent(QExposeEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle mouse events.
+*/
void QWindow::moveEvent(QMoveEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle resize events.
+
+ The resize event is called whenever the window is resized in the windowing system,
+ either directly through the windowing system acknowledging a setGeometry() or resize() request,
+ or indirectly through the user resizing the window manually.
+*/
void QWindow::resizeEvent(QResizeEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle show events.
+
+ The show event is called when the window becomes visible in the windowing system.
+*/
void QWindow::showEvent(QShowEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle show events.
+
+ The show event is called when the window becomes hidden in the windowing system.
+*/
void QWindow::hideEvent(QHideEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle any event sent to the window.
+
+ Remembet to call the base class version if you wish for mouse events,
+ key events, resize events, etc to be dispatched as usual.
+*/
bool QWindow::event(QEvent *ev)
{
switch (ev->type()) {
@@ -1032,58 +1471,111 @@ bool QWindow::event(QEvent *ev)
return true;
}
+/*!
+ Override this to handle key press events.
+
+ \sa keyReleaseEvent
+*/
void QWindow::keyPressEvent(QKeyEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle key release events.
+
+ \sa keyPressEvent
+*/
void QWindow::keyReleaseEvent(QKeyEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle focus in events.
+
+ Focus in events are sent when the window receives keyboard focus.
+
+ \sa focusOutEvent
+*/
void QWindow::focusInEvent(QFocusEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle focus out events.
+
+ Focus out events are sent when the window loses keyboard focus.
+
+ \sa focusInEvent
+*/
void QWindow::focusOutEvent(QFocusEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle mouse press events.
+
+ \sa mouseReleaseEvent()
+*/
void QWindow::mousePressEvent(QMouseEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle mouse release events.
+
+ \sa mousePressEvent()
+*/
void QWindow::mouseReleaseEvent(QMouseEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle mouse double click events.
+
+ \sa mousePressEvent(), QStyleHints::mouseDoubleClickInterval()
+*/
void QWindow::mouseDoubleClickEvent(QMouseEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle mouse move events.
+*/
void QWindow::mouseMoveEvent(QMouseEvent *ev)
{
ev->ignore();
}
#ifndef QT_NO_WHEELEVENT
+/*!
+ Override this to handle mouse wheel or other wheel events.
+*/
void QWindow::wheelEvent(QWheelEvent *ev)
{
ev->ignore();
}
#endif //QT_NO_WHEELEVENT
+/*!
+ Override this to handle touch events.
+*/
void QWindow::touchEvent(QTouchEvent *ev)
{
ev->ignore();
}
+/*!
+ Override this to handle platform dependent events.
+
+ This might make your application non-portable.
+*/
bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(eventType);
@@ -1101,14 +1593,12 @@ bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *resu
\sa mapFromGlobal()
*/
-
QPoint QWindow::mapToGlobal(const QPoint &pos) const
{
return pos + d_func()->globalPosition();
}
-
/*!
\fn QPoint QWindow::mapFromGlobal(const QPoint &pos) const
@@ -1117,14 +1607,12 @@ QPoint QWindow::mapToGlobal(const QPoint &pos) const
\sa mapToGlobal()
*/
-
QPoint QWindow::mapFromGlobal(const QPoint &pos) const
{
return pos - d_func()->globalPosition();
}
-
Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window)
{
return window->d_func();
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index e6c4454104..40a4ec07a6 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -189,8 +189,53 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local,
void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods)
{
- QWindowSystemInterfacePrivate::WheelEvent *e =
- new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o, mods);
+ QPoint point = (o == Qt::Vertical) ? QPoint(0, d) : QPoint(d, 0);
+ handleWheelEvent(tlw, timestamp, local, global, point, point, mods);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
+{
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
+{
+ // Qt 4 sends two separate wheel events for horizontal and vertical
+ // deltas. For Qt 5 we want to send the deltas in one event, but at the
+ // same time preserve source and behavior compatibility with Qt 4.
+ //
+ // In addition high-resolution pixel-based deltas are also supported.
+ // Platforms that does not support these may pass a null point here.
+ // Angle deltas must always be sent in addition to pixel deltas.
+ QWindowSystemInterfacePrivate::WheelEvent *e;
+
+ if (angleDelta.isNull())
+ return;
+
+ // Simple case: vertical deltas only:
+ if (angleDelta.y() != 0 && angleDelta.x() == 0) {
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ return;
+ }
+
+ // Simple case: horizontal deltas only:
+ if (angleDelta.y() == 0 && angleDelta.x() != 0) {
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ return;
+ }
+
+ // Both horizontal and vertical deltas: Send two wheel events.
+ // The first event contains the Qt 5 pixel and angle delta as points,
+ // and in addition the Qt 4 compatibility vertical angle delta.
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+
+ // The second event contains null pixel and angle points and the
+ // Qt 4 compatibility horizontal angle delta.
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
index 78152a1178..836fb40bd7 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.h
@@ -80,7 +80,10 @@ public:
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
ushort count = 1);
+ static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
+ static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
+ // Wheel event compatibility functions. Will be removed: do not use.
static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
index 661b39da88..f5c141b4c9 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -157,13 +157,15 @@ public:
class WheelEvent : public InputEvent {
public:
- WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, int d,
- Qt::Orientation o, Qt::KeyboardModifiers mods)
- : InputEvent(w, time, Wheel, mods), delta(d), localPos(local), globalPos(global), orient(o) { }
- int delta;
+ WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O,
+ Qt::KeyboardModifiers mods)
+ : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global) { }
+ QPoint pixelDelta;
+ QPoint angleDelta;
+ int qt4Delta;
+ Qt::Orientation qt4Orientation;
QPointF localPos;
QPointF globalPos;
- Qt::Orientation orient;
};
class KeyEvent : public InputEvent {
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index f39dc12239..290fcb287e 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -42,6 +42,7 @@
#include "qopengl_p.h"
#include "qopenglcontext.h"
+#include "qopenglfunctions.h"
QT_BEGIN_NAMESPACE
@@ -50,7 +51,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher(const char *str)
init(str);
}
-typedef GLubyte * (*qt_glGetStringi)(GLenum, GLuint);
+typedef const GLubyte * (QOPENGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint);
#ifndef GL_NUM_EXTENSIONS
#define GL_NUM_EXTENSIONS 0x821D
diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp
index e6879a9e60..f47f71c121 100644
--- a/src/gui/opengl/qopenglbuffer.cpp
+++ b/src/gui/opengl/qopenglbuffer.cpp
@@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE
/*!
\class QOpenGLBuffer
- \brief The QOpenGLBuffer class provides functions for creating and managing GL buffer objects.
+ \brief The QOpenGLBuffer class provides functions for creating and managing OpenGL buffer objects.
\since 5.0
\ingroup painting-3D
- Buffer objects are created in the GL server so that the
+ Buffer objects are created in the OpenGL server so that the
client application can avoid uploading vertices, indices,
texture image data, etc every time they are needed.
QOpenGLBuffer objects can be copied around as a reference to the
- underlying GL buffer object:
+ underlying OpenGL buffer object:
\code
QOpenGLBuffer buffer1(QOpenGLBuffer::IndexBuffer);
@@ -74,16 +74,16 @@ QT_BEGIN_NAMESPACE
/*!
\enum QOpenGLBuffer::Type
- This enum defines the type of GL buffer object to create with QOpenGLBuffer.
+ This enum defines the type of OpenGL buffer object to create with QOpenGLBuffer.
\value VertexBuffer Vertex buffer object for use when specifying
vertex arrays.
\value IndexBuffer Index buffer object for use with \c{glDrawElements()}.
\value PixelPackBuffer Pixel pack buffer object for reading pixel
- data from the GL server (for example, with \c{glReadPixels()}).
+ data from the OpenGL server (for example, with \c{glReadPixels()}).
Not supported under OpenGL/ES.
\value PixelUnpackBuffer Pixel unpack buffer object for writing pixel
- data to the GL server (for example, with \c{glTexImage2D()}).
+ data to the OpenGL server (for example, with \c{glTexImage2D()}).
Not supported under OpenGL/ES.
*/
@@ -95,26 +95,26 @@ QT_BEGIN_NAMESPACE
for drawing operations. Under OpenGL/ES 1.1 this is identical
to StaticDraw.
\value StreamRead The data will be set once and used a few times
- for reading data back from the GL server. Not supported
+ for reading data back from the OpenGL server. Not supported
under OpenGL/ES.
\value StreamCopy The data will be set once and used a few times
- for reading data back from the GL server for use in further
+ for reading data back from the OpenGL server for use in further
drawing operations. Not supported under OpenGL/ES.
\value StaticDraw The data will be set once and used many times
for drawing operations.
\value StaticRead The data will be set once and used many times
- for reading data back from the GL server. Not supported
+ for reading data back from the OpenGL server. Not supported
under OpenGL/ES.
\value StaticCopy The data will be set once and used many times
- for reading data back from the GL server for use in further
+ for reading data back from the OpenGL server for use in further
drawing operations. Not supported under OpenGL/ES.
\value DynamicDraw The data will be modified repeatedly and used
many times for drawing operations.
\value DynamicRead The data will be modified repeatedly and used
- many times for reading data back from the GL server.
+ many times for reading data back from the OpenGL server.
Not supported under OpenGL/ES.
\value DynamicCopy The data will be modified repeatedly and used
- many times for reading data back from the GL server for
+ many times for reading data back from the OpenGL server for
use in further drawing operations. Not supported under OpenGL/ES.
*/
@@ -152,7 +152,7 @@ public:
Constructs a new buffer object of type QOpenGLBuffer::VertexBuffer.
Note: this constructor just creates the QOpenGLBuffer instance. The actual
- buffer object in the GL server is not created until create() is called.
+ buffer object in the OpenGL server is not created until create() is called.
\sa create()
*/
@@ -165,7 +165,7 @@ QOpenGLBuffer::QOpenGLBuffer()
Constructs a new buffer object of \a type.
Note: this constructor just creates the QOpenGLBuffer instance. The actual
- buffer object in the GL server is not created until create() is called.
+ buffer object in the OpenGL server is not created until create() is called.
\sa create()
*/
@@ -188,7 +188,7 @@ QOpenGLBuffer::QOpenGLBuffer(const QOpenGLBuffer &other)
/*!
Destroys this buffer object, including the storage being
- used in the GL server.
+ used in the OpenGL server.
*/
QOpenGLBuffer::~QOpenGLBuffer()
{
@@ -256,14 +256,14 @@ namespace {
}
/*!
- Creates the buffer object in the GL server. Returns true if
+ Creates the buffer object in the OpenGL server. Returns true if
the object was created; false otherwise.
This function must be called with a current QOpenGLContext.
The buffer will be bound to and can only be used in
that context (or any other context that is shared with it).
- This function will return false if the GL implementation
+ This function will return false if the OpenGL implementation
does not support buffers, or there is no current QOpenGLContext.
\sa isCreated(), allocate(), write(), destroy()
@@ -303,7 +303,7 @@ bool QOpenGLBuffer::isCreated() const
/*!
Destroys this buffer object, including the storage being
- used in the GL server. All references to the buffer will
+ used in the OpenGL server. All references to the buffer will
become invalid.
*/
void QOpenGLBuffer::destroy()
@@ -398,8 +398,8 @@ void QOpenGLBuffer::allocate(const void *data, int count)
/*!
Binds the buffer associated with this object to the current
- GL context. Returns false if binding was not possible, usually because
- type() is not supported on this GL implementation.
+ OpenGL context. Returns false if binding was not possible, usually because
+ type() is not supported on this OpenGL implementation.
The buffer must be bound to the same QOpenGLContext current when create()
was called, or to another QOpenGLContext that is sharing with it.
@@ -431,7 +431,7 @@ bool QOpenGLBuffer::bind()
/*!
Releases the buffer associated with this object from the
- current GL context.
+ current OpenGL context.
This function must be called with the same QOpenGLContext current
as when bind() was called on the buffer.
@@ -470,7 +470,7 @@ void QOpenGLBuffer::release(QOpenGLBuffer::Type type)
}
/*!
- Returns the GL identifier associated with this buffer; zero if
+ Returns the OpenGL identifier associated with this buffer; zero if
the buffer has not been created.
\sa isCreated()
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 0eb264b2d9..a523cd2cf1 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
{ \
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) { \
- qDebug("[%s line %d] GL Error: %d", \
+ qDebug("[%s line %d] OpenGL Error: %d", \
__FILE__, __LINE__, (int)err); \
} \
}
@@ -649,13 +649,13 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer
object, defined by the \c{GL_EXT_framebuffer_object} extension. In
addition it provides a rendering surface that can be painted on
- with a QPainter, rendered to using native GL calls, or both. This
- surface can be bound and used as a regular texture in your own GL
+ with a QPainter, rendered to using native OpenGL calls, or both. This
+ surface can be bound and used as a regular texture in your own OpenGL
drawing code. By default, the QOpenGLFramebufferObject class
- generates a 2D GL texture (using the \c{GL_TEXTURE_2D} target),
+ generates a 2D OpenGL texture (using the \c{GL_TEXTURE_2D} target),
which is used as the internal rendering target.
- \bold{It is important to have a current GL context when creating a
+ \bold{It is important to have a current OpenGL context when creating a
QOpenGLFramebufferObject, otherwise initialization will fail.}
When using a QPainter to paint to a QOpenGLFramebufferObject you should take
@@ -708,11 +708,11 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
/*! \fn QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum target)
- Constructs an OpenGL framebuffer object and binds a 2D GL texture
+ Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture
to the buffer of the size \a size. The texture is bound to the
\c GL_COLOR_ATTACHMENT0 target in the framebuffer object.
- The \a target parameter is used to specify the GL texture
+ The \a target parameter is used to specify the OpenGL texture
target. The default target is \c GL_TEXTURE_2D. Keep in mind that
\c GL_TEXTURE_2D textures must have a power of 2 width and height
(e.g. 256x512), unless you are using OpenGL 2.0 or higher.
@@ -723,7 +723,7 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
The default internal texture format is \c GL_RGBA8 for desktop
OpenGL, and \c GL_RGBA for OpenGL/ES.
- It is important that you have a current GL context set when
+ It is important that you have a current OpenGL context set when
creating the QOpenGLFramebufferObject, otherwise the initialization
will fail.
@@ -739,7 +739,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum tar
/*! \overload
- Constructs an OpenGL framebuffer object and binds a 2D GL texture
+ Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture
to the buffer of the given \a width and \a height.
\sa size(), texture()
@@ -931,7 +931,7 @@ bool QOpenGLFramebufferObject::release()
Returns the texture id for the texture attached as the default
rendering target in this framebuffer object. This texture id can
- be bound as a normal texture in your own GL code.
+ be bound as a normal texture in your own OpenGL code.
If a multisample framebuffer object is used then the value returned
from this function will be invalid.
@@ -1109,7 +1109,7 @@ bool QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()
/*!
\fn GLuint QOpenGLFramebufferObject::handle() const
- Returns the GL framebuffer object handle for this framebuffer
+ Returns the OpenGL framebuffer object handle for this framebuffer
object (returned by the \c{glGenFrameBuffersEXT()} function). This
handle can be used to attach new images or buffers to the
framebuffer. The user is responsible for cleaning up and
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 13f91e2ad8..c2e177c162 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -421,7 +421,7 @@ bool QOpenGLExtensions::hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension ex
}
/*!
- Initializes GL function resolution for the current context.
+ Initializes OpenGL function resolution for the current context.
After calling this function, the QOpenGLFunctions object can only be
used with the current context and other contexts that share with it.
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 118fe63122..32da27a078 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -63,10 +63,10 @@ QT_BEGIN_NAMESPACE
\ingroup painting-3D
When painting to a QOpenGLPaintDevice using QPainter, the state of
- the current GL context will be altered by the paint engine to reflect
- its needs. Applications should not rely upon the GL state being reset
+ the current OpenGL context will be altered by the paint engine to reflect
+ its needs. Applications should not rely upon the OpenGL state being reset
to its original conditions, particularly the current shader program,
- GL viewport, texture units, and drawing modes.
+ OpenGL viewport, texture units, and drawing modes.
*/
class QOpenGLPaintDevicePrivate
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index c8dc370a8b..6850eac59e 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -957,7 +957,6 @@ bool QBrush::operator==(const QBrush &b) const
*/
QDebug operator<<(QDebug dbg, const QBrush &b)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
static const char *BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
@@ -983,11 +982,6 @@ QDebug operator<<(QDebug dbg, const QBrush &b)
dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QBrush to QDebug");
- return dbg;
- Q_UNUSED(b);
-#endif
}
#endif
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 2c95434843..96491918cd 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2399,7 +2399,6 @@ void QColor::invalidate()
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QColor &c)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
if (!c.isValid())
dbg.nospace() << "QColor(Invalid)";
else if (c.spec() == QColor::Rgb)
@@ -2413,11 +2412,6 @@ QDebug operator<<(QDebug dbg, const QColor &c)
dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QColor to QDebug");
- return dbg;
- Q_UNUSED(c);
-#endif
}
#endif
diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h
index d30328b0fa..44772a4bb5 100644
--- a/src/gui/painting/qfixed_p.h
+++ b/src/gui/painting/qfixed_p.h
@@ -60,48 +60,50 @@
QT_BEGIN_NAMESPACE
struct QFixed {
+private:
+ Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation
public:
- QFixed() : val(0) {}
- QFixed(int i) : val(i<<6) {}
- QFixed(long i) : val(i<<6) {}
+ Q_DECL_CONSTEXPR QFixed() : val(0) {}
+ Q_DECL_CONSTEXPR QFixed(int i) : val(i<<6) {}
+ Q_DECL_CONSTEXPR QFixed(long i) : val(i<<6) {}
QFixed &operator=(int i) { val = (i<<6); return *this; }
QFixed &operator=(long i) { val = (i<<6); return *this; }
- static QFixed fromReal(qreal r) { QFixed f; f.val = (int)(r*qreal(64)); return f; }
- static QFixed fromFixed(int fixed) { QFixed f; f.val = fixed; return f; }
+ Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); }
+ Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor
- inline int value() const { return val; }
+ Q_DECL_CONSTEXPR inline int value() const { return val; }
inline void setValue(int value) { val = value; }
- inline int toInt() const { return (((val)+32) & -64)>>6; }
- inline qreal toReal() const { return ((qreal)val)/(qreal)64; }
+ Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; }
+ Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; }
- inline int truncate() const { return val>>6; }
- inline QFixed round() const { QFixed f; f.val = ((val)+32) & -64; return f; }
- inline QFixed floor() const { QFixed f; f.val = (val) & -64; return f; }
- inline QFixed ceil() const { QFixed f; f.val = (val+63) & -64; return f; }
+ Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; }
+ Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); }
+ Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); }
+ Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); }
- inline QFixed operator+(int i) const { QFixed f; f.val = (val + (i<<6)); return f; }
- inline QFixed operator+(uint i) const { QFixed f; f.val = (val + (i<<6)); return f; }
- inline QFixed operator+(const QFixed &other) const { QFixed f; f.val = (val + other.val); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); }
inline QFixed &operator+=(int i) { val += (i<<6); return *this; }
inline QFixed &operator+=(uint i) { val += (i<<6); return *this; }
inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; }
- inline QFixed operator-(int i) const { QFixed f; f.val = (val - (i<<6)); return f; }
- inline QFixed operator-(uint i) const { QFixed f; f.val = (val - (i<<6)); return f; }
- inline QFixed operator-(const QFixed &other) const { QFixed f; f.val = (val - other.val); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); }
inline QFixed &operator-=(int i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; }
- inline QFixed operator-() const { QFixed f; f.val = -val; return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); }
- inline bool operator==(const QFixed &other) const { return val == other.val; }
- inline bool operator!=(const QFixed &other) const { return val != other.val; }
- inline bool operator<(const QFixed &other) const { return val < other.val; }
- inline bool operator>(const QFixed &other) const { return val > other.val; }
- inline bool operator<=(const QFixed &other) const { return val <= other.val; }
- inline bool operator>=(const QFixed &other) const { return val >= other.val; }
- inline bool operator!() const { return !val; }
+ Q_DECL_CONSTEXPR inline bool operator==(const QFixed &other) const { return val == other.val; }
+ Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &other) const { return val != other.val; }
+ Q_DECL_CONSTEXPR inline bool operator<(const QFixed &other) const { return val < other.val; }
+ Q_DECL_CONSTEXPR inline bool operator>(const QFixed &other) const { return val > other.val; }
+ Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &other) const { return val <= other.val; }
+ Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &other) const { return val >= other.val; }
+ Q_DECL_CONSTEXPR inline bool operator!() const { return !val; }
inline QFixed &operator/=(int x) { val /= x; return *this; }
inline QFixed &operator/=(const QFixed &o) {
@@ -120,7 +122,7 @@ public:
}
return *this;
}
- inline QFixed operator/(int d) const { QFixed f; f.val = val/d; return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator/(int d) const { return fromFixed(val/d); }
inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); }
inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; }
inline QFixed &operator*=(int i) { val *= i; return *this; }
@@ -136,50 +138,50 @@ public:
val = neg ? -res : res;
return *this;
}
- inline QFixed operator*(int i) const { QFixed f = *this; return (f *= i); }
- inline QFixed operator*(uint i) const { QFixed f = *this; return (f *= i); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(int i) const { return fromFixed(val * i); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(uint i) const { return fromFixed(val * i); }
inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); }
private:
- QFixed(qreal i) : val((int)(i*qreal(64))) {}
+ Q_DECL_CONSTEXPR QFixed(qreal i) : val((int)(i*qreal(64))) {}
QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; }
- inline QFixed operator+(qreal i) const { QFixed f; f.val = (val + (int)(i*qreal(64))); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); }
inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; }
- inline QFixed operator-(qreal i) const { QFixed f; f.val = (val - (int)(i*qreal(64))); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); }
inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; }
inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; }
- inline QFixed operator/(qreal d) const { QFixed f; f.val = (int)(val/d); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); }
inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; }
- inline QFixed operator*(qreal d) const { QFixed f = *this; return (f *= d); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); }
int val;
};
Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE);
#define QFIXED_MAX (INT_MAX/256)
-inline int qRound(const QFixed &f) { return f.toInt(); }
-inline int qFloor(const QFixed &f) { return f.floor().truncate(); }
-
-inline QFixed operator*(int i, const QFixed &d) { return d*i; }
-inline QFixed operator+(int i, const QFixed &d) { return d+i; }
-inline QFixed operator-(int i, const QFixed &d) { return -(d-i); }
-inline QFixed operator*(uint i, const QFixed &d) { return d*i; }
-inline QFixed operator+(uint i, const QFixed &d) { return d+i; }
-inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }
-// inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }
-
-inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }
-inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }
-inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }
-inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }
-inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }
-inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }
-inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }
-inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }
-inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }
-inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }
-inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }
-inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }
+Q_DECL_CONSTEXPR inline int qRound(const QFixed &f) { return f.toInt(); }
+Q_DECL_CONSTEXPR inline int qFloor(const QFixed &f) { return f.floor().truncate(); }
+
+Q_DECL_CONSTEXPR inline QFixed operator*(int i, const QFixed &d) { return d*i; }
+Q_DECL_CONSTEXPR inline QFixed operator+(int i, const QFixed &d) { return d+i; }
+Q_DECL_CONSTEXPR inline QFixed operator-(int i, const QFixed &d) { return -(d-i); }
+Q_DECL_CONSTEXPR inline QFixed operator*(uint i, const QFixed &d) { return d*i; }
+Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i; }
+Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }
+// Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }
+
+Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }
+Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }
+Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }
+Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }
#ifndef QT_NO_DEBUG_STREAM
inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
@@ -189,29 +191,28 @@ inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
struct QFixedPoint {
QFixed x;
QFixed y;
- inline QFixedPoint() {}
- inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {}
- QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); }
- static QFixedPoint fromPointF(const QPointF &p) {
+ Q_DECL_CONSTEXPR inline QFixedPoint() {}
+ Q_DECL_CONSTEXPR inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {}
+ Q_DECL_CONSTEXPR QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); }
+ Q_DECL_CONSTEXPR static QFixedPoint fromPointF(const QPointF &p) {
return QFixedPoint(QFixed::fromReal(p.x()), QFixed::fromReal(p.y()));
}
};
Q_DECLARE_TYPEINFO(QFixedPoint, Q_PRIMITIVE_TYPE);
-inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2)
+Q_DECL_CONSTEXPR inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2)
{ return QFixedPoint(p1.x - p2.x, p1.y - p2.y); }
-inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2)
+Q_DECL_CONSTEXPR inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2)
{ return QFixedPoint(p1.x + p2.x, p1.y + p2.y); }
struct QFixedSize {
QFixed width;
QFixed height;
- QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); }
- static QFixedSize fromSizeF(const QSizeF &s) {
- QFixedSize size;
- size.width = QFixed::fromReal(s.width());
- size.height = QFixed::fromReal(s.height());
- return size;
+ Q_DECL_CONSTEXPR QFixedSize() {}
+ Q_DECL_CONSTEXPR QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {}
+ Q_DECL_CONSTEXPR QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); }
+ Q_DECL_CONSTEXPR static QFixedSize fromSizeF(const QSizeF &s) {
+ return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height()));
}
};
Q_DECLARE_TYPEINFO(QFixedSize, Q_PRIMITIVE_TYPE);
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index b6966b12c3..8d05eb56ff 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -985,7 +985,6 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPen &p)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
const char *PEN_STYLES[] = {
"NoPen",
"SolidLine",
@@ -1002,11 +1001,6 @@ QDebug operator<<(QDebug dbg, const QPen &p)
<< ',' << p.dashOffset()
<< ',' << p.miterLimit() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPen to QDebug");
- return dbg;
- Q_UNUSED(p);
-#endif
}
#endif
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index 3a4860a559..ee1f7967cb 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -468,17 +468,11 @@ QRect QPolygon::boundingRect() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPolygon &a)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QPolygon(";
for (int i = 0; i < a.count(); ++i)
dbg.nospace() << a.at(i);
dbg.nospace() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPolygon to QDebug");
- return dbg;
- Q_UNUSED(a);
-#endif
}
#endif
@@ -814,17 +808,11 @@ QDataStream &operator>>(QDataStream &s, QPolygonF &a)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPolygonF &a)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QPolygonF(";
for (int i = 0; i < a.count(); ++i)
dbg.nospace() << a.at(i);
dbg.nospace() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPolygonF to QDebug");
- return dbg;
- Q_UNUSED(a);
-#endif
}
#endif
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 7bf2a631ea..86de48b1dc 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -239,7 +239,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn int QAbstractTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
- Returns the cursor postion for the given \a point with the specified
+ Returns the cursor position for the given \a point with the specified
\a accuracy. Returns -1 if no valid cursor position was found.
*/
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 38070458b7..fd01934eae 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1272,11 +1272,9 @@ void ValueExtractor::extractFont()
extractFont(&f, &dummy);
}
-bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
+bool ValueExtractor::extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size)
{
bool hit = false;
-#if 0
- // ### Qt5
for (int i = 0; i < declarations.count(); ++i) {
const Declaration &decl = declarations.at(i);
switch (decl.d->propertyId) {
@@ -1297,7 +1295,6 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
}
hit = true;
}
-#endif
return hit;
}
@@ -1646,30 +1643,27 @@ void Declaration::borderImageValue(QString *image, int *cuts,
*h = *v;
}
-#if 0
-// ### Qt 5
-QIcon Declaration::iconValue() const
+IconValue Declaration::iconValue() const
{
if (d->parsed.isValid())
- return qvariant_cast<QIcon>(d->parsed);
+ return qvariant_cast<IconValue>(d->parsed);
- QIcon icon;
+ IconValue icon;
for (int i = 0; i < d->values.count();) {
const Value &value = d->values.at(i++);
if (value.type != Value::Uri)
break;
- QString uri = value.variant.toString();
- QIcon::Mode mode = QIcon::Normal;
- QIcon::State state = QIcon::Off;
+ IconValue::IconEntry entry;
+ entry.uri = value.variant.toString();
for (int j = 0; j < 2; j++) {
if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) {
switch (d->values.at(i).variant.toInt()) {
- case Value_Disabled: mode = QIcon::Disabled; break;
- case Value_Active: mode = QIcon::Active; break;
- case Value_Selected: mode = QIcon::Selected; break;
- case Value_Normal: mode = QIcon::Normal; break;
- case Value_On: state = QIcon::On; break;
- case Value_Off: state = QIcon::Off; break;
+ case Value_Disabled: entry.mode = IconValue::Disabled; break;
+ case Value_Active: entry.mode = IconValue::Active; break;
+ case Value_Selected: entry.mode = IconValue::Selected; break;
+ case Value_Normal: entry.mode = IconValue::Normal; break;
+ case Value_On: entry.state = IconValue::On; break;
+ case Value_Off: entry.state = IconValue::Off; break;
default: break;
}
++i;
@@ -1677,12 +1671,7 @@ QIcon Declaration::iconValue() const
break;
}
}
-
- // QIcon is soo broken
- if (icon.isNull())
- icon = QIcon(uri);
- else
- icon.addPixmap(uri, mode, state);
+ icon.entries.push_back(entry);
if (i == d->values.count())
break;
@@ -1691,10 +1680,9 @@ QIcon Declaration::iconValue() const
i++;
}
- d->parsed = QVariant::fromValue<QIcon>(icon);
+ d->parsed = QVariant::fromValue<QCss::IconValue>(icon);
return icon;
}
-#endif
///////////////////////////////////////////////////////////////////////////////
// Selector
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index d50b87dcd5..b19fd8326e 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -411,6 +411,22 @@ struct BorderData {
BrushData color;
};
+struct Q_GUI_EXPORT IconValue
+{
+ enum Mode { Normal, Disabled, Active, Selected }; // In sync with QIcon.
+ enum State { On, Off };
+
+ struct Q_GUI_EXPORT IconEntry
+ {
+ IconEntry() : mode(Normal) , state(On) {}
+
+ Mode mode;
+ State state;
+ QString uri;
+ };
+
+ QList<IconEntry> entries;
+};
// 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; }
// 2. QVector<Selector> - x:hover, y:clicked z:checked
@@ -455,7 +471,7 @@ struct Q_GUI_EXPORT Declaration
QSize sizeValue() const;
QRect rectValue() const;
QString uriValue() const;
-// QIcon iconValue() const;
+ IconValue iconValue() const;
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;
};
@@ -582,7 +598,7 @@ struct Q_GUI_EXPORT ValueExtractor
bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
int extractStyleFeatures();
- bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
+ bool extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size);
int lengthValue(const Declaration &decl);
@@ -842,6 +858,7 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE( QCss::BackgroundData )
Q_DECLARE_METATYPE( QCss::LengthData )
Q_DECLARE_METATYPE( QCss::BorderData )
+Q_DECLARE_METATYPE( QCss::IconValue )
#endif // QT_NO_CSSPARSER
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index bc7f4f7ad6..c63f0fede8 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -115,7 +115,20 @@ private:
return;
const int end = start + length;
for (int i = start + 1; i < end; ++i) {
- if ((m_analysis[i] == m_analysis[start])
+ // According to the unicode spec we should be treating characters in the Common script
+ // (punctuation, spaces, etc) as being the same script as the surrounding text for the
+ // purpose of splitting up text. This is important because, for example, a fullstop
+ // (0x2E) can be used to indicate an abbreviation and so must be treated as part of a
+ // word. Thus it must be passed along with the word in languages that have to calculate
+ // word breaks. For example the thai word "ครม." has no word breaks but the word "ครม"
+ // does.
+ // Unfortuntely because we split up the strings for both wordwrapping and for setting
+ // the font and because Japanese and Chinese are also aliases of the script "Common",
+ // doing this would break too many things. So instead we only pass the full stop
+ // along, and nothing else.
+ if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
+ && m_analysis[i].flags == m_analysis[start].flags
+ && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;
@@ -2689,6 +2702,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos);
// the approximate width of each individual element of the ligature
QFixed perItemWidth = glyphWidth / clusterLength;
+ if (perItemWidth <= 0)
+ return si->position + clusterStart;
QFixed left = x > edge ? edge : edge - glyphWidth;
int n = ((x - left) / perItemWidth).floor().toInt();
QFixed dist = x - left - n * perItemWidth;
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index acb8d70d09..224ef9db8f 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -95,9 +95,9 @@
#include "qsslsocket.h"
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
+#endif
QT_BEGIN_NAMESPACE
-#endif
class QSslErrorPrivate
{
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index f62f3c1229..20ad82407c 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -1384,6 +1384,10 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
return errors;
}
+ if (s_loadRootCertsOnDemand) {
+ setDefaultCaCertificates(defaultCaCertificates() + systemCaCertificates());
+ }
+
QList<QSslCertificate> expiredCerts;
foreach (const QSslCertificate &caCertificate, QSslSocket::defaultCaCertificates()) {
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 836e7225be..31d6064e90 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4680,7 +4680,7 @@ QPaintEngine *QGLWidget::paintEngine() const
return qt_qgl_paint_engine();
}
-typedef GLubyte * (*qt_glGetStringi)(GLenum, GLuint);
+typedef const GLubyte * (QGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint);
#ifndef GL_NUM_EXTENSIONS
#define GL_NUM_EXTENSIONS 0x821D
diff --git a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
index 2c896ef2cc..af9bd0a01c 100644
--- a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
+++ b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
@@ -1,5 +1,5 @@
HEADERS += $$PWD/qfontconfigdatabase_p.h \
- fontdatabases/fontconfig/qfontenginemultifontconfig_p.h
+ $$PWD/qfontenginemultifontconfig_p.h
SOURCES += $$PWD/qfontconfigdatabase.cpp \
- fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
+ $$PWD/qfontenginemultifontconfig.cpp
DEFINES -= QT_NO_FONTCONFIG
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index a9f05f6084..257fe9156f 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -89,12 +89,15 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
return QVariant(QString(QStringLiteral("hicolor")));
case QPlatformTheme::IconThemeSearchPaths:
return xdgIconThemePaths();
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
case QPlatformTheme::StyleNames: {
QStringList styleNames;
styleNames << QStringLiteral("Plastique") << QStringLiteral("Windows");
return QVariant(styleNames);
}
- break;
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(X11KeyboardScheme));
default:
break;
}
@@ -229,6 +232,12 @@ static QStringList kdeIconThemeSearchPaths(const QString &kdeHome)
QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::UseFullScreenForPopupMenu:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(2); // QDialogButtonBox::KdeLayout
case QPlatformTheme::ToolButtonStyle:
return QVariant(m_toolButtonStyle);
case QPlatformTheme::ToolBarIconSize:
@@ -241,6 +250,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(kdeIconThemeSearchPaths(m_kdeHome));
case QPlatformTheme::StyleNames:
return QVariant(m_styleNames);
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(KdeKeyboardScheme));
default:
break;
}
@@ -282,6 +293,10 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(3); // QDialogButtonBox::GnomeLayout
case QPlatformTheme::SystemIconThemeName:
case QPlatformTheme::SystemIconFallbackThemeName:
return QVariant(QString(QStringLiteral("gnome")));
@@ -292,6 +307,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
styleNames << QStringLiteral("GTK+") << QStringLiteral("cleanlooks") << QStringLiteral("windows");
return QVariant(styleNames);
}
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(GnomeKeyboardScheme));
default:
break;
}
diff --git a/src/platformsupport/udev/qudevhelper_p.h b/src/platformsupport/udev/qudevhelper_p.h
index e6046ca085..3895da87b6 100644
--- a/src/platformsupport/udev/qudevhelper_p.h
+++ b/src/platformsupport/udev/qudevhelper_p.h
@@ -43,6 +43,7 @@
#define QUDEVHELPER_P_H
#include <QString>
+#include <QObject>
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/udev/qudevicehelper.cpp b/src/platformsupport/udev/qudevicehelper.cpp
new file mode 100644
index 0000000000..bf3ce67b43
--- /dev/null
+++ b/src/platformsupport/udev/qudevicehelper.cpp
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qudevicehelper_p.h"
+
+#include <QStringList>
+#include <QCoreApplication>
+#include <QObject>
+#include <QHash>
+#include <QSocketNotifier>
+
+#include <linux/input.h>
+
+//#define QT_QPA_UDEVICE_HELPER_DEBUG
+
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+#include <QtDebug>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QUDeviceHelper *QUDeviceHelper::createUDeviceHelper(QUDeviceTypes types, QObject *parent)
+{
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "Try to create new UDeviceHelper";
+#endif
+
+ QUDeviceHelper *helper = 0;
+ struct udev *udev;
+
+ udev = udev_new();
+ if (udev) {
+ helper = new QUDeviceHelper(types, udev, parent);
+ } else {
+ qWarning("Failed to get udev library context.");
+ }
+
+ return helper;
+}
+
+QUDeviceHelper::QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent) :
+ QObject(parent),
+ m_udev(udev), m_types(types), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0)
+{
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "New UDeviceHelper created for type" << types;
+#endif
+
+ if (!m_udev)
+ return;
+
+ m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev");
+ if (!m_udevMonitor) {
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning("Unable to create an Udev monitor. No devices can be detected.");
+#endif
+ return;
+ }
+
+ udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, "input", 0);
+ udev_monitor_enable_receiving(m_udevMonitor);
+ m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor);
+
+ m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this);
+ connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(handleUDevNotification()));
+}
+
+QUDeviceHelper::~QUDeviceHelper()
+{
+ if (m_udevMonitor)
+ udev_monitor_unref(m_udevMonitor);
+
+ if (m_udev)
+ udev_unref(m_udev);
+}
+
+QStringList QUDeviceHelper::scanConnectedDevices()
+{
+ QStringList devices;
+
+ if (!m_udev)
+ return devices;
+
+ udev_enumerate *ue = udev_enumerate_new(m_udev);
+ udev_enumerate_add_match_subsystem(ue, "input");
+
+ if (m_types & UDev_Mouse)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_MOUSE", "1");
+ if (m_types & UDev_Touchpad)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHPAD", "1");
+ if (m_types & UDev_Touchscreen)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHSCREEN", "1");
+ if (m_types & UDev_Keyboard)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_KEYBOARD", "1");
+
+ if (udev_enumerate_scan_devices(ue) != 0) {
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "UDeviceHelper scan connected devices for enumeration failed";
+#endif
+ return devices;
+ }
+
+ udev_list_entry *entry;
+ udev_list_entry_foreach (entry, udev_enumerate_get_list_entry(ue)) {
+ const char *syspath = udev_list_entry_get_name(entry);
+ udev_device *udevice = udev_device_new_from_syspath(m_udev, syspath);
+ QString candidate = QString::fromUtf8(udev_device_get_devnode(udevice));
+ if (candidate.startsWith(QLatin1String("/dev/input/event")))
+ devices << candidate;
+
+ udev_device_unref(udevice);
+ }
+ udev_enumerate_unref(ue);
+
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "UDeviceHelper found matching devices" << devices;
+#endif
+
+ return devices;
+}
+
+void QUDeviceHelper::handleUDevNotification()
+{
+ if (!m_udevMonitor)
+ return;
+
+ struct udev_device *dev;
+ QString devNode;
+ QUDeviceTypes types = QFlag(UDev_Unknown);
+
+ dev = udev_monitor_receive_device(m_udevMonitor);
+ if (!dev)
+ goto cleanup;
+
+ const char *action;
+ action = udev_device_get_action(dev);
+ if (!action)
+ goto cleanup;
+
+ const char *str;
+ str = udev_device_get_devnode(dev);
+ if (!str)
+ goto cleanup;
+
+ devNode = QString::fromUtf8(str);
+ if (!devNode.startsWith(QLatin1String("/dev/input/event")))
+ goto cleanup;
+
+ // does not increase the refcount
+ dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", 0);
+ if (!dev)
+ goto cleanup;
+
+ types = checkDeviceType(dev);
+
+ if (types && (qstrcmp(action, "add") == 0))
+ emit deviceDetected(devNode, types);
+
+ if (types && (qstrcmp(action, "remove") == 0))
+ emit deviceRemoved(devNode, types);
+
+cleanup:
+ udev_device_unref(dev);
+}
+
+QUDeviceHelper::QUDeviceTypes QUDeviceHelper::checkDeviceType(udev_device *dev)
+{
+ QUDeviceTypes types = QFlag(UDev_Unknown);
+
+ if ((m_types & UDev_Keyboard) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )) {
+ const char *capabilities_key = udev_device_get_sysattr_value(dev, "capabilities/key");
+ QStringList val = QString::fromUtf8(capabilities_key).split(QString::fromUtf8(" "), QString::SkipEmptyParts);
+ if (!val.isEmpty()) {
+ bool ok;
+ unsigned long long keys = val.last().toULongLong(&ok, 16);
+ if (ok) {
+ // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable.
+ bool test = (keys >> KEY_Q) & 1;
+ if (test)
+ types |= UDev_Keyboard;
+ }
+ }
+ }
+
+ if ((m_types & UDev_Mouse) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0))
+ types |= UDev_Mouse;
+
+ if ((m_types & UDev_Touchpad) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0))
+ types |= UDev_Touchpad;
+
+ if ((m_types & UDev_Touchscreen) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0))
+ types |= UDev_Touchscreen;
+
+ return types;
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/udev/qudevicehelper_p.h b/src/platformsupport/udev/qudevicehelper_p.h
new file mode 100644
index 0000000000..b7544fa6c2
--- /dev/null
+++ b/src/platformsupport/udev/qudevicehelper_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUDEVICEHELPER_H
+#define QUDEVICEHELPER_H
+
+#include <QObject>
+#include <QSocketNotifier>
+
+#include <libudev.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUDeviceHelper : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(QUDeviceType)
+
+public:
+ enum QUDeviceType {
+ UDev_Unknown = 0x00,
+ UDev_Mouse = 0x01,
+ UDev_Touchpad = 0x02,
+ UDev_Touchscreen = 0x04,
+ UDev_Keyboard = 0x08
+ };
+ Q_DECLARE_FLAGS(QUDeviceTypes, QUDeviceType)
+
+ static QUDeviceHelper *createUDeviceHelper(QUDeviceTypes type, QObject *parent);
+ ~QUDeviceHelper();
+
+ QStringList scanConnectedDevices();
+
+signals:
+ void deviceDetected(const QString &deviceNode, QUDeviceTypes types);
+ void deviceRemoved(const QString &deviceNode, QUDeviceTypes types);
+
+private slots:
+ void handleUDevNotification();
+
+private:
+ QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent = 0);
+
+ void startWatching();
+ void stopWatching();
+
+ QUDeviceTypes checkDeviceType(struct udev_device *dev);
+
+ struct udev *m_udev;
+ QUDeviceTypes m_types;
+ struct udev_monitor *m_udevMonitor;
+ int m_udevMonitorFileDescriptor;
+ QSocketNotifier *m_udevSocketNotifier;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QUDeviceHelper::QUDeviceTypes)
+
+QT_END_NAMESPACE
+
+#endif // QUDEVICEHELPER_H
diff --git a/src/platformsupport/udev/udev.pri b/src/platformsupport/udev/udev.pri
index ac3f7df40a..48ad9d36af 100644
--- a/src/platformsupport/udev/udev.pri
+++ b/src/platformsupport/udev/udev.pri
@@ -1,5 +1,5 @@
contains(QT_CONFIG, libudev) {
- HEADERS += $$PWD/qudevhelper_p.h
- SOURCES += $$PWD/qudevhelper.cpp
+ HEADERS += $$PWD/qudevhelper_p.h $$PWD/qudevicehelper_p.h
+ SOURCES += $$PWD/qudevhelper.cpp $$PWD/qudevicehelper.cpp
LIBS += -ludev
}
diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp
index dfa9594d5b..ca8bf816b6 100644
--- a/src/plugins/accessible/widgets/main.cpp
+++ b/src/plugins/accessible/widgets/main.cpp
@@ -61,6 +61,9 @@ QT_BEGIN_NAMESPACE
class AccessibleFactory : public QAccessiblePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json")
+
public:
AccessibleFactory();
@@ -109,7 +112,6 @@ QStringList AccessibleFactory::keys() const
list << QLatin1String("QStatusBar");
list << QLatin1String("QProgressBar");
list << QLatin1String("QMenuBar");
- list << QLatin1String("Q3PopupMenu");
list << QLatin1String("QMenu");
list << QLatin1String("QHeaderView");
list << QLatin1String("QTabBar");
@@ -251,8 +253,6 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
#ifndef QT_NO_MENU
} else if (classname == QLatin1String("QMenu")) {
iface = new QAccessibleMenu(widget);
- } else if (classname == QLatin1String("Q3PopupMenu")) {
- iface = new QAccessibleMenu(widget);
#endif
#ifndef QT_NO_ITEMVIEWS
} else if (classname == QLatin1String("QAbstractItemView")) {
@@ -345,9 +345,9 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
return iface;
}
-Q_EXPORT_STATIC_PLUGIN(AccessibleFactory)
-Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 0fdd4490f7..39d7e03a1b 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -115,7 +115,7 @@ QString QAccessibleButton::text(QAccessible::Text t) const
#ifndef QT_NO_SHORTCUT
QPushButton *pb = qobject_cast<QPushButton*>(object());
if (pb && pb->isDefault())
- str = (QString)QKeySequence(Qt::Key_Enter);
+ str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText);
#endif
if (str.isEmpty())
str = qt_accHotKey(button()->text());
diff --git a/src/plugins/accessible/widgets/widgets.json b/src/plugins/accessible/widgets/widgets.json
new file mode 100644
index 0000000000..fdeb6f2b52
--- /dev/null
+++ b/src/plugins/accessible/widgets/widgets.json
@@ -0,0 +1,52 @@
+{
+ "Keys": [
+ "QLineEdit",
+ "QComboBox",
+ "QAbstractSpinBox",
+ "QSpinBox",
+ "QDoubleSpinBox",
+ "QScrollBar",
+ "QSlider",
+ "QAbstractSlider",
+ "QToolButton",
+ "QCheckBox",
+ "QRadioButton",
+ "QPushButton",
+ "QAbstractButton",
+ "QDialog",
+ "QMessageBox",
+ "QMainWindow",
+ "QLabel",
+ "QLCDNumber",
+ "QGroupBox",
+ "QStatusBar",
+ "QProgressBar",
+ "QMenuBar",
+ "QMenu",
+ "QHeaderView",
+ "QTabBar",
+ "QToolBar",
+ "QWorkspaceChild",
+ "QSizeGrip",
+ "QAbstractItemView",
+ "QWidget",
+ "QSplitter",
+ "QSplitterHandle",
+ "QTextEdit",
+ "QTipLabel",
+ "QFrame",
+ "QStackedWidget",
+ "QToolBox",
+ "QMdiArea",
+ "QMdiSubWindow",
+ "QWorkspace",
+ "QDialogButtonBox",
+ "QDial",
+ "QRubberBand",
+ "QTextBrowser",
+ "QAbstractScrollArea",
+ "QScrollArea",
+ "QCalendarWidget",
+ "QDockWidget",
+ "QAccessibleWidget" ]
+}
diff --git a/src/plugins/bearer/connman/connman.json b/src/plugins/bearer/connman/connman.json
new file mode 100644
index 0000000000..7a80b8c9be
--- /dev/null
+++ b/src/plugins/bearer/connman/connman.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "connman" ]
+}
diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro
index 25243f8e0a..679637b37f 100644
--- a/src/plugins/bearer/connman/connman.pro
+++ b/src/plugins/bearer/connman/connman.pro
@@ -15,6 +15,8 @@ SOURCES += main.cpp \
qconnmanengine.cpp \
../qnetworksession_impl.cpp
+OTHER_FILES += connman.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp
index f612f0ca9f..be934c7282 100644
--- a/src/plugins/bearer/connman/main.cpp
+++ b/src/plugins/bearer/connman/main.cpp
@@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE
class QConnmanEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "connman.json")
+
public:
QConnmanEnginePlugin();
~QConnmanEnginePlugin();
@@ -84,10 +87,9 @@ QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin)
-Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif
#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/corewlan/corewlan.json b/src/plugins/bearer/corewlan/corewlan.json
new file mode 100644
index 0000000000..b43519ea90
--- /dev/null
+++ b/src/plugins/bearer/corewlan/corewlan.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "corewlan" ]
+}
diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro
index 6a214ac340..82a514fb14 100644
--- a/src/plugins/bearer/corewlan/corewlan.pro
+++ b/src/plugins/bearer/corewlan/corewlan.pro
@@ -19,6 +19,8 @@ SOURCES += main.cpp \
OBJECTIVE_SOURCES += qcorewlanengine.mm
+OTHER_FILES += corewlan.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/corewlan/main.cpp b/src/plugins/bearer/corewlan/main.cpp
index 0f5ad2c7fb..f2ba8bd879 100644
--- a/src/plugins/bearer/corewlan/main.cpp
+++ b/src/plugins/bearer/corewlan/main.cpp
@@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE
class QCoreWlanEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "corewlan.json")
+
public:
QCoreWlanEnginePlugin();
~QCoreWlanEnginePlugin();
@@ -80,9 +83,8 @@ QBearerEngine *QCoreWlanEnginePlugin::create(const QString &key) const
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(QCoreWlanEnginePlugin)
-Q_EXPORT_PLUGIN2(qcorewlanbearer, QCoreWlanEnginePlugin)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/generic/generic.json b/src/plugins/bearer/generic/generic.json
new file mode 100644
index 0000000000..e9357f4c72
--- /dev/null
+++ b/src/plugins/bearer/generic/generic.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "generic" ]
+}
diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro
index 4f86c2a38c..e66c5b2c7a 100644
--- a/src/plugins/bearer/generic/generic.pro
+++ b/src/plugins/bearer/generic/generic.pro
@@ -11,6 +11,8 @@ SOURCES += qgenericengine.cpp \
../qnetworksession_impl.cpp \
main.cpp
+OTHER_FILES += generic.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp
index 0311bcbef0..5f5ad7c238 100644
--- a/src/plugins/bearer/generic/main.cpp
+++ b/src/plugins/bearer/generic/main.cpp
@@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE
class QGenericEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "generic.json")
+
public:
QGenericEnginePlugin();
~QGenericEnginePlugin();
@@ -80,9 +83,8 @@ QBearerEngine *QGenericEnginePlugin::create(const QString &key) const
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(QGenericEnginePlugin)
-Q_EXPORT_PLUGIN2(qgenericbearer, QGenericEnginePlugin)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp
index 74129c1d0a..8baa977a9d 100644
--- a/src/plugins/bearer/nativewifi/main.cpp
+++ b/src/plugins/bearer/nativewifi/main.cpp
@@ -92,6 +92,9 @@ static void resolveLibrary()
class QNativeWifiEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nativewifi.json")
+
public:
QNativeWifiEnginePlugin();
~QNativeWifiEnginePlugin();
@@ -135,9 +138,8 @@ QBearerEngine *QNativeWifiEnginePlugin::create(const QString &key) const
return engine;
}
-Q_EXPORT_STATIC_PLUGIN(QNativeWifiEnginePlugin)
-Q_EXPORT_PLUGIN2(qnativewifibearer, QNativeWifiEnginePlugin)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/nativewifi/nativewifi.json b/src/plugins/bearer/nativewifi/nativewifi.json
new file mode 100644
index 0000000000..f3db199150
--- /dev/null
+++ b/src/plugins/bearer/nativewifi/nativewifi.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "nativewifi" ]
+}
diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro
index ec86cc0b93..3124d58ff2 100644
--- a/src/plugins/bearer/nativewifi/nativewifi.pro
+++ b/src/plugins/bearer/nativewifi/nativewifi.pro
@@ -12,6 +12,8 @@ SOURCES += main.cpp \
qnativewifiengine.cpp \
../qnetworksession_impl.cpp
+OTHER_FILES += nativewifi.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp
index 2278d221fd..c8a8a74e46 100644
--- a/src/plugins/bearer/networkmanager/main.cpp
+++ b/src/plugins/bearer/networkmanager/main.cpp
@@ -52,6 +52,9 @@ QT_BEGIN_NAMESPACE
class QNetworkManagerEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "networkmanager.json")
+
public:
QNetworkManagerEnginePlugin();
~QNetworkManagerEnginePlugin();
@@ -86,10 +89,9 @@ QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin)
-Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_DBUS
#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/networkmanager/networkmanager.json b/src/plugins/bearer/networkmanager/networkmanager.json
new file mode 100644
index 0000000000..3d408d5c20
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/networkmanager.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "networkmanager" ]
+}
diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro
index 262f60a69c..c1c6664897 100644
--- a/src/plugins/bearer/networkmanager/networkmanager.pro
+++ b/src/plugins/bearer/networkmanager/networkmanager.pro
@@ -15,6 +15,8 @@ SOURCES += main.cpp \
qnetworkmanagerengine.cpp \
../qnetworksession_impl.cpp
+OTHER_FILES += networkmanager.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/nla/main.cpp b/src/plugins/bearer/nla/main.cpp
index 4337c1748a..4a2c915d13 100644
--- a/src/plugins/bearer/nla/main.cpp
+++ b/src/plugins/bearer/nla/main.cpp
@@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE
class QNlaEnginePlugin : public QBearerEnginePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nla.json")
+
public:
QNlaEnginePlugin();
~QNlaEnginePlugin();
@@ -78,7 +81,6 @@ QBearerEngine *QNlaEnginePlugin::create(const QString &key) const
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(QNlaEnginePlugin)
-Q_EXPORT_PLUGIN2(qnlabearer, QNlaEnginePlugin)
-
QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/bearer/nla/nla.json b/src/plugins/bearer/nla/nla.json
new file mode 100644
index 0000000000..2554d2c5c4
--- /dev/null
+++ b/src/plugins/bearer/nla/nla.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "nla" ]
+}
diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro
index 76da098dbf..5444269f1f 100644
--- a/src/plugins/bearer/nla/nla.pro
+++ b/src/plugins/bearer/nla/nla.pro
@@ -1,7 +1,7 @@
TARGET = qnlabearer
load(qt_plugin)
-QT = core network
+QT = core core-private network network-private
!wince* {
LIBS += -lWs2_32
@@ -18,6 +18,8 @@ SOURCES += main.cpp \
qnlaengine.cpp \
../qnetworksession_impl.cpp
+OTHER_FILES += nla.json
+
DESTDIR = $$QT.network.plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.json b/src/plugins/generic/evdevkeyboard/evdevkeyboard.json
new file mode 100644
index 0000000000..0e24bb0568
--- /dev/null
+++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "EvdevKeyboard" ]
+}
diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro
index 997a58ef6e..82edf170a8 100644
--- a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro
+++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro
@@ -10,10 +10,13 @@ HEADERS = \
qevdevkeyboardhandler.h \
qevdevkeyboardmanager.h
-QT += core-private
+QT += core-private platformsupport-private
LIBS += -ludev
SOURCES = main.cpp \
qevdevkeyboardhandler.cpp \
qevdevkeyboardmanager.cpp
+
+OTHER_FILES += \
+ evdevkeyboard.json
diff --git a/src/plugins/generic/evdevkeyboard/main.cpp b/src/plugins/generic/evdevkeyboard/main.cpp
index 6df4e29fcb..71d15720bd 100644
--- a/src/plugins/generic/evdevkeyboard/main.cpp
+++ b/src/plugins/generic/evdevkeyboard/main.cpp
@@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE
class QEvdevKeyboardPlugin : public QGenericPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevkeyboard.json")
+
public:
QEvdevKeyboardPlugin();
@@ -72,6 +75,6 @@ QObject* QEvdevKeyboardPlugin::create(const QString &key,
return 0;
}
-Q_EXPORT_PLUGIN2(qevdevkeyboardplugin, QEvdevKeyboardPlugin)
-
QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp
index cb23d3a49c..0938fdc2e4 100644
--- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp
+++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp
@@ -42,28 +42,27 @@
#include "qevdevkeyboardmanager.h"
#include <QStringList>
-#include <QDebug>
#include <QCoreApplication>
-#include <linux/input.h>
-#include <linux/kd.h>
-
//#define QT_QPA_KEYMAP_DEBUG
+#ifdef QT_QPA_KEYMAP_DEBUG
+#include <QDebug>
+#endif
+
QT_BEGIN_NAMESPACE
QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &specification)
- : m_udev(0), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0)
{
Q_UNUSED(key);
- bool useUDev = false;
+ bool useUDev = true;
QStringList args = specification.split(QLatin1Char(':'));
QStringList devices;
foreach (const QString &arg, args) {
- if (arg.startsWith("udev") && !arg.contains("no")) {
- useUDev = true;
+ if (arg.startsWith("udev") && arg.contains("no")) {
+ useUDev = false;
} else if (arg.startsWith("/dev/")) {
// if device is specified try to use it
devices.append(arg);
@@ -71,182 +70,69 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
}
}
+ // build new specification without /dev/ elements
m_spec = args.join(":");
// add all keyboards for devices specified in the argument list
foreach (const QString &device, devices)
addKeyboard(device);
- // no udev and no devices specified, try a fallback
- if (!useUDev && devices.isEmpty()) {
- addKeyboard();
- return;
- }
+ if (useUDev) {
+#ifdef QT_QPA_KEYMAP_DEBUG
+ qWarning() << "Use UDev for device discovery";
+#endif
+
+ m_udeviceHelper = QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Keyboard, this);
+ if (m_udeviceHelper) {
+ // scan and add already connected keyboards
+ QStringList devices = m_udeviceHelper->scanConnectedDevices();
+ foreach (QString device, devices) {
+ addKeyboard(device);
+ }
- m_udev = udev_new();
- if (!m_udev) {
- qWarning() << "Failed to read udev configuration. Try to open a keyboard without it";
- addKeyboard();
- } else {
- // Look for already attached devices:
- parseConnectedDevices();
- // Watch for device add/remove
- startWatching();
+ connect(m_udeviceHelper, SIGNAL(deviceDetected(QString,QUDeviceTypes)), this, SLOT(addKeyboard(QString)));
+ connect(m_udeviceHelper, SIGNAL(deviceRemoved(QString,QUDeviceTypes)), this, SLOT(removeKeyboard(QString)));
+ }
}
}
QEvdevKeyboardManager::~QEvdevKeyboardManager()
{
- // cleanup udev related resources
- stopWatching();
- if (m_udev)
- udev_unref(m_udev);
-
- // cleanup all resources of connected keyboards
qDeleteAll(m_keyboards);
m_keyboards.clear();
}
-void QEvdevKeyboardManager::addKeyboard(const QString &devnode)
+void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode)
{
+#ifdef QT_QPA_KEYMAP_DEBUG
+ qWarning() << "Adding keyboard at" << deviceNode;
+#endif
+
QString specification = m_spec;
- QString deviceString = devnode;
- if (!deviceString.isEmpty()) {
+ if (!deviceNode.isEmpty()) {
specification.append(":");
- specification.append(deviceString);
- } else {
- deviceString = "default";
+ specification.append(deviceNode);
}
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Adding keyboard at" << deviceString;
-#endif
-
QEvdevKeyboardHandler *keyboard;
keyboard = QEvdevKeyboardHandler::createLinuxInputKeyboardHandler("EvdevKeyboard", specification);
if (keyboard)
- m_keyboards.insert(deviceString, keyboard);
+ m_keyboards.insert(deviceNode, keyboard);
else
- qWarning() << "Failed to open keyboard";
+ qWarning("Failed to open keyboard");
}
-void QEvdevKeyboardManager::removeKeyboard(const QString &devnode)
+void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode)
{
- if (m_keyboards.contains(devnode)) {
+ if (m_keyboards.contains(deviceNode)) {
#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Removing keyboard at" << devnode;
+ qWarning() << "Removing keyboard at" << deviceNode;
#endif
- QEvdevKeyboardHandler *keyboard = m_keyboards.value(devnode);
- m_keyboards.remove(devnode);
+ QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode);
+ m_keyboards.remove(deviceNode);
delete keyboard;
}
}
-void QEvdevKeyboardManager::startWatching()
-{
- m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev");
- if (!m_udevMonitor) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("Unable to create an Udev monitor. No devices can be detected.");
-#endif
- return;
- }
-
- udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, "input", NULL);
- udev_monitor_enable_receiving(m_udevMonitor);
- m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor);
-
- m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this);
- connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(deviceDetected()));
-}
-
-void QEvdevKeyboardManager::stopWatching()
-{
- if (m_udevSocketNotifier)
- delete m_udevSocketNotifier;
-
- if (m_udevMonitor)
- udev_monitor_unref(m_udevMonitor);
-
- m_udevSocketNotifier = 0;
- m_udevMonitor = 0;
- m_udevMonitorFileDescriptor = 0;
-}
-
-void QEvdevKeyboardManager::deviceDetected()
-{
- if (!m_udevMonitor)
- return;
-
- struct udev_device *dev;
- dev = udev_monitor_receive_device(m_udevMonitor);
- if (!dev)
- return;
-
- if (qstrcmp(udev_device_get_action(dev), "add") == 0) {
- checkDevice(dev);
- } else {
- // We can't determine what the device was, so we handle false positives outside of this class
- QString str = udev_device_get_devnode(dev);
- if (!str.isEmpty())
- removeKeyboard(str);
- }
-
- udev_device_unref(dev);
-}
-
-void QEvdevKeyboardManager::parseConnectedDevices()
-{
- struct udev_enumerate *enumerate;
- struct udev_list_entry *devices;
- struct udev_list_entry *dev_list_entry;
- struct udev_device *dev;
- const char *str;
-
- enumerate = udev_enumerate_new(m_udev);
- udev_enumerate_add_match_subsystem(enumerate, "input");
- udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
-
- udev_list_entry_foreach(dev_list_entry, devices) {
- str = udev_list_entry_get_name(dev_list_entry);
- dev = udev_device_new_from_syspath(m_udev, str);
- checkDevice(dev);
- }
-
- udev_enumerate_unref(enumerate);
-}
-
-void QEvdevKeyboardManager::checkDevice(udev_device *dev)
-{
- const char *str;
- QString devnode;
-
- str = udev_device_get_devnode(dev);
- if (!str)
- return;
-
- devnode = str;
-
- dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL);
- if (!dev)
- return;
-
- str = udev_device_get_sysattr_value(dev, "capabilities/key");
- QStringList val = QString(str).split(' ', QString::SkipEmptyParts);
-
- bool ok;
- unsigned long long keys = val.last().toULongLong(&ok, 16);
- if (!ok)
- return;
-
- // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable.
- bool test = (keys >> KEY_Q) & 1;
- if (test) {
- addKeyboard(devnode);
- return;
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h
index 3caed6ff43..c776af2ec5 100644
--- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h
+++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h
@@ -44,12 +44,12 @@
#include "qevdevkeyboardhandler.h"
+#include <QtPlatformSupport/private/qudevicehelper_p.h>
+
#include <QObject>
#include <QHash>
#include <QSocketNotifier>
-#include <libudev.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -62,24 +62,13 @@ public:
~QEvdevKeyboardManager();
private slots:
- void deviceDetected();
+ void addKeyboard(const QString &deviceNode = QString());
+ void removeKeyboard(const QString &deviceNode);
private:
- void startWatching();
- void stopWatching();
- void parseConnectedDevices();
- void checkDevice(struct udev_device *dev);
-
- void addKeyboard(const QString &devnode = QString());
- void removeKeyboard(const QString &devnode);
-
QString m_spec;
QHash<QString,QEvdevKeyboardHandler*> m_keyboards;
-
- struct udev *m_udev;
- struct udev_monitor *m_udevMonitor;
- int m_udevMonitorFileDescriptor;
- QSocketNotifier *m_udevSocketNotifier;
+ QUDeviceHelper *m_udeviceHelper;
};
QT_END_HEADER
diff --git a/src/plugins/generic/evdevmouse/evdevmouse.json b/src/plugins/generic/evdevmouse/evdevmouse.json
new file mode 100644
index 0000000000..00ddd3a9cf
--- /dev/null
+++ b/src/plugins/generic/evdevmouse/evdevmouse.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "EvdevMouse" ]
+}
diff --git a/src/plugins/generic/evdevmouse/evdevmouse.pro b/src/plugins/generic/evdevmouse/evdevmouse.pro
index f25199161b..c5d162fb2f 100644
--- a/src/plugins/generic/evdevmouse/evdevmouse.pro
+++ b/src/plugins/generic/evdevmouse/evdevmouse.pro
@@ -11,3 +11,6 @@ QT += core-private platformsupport-private
SOURCES = main.cpp \
qevdevmouse.cpp
+
+OTHER_FILES += \
+ evdevmouse.json
diff --git a/src/plugins/generic/evdevmouse/main.cpp b/src/plugins/generic/evdevmouse/main.cpp
index 34ca62f960..47a4ddf56b 100644
--- a/src/plugins/generic/evdevmouse/main.cpp
+++ b/src/plugins/generic/evdevmouse/main.cpp
@@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE
class QEvdevMousePlugin : public QGenericPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevmouse.json")
+
public:
QEvdevMousePlugin();
@@ -72,6 +75,6 @@ QObject* QEvdevMousePlugin::create(const QString &key,
return 0;
}
-Q_EXPORT_PLUGIN2(qevdevmouseplugin, QEvdevMousePlugin)
-
QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/evdevtouch/evdevtouch.json b/src/plugins/generic/evdevtouch/evdevtouch.json
new file mode 100644
index 0000000000..6a6959c8e6
--- /dev/null
+++ b/src/plugins/generic/evdevtouch/evdevtouch.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "EvdevTouch" ]
+}
diff --git a/src/plugins/generic/evdevtouch/evdevtouch.pro b/src/plugins/generic/evdevtouch/evdevtouch.pro
index 78fe551aa2..284f1d1221 100644
--- a/src/plugins/generic/evdevtouch/evdevtouch.pro
+++ b/src/plugins/generic/evdevtouch/evdevtouch.pro
@@ -12,3 +12,6 @@ SOURCES = main.cpp \
qevdevtouch.cpp
QT += core-private platformsupport-private
+
+OTHER_FILES += \
+ evdevtouch.json
diff --git a/src/plugins/generic/evdevtouch/main.cpp b/src/plugins/generic/evdevtouch/main.cpp
index 526e336fd8..47b026ac96 100644
--- a/src/plugins/generic/evdevtouch/main.cpp
+++ b/src/plugins/generic/evdevtouch/main.cpp
@@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE
class QTouchScreenPlugin : public QGenericPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtouch.json")
+
public:
QTouchScreenPlugin();
@@ -71,6 +74,6 @@ QObject* QTouchScreenPlugin::create(const QString &key,
return 0;
}
-Q_EXPORT_PLUGIN2(qevdevtouchplugin, QTouchScreenPlugin)
-
QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
index c5064663a1..ca8f492c5d 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
@@ -57,7 +57,7 @@ public:
bool isValid() const;
- void invokeAction(QInputPanel::Action a, int x);
+ void invokeAction(QInputMethod::Action a, int x);
void reset();
void commit();
void update(Qt::InputMethodQueries);
diff --git a/src/plugins/platforminputcontexts/maliit/qmaliitplatforminputcontext.h b/src/plugins/platforminputcontexts/maliit/qmaliitplatforminputcontext.h
index 3760885641..a17abe7cbb 100644
--- a/src/plugins/platforminputcontexts/maliit/qmaliitplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/maliit/qmaliitplatforminputcontext.h
@@ -59,7 +59,7 @@ public:
bool isValid() const;
- void invokeAction(QInputPanel::Action action, int x);
+ void invokeAction(QInputMethod::Action action, int x);
void reset(void);
void update(Qt::InputMethodQueries);
virtual QRectF keyboardRect() const;
diff --git a/src/plugins/platforms/blackberry/blackberry.pro b/src/plugins/platforms/blackberry/blackberry.pro
new file mode 100644
index 0000000000..94b9c5dbc8
--- /dev/null
+++ b/src/plugins/platforms/blackberry/blackberry.pro
@@ -0,0 +1,71 @@
+TARGET = blackberry
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+QT += opengl opengl-private platformsupport platformsupport-private widgets-private
+
+# Uncomment this to build with support for IMF once it becomes available in the BBNDK
+#CONFIG += qbb_imf
+
+# Uncomment these to enable debugging output for various aspects of the plugin
+#DEFINES += QBBBUFFER_DEBUG
+#DEFINES += QBBCLIPBOARD_DEBUG
+#DEFINES += QBBEVENTTHREAD_DEBUG
+#DEFINES += QBBGLBACKINGSTORE_DEBUG
+#DEFINES += QBBGLCONTEXT_DEBUG
+#DEFINES += QBBINPUTCONTEXT_DEBUG
+#DEFINES += QBBINPUTCONTEXT_IMF_EVENT_DEBUG
+#DEFINES += QBBINTEGRATION_DEBUG
+#DEFINES += QBBNAVIGATORTHREAD_DEBUG
+#DEFINES += QBBRASTERBACKINGSTORE_DEBUG
+#DEFINES += QBBROOTWINDOW_DEBUG
+#DEFINES += QBBSCREEN_DEBUG
+#DEFINES += QBBVIRTUALKEYBOARD_DEBUG
+#DEFINES += QBBWINDOW_DEBUG
+
+SOURCES = main.cpp \
+ qbbbuffer.cpp \
+ qbbeventthread.cpp \
+ qbbglcontext.cpp \
+ qbbglbackingstore.cpp \
+ qbbintegration.cpp \
+ qbbnavigatorthread.cpp \
+ qbbscreen.cpp \
+ qbbwindow.cpp \
+ qbbrasterbackingstore.cpp \
+ qbbvirtualkeyboard.cpp \
+ qbbclipboard.cpp \
+ qbbrootwindow.cpp
+
+HEADERS = qbbbuffer.h \
+ qbbeventthread.h \
+ qbbkeytranslator.h \
+ qbbintegration.h \
+ qbbnavigatorthread.h \
+ qbbglcontext.h \
+ qbbglbackingstore.h \
+ qbbscreen.h \
+ qbbwindow.h \
+ qbbrasterbackingstore.h \
+ qbbvirtualkeyboard.h \
+ qbbclipboard.h \
+ qbbrootwindow.h
+
+CONFIG(qbb_imf) {
+ DEFINES += QBB_IMF
+ HEADERS += qbbinputcontext_imf.h
+ SOURCES += qbbinputcontext_imf.cpp
+} else {
+ HEADERS += qbbinputcontext_noimf.h
+ SOURCES += qbbinputcontext_noimf.cpp
+}
+
+QMAKE_CXXFLAGS += -I./private
+
+LIBS += -lpps -lscreen -lEGL -lclipboard
+
+include (../../../platformsupport/eglconvenience/eglconvenience.pri)
+include (../../../platformsupport/fontdatabases/fontdatabases.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/blackberry/main.cpp b/src/plugins/platforms/blackberry/main.cpp
new file mode 100644
index 0000000000..b9e09c0384
--- /dev/null
+++ b/src/plugins/platforms/blackberry/main.cpp
@@ -0,0 +1,72 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qbbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBBIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QBBIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << QLatin1String("blackberry");
+ return list;
+}
+
+QPlatformIntegration *QBBIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == QLatin1String("blackberry"))
+ return new QBBIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(blackberry, QBBIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbbuffer.cpp b/src/plugins/platforms/blackberry/qbbbuffer.cpp
new file mode 100644
index 0000000000..c4ac04898d
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbbuffer.cpp
@@ -0,0 +1,165 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbbuffer.h"
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+#include <sys/mman.h>
+
+QT_BEGIN_NAMESPACE
+
+QBBBuffer::QBBBuffer()
+ : m_buffer(0)
+{
+#if defined(QBBBUFFER_DEBUG)
+ qDebug() << "QBBBuffer::QBBBuffer - empty";
+#endif
+}
+
+QBBBuffer::QBBBuffer(screen_buffer_t buffer)
+ : m_buffer(buffer)
+{
+#if defined(QBBBUFFER_DEBUG)
+ qDebug() << "QBBBuffer::QBBBuffer - normal";
+#endif
+
+ // Get size of buffer
+ errno = 0;
+ int size[2];
+ int result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (result != 0) {
+ qFatal("QBB: failed to query buffer size, errno=%d", errno);
+ }
+
+ // Get stride of buffer
+ errno = 0;
+ int stride;
+ result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
+ if (result != 0) {
+ qFatal("QBB: failed to query buffer stride, errno=%d", errno);
+ }
+
+ // Get access to buffer's data
+ errno = 0;
+ uchar *dataPtr = 0;
+ result = screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr);
+ if (result != 0) {
+ qFatal("QBB: failed to query buffer pointer, errno=%d", errno);
+ }
+ if (dataPtr == NULL) {
+ qFatal("QBB: buffer pointer is NULL, errno=%d", errno);
+ }
+
+ // Get format of buffer
+ errno = 0;
+ int screenFormat;
+ result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat);
+ if (result != 0) {
+ qFatal("QBB: failed to query buffer format, errno=%d", errno);
+ }
+
+ // Convert screen format to QImage format
+ QImage::Format imageFormat = QImage::Format_Invalid;
+ switch (screenFormat) {
+ case SCREEN_FORMAT_RGBX4444:
+ imageFormat = QImage::Format_RGB444;
+ break;
+ case SCREEN_FORMAT_RGBA4444:
+ imageFormat = QImage::Format_ARGB4444_Premultiplied;
+ break;
+ case SCREEN_FORMAT_RGBX5551:
+ imageFormat = QImage::Format_RGB555;
+ break;
+ case SCREEN_FORMAT_RGB565:
+ imageFormat = QImage::Format_RGB16;
+ break;
+ case SCREEN_FORMAT_RGBX8888:
+ imageFormat = QImage::Format_RGB32;
+ break;
+ case SCREEN_FORMAT_RGBA8888:
+ imageFormat = QImage::Format_ARGB32_Premultiplied;
+ break;
+ default:
+ qFatal("QBB: unsupported buffer format, format=%d", screenFormat);
+ }
+
+ // wrap buffer in an image
+ m_image = QImage(dataPtr, size[0], size[1], stride, imageFormat);
+}
+
+QBBBuffer::QBBBuffer(const QBBBuffer &other)
+ : m_buffer(other.m_buffer),
+ m_image(other.m_image)
+{
+#if defined(QBBBUFFER_DEBUG)
+ qDebug() << "QBBBuffer::QBBBuffer - copy";
+#endif
+}
+
+QBBBuffer::~QBBBuffer()
+{
+#if defined(QBBBUFFER_DEBUG)
+ qDebug() << "QBBBuffer::~QBBBuffer";
+#endif
+}
+
+void QBBBuffer::invalidateInCache()
+{
+#if defined(QBBBUFFER_DEBUG)
+ qDebug() << "QBBBuffer::invalidateInCache";
+#endif
+
+ // Verify native buffer exists
+ if (m_buffer == 0) {
+ qFatal("QBB: can't invalidate cache for null buffer");
+ }
+
+ // Evict buffer's data from cache
+ errno = 0;
+ int result = msync(m_image.bits(), m_image.height() * m_image.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY);
+ if (result != 0) {
+ qFatal("QBB: failed to invalidate cache, errno=%d", errno);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbbuffer.h b/src/plugins/platforms/blackberry/qbbbuffer.h
new file mode 100644
index 0000000000..45cedb21a8
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbbuffer.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBBUFFER_H
+#define QBBBUFFER_H
+
+#include <QtGui/QImage>
+
+#include <screen/screen.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBBBuffer
+{
+public:
+ QBBBuffer();
+ QBBBuffer(screen_buffer_t buffer);
+ QBBBuffer(const QBBBuffer &other);
+ virtual ~QBBBuffer();
+
+ screen_buffer_t nativeBuffer() const { return m_buffer; }
+ const QImage *image() const { return (m_buffer != NULL) ? &m_image : NULL; }
+ QImage *image() { return (m_buffer != NULL) ? &m_image : NULL; }
+
+ QRect rect() const { return m_image.rect(); }
+
+ void invalidateInCache();
+
+private:
+ screen_buffer_t m_buffer;
+ QImage m_image;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBBUFFER_H
diff --git a/src/plugins/platforms/blackberry/qbbclipboard.cpp b/src/plugins/platforms/blackberry/qbbclipboard.cpp
new file mode 100644
index 0000000000..fce016d5ee
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbclipboard.cpp
@@ -0,0 +1,132 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qbbclipboard.h"
+
+#include <QtGui/QColor>
+
+#include <QtCore/QDebug>
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+
+#include <clipboard/clipboard.h>
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+static const char *typeList[] = {"text/html", "text/plain", "application/x-color"};
+
+QBBClipboard::QBBClipboard()
+{
+ m_mimeData = 0;
+}
+
+QBBClipboard::~QBBClipboard()
+{
+ delete m_mimeData;
+}
+
+void QBBClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ if (mode != QClipboard::Clipboard)
+ return;
+
+ if (m_mimeData != data) {
+ delete m_mimeData;
+ m_mimeData = data;
+ }
+
+ empty_clipboard();
+
+ if (data == 0)
+ return;
+
+ QStringList format = data->formats();
+ for (int i = 0; i < format.size(); ++i) {
+ QString type = format.at(i);
+ QByteArray buf = data->data(type);
+ if (!buf.size())
+ continue;
+
+ int ret = set_clipboard_data(type.toUtf8().data(), buf.size(), buf.data());
+#if defined(QBBCLIPBOARD_DEBUG)
+ qDebug() << "QBB: set " << type.toUtf8().data() << "to clipboard, size=" << buf.size() << ";ret=" << ret;
+#else
+ Q_UNUSED(ret);
+#endif
+ }
+}
+
+void QBBClipboard::readClipboardBuff(const char *type)
+{
+ char *pbuffer;
+ if (is_clipboard_format_present(type) == 0) {
+ int size = get_clipboard_data(type, &pbuffer);
+ if (size != -1 && pbuffer) {
+ QString qtype = type;
+#if defined(QBBCLIPBOARD_DEBUG)
+ qDebug() << "QBB: clipboard has " << qtype;
+#endif
+ m_mimeData->setData(qtype, QByteArray(pbuffer, size));
+ delete pbuffer;
+ }
+ }
+}
+
+QMimeData *QBBClipboard::mimeData(QClipboard::Mode mode)
+{
+ if (mode != QClipboard::Clipboard)
+ return 0;
+
+ if (!m_mimeData)
+ m_mimeData = new QMimeData();
+
+ m_mimeData->clear();
+
+ for (int i = 0; i < 3; i++)
+ readClipboardBuff(typeList[i]);
+
+ return m_mimeData;
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_CLIPBOAR
diff --git a/src/plugins/platforms/blackberry/qbbclipboard.h b/src/plugins/platforms/blackberry/qbbclipboard.h
new file mode 100644
index 0000000000..b9de9b3e36
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbclipboard.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBCLIPBOARD_H
+#define QBBCLIPBOARD_H
+
+#ifndef QT_NO_CLIPBOARD
+#include <QtGui/QPlatformClipboard>
+#include <QMimeData>
+
+QT_BEGIN_NAMESPACE
+
+class QBBClipboard : public QPlatformClipboard
+{
+public:
+ QBBClipboard();
+ virtual ~QBBClipboard();
+ virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
+ virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
+
+private:
+ QMimeData *m_mimeData;
+ void readClipboardBuff(const char *type);
+};
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_CLIPBOARD
+#endif //QBBCLIPBOARD_H
diff --git a/src/plugins/platforms/blackberry/qbbeventthread.cpp b/src/plugins/platforms/blackberry/qbbeventthread.cpp
new file mode 100644
index 0000000000..547428d1c4
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbeventthread.cpp
@@ -0,0 +1,559 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbeventthread.h"
+#include "qbbintegration.h"
+#include "qbbkeytranslator.h"
+
+#if defined(QBB_IMF)
+#include "qbbinputcontext_imf.h"
+#else
+#include "qbbinputcontext_noimf.h"
+#endif
+
+#include <QtGui/QWindow>
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QGuiApplication>
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/keycodes.h>
+
+#include <cctype>
+
+QBBEventThread::QBBEventThread(screen_context_t context, QPlatformScreen& screen)
+ : QThread(),
+ m_screenContext(context),
+ m_platformScreen(screen),
+ m_quit(false),
+ m_lastButtonState(Qt::NoButton),
+ m_lastMouseWindow(0)
+{
+ // Create a touch device
+ m_touchDevice = new QTouchDevice;
+ m_touchDevice->setType(QTouchDevice::TouchScreen);
+ m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure | QTouchDevice::NormalizedPosition);
+ QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+
+ // initialize array of touch points
+ for (int i = 0; i < MaximumTouchPoints; i++) {
+
+ // map array index to id
+ m_touchPoints[i].id = i;
+
+ // pressure is not supported - use default
+ m_touchPoints[i].pressure = 1.0;
+
+ // nothing touching
+ m_touchPoints[i].state = Qt::TouchPointReleased;
+ }
+}
+
+QBBEventThread::~QBBEventThread()
+{
+ // block until thread terminates
+ shutdown();
+}
+
+void QBBEventThread::run()
+{
+ screen_event_t event;
+
+ // create screen event
+ errno = 0;
+ int result = screen_create_event(&event);
+ if (result) {
+ qFatal("QBB: failed to create event, errno=%d", errno);
+ }
+
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: event loop started";
+#endif
+
+ // loop indefinitely
+ while (!m_quit) {
+
+ // block until screen event is available
+ errno = 0;
+ result = screen_get_event(m_screenContext, event, -1);
+ if (result) {
+ qFatal("QBB: failed to get event, errno=%d", errno);
+ }
+
+ // process received event
+ dispatchEvent(event);
+ }
+
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: event loop stopped";
+#endif
+
+ // cleanup
+ screen_destroy_event(event);
+}
+
+void QBBEventThread::shutdown()
+{
+ screen_event_t event;
+
+ // create screen event
+ errno = 0;
+ int result = screen_create_event(&event);
+ if (result) {
+ qFatal("QBB: failed to create event, errno=%d", errno);
+ }
+
+ // set the event type as user
+ errno = 0;
+ int type = SCREEN_EVENT_USER;
+ result = screen_set_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type);
+ if (result) {
+ qFatal("QBB: failed to set event type, errno=%d", errno);
+ }
+
+ // NOTE: ignore SCREEN_PROPERTY_USER_DATA; treat all user events as shutdown events
+
+ // post event to event loop so it will wake up and die
+ errno = 0;
+ result = screen_send_event(m_screenContext, event, getpid());
+ if (result) {
+ qFatal("QBB: failed to set event type, errno=%d", errno);
+ }
+
+ // cleanup
+ screen_destroy_event(event);
+
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: event loop shutdown begin";
+#endif
+
+ // block until thread terminates
+ wait();
+
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: event loop shutdown end";
+#endif
+}
+
+void QBBEventThread::dispatchEvent(screen_event_t event)
+{
+ // get the event type
+ errno = 0;
+ int qnxType;
+ int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType);
+ if (result) {
+ qFatal("QBB: failed to query event type, errno=%d", errno);
+ }
+
+ switch (qnxType) {
+ case SCREEN_EVENT_MTOUCH_TOUCH:
+ case SCREEN_EVENT_MTOUCH_MOVE:
+ case SCREEN_EVENT_MTOUCH_RELEASE:
+ handleTouchEvent(event, qnxType);
+ break;
+
+ case SCREEN_EVENT_KEYBOARD:
+ handleKeyboardEvent(event);
+ break;
+
+ case SCREEN_EVENT_POINTER:
+ handlePointerEvent(event);
+ break;
+
+ case SCREEN_EVENT_CLOSE:
+ handleCloseEvent(event);
+ break;
+
+ case SCREEN_EVENT_USER:
+ // treat all user events as shutdown requests
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: QNX user event";
+#endif
+ m_quit = true;
+ break;
+
+ default:
+ // event ignored
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: QNX unknown event";
+#endif
+ break;
+ }
+}
+
+void QBBEventThread::handleKeyboardEvent(screen_event_t event)
+{
+ // get flags of key event
+ errno = 0;
+ int flags;
+ int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
+ if (result) {
+ qFatal("QBB: failed to query event flags, errno=%d", errno);
+ }
+
+ // get key code
+ errno = 0;
+ int sym;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym);
+ if (result) {
+ qFatal("QBB: failed to query event sym, errno=%d", errno);
+ }
+
+ int modifiers;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
+ if (result) {
+ qFatal("QBB: failed to query event modifiers, errno=%d", errno);
+ }
+
+ int scan;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan);
+ if (result) {
+ qFatal("QBB: failed to query event modifiers, errno=%d", errno);
+ }
+
+ int cap;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
+ if (result) {
+ qFatal("QBB: failed to query event cap, errno=%d", errno);
+ }
+
+ injectKeyboardEvent(flags, sym, modifiers, scan, cap);
+}
+
+void QBBEventThread::injectKeyboardEvent(int flags, int sym, int modifiers, int scan, int cap)
+{
+ Q_UNUSED(scan);
+
+ Qt::KeyboardModifiers qtMod = Qt::NoModifier;
+ if (modifiers & KEYMOD_SHIFT)
+ qtMod |= Qt::ShiftModifier;
+ if (modifiers & KEYMOD_CTRL)
+ qtMod |= Qt::ControlModifier;
+ if (modifiers & KEYMOD_ALT)
+ qtMod |= Qt::AltModifier;
+
+ // determine event type
+ QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease;
+
+ // Check if the key cap is valid
+ if (flags & KEY_CAP_VALID) {
+ Qt::Key key;
+ QString keyStr;
+
+ if (cap >= 0x20 && cap <= 0x0ff) {
+ key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case.
+
+ if ( qtMod & Qt::ControlModifier ) {
+ keyStr = QChar((int)(key & 0x3f));
+ } else {
+ if (flags & KEY_SYM_VALID) {
+ keyStr = QChar(sym);
+ }
+ }
+ } else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) {
+ key = (Qt::Key)cap;
+ keyStr = QChar(sym);
+ } else {
+ if (isKeypadKey(cap))
+ qtMod |= Qt::KeypadModifier; // Is this right?
+ key = keyTranslator(cap);
+ }
+
+ QWindowSystemInterface::handleKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod, keyStr);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
+#endif
+ }
+}
+
+void QBBEventThread::handlePointerEvent(screen_event_t event)
+{
+ errno = 0;
+
+ // Query the window that was clicked
+ screen_window_t qnxWindow;
+ void *handle;
+ int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle);
+ if (result) {
+ qFatal("QBB: failed to query event window, errno=%d", errno);
+ }
+ qnxWindow = static_cast<screen_window_t>(handle);
+
+ // Query the button states
+ int buttonState = 0;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState);
+ if (result) {
+ qFatal("QBB: failed to query event button state, errno=%d", errno);
+ }
+
+ // Query the window position
+ int windowPos[2];
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
+ if (result) {
+ qFatal("QBB: failed to query event window position, errno=%d", errno);
+ }
+
+ // Query the screen position
+ int pos[2];
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
+ if (result) {
+ qFatal("QBB: failed to query event position, errno=%d", errno);
+ }
+
+ // Query the wheel delta
+ int wheelDelta = 0;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta);
+ if (result) {
+ qFatal("QBB: failed to query event wheel delta, errno=%d", errno);
+ }
+
+ // Map window handle to top-level QWindow
+ QWindow *w = QBBIntegration::window(qnxWindow);
+
+ // Generate enter and leave events as needed.
+ if (qnxWindow != m_lastMouseWindow) {
+ QWindow *wOld = QBBIntegration::window(m_lastMouseWindow);
+
+ if (wOld) {
+ QWindowSystemInterface::handleLeaveEvent(wOld);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt leave, w=" << wOld;
+#endif
+ }
+
+ if (w) {
+ QWindowSystemInterface::handleEnterEvent(w);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt enter, w=" << w;
+#endif
+ }
+ }
+ m_lastMouseWindow = qnxWindow;
+
+ // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale
+ // this via a system preference at some point. But for now this is a sane value and makes
+ // the wheel usable.
+ wheelDelta *= -10;
+
+ // convert point to local coordinates
+ QPoint globalPoint(pos[0], pos[1]);
+ QPoint localPoint(windowPos[0], windowPos[1]);
+
+ // Convert buttons.
+ Qt::MouseButtons buttons = Qt::NoButton;
+ if (buttonState & 1)
+ buttons |= Qt::LeftButton;
+ if (buttonState & 2)
+ buttons |= Qt::MidButton;
+ if (buttonState & 4)
+ buttons |= Qt::RightButton;
+
+ if (w) {
+ // Inject mouse event into Qt only if something has changed.
+ if (m_lastGlobalMousePoint != globalPoint ||
+ m_lastLocalMousePoint != localPoint ||
+ m_lastButtonState != buttons) {
+ QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons);
+#endif
+ }
+
+ if (wheelDelta) {
+ // Screen only supports a single wheel, so we will assume Vertical orientation for
+ // now since that is pretty much standard.
+ QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << static_cast<int>(wheelDelta);
+#endif
+ }
+ }
+
+ m_lastGlobalMousePoint = globalPoint;
+ m_lastLocalMousePoint = localPoint;
+ m_lastButtonState = buttons;
+}
+
+void QBBEventThread::handleTouchEvent(screen_event_t event, int qnxType)
+{
+ // get display coordinates of touch
+ errno = 0;
+ int pos[2];
+ int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
+ if (result) {
+ qFatal("QBB: failed to query event position, errno=%d", errno);
+ }
+
+ // get window coordinates of touch
+ errno = 0;
+ int windowPos[2];
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
+ if (result) {
+ qFatal("QBB: failed to query event window position, errno=%d", errno);
+ }
+
+ // determine which finger touched
+ errno = 0;
+ int touchId;
+ result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId);
+ if (result) {
+ qFatal("QBB: failed to query event touch id, errno=%d", errno);
+ }
+
+ // determine which window was touched
+ errno = 0;
+ void *handle;
+ result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle);
+ if (result) {
+ qFatal("QBB: failed to query event window, errno=%d", errno);
+ }
+ screen_window_t qnxWindow = static_cast<screen_window_t>(handle);
+
+ // check if finger is valid
+ if (touchId < MaximumTouchPoints) {
+
+ // Map window handle to top-level QWindow
+ QWindow *w = QBBIntegration::window(qnxWindow);
+
+ // Generate enter and leave events as needed.
+ if (qnxWindow != m_lastMouseWindow) {
+ QWindow *wOld = QBBIntegration::window(m_lastMouseWindow);
+
+ if (wOld) {
+ QWindowSystemInterface::handleLeaveEvent(wOld);
+ #if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt leave, w=" << wOld;
+ #endif
+ }
+
+ if (w) {
+ QWindowSystemInterface::handleEnterEvent(w);
+ #if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt enter, w=" << w;
+ #endif
+ }
+ }
+ m_lastMouseWindow = qnxWindow;
+
+ if (w) {
+ // convert primary touch to mouse event
+ if (touchId == 0) {
+
+ // convert point to local coordinates
+ QPoint globalPoint(pos[0], pos[1]);
+ QPoint localPoint(windowPos[0], windowPos[1]);
+
+ // map touch state to button state
+ Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton;
+
+ // inject event into Qt
+ QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << buttons;
+#endif
+ }
+
+ // get size of screen which contains window
+ QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w);
+ QSizeF screenSize = platformScreen->physicalSize();
+
+ // update cached position of current touch point
+ m_touchPoints[touchId].normalPosition = QPointF( static_cast<qreal>(pos[0]) / screenSize.width(), static_cast<qreal>(pos[1]) / screenSize.height() );
+ m_touchPoints[touchId].area = QRectF( pos[0], pos[1], 0.0, 0.0 );
+
+ // determine event type and update state of current touch point
+ QEvent::Type type = QEvent::None;
+ switch (qnxType) {
+ case SCREEN_EVENT_MTOUCH_TOUCH:
+ m_touchPoints[touchId].state = Qt::TouchPointPressed;
+ type = QEvent::TouchBegin;
+ break;
+ case SCREEN_EVENT_MTOUCH_MOVE:
+ m_touchPoints[touchId].state = Qt::TouchPointMoved;
+ type = QEvent::TouchUpdate;
+ break;
+ case SCREEN_EVENT_MTOUCH_RELEASE:
+ m_touchPoints[touchId].state = Qt::TouchPointReleased;
+ type = QEvent::TouchEnd;
+ break;
+ }
+
+ // build list of active touch points
+ QList<QWindowSystemInterface::TouchPoint> pointList;
+ for (int i = 0; i < MaximumTouchPoints; i++) {
+ if (i == touchId) {
+ // current touch point is always active
+ pointList.append(m_touchPoints[i]);
+ } else if (m_touchPoints[i].state != Qt::TouchPointReleased) {
+ // finger is down but did not move
+ m_touchPoints[i].state = Qt::TouchPointStationary;
+ pointList.append(m_touchPoints[i]);
+ }
+ }
+
+ // inject event into Qt
+ QWindowSystemInterface::handleTouchEvent(w, m_touchDevice, pointList);
+#if defined(QBBEVENTTHREAD_DEBUG)
+ qDebug() << "QBB: Qt touch, w=" << w << ", p=(" << pos[0] << "," << pos[1] << "), t=" << type;
+#endif
+ }
+ }
+}
+
+void QBBEventThread::handleCloseEvent(screen_event_t event)
+{
+ // Query the window that was closed
+ void *handle;
+ int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle);
+ if (result != 0) {
+ qFatal("QBB: failed to query event window, errno=%d", errno);
+ }
+ screen_window_t qnxWindow = static_cast<screen_window_t>(handle);
+
+ // Map window handle to top-level QWindow
+ QWindow *w = QBBIntegration::window(qnxWindow);
+ if (w != 0) {
+ QWindowSystemInterface::handleCloseEvent(w);
+ }
+}
+
diff --git a/src/plugins/platforms/blackberry/qbbeventthread.h b/src/plugins/platforms/blackberry/qbbeventthread.h
new file mode 100644
index 0000000000..afa738830c
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbeventthread.h
@@ -0,0 +1,90 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBEVENTTHREAD_H
+#define QBBEVENTTHREAD_H
+
+#include <QtCore/QThread>
+
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QWindowSystemInterface>
+
+#include <screen/screen.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBBEventThread : public QThread
+{
+public:
+ QBBEventThread(screen_context_t context, QPlatformScreen& screen);
+ virtual ~QBBEventThread();
+
+ static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
+
+protected:
+ virtual void run();
+
+private:
+ enum {
+ MaximumTouchPoints = 10
+ };
+
+ void shutdown();
+ void dispatchEvent(screen_event_t event);
+ void handleKeyboardEvent(screen_event_t event);
+ void handlePointerEvent(screen_event_t event);
+ void handleTouchEvent(screen_event_t event, int type);
+ void handleCloseEvent(screen_event_t event);
+
+ screen_context_t m_screenContext;
+ QPlatformScreen& m_platformScreen;
+ bool m_quit;
+ QPoint m_lastGlobalMousePoint;
+ QPoint m_lastLocalMousePoint;
+ Qt::MouseButtons m_lastButtonState;
+ screen_window_t m_lastMouseWindow;
+ QTouchDevice *m_touchDevice;
+ QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints];
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBEVENTTHREAD_H
diff --git a/src/plugins/platforms/blackberry/qbbglbackingstore.cpp b/src/plugins/platforms/blackberry/qbbglbackingstore.cpp
new file mode 100644
index 0000000000..91b07770e1
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbglbackingstore.cpp
@@ -0,0 +1,189 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbglbackingstore.h"
+#include "qbbglcontext.h"
+#include "qbbwindow.h"
+#include "qbbscreen.h"
+
+#include <QtGui/qwindow.h>
+
+#include <QtOpenGL/private/qgl_p.h>
+#include <QtOpenGL/QGLContext>
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QBBGLPaintDevice::QBBGLPaintDevice(QWindow *window)
+ : QGLPaintDevice(),
+ m_window(0),
+ m_glContext(0)
+{
+ m_window = static_cast<QBBWindow*>(window->handle());
+
+ // Extract the QPlatformOpenGLContext from the window
+ QPlatformOpenGLContext *platformOpenGLContext = m_window->platformOpenGLContext();
+
+ // Convert this to a QGLContext
+ m_glContext = QGLContext::fromOpenGLContext(platformOpenGLContext->context());
+}
+
+QBBGLPaintDevice::~QBBGLPaintDevice()
+{
+ // Cleanup GL context
+ delete m_glContext;
+}
+
+QPaintEngine *QBBGLPaintDevice::paintEngine() const
+{
+ // Select a paint engine based on configued OpenGL version
+ return qt_qgl_paint_engine();
+}
+
+QSize QBBGLPaintDevice::size() const
+{
+ // Get size of EGL surface
+ return m_window->geometry().size();
+}
+
+
+QBBGLBackingStore::QBBGLBackingStore(QWindow *window)
+ : QPlatformBackingStore(window),
+ m_openGLContext(0),
+ m_paintDevice(0),
+ m_requestedSize(),
+ m_size()
+{
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::QBBGLBackingStore - w=" << window;
+#endif
+
+ // Create an OpenGL paint device which in turn creates a QGLContext for us
+ m_paintDevice = new QBBGLPaintDevice(window);
+ m_openGLContext = m_paintDevice->context()->contextHandle();
+}
+
+QBBGLBackingStore::~QBBGLBackingStore()
+{
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::~QBBGLBackingStore - w=" << window();
+#endif
+
+ // cleanup OpenGL paint device
+ delete m_paintDevice;
+}
+
+void QBBGLBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::flush - w=" << window;
+#endif
+
+ // update the display with newly rendered content
+ m_openGLContext->swapBuffers(window);
+}
+
+void QBBGLBackingStore::resize(const QSize &size, const QRegion &staticContents)
+{
+ Q_UNUSED(staticContents);
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::resize - w=" << window() << ", s=" << size;
+#endif
+ // NOTE: defer resizing window buffers until next paint as
+ // resize() can be called multiple times before a paint occurs
+ m_requestedSize = size;
+}
+
+void QBBGLBackingStore::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::beginPaint - w=" << window();
+#endif
+
+ // resize EGL surface if window surface resized
+ if (m_size != m_requestedSize) {
+ resizeSurface(m_requestedSize);
+ }
+}
+
+void QBBGLBackingStore::endPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+#if defined(QBBGLBACKINGSTORE_DEBUG)
+ qDebug() << "QBBGLBackingStore::endPaint - w=" << window();
+#endif
+}
+
+void QBBGLBackingStore::resizeSurface(const QSize &size)
+{
+ // need to destroy surface so make sure its not current
+ bool restoreCurrent = false;
+ QBBGLContext *platformContext = static_cast<QBBGLContext *>(m_openGLContext->handle());
+ if (platformContext->isCurrent()) {
+ m_openGLContext->doneCurrent();
+ restoreCurrent = true;
+ }
+
+ // destroy old EGL surface
+ platformContext->destroySurface();
+
+ // resize window's buffers
+ static_cast<QBBWindow*>(window()->handle())->setBufferSize(size);
+
+ // re-create EGL surface with new size
+ m_size = size;
+ platformContext->createSurface(window()->handle());
+
+ // make context current again
+ if (restoreCurrent) {
+ m_openGLContext->makeCurrent(window());
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbglbackingstore.h b/src/plugins/platforms/blackberry/qbbglbackingstore.h
new file mode 100644
index 0000000000..5455c5767c
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbglbackingstore.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBGLBACKINGSTORE_H
+#define QBBGLBACKINGSTORE_H
+
+#include <QtGui/qplatformbackingstore_qpa.h>
+#include <QtOpenGL/private/qglpaintdevice_p.h>
+
+#include <screen/screen.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGLContext;
+class QBBGLContext;
+class QBBScreen;
+class QBBWindow;
+
+class QBBGLPaintDevice : public QGLPaintDevice
+{
+public:
+ QBBGLPaintDevice(QWindow *window);
+ virtual ~QBBGLPaintDevice();
+
+ virtual QPaintEngine *paintEngine() const;
+ virtual QSize size() const;
+ virtual QGLContext *context() const { return m_glContext; }
+
+private:
+ QBBWindow *m_window;
+ QGLContext *m_glContext;
+};
+
+class QBBGLBackingStore : public QPlatformBackingStore
+{
+public:
+ QBBGLBackingStore(QWindow *window);
+ virtual ~QBBGLBackingStore();
+
+ virtual QPaintDevice *paintDevice() { return m_paintDevice; }
+ virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ virtual void resize(const QSize &size, const QRegion &staticContents);
+ virtual void beginPaint(const QRegion &region);
+ virtual void endPaint(const QRegion &region);
+
+ void resizeSurface(const QSize &size);
+
+private:
+ QOpenGLContext *m_openGLContext;
+ QBBGLPaintDevice *m_paintDevice;
+ QSize m_requestedSize;
+ QSize m_size;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBGLBACKINGSTORE_H
diff --git a/src/plugins/platforms/blackberry/qbbglcontext.cpp b/src/plugins/platforms/blackberry/qbbglcontext.cpp
new file mode 100644
index 0000000000..fb74fdb5d2
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbglcontext.cpp
@@ -0,0 +1,356 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbglcontext.h"
+#include "qbbrootwindow.h"
+#include "qbbscreen.h"
+#include "qbbwindow.h"
+
+#include "private/qeglconvenience_p.h"
+
+#include <QtCore/QDebug>
+#include <QtGui/QOpenGLContext>
+
+QT_BEGIN_NAMESPACE
+
+EGLDisplay QBBGLContext::ms_eglDisplay = EGL_NO_DISPLAY;
+
+static EGLenum checkEGLError(const char *msg)
+{
+ static const char *errmsg[] =
+ {
+ "EGL function succeeded",
+ "EGL is not initialized, or could not be initialized, for the specified display",
+ "EGL cannot access a requested resource",
+ "EGL failed to allocate resources for the requested operation",
+ "EGL fail to access an unrecognized attribute or attribute value was passed in an attribute list",
+ "EGLConfig argument does not name a valid EGLConfig",
+ "EGLContext argument does not name a valid EGLContext",
+ "EGL current surface of the calling thread is no longer valid",
+ "EGLDisplay argument does not name a valid EGLDisplay",
+ "EGL arguments are inconsistent",
+ "EGLNativePixmapType argument does not refer to a valid native pixmap",
+ "EGLNativeWindowType argument does not refer to a valid native window",
+ "EGL one or more argument values are invalid",
+ "EGLSurface argument does not name a valid surface configured for rendering",
+ "EGL power management event has occurred",
+ };
+ EGLenum error = eglGetError();
+ fprintf(stderr, "%s: %s\n", msg, errmsg[error - EGL_SUCCESS]);
+ return error;
+}
+
+QBBGLContext::QBBGLContext(QOpenGLContext *glContext)
+ : QPlatformOpenGLContext(),
+ m_glContext(glContext),
+ m_eglSurface(EGL_NO_SURFACE)
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QSurfaceFormat format = m_glContext->format();
+
+ // Set current rendering API
+ EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
+ }
+
+ // Get colour channel sizes from window format
+ int alphaSize = format.alphaBufferSize();
+ int redSize = format.redBufferSize();
+ int greenSize = format.greenBufferSize();
+ int blueSize = format.blueBufferSize();
+
+ // Check if all channels are don't care
+ if (alphaSize == -1 && redSize == -1 && greenSize == -1 && blueSize == -1) {
+ // Set colour channels based on depth of window's screen
+ QBBScreen *screen = static_cast<QBBScreen*>(QBBScreen::screens().first());
+ int depth = screen->depth();
+ if (depth == 32) {
+ // SCREEN_FORMAT_RGBA8888
+ alphaSize = 8;
+ redSize = 8;
+ greenSize = 8;
+ blueSize = 8;
+ } else {
+ // SCREEN_FORMAT_RGB565
+ alphaSize = 0;
+ redSize = 5;
+ greenSize = 6;
+ blueSize = 5;
+ }
+ } else {
+ // Choose best match based on supported pixel formats
+ if (alphaSize <= 0 && redSize <= 5 && greenSize <= 6 && blueSize <= 5) {
+ // SCREEN_FORMAT_RGB565
+ alphaSize = 0;
+ redSize = 5;
+ greenSize = 6;
+ blueSize = 5;
+ } else {
+ // SCREEN_FORMAT_RGBA8888
+ alphaSize = 8;
+ redSize = 8;
+ greenSize = 8;
+ blueSize = 8;
+ }
+ }
+
+ // Update colour channel sizes in window format
+ format.setAlphaBufferSize(alphaSize);
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setSamples(2);
+
+ // Select EGL config based on requested window format
+ m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format);
+ if (m_eglConfig == 0) {
+ qFatal("QBB: failed to find EGL config");
+ }
+
+ m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttrs());
+ if (m_eglContext == EGL_NO_CONTEXT) {
+ checkEGLError("eglCreateContext");
+ qFatal("QBB: failed to create EGL context, err=%d", eglGetError());
+ }
+
+ // Query/cache window format of selected EGL config
+ m_windowFormat = q_glFormatFromConfig(ms_eglDisplay, m_eglConfig);
+}
+
+QBBGLContext::~QBBGLContext()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ // Cleanup EGL context if it exists
+ if (m_eglContext != EGL_NO_CONTEXT) {
+ eglDestroyContext(ms_eglDisplay, m_eglContext);
+ }
+
+ // Cleanup EGL surface if it exists
+ destroySurface();
+}
+
+void QBBGLContext::initialize()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // Initialize connection to EGL
+ ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (ms_eglDisplay == EGL_NO_DISPLAY) {
+ checkEGLError("eglGetDisplay");
+ qFatal("QBB: failed to obtain EGL display");
+ }
+
+ EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0);
+ if (eglResult != EGL_TRUE) {
+ checkEGLError("eglInitialize");
+ qFatal("QBB: failed to initialize EGL display, err=%d", eglGetError());
+ }
+}
+
+void QBBGLContext::shutdown()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // Close connection to EGL
+ eglTerminate(ms_eglDisplay);
+}
+
+bool QBBGLContext::makeCurrent(QPlatformSurface *surface)
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // Set current rendering API
+ EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
+ }
+
+ if (m_eglSurface == EGL_NO_SURFACE)
+ createSurface(surface);
+
+ eglResult = eglMakeCurrent(ms_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
+ if (eglResult != EGL_TRUE) {
+ checkEGLError("eglMakeCurrent");
+ qFatal("QBB: failed to set current EGL context, err=%d", eglGetError());
+ }
+ return (eglResult == EGL_TRUE);
+}
+
+void QBBGLContext::doneCurrent()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // set current rendering API
+ EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
+ }
+
+ // clear curent EGL context and unbind EGL surface
+ eglResult = eglMakeCurrent(ms_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to clear current EGL context, err=%d", eglGetError());
+ }
+}
+
+void QBBGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ Q_UNUSED(surface);
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ // Set current rendering API
+ EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
+ }
+
+ // Post EGL surface to window
+ eglResult = eglSwapBuffers(ms_eglDisplay, m_eglSurface);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to swap EGL buffers, err=%d", eglGetError());
+ }
+}
+
+QFunctionPointer QBBGLContext::getProcAddress(const QByteArray &procName)
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ // Set current rendering API
+ EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to set EGL API, err=%d", eglGetError());
+ }
+
+ // Lookup EGL extension function pointer
+ return static_cast<QFunctionPointer>(eglGetProcAddress(procName.constData()));
+}
+
+EGLint *QBBGLContext::contextAttrs()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ // Choose EGL settings based on OpenGL version
+#if defined(QT_OPENGL_ES_2)
+ static EGLint attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+ return attrs;
+#else
+ return 0;
+#endif
+}
+
+bool QBBGLContext::isCurrent() const
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ return (eglGetCurrentContext() == m_eglContext);
+}
+
+void QBBGLContext::createSurface(QPlatformSurface *surface)
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // Get a pointer to the corresponding platform window
+ QBBWindow *platformWindow = dynamic_cast<QBBWindow*>(surface);
+ if (!platformWindow) {
+ qFatal("QBB: unable to create EGLSurface without a QBBWindow");
+ }
+
+ // If the platform window does not yet have any buffers, we create
+ // a temporary set of buffers with a size of 1x1 pixels. This will
+ // suffice until such time as the platform window has obtained
+ // buffers of the proper size
+ if (!platformWindow->hasBuffers()) {
+ platformWindow->setPlatformOpenGLContext(this);
+ m_surfaceSize = platformWindow->geometry().size();
+ platformWindow->setBufferSize(m_surfaceSize);
+ }
+
+ // Obtain the native handle for our window
+ screen_window_t handle = platformWindow->nativeHandle();
+
+ const EGLint eglSurfaceAttrs[] =
+ {
+ EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
+ EGL_NONE
+ };
+
+ // Create EGL surface
+ m_eglSurface = eglCreateWindowSurface(ms_eglDisplay, m_eglConfig, (EGLNativeWindowType) handle, eglSurfaceAttrs);
+ if (m_eglSurface == EGL_NO_SURFACE) {
+ checkEGLError("eglCreateWindowSurface");
+ qFatal("QBB: failed to create EGL surface, err=%d", eglGetError());
+ }
+}
+
+void QBBGLContext::destroySurface()
+{
+#if defined(QBBGLCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ // Destroy EGL surface if it exists
+ if (m_eglSurface != EGL_NO_SURFACE) {
+ EGLBoolean eglResult = eglDestroySurface(ms_eglDisplay, m_eglSurface);
+ if (eglResult != EGL_TRUE) {
+ qFatal("QBB: failed to destroy EGL surface, err=%d", eglGetError());
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbglcontext.h b/src/plugins/platforms/blackberry/qbbglcontext.h
new file mode 100644
index 0000000000..8ea1df5f40
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbglcontext.h
@@ -0,0 +1,93 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBGLCONTEXT_H
+#define QBBGLCONTEXT_H
+
+#include <QtGui/QPlatformOpenGLContext>
+#include <QtGui/QSurfaceFormat>
+#include <QtCore/QSize>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBBWindow;
+
+class QBBGLContext : public QPlatformOpenGLContext
+{
+public:
+ QBBGLContext(QOpenGLContext *glContext);
+ virtual ~QBBGLContext();
+
+ static void initialize();
+ static void shutdown();
+
+ virtual bool makeCurrent(QPlatformSurface *surface);
+ virtual void doneCurrent();
+ virtual void swapBuffers(QPlatformSurface *surface);
+ virtual QFunctionPointer getProcAddress(const QByteArray &procName);
+
+ virtual QSurfaceFormat format() const { return m_windowFormat; }
+
+ bool isCurrent() const;
+
+ void createSurface(QPlatformSurface *surface);
+ void destroySurface();
+
+private:
+ /** \todo Should this be non-static so we can use additional displays? */
+ static EGLDisplay ms_eglDisplay;
+
+ QSurfaceFormat m_windowFormat;
+ QOpenGLContext *m_glContext;
+
+ EGLConfig m_eglConfig;
+ EGLContext m_eglContext;
+ EGLSurface m_eglSurface;
+ QSize m_surfaceSize;
+
+ static EGLint *contextAttrs();
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBGLCONTEXT_H
diff --git a/src/plugins/platforms/blackberry/qbbinputcontext_imf.cpp b/src/plugins/platforms/blackberry/qbbinputcontext_imf.cpp
new file mode 100644
index 0000000000..fab3d3f151
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbinputcontext_imf.cpp
@@ -0,0 +1,1696 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbinputcontext_imf.h"
+#include "qbbeventthread.h"
+#include "qbbvirtualkeyboard.h"
+
+#include <QtWidgets/QAbstractSpinBox>
+#include <QtWidgets/QAction>
+
+#include <QtGui/QGuiApplication>
+#include <QtGui/QInputMethodEvent>
+#include <QtGui/QTextCharFormat>
+
+#include <QtCore/QDebug>
+#include <QtCore/QMutex>
+#include <QtCore/QVariant>
+#include <QtCore/QVariantHash>
+#include <QtCore/QWaitCondition>
+
+#include <dlfcn.h>
+#include "imf/imf_client.h"
+#include "imf/input_control.h"
+#include <process.h>
+#include <sys/keycodes.h>
+
+/** TODO:
+ Support inputMethodHints to restrict input (needs additional features in IMF).
+*/
+
+#define STRX(x) #x
+#define STR(x) STRX(x)
+
+// Someone tell me why input_control methods are in this namespace, but the rest is not.
+using namespace InputMethodSystem;
+
+#define qs(x) QString::fromLatin1(x)
+#define iarg(name) event->mArgs[qs(#name)] = QVariant::fromValue(name)
+#define parg(name) event->mArgs[qs(#name)] = QVariant::fromValue((void*)name)
+namespace
+{
+
+spannable_string_t *toSpannableString(const QString &text);
+static const input_session_t *sInputSession = 0;
+bool isSessionOkay(input_session_t *ic)
+{
+ return ic !=0 && sInputSession != 0 && ic->component_id == sInputSession->component_id;
+}
+
+enum ImfEventType
+{
+ ImfBeginBatchEdit,
+ ImfClearMetaKeyStates,
+ ImfCommitText,
+ ImfDeleteSurroundingText,
+ ImfEndBatchEdit,
+ ImfFinishComposingText,
+ ImfGetCursorCapsMode,
+ ImfGetCursorPosition,
+ ImfGetExtractedText,
+ ImfGetSelectedText,
+ ImfGetTextAfterCursor,
+ ImfGetTextBeforeCursor,
+ ImfPerformEditorAction,
+ ImfReportFullscreenMode,
+ ImfSendEvent,
+ ImfSendAsyncEvent,
+ ImfSetComposingRegion,
+ ImfSetComposingText,
+ ImfSetSelection
+};
+
+// We use this class as a round about way to support a posting synchronous event into
+// Qt's main thread from the IMF thread.
+class ImfEventResult
+{
+public:
+ ImfEventResult()
+ {
+ m_mutex.lock();
+ }
+
+ ~ImfEventResult()
+ {
+ m_mutex.unlock();
+ }
+
+ void wait()
+ {
+ m_wait.wait(&m_mutex);
+ }
+
+ void signal()
+ {
+ m_wait.wakeAll();
+ }
+
+ void setResult(const QVariant& result)
+ {
+ m_mutex.lock();
+ m_retVal = result;
+ signal();
+ m_mutex.unlock();
+ }
+
+ QVariant result()
+ {
+ return m_retVal;
+ }
+
+private:
+ QVariant m_retVal;
+ QMutex m_mutex;
+ QWaitCondition m_wait;
+};
+
+class ImfEvent : public QEvent
+{
+ public:
+ ImfEvent(input_session_t *session, ImfEventType type, ImfEventResult *result) :
+ QEvent((QEvent::Type)sUserEventType),
+ m_session(session),
+ m_imfType(type),
+ m_result(result)
+ {
+ }
+ ~ImfEvent() { }
+
+ input_session_t *m_session;
+ ImfEventType m_imfType;
+ QVariantHash m_args;
+ ImfEventResult *m_result;
+
+ static int sUserEventType;
+};
+int ImfEvent::sUserEventType = QEvent::registerEventType();
+
+static int32_t imfBeginBatchEdit(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfBeginBatchEdit, &result);
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfClearMetaKeyStates(input_session_t *ic, int32_t states)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfClearMetaKeyStates, &result);
+ iarg(states);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfCommitText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfCommitText, &result);
+ parg(text);
+ iarg(new_cursor_position);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfDeleteSurroundingText(input_session_t *ic, int32_t left_length, int32_t right_length)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfDeleteSurroundingText, &result);
+ iarg(left_length);
+ iarg(right_length);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfEndBatchEdit(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfEndBatchEdit, &result);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfFinishComposingText(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfFinishComposingText, &result);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static int32_t imfGetCursorCapsMode(input_session_t *ic, int32_t req_modes)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetCursorCapsMode, &result);
+ iarg(req_modes);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static int32_t imfGetCursorPosition(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetCursorPosition, &result);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+
+ return ret;
+}
+
+static extracted_text_t *imfGetExtractedText(input_session_t *ic, extracted_text_request_t *request, int32_t flags)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic)) {
+ extracted_text_t *et = (extracted_text_t *)calloc(sizeof(extracted_text_t),1);
+ et->text = (spannable_string_t *)calloc(sizeof(spannable_string_t),1);
+ return et;
+ }
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetExtractedText, &result);
+ parg(request);
+ iarg(flags);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ return result.result().value<extracted_text_t *>();
+}
+
+static spannable_string_t *imfGetSelectedText(input_session_t *ic, int32_t flags)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetSelectedText, &result);
+ iarg(flags);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ return result.result().value<extracted_text_t *>();
+}
+
+static spannable_string_t *imfGetTextAfterCursor(input_session_t *ic, int32_t n, int32_t flags)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetTextAfterCursor, &result);
+ iarg(n);
+ iarg(flags);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ return result.result().value<extracted_text_t *>();
+}
+
+static spannable_string_t *imfGetTextBeforeCursor(input_session_t *ic, int32_t n, int32_t flags)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfGetTextBeforeCursor, &result);
+ iarg(n);
+ iarg(flags);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ return result.result().value<extracted_text_t *>();
+}
+
+static int32_t imfPerformEditorAction(input_session_t *ic, int32_t editor_action)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfPerformEditorAction, &result);
+ iarg(editor_action);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static int32_t imfReportFullscreenMode(input_session_t *ic, int32_t enabled)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfReportFullscreenMode, &result);
+ iarg(enabled);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static int32_t imfSendEvent(input_session_t *ic, event_t *event)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEvent *imfEvent = new ImfEvent(ic, ImfSendEvent, 0);
+ imfEvent->m_args[qs("event")] = QVariant::fromValue(static_cast<void *>(event));
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), imfEvent);
+
+ return 0;
+}
+
+static int32_t imfSendAsyncEvent(input_session_t *ic, event_t *event)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEvent *imfEvent = new ImfEvent(ic, ImfSendAsyncEvent, 0);
+ imfEvent->m_args[qs("event")] = QVariant::fromValue(static_cast<void *>(event));
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), imfEvent);
+
+ return 0;
+}
+
+static int32_t imfSetComposingRegion(input_session_t *ic, int32_t start, int32_t end)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfSetComposingRegion, &result);
+ iarg(start);
+ iarg(end);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static int32_t imfSetComposingText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfSetComposingText, &result);
+ parg(text);
+ iarg(new_cursor_position);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static int32_t imfSetSelection(input_session_t *ic, int32_t start, int32_t end)
+{
+#if defined(QBBINPUTCONTEXT_IMF_EVENT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ ImfEventResult result;
+ ImfEvent *event = new ImfEvent(ic, ImfSetSelection, &result);
+ iarg(start);
+ iarg(end);
+
+ QCoreApplication::postEvent(QCoreApplication::instance(), event);
+
+ result.wait();
+ int32_t ret = result.result().value<int32_t>();
+ return ret;
+}
+
+static connection_interface_t ic_funcs = {
+ imfBeginBatchEdit,
+ imfClearMetaKeyStates,
+ imfCommitText,
+ imfDeleteSurroundingText,
+ imfEndBatchEdit,
+ imfFinishComposingText,
+ imfGetCursorCapsMode,
+ imfGetCursorPosition,
+ imfGetExtractedText,
+ imfGetSelectedText,
+ imfGetTextAfterCursor,
+ imfGetTextBeforeCursor,
+ imfPerformEditorAction,
+ imfReportFullscreenMode,
+ NULL, //ic_send_key_event
+ imfSendEvent,
+ imfSendAsyncEvent,
+ imfSetComposingRegion,
+ imfSetComposingText,
+ imfSetSelection,
+ NULL, //ic_set_candidates,
+};
+
+static void
+initEvent(event_t *pEvent, const input_session_t *pSession, EventType eventType, int eventId)
+{
+ static int s_transactionId;
+
+ // Make sure structure is squeaky clean since it's not clear just what is significant.
+ memset(pEvent, 0, sizeof(event_t));
+ pEvent->event_type = eventType;
+ pEvent->event_id = eventId;
+ pEvent->pid = getpid();
+ pEvent->component_id = pSession->component_id;
+ pEvent->transaction_id = ++s_transactionId;
+}
+
+spannable_string_t *toSpannableString(const QString &text)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << text;
+#endif
+
+ spannable_string_t *pString = reinterpret_cast<spannable_string_t *>(malloc(sizeof(spannable_string_t)));
+ pString->str = (wchar_t *)malloc(sizeof(wchar_t) * text.length() + 1);
+ pString->length = text.length();
+ pString->spans = NULL;
+ pString->spans_count = 0;
+
+ const QChar *pData = text.constData();
+ wchar_t *pDst = pString->str;
+
+ while (!pData->isNull())
+ {
+ *pDst = pData->unicode();
+ pDst++;
+ pData++;
+ }
+ *pDst = 0;
+
+ return pString;
+}
+
+} // namespace
+
+static const input_session_t *(*p_ictrl_open_session)(connection_interface_t *) = 0;
+static void (*p_ictrl_close_session)(input_session_t *) = 0;
+static int32_t (*p_ictrl_dispatch_event)(event_t*) = 0;
+static int32_t (*p_imf_client_init)() = 0;
+static void (*p_imf_client_disconnect)() = 0;
+static int32_t (*p_vkb_init_selection_service)() = 0;
+static int32_t (*p_ictrl_get_num_active_sessions)() = 0;
+static bool s_imfInitFailed = false;
+
+static bool imfAvailable()
+{
+ static bool s_imfDisabled = getenv("DISABLE_IMF") != NULL;
+ static bool s_imfReady = false;
+
+ if ( s_imfInitFailed || s_imfDisabled) {
+ return false;
+ }
+ else if ( s_imfReady ) {
+ return true;
+ }
+
+ if ( p_imf_client_init == NULL ) {
+ void *handle = dlopen("libinput_client.so.1", 0);
+ if ( handle ) {
+ p_imf_client_init = (int32_t (*)()) dlsym(handle, "imf_client_init");
+ p_imf_client_disconnect = (void (*)()) dlsym(handle, "imf_client_disconnect");
+ p_ictrl_open_session = (const input_session_t *(*)(connection_interface_t *))dlsym(handle, "ictrl_open_session");
+ p_ictrl_close_session = (void (*)(input_session_t *))dlsym(handle, "ictrl_close_session");
+ p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event");
+ p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service");
+ p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions");
+ }
+ else
+ {
+ qCritical() << Q_FUNC_INFO << "libinput_client.so.1 is not present - IMF services are disabled.";
+ s_imfDisabled = true;
+ return false;
+ }
+ if ( p_imf_client_init && p_ictrl_open_session && p_ictrl_dispatch_event ) {
+ s_imfReady = true;
+ }
+ else {
+ p_ictrl_open_session = NULL;
+ p_ictrl_dispatch_event = NULL;
+ s_imfDisabled = true;
+ qCritical() << Q_FUNC_INFO << "libinput_client.so.1 did not contain the correct symbols, library mismatch? IMF services are disabled.";
+ return false;
+ }
+ }
+
+ return s_imfReady;
+}
+
+QBBInputContext::QBBInputContext():
+ QPlatformInputContext(),
+ m_lastCaretPos(0),
+ m_isComposing(false),
+ m_inputPanelVisible(false),
+ m_inputPanelLocale(QLocale::c())
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!imfAvailable())
+ return;
+
+ if ( p_imf_client_init() != 0 ) {
+ s_imfInitFailed = true;
+ qCritical("imf_client_init failed - IMF services will be unavailable");
+ }
+
+ QCoreApplication::instance()->installEventFilter(this);
+
+ // p_vkb_init_selection_service();
+
+ QBBVirtualKeyboard &keyboard = QBBVirtualKeyboard::instance();
+ connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
+ connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
+ keyboardVisibilityChanged(keyboard.isVisible());
+ keyboardLocaleChanged(keyboard.locale());
+
+ QInputMethod *inputMethod = qApp->inputMethod();
+ connect(inputMethod, SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged()));
+
+}
+
+QBBInputContext::~QBBInputContext()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!imfAvailable())
+ return;
+
+ QCoreApplication::instance()->removeEventFilter(this);
+ p_imf_client_disconnect();
+}
+
+#define getarg(type, name) type name = imfEvent->mArgs[qs(#name)].value<type>()
+#define getparg(type, name) type name = (type)(imfEvent->mArgs[qs(#name)].value<void*>())
+
+bool QBBInputContext::isValid() const
+{
+ return imfAvailable();
+}
+
+bool QBBInputContext::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == ImfEvent::sUserEventType) {
+ // Forward the event to our real handler.
+ ImfEvent *imfEvent = static_cast<ImfEvent *>(event);
+ switch (imfEvent->m_imfType) {
+ case ImfBeginBatchEdit: {
+ int32_t ret = onBeginBatchEdit(imfEvent->m_session);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfClearMetaKeyStates: {
+ getarg(int32_t, states);
+ int32_t ret = onClearMetaKeyStates(imfEvent->m_session, states);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfCommitText: {
+ getparg(spannable_string_t*, text);
+ getarg(int32_t, new_cursor_position);
+ int32_t ret = onCommitText(imfEvent->m_session, text, new_cursor_position);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfDeleteSurroundingText: {
+ getarg(int32_t, left_length);
+ getarg(int32_t, right_length);
+ int32_t ret = onDeleteSurroundingText(imfEvent->m_session, left_length, right_length);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfEndBatchEdit: {
+ int32_t ret = onEndBatchEdit(imfEvent->m_session);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfFinishComposingText: {
+ int32_t ret = onFinishComposingText(imfEvent->m_session);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfGetCursorCapsMode: {
+ getarg(int32_t, req_modes);
+ int32_t ret = onGetCursorCapsMode(imfEvent->m_session, req_modes);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfGetCursorPosition: {
+ int32_t ret = onGetCursorPosition(imfEvent->m_session);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfGetExtractedText: {
+ getparg(extracted_text_request_t*, request);
+ getarg(int32_t, flags);
+ extracted_text_t *ret = onGetExtractedText(imfEvent->m_session, request, flags);
+ imfEvent->m_result->setResult(QVariant::fromValue(static_cast<void *>(ret)));
+ break;
+ }
+
+ case ImfGetSelectedText: {
+ getarg(int32_t, flags);
+ spannable_string_t *ret = onGetSelectedText(imfEvent->m_session, flags);
+ imfEvent->m_result->setResult(QVariant::fromValue(static_cast<void *>(ret)));
+ break;
+ }
+
+ case ImfGetTextAfterCursor: {
+ getarg(int32_t, n);
+ getarg(int32_t, flags);
+ spannable_string_t *ret = onGetTextAfterCursor(imfEvent->m_session, n, flags);
+ imfEvent->m_result->setResult(QVariant::fromValue(static_cast<void *>(ret)));
+ break;
+ }
+
+ case ImfGetTextBeforeCursor: {
+ getarg(int32_t, n);
+ getarg(int32_t, flags);
+ spannable_string_t *ret = onGetTextBeforeCursor(imfEvent->m_session, n, flags);
+ imfEvent->m_result->setResult(QVariant::fromValue((void*)ret));
+ break;
+ }
+
+ case ImfPerformEditorAction: {
+ getarg(int32_t, editor_action);
+ int32_t ret = onPerformEditorAction(imfEvent->m_session, editor_action);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfReportFullscreenMode: {
+ getarg(int32_t, enabled);
+ int32_t ret = onReportFullscreenMode(imfEvent->m_session, enabled);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfSendEvent: {
+ getparg(event_t*, event);
+ onSendEvent(imfEvent->m_session, event);
+ break;
+ }
+
+ case ImfSendAsyncEvent: {
+ getparg(event_t*, event);
+ onSendAsyncEvent(imfEvent->m_session, event);
+ break;
+ }
+
+ case ImfSetComposingRegion: {
+ getarg(int32_t, start);
+ getarg(int32_t, end);
+ int32_t ret = onSetComposingRegion(imfEvent->m_session, start, end);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfSetComposingText: {
+ getparg(spannable_string_t*, text);
+ getarg(int32_t, new_cursor_position);
+ int32_t ret = onSetComposingText(imfEvent->m_session, text, new_cursor_position);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+
+ case ImfSetSelection: {
+ getarg(int32_t, start);
+ getarg(int32_t, end);
+ int32_t ret = onSetSelection(imfEvent->m_session, start, end);
+ imfEvent->m_result->setResult(QVariant::fromValue(ret));
+ break;
+ }
+ }; //switch
+
+ return true;
+ } else {
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+ }
+}
+
+bool QBBInputContext::filterEvent( const QEvent *event )
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << event;
+#endif
+ switch (event->type()) {
+ case QEvent::CloseSoftwareInputPanel: {
+ return dispatchCloseSoftwareInputPanel();
+ }
+ case QEvent::RequestSoftwareInputPanel: {
+ return dispatchRequestSoftwareInputPanel();
+ }
+ default:
+ return false;
+ }
+}
+
+void QBBInputContext::reset()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ endComposition();
+}
+
+void QBBInputContext::update(Qt::InputMethodQueries queries)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ reset();
+
+ QPlatformInputContext::update(queries);
+}
+
+void QBBInputContext::closeSession()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO
+#endif
+ if (!imfAvailable())
+ return;
+
+ if (sInputSession) {
+ p_ictrl_close_session((input_session_t *)sInputSession);
+ sInputSession = 0;
+ }
+}
+
+void QBBInputContext::openSession()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO
+#endif
+ if (!imfAvailable())
+ return;
+
+ closeSession();
+ sInputSession = p_ictrl_open_session(&ic_funcs);
+}
+
+bool QBBInputContext::hasSession()
+{
+ return sInputSession != 0;
+}
+
+bool QBBInputContext::hasSelectedText()
+{
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!input)
+ return false;
+
+ QInputMethodQueryEvent query(Qt::ImCurrentSelection);
+ QCoreApplication::sendEvent(input, &query);
+
+ return !query.value(Qt::ImCurrentSelection).toString().isEmpty();
+}
+
+bool QBBInputContext::dispatchRequestSoftwareInputPanel()
+{
+ QBBVirtualKeyboard::instance().showKeyboard();
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << "QBB: requesting virtual keyboard";
+#endif
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return true;
+
+ if (!hasSession())
+ openSession();
+
+ // This also means that the caret position has moved
+ QInputMethodQueryEvent query(Qt::ImCursorPosition);
+ QCoreApplication::sendEvent(input, &query);
+ int caretPos = query.value(Qt::ImCursorPosition).toInt();
+ caret_event_t caretEvent;
+ memset(&caretEvent, 0, sizeof(caret_event_t));
+ initEvent(&caretEvent.event, sInputSession, EVENT_CARET, CARET_POS_CHANGED);
+ caretEvent.old_pos = m_lastCaretPos;
+ m_lastCaretPos = caretEvent.new_pos = caretPos;
+ p_ictrl_dispatch_event((event_t *)&caretEvent);
+ return true;
+}
+
+bool QBBInputContext::dispatchCloseSoftwareInputPanel()
+{
+ QBBVirtualKeyboard::instance().hideKeyboard();
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << "QBB: hiding virtual keyboard";
+#endif
+
+ // This also means we are stopping composition, but we should already have done that.
+ return true;
+}
+
+/**
+ * IMF Event Dispatchers.
+ */
+bool QBBInputContext::dispatchFocusEvent(FocusEventId id, int hints)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!sInputSession) {
+ qWarning() << Q_FUNC_INFO << "Attempt to dispatch a focus event with no input session.";
+ return false;
+ }
+
+ if (!imfAvailable())
+ return false;
+
+ // Set the last caret position to 0 since we don't really have one and we don't
+ // want to have the old one.
+ m_lastCaretPos = 0;
+
+ focus_event_t focusEvent;
+ memset(&focusEvent, 0, sizeof(focusEvent));
+ initEvent(&focusEvent.event, sInputSession, EVENT_FOCUS, id);
+ focusEvent.style = DEFAULT_STYLE;
+
+ if (hints && Qt::ImhNoPredictiveText)
+ focusEvent.style |= NO_PREDICTION | NO_AUTO_CORRECTION;
+ if (hints && Qt::ImhNoAutoUppercase)
+ focusEvent.style |= NO_AUTO_TEXT;
+
+ p_ictrl_dispatch_event((event_t *)&focusEvent);
+
+ return true;
+}
+
+bool QBBInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
+{
+ if (!imfAvailable())
+ return false;
+
+ int key = (flags & KEY_SYM_VALID) ? sym : cap;
+ bool navKey = false;
+ switch ( key ) {
+ case KEYCODE_RETURN:
+ /* In a single line edit we should end composition because enter might be used by something.
+ endComposition();
+ return false;*/
+ break;
+
+ case KEYCODE_BACKSPACE:
+ case KEYCODE_DELETE:
+ // If there is a selection range, then we want a delete key to operate on that (by
+ // deleting the contents of the select range) rather than operating on the composition
+ // range.
+ if (hasSelectedText())
+ return false;
+ break;
+ case KEYCODE_LEFT:
+ key = NAVIGATE_LEFT;
+ navKey = true;
+ break;
+ case KEYCODE_RIGHT:
+ key = NAVIGATE_RIGHT;
+ navKey = true;
+ break;
+ case KEYCODE_UP:
+ key = NAVIGATE_UP;
+ navKey = true;
+ break;
+ case KEYCODE_DOWN:
+ key = NAVIGATE_DOWN;
+ navKey = true;
+ break;
+ case KEYCODE_CAPS_LOCK:
+ case KEYCODE_LEFT_SHIFT:
+ case KEYCODE_RIGHT_SHIFT:
+ case KEYCODE_LEFT_CTRL:
+ case KEYCODE_RIGHT_CTRL:
+ case KEYCODE_LEFT_ALT:
+ case KEYCODE_RIGHT_ALT:
+ case KEYCODE_MENU:
+ case KEYCODE_LEFT_HYPER:
+ case KEYCODE_RIGHT_HYPER:
+ case KEYCODE_INSERT:
+ case KEYCODE_HOME:
+ case KEYCODE_PG_UP:
+ case KEYCODE_END:
+ case KEYCODE_PG_DOWN:
+ // Don't send these
+ key = 0;
+ break;
+ }
+
+ if ( mod & KEYMOD_CTRL ) {
+ // If CTRL is pressed, just let AIR handle it. But terminate any composition first
+ //endComposition();
+ return false;
+ }
+
+ // Pass the keys we don't know about on through
+ if ( key == 0 )
+ return false;
+
+ // IMF doesn't need key releases so just swallow them.
+ if (!(flags & KEY_DOWN))
+ return true;
+
+ if ( navKey ) {
+ // Even if we're forwarding up events, we can't do this for
+ // navigation keys.
+ if ( flags & KEY_DOWN ) {
+ navigation_event_t navEvent;
+ initEvent(&navEvent.event, sInputSession, EVENT_NAVIGATION, key);
+ navEvent.magnitude = 1;
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "dispatch navigation event " << key;
+#endif
+ p_ictrl_dispatch_event(&navEvent.event);
+ }
+ }
+ else {
+ key_event_t keyEvent;
+ initEvent(&keyEvent.event, sInputSession, EVENT_KEY, flags & KEY_DOWN ? IMF_KEY_DOWN : IMF_KEY_UP);
+ keyEvent.key_code = key;
+ keyEvent.character = 0;
+ keyEvent.meta_key_state = 0;
+
+ p_ictrl_dispatch_event(&keyEvent.event);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "dispatch key event " << key;
+#endif
+ }
+
+ scan = 0;
+ return true;
+}
+
+void QBBInputContext::endComposition()
+{
+ if (!m_isComposing)
+ return;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return;
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(QLatin1String(""), attributes);
+ event.setCommitString(m_composingText);
+ m_composingText = QString();
+ m_isComposing = false;
+ QCoreApplication::sendEvent(input, &event);
+
+ action_event_t actionEvent;
+ memset(&actionEvent, 0, sizeof(actionEvent));
+ initEvent(&actionEvent.event, sInputSession, EVENT_ACTION, ACTION_END_COMPOSITION);
+ p_ictrl_dispatch_event(&actionEvent.event);
+}
+
+void QBBInputContext::setComposingText(QString const& composingText)
+{
+ m_composingText = composingText;
+ m_isComposing = true;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return;
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ QTextCharFormat format;
+ format.setFontUnderline(true);
+ attributes.push_back(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, composingText.length(), format));
+
+ QInputMethodEvent event(composingText, attributes);
+
+ QCoreApplication::sendEvent(input, &event);
+}
+
+int32_t QBBInputContext::processEvent(event_t *event)
+{
+ int32_t result = -1;
+ switch (event->event_type) {
+ case EVENT_SPELL_CHECK: {
+ #if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "EVENT_SPELL_CHECK";
+ #endif
+ result = 0;
+ break;
+ }
+
+ case EVENT_NAVIGATION: {
+ #if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "EVENT_NAVIGATION";
+ #endif
+
+ int key = event->event_id == NAVIGATE_UP ? KEYCODE_UP :
+ event->event_id == NAVIGATE_DOWN ? KEYCODE_DOWN :
+ event->event_id == NAVIGATE_LEFT ? KEYCODE_LEFT :
+ event->event_id == NAVIGATE_RIGHT ? KEYCODE_RIGHT : 0;
+
+ QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_CAP_VALID, key, 0, 0, 0);
+ QBBEventThread::injectKeyboardEvent(KEY_CAP_VALID, key, 0, 0, 0);
+ result = 0;
+ break;
+ }
+
+ case EVENT_KEY: {
+ #if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "EVENT_KEY";
+ #endif
+ key_event_t *kevent = static_cast<key_event_t *>(event);
+
+ QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_SYM_VALID | KEY_CAP_VALID, kevent->key_code, 0, 0, kevent->key_code);
+ QBBEventThread::injectKeyboardEvent(KEY_SYM_VALID | KEY_CAP_VALID, kevent->key_code, 0, 0, kevent->key_code);
+
+ result = 0;
+ break;
+ }
+
+ case EVENT_ACTION:
+ // Don't care, indicates that IMF is done.
+ break;
+
+ case EVENT_CARET:
+ case EVENT_NOTHING:
+ case EVENT_FOCUS:
+ case EVENT_USER_ACTION:
+ case EVENT_STROKE:
+ case EVENT_INVOKE_LATER:
+ qCritical() << Q_FUNC_INFO << "Unsupported event type: " << event->event_type;
+ break;
+ default:
+ qCritical() << Q_FUNC_INFO << "Unknown event type: " << event->event_type;
+ }
+ return result;
+}
+
+/**
+ * IMF Event Handlers
+ */
+
+int32_t QBBInputContext::onBeginBatchEdit(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // We don't care.
+ return 0;
+}
+
+int32_t QBBInputContext::onClearMetaKeyStates(input_session_t *ic, int32_t states)
+{
+ Q_UNUSED(states);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // Should never get called.
+ qCritical() << Q_FUNC_INFO << "onClearMetaKeyStates is unsupported.";
+ return 0;
+}
+
+int32_t QBBInputContext::onCommitText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
+{
+ Q_UNUSED(new_cursor_position); // TODO: How can we set the cursor position it's not part of the API.
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ QString commitString = QString::fromWCharArray(text->str, text->length);
+
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "Committing [" << commitString << "]";
+#endif
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(QLatin1String(""), attributes);
+ event.setCommitString(commitString, 0, 0);
+
+ QCoreApplication::sendEvent(input, &event);
+ m_composingText = QString();
+
+ return 0;
+}
+
+int32_t QBBInputContext::onDeleteSurroundingText(input_session_t *ic, int32_t left_length, int32_t right_length)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "L:" << left_length << " R:" << right_length;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ if (hasSelectedText()) {
+ QBBEventThread::injectKeyboardEvent(KEY_DOWN | KEY_CAP_VALID, KEYCODE_DELETE, 0, 0, 0);
+ QBBEventThread::injectKeyboardEvent(KEY_CAP_VALID, KEYCODE_DELETE, 0, 0, 0);
+ reset();
+ return 0;
+ }
+
+ int replacementLength = left_length + right_length;
+ int replacementStart = -left_length;
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(QLatin1String(""), attributes);
+ event.setCommitString(QLatin1String(""), replacementStart, replacementLength);
+ QCoreApplication::sendEvent(input, &event);
+
+ return 0;
+}
+
+int32_t QBBInputContext::onEndBatchEdit(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ return 0;
+}
+
+int32_t QBBInputContext::onFinishComposingText(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ // Only update the control, no need to send a message back to imf (don't call
+ // end composition)
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(QLatin1String(""), attributes);
+ event.setCommitString(m_composingText);
+ m_composingText = QString();
+ m_isComposing = false;
+ QCoreApplication::sendEvent(input, &event);
+
+ return 0;
+}
+
+int32_t QBBInputContext::onGetCursorCapsMode(input_session_t *ic, int32_t req_modes)
+{
+ Q_UNUSED(req_modes);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // Should never get called.
+ qCritical() << Q_FUNC_INFO << "onGetCursorCapsMode is unsupported.";
+
+ return 0;
+}
+
+int32_t QBBInputContext::onGetCursorPosition(input_session_t *ic)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition);
+ QCoreApplication::sendEvent(input, &query);
+ m_lastCaretPos = query.value(Qt::ImCursorPosition).toInt();
+
+ return m_lastCaretPos;
+}
+
+extracted_text_t *QBBInputContext::onGetExtractedText(input_session_t *ic, extracted_text_request_t *request, int32_t flags)
+{
+ Q_UNUSED(flags);
+ Q_UNUSED(request);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic)) {
+ extracted_text_t *et = (extracted_text_t *)calloc(sizeof(extracted_text_t),1);
+ et->text = reinterpret_cast<spannable_string_t *>(calloc(sizeof(spannable_string_t),1));
+ return et;
+ }
+
+ // Used to update dictionaries, but not supported right now.
+ extracted_text_t *et = (extracted_text_t *)calloc(sizeof(extracted_text_t),1);
+ et->text = reinterpret_cast<spannable_string_t *>(calloc(sizeof(spannable_string_t),1));
+
+ return et;
+}
+
+spannable_string_t *QBBInputContext::onGetSelectedText(input_session_t *ic, int32_t flags)
+{
+ Q_UNUSED(flags);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ QInputMethodQueryEvent query(Qt::ImCurrentSelection);
+ QCoreApplication::sendEvent(input, &query);
+ QString text = query.value(Qt::ImCurrentSelection).toString();
+
+ return toSpannableString(text);
+}
+
+spannable_string_t *QBBInputContext::onGetTextAfterCursor(input_session_t *ic, int32_t n, int32_t flags)
+{
+ Q_UNUSED(flags);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return toSpannableString("");
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImSurroundingText);
+ QCoreApplication::sendEvent(input, &query);
+ QString text = query.value(Qt::ImSurroundingText).toString();
+ m_lastCaretPos = query.value(Qt::ImCursorPosition).toInt();
+
+ return toSpannableString(text.mid(m_lastCaretPos+1, n));
+}
+
+spannable_string_t *QBBInputContext::onGetTextBeforeCursor(input_session_t *ic, int32_t n, int32_t flags)
+{
+ Q_UNUSED(flags);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return toSpannableString("");
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return toSpannableString("");
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImSurroundingText);
+ QCoreApplication::sendEvent(input, &query);
+ QString text = query.value(Qt::ImSurroundingText).toString();
+ m_lastCaretPos = query.value(Qt::ImCursorPosition).toInt();
+
+ if (n < m_lastCaretPos) {
+ return toSpannableString(text.mid(m_lastCaretPos - n, n));
+ } else {
+ return toSpannableString(text.mid(0, m_lastCaretPos));
+ }
+}
+
+int32_t QBBInputContext::onPerformEditorAction(input_session_t *ic, int32_t editor_action)
+{
+ Q_UNUSED(editor_action);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // Should never get called.
+ qCritical() << Q_FUNC_INFO << "onPerformEditorAction is unsupported.";
+
+ return 0;
+}
+
+int32_t QBBInputContext::onReportFullscreenMode(input_session_t *ic, int32_t enabled)
+{
+ Q_UNUSED(enabled);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // Should never get called.
+ qCritical() << Q_FUNC_INFO << "onReportFullscreenMode is unsupported.";
+
+ return 0;
+}
+
+int32_t QBBInputContext::onSendEvent(input_session_t *ic, event_t *event)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ return processEvent(event);
+}
+
+int32_t QBBInputContext::onSendAsyncEvent(input_session_t *ic, event_t *event)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ return processEvent(event);
+}
+
+int32_t QBBInputContext::onSetComposingRegion(input_session_t *ic, int32_t start, int32_t end)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImSurroundingText);
+ QCoreApplication::sendEvent(input, &query);
+ QString text = query.value(Qt::ImSurroundingText).toString();
+ m_lastCaretPos = query.value(Qt::ImCursorPosition).toInt();
+
+ QString empty = QString::fromLatin1("");
+ text = text.mid(start, end - start);
+
+ // Delete the current text.
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(empty, attributes);
+ event.setCommitString(empty, start - m_lastCaretPos, end - start);
+ QCoreApplication::sendEvent(input, &event);
+
+ // Move the specified text into a preedit string.
+ setComposingText(text);
+
+ return 0;
+}
+
+int32_t QBBInputContext::onSetComposingText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position)
+{
+ Q_UNUSED(new_cursor_position);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ QInputPanel *panel = qApp->inputPanel();
+ QObject *input = panel->inputItem();
+ if (!imfAvailable() || !input)
+ return 0;
+
+ m_isComposing = true;
+
+ QString preeditString = QString::fromWCharArray(text->str, text->length);
+ setComposingText(preeditString);
+
+ return 0;
+}
+
+int32_t QBBInputContext::onSetSelection(input_session_t *ic, int32_t start, int32_t end)
+{
+ Q_UNUSED(start);
+ Q_UNUSED(end);
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+
+ if (!isSessionOkay(ic))
+ return 0;
+
+ // Should never get called.
+ qCritical() << Q_FUNC_INFO << "onSetSelection is unsupported.";
+
+ return 0;
+}
+
+void QBBInputContext::showInputPanel()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ dispatchRequestSoftwareInputPanel();
+}
+
+void QBBInputContext::hideInputPanel()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ dispatchCloseSoftwareInputPanel();
+}
+
+bool QBBInputContext::isInputPanelVisible() const
+{
+ return m_inputPanelVisible;
+}
+
+QLocale QBBInputContext::locale() const
+{
+ return m_inputPanelLocale;
+}
+
+void QBBInputContext::keyboardVisibilityChanged(bool visible)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "visible=" << visible;
+#endif
+ if (m_inputPanelVisible != visible) {
+ m_inputPanelVisible = visible;
+ emitInputPanelVisibleChanged();
+ }
+}
+
+void QBBInputContext::keyboardLocaleChanged(const QLocale &locale)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "locale=" << locale;
+#endif
+ if (m_inputPanelLocale != locale) {
+ m_inputPanelLocale = locale;
+ emitLocaleChanged();
+ }
+}
+
+void QBBInputContext::inputItemChanged()
+{
+ QInputMethod *inputMethod = qApp->inputMethod();
+ QObject *inputItem = inputMethod->inputItem();
+
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "input item=" << inputItem;
+#endif
+
+ if (!inputItem) {
+ if (m_inputPanelVisible)
+ hideInputPanel();
+ } else {
+ if (qobject_cast<QAbstractSpinBox*>(inputItem)) {
+ QBBVirtualKeyboard::instance().setKeyboardMode(QBBVirtualKeyboard::NumPunc);
+ } else {
+ QBBVirtualKeyboard::instance().setKeyboardMode(QBBVirtualKeyboard::Default);
+ }
+ if (!m_inputPanelVisible)
+ showInputPanel();
+ }
+}
diff --git a/src/plugins/platforms/blackberry/qbbinputcontext_imf.h b/src/plugins/platforms/blackberry/qbbinputcontext_imf.h
new file mode 100644
index 0000000000..135ec02971
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbinputcontext_imf.h
@@ -0,0 +1,132 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBINPUTCONTEXT_H
+#define QBBINPUTCONTEXT_H
+
+#include <QtGui/QPlatformInputContext>
+
+#include <QtCore/QLocale>
+#include <QtCore/QMetaType>
+#include <QtGui/QPlatformIntegration>
+
+#include "imf/imf_client.h"
+#include "imf/input_control.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBBInputContext : public QPlatformInputContext
+{
+ Q_OBJECT
+public:
+ QBBInputContext();
+ ~QBBInputContext();
+
+ virtual bool isValid() const;
+
+ virtual bool filterEvent(const QEvent *event);
+ virtual void reset();
+ virtual void update(Qt::InputMethodQueries);
+ bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
+
+ virtual void showInputPanel();
+ virtual void hideInputPanel();
+ virtual bool isInputPanelVisible() const;
+
+ virtual QLocale locale() const;
+
+protected:
+ // Filters only for IMF events.
+ bool eventFilter(QObject *obj, QEvent *event);
+
+private Q_SLOTS:
+ void keyboardVisibilityChanged(bool visible);
+ void keyboardLocaleChanged(const QLocale &locale);
+ void inputItemChanged();
+
+private:
+ // IMF Event dispatchers
+ bool dispatchFocusEvent(FocusEventId id, int hints = Qt::ImhNone);
+ bool dispatchRequestSoftwareInputPanel();
+ bool dispatchCloseSoftwareInputPanel();
+ int32_t processEvent(event_t *event);
+
+ void closeSession();
+ void openSession();
+ bool hasSession();
+ void endComposition();
+ void setComposingText(QString const &composingText);
+ bool hasSelectedText();
+
+ // IMF Event handlers - these events will come in from QCoreApplication.
+ int32_t onBeginBatchEdit(input_session_t *ic);
+ int32_t onClearMetaKeyStates(input_session_t *ic, int32_t states);
+ int32_t onCommitText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position);
+ int32_t onDeleteSurroundingText(input_session_t *ic, int32_t left_length, int32_t right_length);
+ int32_t onEndBatchEdit(input_session_t *ic);
+ int32_t onFinishComposingText(input_session_t *ic);
+ int32_t onGetCursorCapsMode(input_session_t *ic, int32_t req_modes);
+ int32_t onGetCursorPosition(input_session_t *ic);
+ extracted_text_t *onGetExtractedText(input_session_t *ic, extracted_text_request_t *request, int32_t flags);
+ spannable_string_t *onGetSelectedText(input_session_t *ic, int32_t flags);
+ spannable_string_t *onGetTextAfterCursor(input_session_t *ic, int32_t n, int32_t flags);
+ spannable_string_t *onGetTextBeforeCursor(input_session_t *ic, int32_t n, int32_t flags);
+ int32_t onPerformEditorAction(input_session_t *ic, int32_t editor_action);
+ int32_t onReportFullscreenMode(input_session_t *ic, int32_t enabled);
+ int32_t onSendEvent(input_session_t *ic, event_t *event);
+ int32_t onSendAsyncEvent(input_session_t *ic, event_t *event);
+ int32_t onSetComposingRegion(input_session_t *ic, int32_t start, int32_t end);
+ int32_t onSetComposingText(input_session_t *ic, spannable_string_t *text, int32_t new_cursor_position);
+ int32_t onSetSelection(input_session_t *ic, int32_t start, int32_t end);
+ int32_t onForceUpdate();
+
+ int m_lastCaretPos;
+ bool m_isComposing;
+ QString m_composingText;
+ bool m_inputPanelVisible;
+ QLocale m_inputPanelLocale;
+};
+
+Q_DECLARE_METATYPE(extracted_text_t*)
+
+QT_END_NAMESPACE
+
+#endif // QBBINPUTCONTEXT_H
diff --git a/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp
new file mode 100644
index 0000000000..abe84e2e53
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.cpp
@@ -0,0 +1,187 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbinputcontext_noimf.h"
+#include "qbbvirtualkeyboard.h"
+
+#include <QtCore/QDebug>
+#include <QtGui/QGuiApplication>
+#include <QtWidgets/QAbstractSpinBox>
+
+QBBInputContext::QBBInputContext() :
+ QPlatformInputContext(),
+ m_inputPanelVisible(false),
+ m_inputPanelLocale(QLocale::c())
+{
+ QBBVirtualKeyboard &keyboard = QBBVirtualKeyboard::instance();
+ connect(&keyboard, SIGNAL(visibilityChanged(bool)), this, SLOT(keyboardVisibilityChanged(bool)));
+ connect(&keyboard, SIGNAL(localeChanged(QLocale)), this, SLOT(keyboardLocaleChanged(QLocale)));
+ keyboardVisibilityChanged(keyboard.isVisible());
+ keyboardLocaleChanged(keyboard.locale());
+
+ QInputMethod *inputMethod = qApp->inputMethod();
+ connect(inputMethod, SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged()));
+}
+
+QBBInputContext::~QBBInputContext()
+{
+}
+
+bool QBBInputContext::isValid() const
+{
+ return true;
+}
+
+bool QBBInputContext::hasPhysicalKeyboard()
+{
+ // TODO: This should query the system to check if a USB keyboard is connected.
+ return false;
+}
+
+void QBBInputContext::reset()
+{
+}
+
+bool QBBInputContext::filterEvent( const QEvent *event )
+{
+ if (hasPhysicalKeyboard())
+ return false;
+
+ if (event->type() == QEvent::CloseSoftwareInputPanel) {
+ QBBVirtualKeyboard::instance().hideKeyboard();
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << "QBB: hiding virtual keyboard";
+#endif
+ return false;
+ }
+
+ if (event->type() == QEvent::RequestSoftwareInputPanel) {
+ QBBVirtualKeyboard::instance().showKeyboard();
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << "QBB: requesting virtual keyboard";
+#endif
+ return false;
+ }
+
+ return false;
+
+}
+
+bool QBBInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
+{
+ Q_UNUSED(flags);
+ Q_UNUSED(sym);
+ Q_UNUSED(mod);
+ Q_UNUSED(scan);
+ Q_UNUSED(cap);
+ return false;
+}
+
+void QBBInputContext::showInputPanel()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QBBVirtualKeyboard::instance().showKeyboard();
+}
+
+void QBBInputContext::hideInputPanel()
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QBBVirtualKeyboard::instance().hideKeyboard();
+}
+
+bool QBBInputContext::isInputPanelVisible() const
+{
+ return m_inputPanelVisible;
+}
+
+QLocale QBBInputContext::locale() const
+{
+ return m_inputPanelLocale;
+}
+
+void QBBInputContext::keyboardVisibilityChanged(bool visible)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "visible=" << visible;
+#endif
+ if (m_inputPanelVisible != visible) {
+ m_inputPanelVisible = visible;
+ emitInputPanelVisibleChanged();
+ }
+}
+
+void QBBInputContext::keyboardLocaleChanged(const QLocale &locale)
+{
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "locale=" << locale;
+#endif
+ if (m_inputPanelLocale != locale) {
+ m_inputPanelLocale = locale;
+ emitLocaleChanged();
+ }
+}
+
+void QBBInputContext::inputItemChanged()
+{
+ QInputMethod *inputMethod = qApp->inputMethod();
+ QObject *inputItem = inputMethod->inputItem();
+
+#if defined(QBBINPUTCONTEXT_DEBUG)
+ qDebug() << Q_FUNC_INFO << "input item=" << inputItem;
+#endif
+
+ if (!inputItem) {
+ if (m_inputPanelVisible)
+ hideInputPanel();
+ } else {
+ if (qobject_cast<QAbstractSpinBox*>(inputItem)) {
+ QBBVirtualKeyboard::instance().setKeyboardMode(QBBVirtualKeyboard::NumPunc);
+ } else {
+ QBBVirtualKeyboard::instance().setKeyboardMode(QBBVirtualKeyboard::Default);
+ }
+ if (!m_inputPanelVisible)
+ showInputPanel();
+ }
+}
diff --git a/src/plugins/platforms/blackberry/qbbinputcontext_noimf.h b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.h
new file mode 100644
index 0000000000..3d4d6da830
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbinputcontext_noimf.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBINPUTCONTEXT_H
+#define QBBINPUTCONTEXT_H
+
+#include <QtCore/QLocale>
+#include <QtGui/QPlatformInputContext>
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QBBInputContext : public QPlatformInputContext
+{
+ Q_OBJECT
+public:
+ explicit QBBInputContext();
+ ~QBBInputContext();
+
+ virtual bool isValid() const;
+
+ void reset();
+ virtual bool filterEvent( const QEvent *event );
+ bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
+
+ virtual void showInputPanel();
+ virtual void hideInputPanel();
+ virtual bool isInputPanelVisible() const;
+
+ virtual QLocale locale() const;
+
+private Q_SLOTS:
+ void keyboardVisibilityChanged(bool visible);
+ void keyboardLocaleChanged(const QLocale &locale);
+ void inputItemChanged();
+
+private:
+ bool hasPhysicalKeyboard();
+
+ bool m_inputPanelVisible;
+ QLocale m_inputPanelLocale;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBINPUTCONTEXT_H
diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp
new file mode 100644
index 0000000000..9f922a419e
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbintegration.cpp
@@ -0,0 +1,293 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbbintegration.h"
+#include "qbbeventthread.h"
+#include "qbbglbackingstore.h"
+#include "qbbglcontext.h"
+#include "qbbnavigatorthread.h"
+#include "qbbrasterbackingstore.h"
+#include "qbbscreen.h"
+#include "qbbwindow.h"
+#include "qbbvirtualkeyboard.h"
+#include "qbbclipboard.h"
+#include "qbbglcontext.h"
+
+#if defined(QBB_IMF)
+#include "qbbinputcontext_imf.h"
+#else
+#include "qbbinputcontext_noimf.h"
+#endif
+
+#include "private/qgenericunixfontdatabase_p.h"
+#include "private/qgenericunixeventdispatcher_p.h"
+
+#include <QtGui/QPlatformWindow>
+#include <QtGui/QWindowSystemInterface>
+#include <QtGui/QOpenGLContext>
+
+#include <QtCore/QDebug>
+#include <QtCore/QHash>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QBBWindowMapper QBBIntegration::ms_windowMapper;
+QMutex QBBIntegration::ms_windowMapperMutex;
+
+QBBIntegration::QBBIntegration()
+ : QPlatformIntegration()
+ , m_eventThread(0)
+ , m_navigatorThread(0)
+ , m_inputContext(0)
+ , m_fontDatabase(new QGenericUnixFontDatabase())
+ , m_paintUsingOpenGL(false)
+ , m_eventDispatcher(createUnixEventDispatcher())
+#ifndef QT_NO_CLIPBOARD
+ , m_clipboard(0)
+#endif
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // Open connection to QNX composition manager
+ errno = 0;
+ int result = screen_create_context(&m_screenContext, SCREEN_APPLICATION_CONTEXT);
+ if (result != 0) {
+ qFatal("QBB: failed to connect to composition manager, errno=%d", errno);
+ }
+
+ // Create displays for all possible screens (which may not be attached)
+ QBBScreen::createDisplays(m_screenContext);
+ Q_FOREACH (QPlatformScreen *screen, QBBScreen::screens()) {
+ screenAdded(screen);
+ }
+
+ // Initialize global OpenGL resources
+ QBBGLContext::initialize();
+
+ // Create/start event thread
+ m_eventThread = new QBBEventThread(m_screenContext, *QBBScreen::primaryDisplay());
+ m_eventThread->start();
+
+ // Create/start navigator thread
+ m_navigatorThread = new QBBNavigatorThread(*QBBScreen::primaryDisplay());
+ m_navigatorThread->start();
+
+ // Create/start the keyboard class.
+ QBBVirtualKeyboard::instance();
+
+ // Set up the input context
+ m_inputContext = new QBBInputContext;
+}
+
+QBBIntegration::~QBBIntegration()
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << "QBB: platform plugin shutdown begin";
+#endif
+ // Destroy the keyboard class.
+ QBBVirtualKeyboard::destroy();
+
+#ifndef QT_NO_CLIPBOARD
+ // Delete the clipboard
+ delete m_clipboard;
+#endif
+
+ // Stop/destroy event thread
+ delete m_eventThread;
+
+ // Stop/destroy navigator thread
+ delete m_navigatorThread;
+
+ // Destroy all displays
+ QBBScreen::destroyDisplays();
+
+ // Close connection to QNX composition manager
+ screen_destroy_context(m_screenContext);
+
+ // Cleanup global OpenGL resources
+ QBBGLContext::shutdown();
+
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << "QBB: platform plugin shutdown end";
+#endif
+}
+
+bool QBBIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+#if defined(QT_OPENGL_ES)
+ case OpenGL:
+ return true;
+#endif
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformWindow *QBBIntegration::createPlatformWindow(QWindow *window) const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ // New windows are created on the primary display.
+ return new QBBWindow(window, m_screenContext);
+}
+
+QPlatformBackingStore *QBBIntegration::createPlatformBackingStore(QWindow *window) const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ if (paintUsingOpenGL())
+ return new QBBGLBackingStore(window);
+ else
+ return new QBBRasterBackingStore(window);
+}
+
+QPlatformOpenGLContext *QBBIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ return new QBBGLContext(context);
+}
+
+QPlatformInputContext *QBBIntegration::inputContext() const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ return m_inputContext;
+}
+
+void QBBIntegration::moveToScreen(QWindow *window, int screen)
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << "QBBIntegration::moveToScreen - w=" << window << ", s=" << screen;
+#endif
+
+ // get platform window used by widget
+ QBBWindow *platformWindow = static_cast<QBBWindow *>(window->handle());
+
+ // lookup platform screen by index
+ QBBScreen *platformScreen = static_cast<QBBScreen*>(QBBScreen::screens().at(screen));
+
+ // move the platform window to the platform screen
+ platformWindow->setScreen(platformScreen);
+}
+
+QList<QPlatformScreen *> QBBIntegration::screens() const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ return QBBScreen::screens();
+}
+
+QAbstractEventDispatcher *QBBIntegration::guiThreadEventDispatcher() const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ return m_eventDispatcher;
+}
+
+#ifndef QT_NO_CLIPBOARD
+QPlatformClipboard *QBBIntegration::clipboard() const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ if (!m_clipboard) {
+ m_clipboard = new QBBClipboard;
+ }
+ return m_clipboard;
+}
+#endif
+
+QVariant QBBIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ if (hint == ShowIsFullScreen)
+ return true;
+
+ return QPlatformIntegration::styleHint(hint);
+}
+
+QWindow *QBBIntegration::window(screen_window_t qnxWindow)
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QMutexLocker locker(&ms_windowMapperMutex);
+ Q_UNUSED(locker);
+ return ms_windowMapper.value(qnxWindow, 0);
+}
+
+void QBBIntegration::addWindow(screen_window_t qnxWindow, QWindow *window)
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QMutexLocker locker(&ms_windowMapperMutex);
+ Q_UNUSED(locker);
+ ms_windowMapper.insert(qnxWindow, window);
+}
+
+void QBBIntegration::removeWindow(screen_window_t qnxWindow)
+{
+#if defined(QBBINTEGRATION_DEBUG)
+ qDebug() << Q_FUNC_INFO;
+#endif
+ QMutexLocker locker(&ms_windowMapperMutex);
+ Q_UNUSED(locker);
+ ms_windowMapper.remove(qnxWindow);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbintegration.h b/src/plugins/platforms/blackberry/qbbintegration.h
new file mode 100644
index 0000000000..6b54329dac
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbintegration.h
@@ -0,0 +1,119 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBINTEGRATION_H
+#define QBBINTEGRATION_H
+
+#include <QtGui/qplatformintegration_qpa.h>
+
+#include <QtCore/qmutex.h>
+
+#include <screen/screen.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBBEventThread;
+class QBBInputContext;
+class QBBNavigatorThread;
+class QBBWindow;
+
+#ifndef QT_NO_CLIPBOARD
+class QBBClipboard;
+#endif
+
+template<class K, class V> class QHash;
+typedef QHash<screen_window_t, QWindow *> QBBWindowMapper;
+
+class QBBIntegration : public QPlatformIntegration
+{
+public:
+ QBBIntegration();
+ virtual ~QBBIntegration();
+
+ virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
+
+ virtual QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+
+ virtual QPlatformInputContext *inputContext() const;
+
+ virtual QList<QPlatformScreen *> screens() const;
+ virtual void moveToScreen(QWindow *window, int screen);
+
+ virtual QAbstractEventDispatcher *guiThreadEventDispatcher() const;
+
+ virtual QPlatformFontDatabase *fontDatabase() const { return m_fontDatabase; }
+
+#ifndef QT_NO_CLIPBOARD
+ virtual QPlatformClipboard *clipboard() const;
+#endif
+
+ virtual QVariant styleHint(StyleHint hint) const;
+
+ bool paintUsingOpenGL() const { return m_paintUsingOpenGL; }
+
+ static QWindow *window(screen_window_t qnxWindow);
+
+private:
+ static void addWindow(screen_window_t qnxWindow, QWindow *window);
+ static void removeWindow(screen_window_t qnxWindow);
+
+ screen_context_t m_screenContext;
+ QBBEventThread *m_eventThread;
+ QBBNavigatorThread *m_navigatorThread;
+ QBBInputContext *m_inputContext;
+ QPlatformFontDatabase *m_fontDatabase;
+ bool m_paintUsingOpenGL;
+ QAbstractEventDispatcher *m_eventDispatcher;
+#ifndef QT_NO_CLIPBOARD
+ mutable QBBClipboard* m_clipboard;
+#endif
+
+ static QBBWindowMapper ms_windowMapper;
+ static QMutex ms_windowMapperMutex;
+
+ friend class QBBWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBBINTEGRATION_H
diff --git a/src/plugins/platforms/blackberry/qbbkeytranslator.h b/src/plugins/platforms/blackberry/qbbkeytranslator.h
new file mode 100644
index 0000000000..fdc1220aba
--- /dev/null
+++ b/src/plugins/platforms/blackberry/qbbkeytranslator.h
@@ -0,0 +1,269 @@
+/***************************************************************************
+**
+** Copyright (C) 2011 - 2012 Research In Motion
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBBKEYTRANSLATOR_H
+#define QBBKEYTRANSLATOR_H
+
+#include <sys/keyc