diff options
author | Martin Smith <martin.smith@nokia.com> | 2010-06-18 12:48:31 (GMT) |
---|---|---|
committer | Martin Smith <martin.smith@nokia.com> | 2010-06-18 12:48:31 (GMT) |
commit | 94ac0b1608cd3142096835536ac56f9335094a33 (patch) | |
tree | c337a28795dc1b086911e70dbcd133c443360fbe | |
parent | f0ef28beec5531d2cd0c2829b272710dbc3991af (diff) | |
parent | 618a64c9aa855625e34635c368c18e53aa3cffe1 (diff) | |
download | Qt-94ac0b1608cd3142096835536ac56f9335094a33.zip Qt-94ac0b1608cd3142096835536ac56f9335094a33.tar.gz Qt-94ac0b1608cd3142096835536ac56f9335094a33.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
47 files changed, 543 insertions, 273 deletions
diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 939c38e..8b787cb 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -78,6 +78,7 @@ Where supported options are as follows: as a comments. Also empty lines are ignored. The paths in <file> can be absolute or relative to <file>. [-u|unsigned] = Preserves the unsigned package. + [-o|only-unsigned] = Creates only unsigned package. [-s|stub] = Generates stub sis for ROM. [-n|sisname <name>] = Specifies the final sis name. Where parameters are as follows: @@ -121,11 +122,13 @@ my $certfile = ""; my $preserveUnsigned = ""; my $stub = ""; my $signed_sis_name = ""; +my $onlyUnsigned = ""; unless (GetOptions('i|install' => \$install, 'p|preprocess' => \$preprocessonly, 'c|certfile=s' => \$certfile, 'u|unsigned' => \$preserveUnsigned, + 'o|only-unsigned' => \$onlyUnsigned, 's|stub' => \$stub, 'n|sisname=s' => \$signed_sis_name,)) { Usage(); @@ -292,7 +295,10 @@ if($stub) { # Create stub SIS. system ("makesis -s $pkgoutput $stub_sis_name"); } else { - if ($certtext eq "Self Signed" && !@certificates && $templatepkg !~ m/_installer\.pkg$/i) { + if ($certtext eq "Self Signed" + && !@certificates + && $templatepkg !~ m/_installer\.pkg$/i + && !$onlyUnsigned) { print("Auto-patching capabilities for self signed package.\n"); system ("patch_capabilities $pkgoutput"); } @@ -302,6 +308,25 @@ if($stub) { system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed"); print("\n"); + my $targetInsert = ""; + if ($targetplatform ne "-") { + $targetInsert = " for $targetplatform"; + } + + if ($onlyUnsigned) { + stat($unsigned_sis_name); + if( -e _ ) { + print ("Successfully created unsigned package ${unsigned_sis_name}${targetInsert}!\n"); + } else { + print ("\nUnsigned package creation failed!\n"); + } + + if (!$preservePkgOutput) { + unlink $pkgoutput; + } + exit; + } + # Sign SIS with certificate info given as an argument. my $relcert = File::Spec->abs2rel($certificate); my $relkey = File::Spec->abs2rel($key); @@ -311,11 +336,7 @@ if($stub) { # Check if creating signed SIS Succeeded stat($signed_sis_name); if( -e _ ) { - my $targetInsert = ""; - if ($targetplatform ne "-") { - $targetInsert = "for $targetplatform "; - } - print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n"); + print ("Successfully created signed package ${signed_sis_name}${targetInsert} using certificate: $certtext!\n"); # Sign with additional certificates & keys for my $row ( @certificates ) { diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index 9741bc3..501939a 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -269,7 +269,8 @@ if (@ARGV) } print ("\n"); - print ("NOTE: A patched package should not be used for distribution!\n"); + print ("NOTE: A patched package may not work as expected due to reduced capabilities.\n"); + print (" Therefore it should not be used for any kind of Symbian signing or distribution!\n"); print ("\n"); } } diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 9a721da..9c4bfa8 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -115,6 +115,8 @@ Rectangle { id: nameInputText anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } focus: false + autoScroll: false + maximumLength: 24 onTextChanged: { var newWidth = nameInputText.width + dialogText.width + 40; if ( (newWidth > nameInputDialog.width && newWidth < screen.width) diff --git a/demos/declarative/snake/content/Link.qml b/demos/declarative/snake/content/Link.qml index 9aa6006..f4d7165 100644 --- a/demos/declarative/snake/content/Link.qml +++ b/demos/declarative/snake/content/Link.qml @@ -73,12 +73,14 @@ Item { id:link } } + /* transform: Rotation { id: actualImageRotation origin.x: width/2; origin.y: height/2; angle: rotation * 90 Behavior on angle { NumberAnimation { duration: spawned ? 200 : 0} } } + */ } Image { diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 173fb6d..03c0ec4 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -425,6 +425,9 @@ value will not be accessible from script. \l {Extending QML - Signal Support Example} shows the complete code used to implement the onPartyStarted signal property. +If you want to use signals from items not created in QML, you can access their +signals with the \l {Connections} element. + \section1 Property Value Sources \snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 0 diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 7d696d7..784c59a 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -269,5 +269,10 @@ For example: \c [project/main.qml] \snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0 +Note that the resource system cannot be accessed from QML directly. If the main QML file is +loaded as a resource, all files specifed as relative paths in QML will also be loaded from +the resource system. Using the resource system is completely transparent to the QML layer. +This also means that if the main QML file is not loaded as a resource then files in the resource +system cannot be accessed from QML. */ diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index 6ffc568..316764b 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -127,6 +127,7 @@ \row \o \c run \o Run the application on the emulator. \row \o \c runonphone \o Run the application on a device. \row \o \c sis \o Create signed \c .sis file for project. + \row \o \c unsigned_sis \o Create unsigned \c .sis file for project. \row \o \c installer_sis \o Create signed \l{Smart Installer}{smart installer} \c .sis file for project. Smart installer will attempt to download @@ -193,6 +194,7 @@ \row \o -p \o Only preprocess the template \c .pkg file. \row \o -c <file> \o Read certificate information from a file. \row \o -u \o Preserves unsigned package. + \row \o -o \o Creates only unsigned package. \row \o -s \o Generates stub sis for ROM. \row \o -n <name> \o Specifies the final sis name. \endtable diff --git a/mkspecs/features/sis_targets.prf b/mkspecs/features/sis_targets.prf index b149a22..37b758b 100644 --- a/mkspecs/features/sis_targets.prf +++ b/mkspecs/features/sis_targets.prf @@ -32,6 +32,24 @@ equals(GENERATE_SIS_TARGETS, true) { ok_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) $$basename(TARGET)_template.pkg \ $(QT_SIS_TARGET) $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) + unsigned_sis_target.target = unsigned_sis + unsigned_sis_target.commands = $(if $(wildcard $$basename(TARGET)_template.pkg), \ + $(if $(wildcard $$make_cache_name), \ + $(MAKE) -f $(MAKEFILE) ok_unsigned_sis MAKEFILES=$$make_cache_name \ + , \ + $(if $(QT_SIS_TARGET), \ + $(MAKE) -f $(MAKEFILE) ok_unsigned_sis \ + , \ + $(MAKE) -f $(MAKEFILE) fail_sis_nocache \ + ) \ + ) \ + , \ + $(MAKE) -f $(MAKEFILE) fail_sis_nopkg \ + ) + + ok_unsigned_sis_target.target = ok_unsigned_sis + ok_unsigned_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) -o $$basename(TARGET)_template.pkg $(QT_SIS_TARGET) + target_sis_target.target = $${sis_destdir}$${TARGET}.sis target_sis_target.commands = $(MAKE) -f $(MAKEFILE) sis @@ -74,6 +92,8 @@ equals(GENERATE_SIS_TARGETS, true) { QMAKE_EXTRA_TARGETS += sis_target \ ok_sis_target \ + unsigned_sis_target \ + ok_unsigned_sis_target \ target_sis_target \ installer_sis_target \ ok_installer_sis_target \ @@ -114,6 +134,10 @@ equals(GENERATE_SIS_TARGETS, true) { - $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) sis_target.depends = first + unsigned_sis_target.target = unsigned_sis + unsigned_sis_target.commands = createpackage $(QT_SIS_OPTIONS) -o $$basename(TARGET)_template.pkg + unsigned_sis_target.depends = first + target_sis_target.target = $${sis_destdir}$${TARGET}.sis target_sis_target.commands = $(MAKE) -f $(MAKEFILE) sis @@ -128,6 +152,7 @@ equals(GENERATE_SIS_TARGETS, true) { } QMAKE_EXTRA_TARGETS += sis_target \ + unsigned_sis_target \ target_sis_target \ installer_sis_target } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-dump.c b/src/3rdparty/harfbuzz/src/harfbuzz-dump.c index a1ef6b6..54d42e9 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-dump.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-dump.c @@ -519,13 +519,13 @@ Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE) DUMP_FINT (ValueRecord, XAdvance); if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE) - RECURSE (Device, Device, &*ValueRecord->XPlacementDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_X_PLACEMENT_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE) - RECURSE (Device, Device, &*ValueRecord->YPlacementDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_Y_PLACEMENT_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE) - RECURSE (Device, Device, &*ValueRecord->XAdvanceDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_X_ADVANCE_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE) - RECURSE (Device, Device, &*ValueRecord->YAdvanceDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_Y_ADVANCE_DEVICE]); #ifdef HB_SUPPORT_MULTIPLE_MASTER if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT) DUMP_FUINT (ValueRecord, XIdPlacement); diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-global.h b/src/3rdparty/harfbuzz/src/harfbuzz-global.h index bccd6a2..5b2b679 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-global.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-global.h @@ -39,7 +39,7 @@ #define HB_END_HEADER /* nothing */ #endif -#if defined(__GNUC__) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(__ARMCC__) || defined(__CC_ARM) || defined(_MSC_VER) #define HB_USE_PACKED_STRUCTS #endif diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h b/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h index d513c27..3a4952b 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h @@ -38,6 +38,11 @@ HB_BEGIN_HEADER /* shared tables */ +#define VR_X_PLACEMENT_DEVICE 0 +#define VR_Y_PLACEMENT_DEVICE 1 +#define VR_X_ADVANCE_DEVICE 2 +#define VR_Y_ADVANCE_DEVICE 3 + struct HB_ValueRecord_ { HB_Short XPlacement; /* horizontal adjustment for @@ -48,14 +53,10 @@ struct HB_ValueRecord_ advance */ HB_Short YAdvance; /* vertical adjustment for advance */ - HB_Device* XPlacementDevice; /* device table for horizontal - placement */ - HB_Device* YPlacementDevice; /* device table for vertical - placement */ - HB_Device* XAdvanceDevice; /* device table for horizontal - advance */ - HB_Device* YAdvanceDevice; /* device table for vertical - advance */ + + HB_Device** DeviceTables; /* device tables for placement + and advance */ + #ifdef HB_SUPPORT_MULTIPLE_MASTER HB_UShort XIdPlacement; /* horizontal placement metric ID */ HB_UShort YIdPlacement; /* vertical placement metric ID */ @@ -70,6 +71,8 @@ typedef struct HB_ValueRecord_ HB_ValueRecord; /* Mask values to scan the value format of the ValueRecord structure. We always expand compressed ValueRecords of the font. */ +#define HB_GPOS_FORMAT_HAVE_DEVICE_TABLES 0x00F0 + #define HB_GPOS_FORMAT_HAVE_X_PLACEMENT 0x0001 #define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT 0x0002 #define HB_GPOS_FORMAT_HAVE_X_ADVANCE 0x0004 @@ -533,18 +536,18 @@ typedef struct HB_ContextPos_ HB_ContextPos; struct HB_ChainPosRule_ { + HB_UShort* Backtrack; /* array of backtrack glyph IDs */ + HB_UShort* Input; /* array of input glyph IDs */ + HB_UShort* Lookahead; /* array of lookahead glyph IDs */ + HB_PosLookupRecord* PosLookupRecord; + /* array of PosLookupRecords */ HB_UShort BacktrackGlyphCount; /* total number of backtrack glyphs */ - HB_UShort* Backtrack; /* array of backtrack glyph IDs */ HB_UShort InputGlyphCount; /* total number of input glyphs */ - HB_UShort* Input; /* array of input glyph IDs */ HB_UShort LookaheadGlyphCount; /* total number of lookahead glyphs */ - HB_UShort* Lookahead; /* array of lookahead glyph IDs */ HB_UShort PosCount; /* number of PosLookupRecords */ - HB_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecords */ }; typedef struct HB_ChainPosRule_ HB_ChainPosRule; @@ -574,20 +577,20 @@ typedef struct HB_ChainContextPosFormat1_ HB_ChainContextPosFormat1; struct HB_ChainPosClassRule_ { + HB_UShort* Backtrack; /* array of backtrack classes */ + HB_UShort* Input; /* array of context classes */ + HB_UShort* Lookahead; /* array of lookahead classes */ + HB_PosLookupRecord* PosLookupRecord; + /* array of substitution lookups */ HB_UShort BacktrackGlyphCount; /* total number of backtrack classes */ - HB_UShort* Backtrack; /* array of backtrack classes */ HB_UShort InputGlyphCount; /* total number of context classes */ - HB_UShort* Input; /* array of context classes */ HB_UShort LookaheadGlyphCount; /* total number of lookahead classes */ - HB_UShort* Lookahead; /* array of lookahead classes */ HB_UShort PosCount; /* number of PosLookupRecords */ - HB_PosLookupRecord* PosLookupRecord; - /* array of substitution lookups */ }; typedef struct HB_ChainPosClassRule_ HB_ChainPosClassRule; diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c index 61e42fd..1933f3d 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c @@ -256,6 +256,20 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, else vr->YAdvance = 0; + if ( format & HB_GPOS_FORMAT_HAVE_DEVICE_TABLES ) + { + if ( ALLOC_ARRAY( vr->DeviceTables, 4, HB_Device ) ) + return error; + vr->DeviceTables[VR_X_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_Y_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_X_PLACEMENT_DEVICE] = 0; + vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] = 0; + } + else + { + vr->DeviceTables = 0; + } + if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) { if ( ACCESS_Frame( 2L ) ) @@ -271,18 +285,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->XPlacementDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE], stream ) ) != HB_Err_Ok ) return error; (void)FILE_Seek( cur_offset ); } - else - goto empty1; - } - else - { - empty1: - vr->XPlacementDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) @@ -300,18 +307,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->YPlacementDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail3; (void)FILE_Seek( cur_offset ); } - else - goto empty2; - } - else - { - empty2: - vr->YPlacementDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) @@ -329,18 +329,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->XAdvanceDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail2; (void)FILE_Seek( cur_offset ); } - else - goto empty3; - } - else - { - empty3: - vr->XAdvanceDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) @@ -358,18 +351,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->YAdvanceDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail1; (void)FILE_Seek( cur_offset ); } - else - goto empty4; - } - else - { - empty4: - vr->YAdvanceDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT ) @@ -447,13 +433,15 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); Fail2: - _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); Fail3: - _HB_OPEN_Free_Device( &vr->YPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); + + FREE( vr->DeviceTables ); return error; } @@ -462,13 +450,14 @@ static void Free_ValueRecord( HB_ValueRecord* vr, HB_UShort format ) { if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->YPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->XPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE] ); + FREE( vr->DeviceTables ); } @@ -511,24 +500,34 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi, { /* pixel -> fractional pixel */ + if ( format & HB_GPOS_FORMAT_HAVE_DEVICE_TABLES ) + { + if ( ALLOC_ARRAY( vr->DeviceTables, 4, HB_Device ) ) + return error; + vr->DeviceTables[VR_X_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_Y_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_X_PLACEMENT_DEVICE] = 0; + vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] = 0; + } + if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) { - _HB_OPEN_Get_Device( &vr->XPlacementDevice, x_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE], x_ppem, &pixel_value ); gd->x_pos += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) { - _HB_OPEN_Get_Device( &vr->YPlacementDevice, y_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE], y_ppem, &pixel_value ); gd->y_pos += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) { - _HB_OPEN_Get_Device( &vr->XAdvanceDevice, x_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE], x_ppem, &pixel_value ); gd->x_advance += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) { - _HB_OPEN_Get_Device( &vr->YAdvanceDevice, y_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE], y_ppem, &pixel_value ); gd->y_advance += pixel_value << 6; } } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h index 32f5781..ab5c07a 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h @@ -258,6 +258,10 @@ typedef struct HB_Font_ { void *userData; } HB_FontRec; +#ifdef HB_USE_PACKED_STRUCTS +#pragma pack(pop) +#endif + typedef struct HB_ShaperItem_ HB_ShaperItem; struct HB_ShaperItem_ { @@ -285,10 +289,6 @@ struct HB_ShaperItem_ { HB_Bool HB_ShapeItem(HB_ShaperItem *item); -#ifdef HB_USE_PACKED_STRUCTS -#pragma pack(pop) -#endif - HB_END_HEADER #endif diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index c1ff353..73c71ea 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -62,6 +62,9 @@ public: QByteArray defaultBuf; int ioIndex; + virtual qint64 peek(char *data, qint64 maxSize); + virtual QByteArray peek(qint64 maxSize); + #ifndef QT_NO_QOBJECT // private slots void _q_emitSignals(); @@ -83,6 +86,21 @@ void QBufferPrivate::_q_emitSignals() } #endif +qint64 QBufferPrivate::peek(char *data, qint64 maxSize) +{ + qint64 readBytes = qMin(maxSize, static_cast<qint64>(buf->size()) - pos); + memcpy(data, buf->constData() + pos, readBytes); + return readBytes; +} + +QByteArray QBufferPrivate::peek(qint64 maxSize) +{ + qint64 readBytes = qMin(maxSize, static_cast<qint64>(buf->size()) - pos); + if (pos == 0 && maxSize >= buf->size()) + return *buf; + return QByteArray(buf->constData() + pos, readBytes); +} + /*! \class QBuffer \reentrant diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index d2e4f75..ea60792 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1442,6 +1442,35 @@ bool QIODevicePrivate::putCharHelper(char c) return q_func()->write(&c, 1) == 1; } +/*! + \internal +*/ +qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) +{ + qint64 readBytes = q_func()->read(data, maxSize); + if (readBytes <= 0) + return readBytes; + + buffer.ungetBlock(data, readBytes); + pos -= readBytes; + return readBytes; +} + +/*! + \internal +*/ +QByteArray QIODevicePrivate::peek(qint64 maxSize) +{ + QByteArray result = q_func()->read(maxSize); + + if (result.isEmpty()) + return result; + + buffer.ungetBlock(result.constData(), result.size()); + pos -= result.size(); + return result; +} + /*! \fn bool QIODevice::getChar(char *c) Reads one character from the device and stores it in \a c. If \a c @@ -1476,14 +1505,7 @@ bool QIODevice::getChar(char *c) */ qint64 QIODevice::peek(char *data, qint64 maxSize) { - Q_D(QIODevice); - qint64 readBytes = read(data, maxSize); - if (readBytes <= 0) - return readBytes; - - d->buffer.ungetBlock(data, readBytes); - d->pos -= readBytes; - return readBytes; + return d_func()->peek(data, maxSize); } /*! @@ -1505,16 +1527,7 @@ qint64 QIODevice::peek(char *data, qint64 maxSize) */ QByteArray QIODevice::peek(qint64 maxSize) { - Q_D(QIODevice); - QByteArray result = read(maxSize); - - if (result.isEmpty()) - return result; - - d->buffer.ungetBlock(result.constData(), result.size()); - d->pos -= result.size(); - - return result; + return d_func()->peek(maxSize); } /*! diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 225a0b9..4a25562 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -231,7 +231,9 @@ public: accessMode = q_func()->isSequential() ? Sequential : RandomAccess; return accessMode == Sequential; } - + + virtual qint64 peek(char *data, qint64 maxSize); + virtual QByteArray peek(qint64 maxSize); #ifdef QT_NO_QOBJECT QIODevice *q_ptr; diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index fdc1444..6dfd4d9 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1214,6 +1214,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) default: break; } + stealThisEvent = d->stealMouse; // Update stealThisEvent and grabber in case changed by function calls above grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()); if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) { d->clearDelayedPress(); diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 0be8dac..b198077 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -79,8 +79,24 @@ #endif #include "private/qdeclarativeanchors_p.h" +static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent) +{ + QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj); + if (!gobj) + return QDeclarativePrivate::IncompatibleObject; + + QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent); + if (!gparent) + return QDeclarativePrivate::IncompatibleParent; + + gobj->setParentItem(gparent); + return QDeclarativePrivate::Parented; +} + void QDeclarativeItemModule::defineModule() { + QDeclarativePrivate::registerAutoParentFunction(qgraphicsobject_autoParent); + #ifdef QT_NO_MOVIE qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage", qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie")); diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index ad61bab..b9231a1 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -358,6 +358,8 @@ Column { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Column. + Items with a width or height of 0 will not be positioned. + \sa Row, {declarative/positioners}{Positioners example} */ /*! @@ -502,6 +504,8 @@ Row { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Row. + Items with a width or height of 0 will not be positioned. + \sa Column, {declarative/positioners}{Positioners example} */ /*! @@ -657,6 +661,8 @@ Grid { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Grid. + Items with a width or height of 0 will not be positioned. + \sa Flow, {declarative/positioners}{Positioners example} */ /*! @@ -913,6 +919,8 @@ void QDeclarativeGrid::reportConflictingAnchors() positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Flow. + Items with a width or height of 0 will not be positioned. + \sa Grid, {declarative/positioners}{Positioners example} */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index cba01ef..9e5dfb5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -100,6 +100,7 @@ void QDeclarativeTextInput::setText(const QString &s) if(s == text()) return; d->control->setText(s); + d->updateHorizontalScroll(); //emit textChanged(); } @@ -337,6 +338,7 @@ void QDeclarativeTextInput::setHAlign(HAlignment align) return; d->hAlign = align; updateRect(); + d->updateHorizontalScroll(); emit horizontalAlignmentChanged(d->hAlign); } @@ -554,7 +556,9 @@ void QDeclarativeTextInput::setAutoScroll(bool b) return; d->autoScroll = b; - + d->updateHorizontalScroll(); + //We need to repaint so that the scrolling is taking into account. + updateSize(true); emit autoScrollChanged(d->autoScroll); } @@ -836,17 +840,23 @@ void QDeclarativeTextInput::moveCursor() Q_D(QDeclarativeTextInput); if(!d->cursorItem) return; + d->updateHorizontalScroll(); d->cursorItem->setX(d->control->cursorToX() - d->hscroll); } /*! - \qmlmethod rect TextInput::positionToRectangle(int x) + \qmlmethod rect TextInput::positionToRectangle(int pos) + + This function takes a character position and returns the rectangle that the + cursor would occupy, if it was placed at that character position. + + This is similar to setting the cursorPosition, and then querying the cursor + rectangle, but the cursorPosition is not changed. */ -QRectF QDeclarativeTextInput::positionToRectangle(int x) const +QRectF QDeclarativeTextInput::positionToRectangle(int pos) const { Q_D(const QDeclarativeTextInput); - QFontMetrics fm = QFontMetrics(d->font); - return QRectF(d->control->cursorToX(x)-d->hscroll, + return QRectF(d->control->cursorToX(pos)-d->hscroll, 0.0, d->control->cursorWidth(), cursorRectangle().height()); @@ -1006,61 +1016,73 @@ void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry, QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); } -void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) +void QDeclarativeTextInputPrivate::updateHorizontalScroll() { - Q_D(QDeclarativeTextInput); - p->setRenderHint(QPainter::TextAntialiasing, true); - p->save(); - p->setPen(QPen(d->color)); - int flags = QLineControl::DrawText; - if(!isReadOnly() && d->cursorVisible && !d->cursorItem) - flags |= QLineControl::DrawCursor; - if (d->control->hasSelectedText()) - flags |= QLineControl::DrawSelections; - QPoint offset = QPoint(0,0); - QFontMetrics fm = QFontMetrics(d->font); - int cix = qRound(d->control->cursorToX()); - QRect br(boundingRect().toRect()); + Q_Q(QDeclarativeTextInput); + QFontMetrics fm = QFontMetrics(font); + int cix = qRound(control->cursorToX()); + QRect br(q->boundingRect().toRect()); //###Is this using bearing appropriately? int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; - if (d->autoScroll) { + int widthUsed = qRound(control->naturalTextWidth()) + 1 + minRB; + if (autoScroll) { if ((minLB + widthUsed) <= br.width()) { // text fits in br; use hscroll for alignment - switch (d->hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { + switch (hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { case Qt::AlignRight: - d->hscroll = widthUsed - br.width() + 1; + hscroll = widthUsed - br.width() + 1; break; case Qt::AlignHCenter: - d->hscroll = (widthUsed - br.width()) / 2; + hscroll = (widthUsed - br.width()) / 2; break; default: // Left - d->hscroll = 0; + hscroll = 0; break; } - d->hscroll -= minLB; - } else if (cix - d->hscroll >= br.width()) { + hscroll -= minLB; + } else if (cix - hscroll >= br.width()) { // text doesn't fit, cursor is to the right of br (scroll right) - d->hscroll = cix - br.width() + 1; - } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) { + hscroll = cix - br.width() + 1; + } else if (cix - hscroll < 0 && hscroll < widthUsed) { // text doesn't fit, cursor is to the left of br (scroll left) - d->hscroll = cix; - } else if (widthUsed - d->hscroll < br.width()) { + hscroll = cix; + } else if (widthUsed - hscroll < br.width()) { // text doesn't fit, text document is to the left of br; align // right - d->hscroll = widthUsed - br.width() + 1; + hscroll = widthUsed - br.width() + 1; + } + } else { + if(hAlign == QDeclarativeTextInput::AlignRight){ + hscroll = q->width() - widthUsed; + }else if(hAlign == QDeclarativeTextInput::AlignHCenter){ + hscroll = (q->width() - widthUsed) / 2; + } else { + hscroll = 0; } + hscroll -= minLB; + } +} + +void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) +{ + Q_D(QDeclarativeTextInput); + p->setRenderHint(QPainter::TextAntialiasing, true); + p->save(); + p->setPen(QPen(d->color)); + int flags = QLineControl::DrawText; + if(!isReadOnly() && d->cursorVisible && !d->cursorItem) + flags |= QLineControl::DrawCursor; + if (d->control->hasSelectedText()) + flags |= QLineControl::DrawSelections; + QPoint offset = QPoint(0,0); + QFontMetrics fm = QFontMetrics(d->font); + QRect br(boundingRect().toRect()); + if (d->autoScroll) { // the y offset is there to keep the baseline constant in case we have script changes in the text. offset = br.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); } else { - if(d->hAlign == AlignRight){ - d->hscroll = width() - widthUsed; - }else if(d->hAlign == AlignHCenter){ - d->hscroll = (width() - widthUsed) / 2; - } - d->hscroll -= minLB; offset = QPoint(d->hscroll, 0); } d->control->draw(p, offset, r, flags); @@ -1230,6 +1252,7 @@ void QDeclarativeTextInput::moveCursorSelection(int position) { Q_D(QDeclarativeTextInput); d->control->moveCursor(position, true); + d->updateHorizontalScroll(); } /*! @@ -1420,6 +1443,7 @@ void QDeclarativeTextInput::selectionChanged() void QDeclarativeTextInput::q_textChanged() { Q_D(QDeclarativeTextInput); + d->updateHorizontalScroll(); updateSize(); emit textChanged(); if(hasAcceptableInput() != d->oldValidity){ diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index c539bd3..03f55ae 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -112,7 +112,7 @@ public: //Auxilliary functions needed to control the TextInput from QML Q_INVOKABLE int positionAt(int x) const; - Q_INVOKABLE QRectF positionToRectangle(int x) const; + Q_INVOKABLE QRectF positionToRectangle(int pos) const; Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void openSoftwareInputPanel(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 6865147..8b74bcc 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -99,6 +99,7 @@ public: void init(); void startCreatingCursor(); void focusChanged(bool hasFocus); + void updateHorizontalScroll(); QLineControl* control; diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 55ee783..b4919ff 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -60,7 +60,6 @@ #include <QFileInfo> #include <QtCore/qdebug.h> #include <QApplication> -#include <QGraphicsObject> QT_BEGIN_NAMESPACE @@ -579,20 +578,26 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent) if (!ret) return QScriptValue(QScriptValue::NullValue); - QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(ret); - bool needParent = (gobj != 0); - if(parent){ + + if (parent) { ret->setParent(parent); - if (gobj) { - QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent); - if(gparent){ - gobj->setParentItem(gparent); + QList<QDeclarativePrivate::AutoParentFunction> functions = QDeclarativeMetaType::parentFunctions(); + + bool needParent = false; + + for (int ii = 0; ii < functions.count(); ++ii) { + QDeclarativePrivate::AutoParentResult res = functions.at(ii)(ret, parent); + if (res == QDeclarativePrivate::Parented) { needParent = false; + break; + } else if (res == QDeclarativePrivate::IncompatibleParent) { + needParent = true; } } + + if (needParent) + qWarning("QDeclarativeComponent: Created graphical object was not placed in the graphics scene."); } - if(needParent) - qWarning("QDeclarativeComponent: Created graphical object was not placed in the graphics scene."); QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine); QDeclarativeData::get(ret, true)->setImplicitDestructible(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 0715624..5c4d229 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -93,7 +93,6 @@ #include <QtGui/qcolor.h> #include <QtGui/qvector3d.h> #include <QtGui/qsound.h> -#include <QGraphicsObject> #include <QtCore/qcryptographichash.h> #include <private/qobject_p.h> @@ -1195,10 +1194,12 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS Q_ASSERT(obj); obj->setParent(parentArg); - QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj); - QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg); - if(gobj && gparent) - gobj->setParentItem(gparent); + + QList<QDeclarativePrivate::AutoParentFunction> functions = QDeclarativeMetaType::parentFunctions(); + for (int ii = 0; ii < functions.count(); ++ii) { + if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg)) + break; + } QDeclarativeData::get(obj, true)->setImplicitDestructible(); return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 5fcb7ee..c32cab6 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -112,6 +112,8 @@ struct QDeclarativeMetaTypeData QBitArray objects; QBitArray interfaces; QBitArray lists; + + QList<QDeclarativePrivate::AutoParentFunction> parentFunctions; }; Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData) Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock) @@ -483,6 +485,16 @@ int QDeclarativeType::index() const return d->m_index; } +int QDeclarativePrivate::registerAutoParentFunction(AutoParentFunction function) +{ + QWriteLocker lock(metaTypeDataLock()); + QDeclarativeMetaTypeData *data = metaTypeData(); + + data->parentFunctions.append(function); + + return data->parentFunctions.count() - 1; +} + int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface) { if (interface.version > 0) @@ -583,6 +595,13 @@ bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor)))); } +QList<QDeclarativePrivate::AutoParentFunction> QDeclarativeMetaType::parentFunctions() +{ + QReadLocker lock(metaTypeDataLock()); + QDeclarativeMetaTypeData *data = metaTypeData(); + return data->parentFunctions; +} + QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok) { if (!isQObject(v.userType())) { diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h index bf6a700..4c98b6f 100644 --- a/src/declarative/qml/qdeclarativemetatype_p.h +++ b/src/declarative/qml/qdeclarativemetatype_p.h @@ -99,6 +99,8 @@ public: static StringConverter customStringConverter(int); static bool isModule(const QByteArray &module, int versionMajor, int versionMinor); + + static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions(); }; class QDeclarativeTypePrivate; diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index e657dd5..cd859fe 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -214,6 +214,10 @@ namespace QDeclarativePrivate const char *iid; }; + enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent }; + typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent); + + int Q_DECLARATIVE_EXPORT registerAutoParentFunction(AutoParentFunction); int Q_DECLARATIVE_EXPORT registerType(const RegisterType &); int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &); diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index b149120..1e49ad9 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlattachedproperty bool Package::name + \qmlattachedproperty string Package::name This attached property holds the name of an item within a Package. */ diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 6ca799d..83db3ec 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -572,6 +572,18 @@ void QGraphicsGridLayout::removeAt(int index) if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) layoutItem->setParentLayoutItem(0); d->engine.removeItem(gridItem); + + // recalculate rowInfo.count if we remove an item that is on the right/bottommost row + for (int j = 0; j < NOrientations; ++j) { + // 0: Hor, 1: Ver + const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical); + const int oldCount = d->engine.rowCount(orient); + if (gridItem->lastRow(orient) == oldCount - 1) { + const int newCount = d->engine.effectiveLastRow(orient) + 1; + d->engine.removeRows(newCount, oldCount - newCount, orient); + } + } + delete gridItem; invalidate(); } diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8042c46..c9176d1 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3277,7 +3277,8 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim */ void QGraphicsItem::clearFocus() { - d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); + if (hasFocus()) + d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); } /*! diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 9722683..b828722 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -147,7 +147,7 @@ void QGraphicsLinearLayoutPrivate::removeGridItem(QGridLayoutItem *gridItem) { int index = gridItem->firstRow(orientation); engine.removeItem(gridItem); - engine.removeRow(index, orientation); + engine.removeRows(index, 1, orientation); } void QGraphicsLinearLayoutPrivate::fixIndex(int *index) const diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index cbf704e..9ac9a8e 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -363,8 +363,8 @@ public: QGridLayoutItem *itemAt(int row, int column, Qt::Orientation orientation = Qt::Vertical) const; inline void insertRow(int row, Qt::Orientation orientation = Qt::Vertical) { insertOrRemoveRows(row, +1, orientation); } - inline void removeRow(int row, Qt::Orientation orientation = Qt::Vertical) - { insertOrRemoveRows(row, -1, orientation); } + inline void removeRows(int row, int count, Qt::Orientation orientation) + { insertOrRemoveRows(row, -count, orientation); } void invalidate(); void setGeometries(const QLayoutStyleInfo &styleInfo, const QRectF &contentsGeometry); diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp index 3bdc971..9fcc718 100644 --- a/src/gui/kernel/qclipboard_x11.cpp +++ b/src/gui/kernel/qclipboard_x11.cpp @@ -1518,7 +1518,7 @@ bool qt_xfixes_selection_changed(Window selectionOwner, Time timestamp) (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp); #endif if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) || - (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp)) + (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) return qt_check_selection_sentinel(); return false; } @@ -1532,7 +1532,7 @@ bool qt_xfixes_clipboard_changed(Window clipboardOwner, Time timestamp) (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp); #endif if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) || - (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp)) + (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) return qt_check_clipboard_sentinel(); return false; } diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 1b01960..bf03545 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -234,12 +234,12 @@ void QOutlineMapper::endOutline() // Check for out of dev bounds... - const bool do_clip = (controlPointRect.left() < -QT_RASTER_COORD_LIMIT + const bool do_clip = !m_in_clip_elements && ((controlPointRect.left() < -QT_RASTER_COORD_LIMIT || controlPointRect.right() > QT_RASTER_COORD_LIMIT || controlPointRect.top() < -QT_RASTER_COORD_LIMIT || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT || controlPointRect.width() > QT_RASTER_COORD_LIMIT - || controlPointRect.height() > QT_RASTER_COORD_LIMIT); + || controlPointRect.height() > QT_RASTER_COORD_LIMIT)); if (do_clip) { clipElements(elements, elementTypes(), element_count); @@ -353,7 +353,13 @@ void QOutlineMapper::clipElements(const QPointF *elements, // instead of going through convenience functionallity, but since // this part of code hardly every used, it shouldn't matter. + m_in_clip_elements = true; + QPainterPath path; + + if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) + path.setFillRule(Qt::WindingFill); + if (types) { for (int i=0; i<element_count; ++i) { switch (types[i]) { @@ -389,6 +395,8 @@ void QOutlineMapper::clipElements(const QPointF *elements, else convertPath(clippedPath); m_txop = old_txop; + + m_in_clip_elements = false; } QT_END_NAMESPACE diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index 39b7593..f64d03b 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -95,7 +95,8 @@ public: m_tags(0), m_contours(0), m_polygon_dev(0), - m_round_coords(false) + m_round_coords(false), + m_in_clip_elements(false) { } @@ -235,6 +236,7 @@ public: qreal m_dy; bool m_valid; + bool m_in_clip_elements; private: bool m_round_coords; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f10f12f..a212718 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -459,13 +459,12 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) QRasterPaintEngineState *s = state(); ensureOutlineMapper(); - d->outlineMapper->m_clip_rect = d->deviceRect.adjusted(-10, -10, 10, 10); - - // This is the upp - QRect bounds(-QT_RASTER_COORD_LIMIT, -QT_RASTER_COORD_LIMIT, - QT_RASTER_COORD_LIMIT*2 - 1, QT_RASTER_COORD_LIMIT * 2 - 1); - d->outlineMapper->m_clip_rect = bounds.intersected(d->outlineMapper->m_clip_rect); + d->outlineMapper->m_clip_rect = d->deviceRect; + if (d->outlineMapper->m_clip_rect.width() > QT_RASTER_COORD_LIMIT) + d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); + if (d->outlineMapper->m_clip_rect.height() > QT_RASTER_COORD_LIMIT) + d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); d->rasterizer->setClipRect(d->deviceRect); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index ff82d59..e0746fb 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -494,11 +494,9 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) } else { d->activeStroker->moveTo(points[0], points[1]); points += 2; - ++types; while (points < lastPoint) { d->activeStroker->lineTo(points[0], points[1]); points += 2; - ++types; } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); @@ -561,12 +559,10 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->moveTo(p.x(), p.y()); points += 2; - ++types; while (points < lastPoint) { QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->lineTo(p.x(), p.y()); points += 2; - ++types; } if (path.hasImplicitClose()) d->activeStroker->lineTo(p.x(), p.y()); diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 3be6d28..7ceed61 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -237,7 +237,8 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay *nglyphs = len; for (int i = 0; i < len; ++i) { outGlyphs[i] = 0; - logClusters[i] = i; + if (logClusters) + logClusters[i] = i; outAdvances_x[i] = QFixed(); outAdvances_y[i] = QFixed(); outAttributes[i].clusterStart = true; diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml index c8b863c..7f2f85a 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml @@ -9,12 +9,13 @@ Rectangle { Item { objectName: "myDelegate" height: 20 + width: 240 Text { - y: index*20 + objectName: "myName" text: name } Text { - y: index*20 + objectName: "myNumber" x: 100 text: number } diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 3cc68f4..7299a43 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -45,6 +45,7 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> #include <private/qdeclarativerepeater_p.h> #include <private/qdeclarativetext_p.h> @@ -75,6 +76,8 @@ private slots: private: QDeclarativeView *createView(); template<typename T> + T *findItem(QGraphicsObject *parent, const QString &objectName, int index); + template<typename T> T *findItem(QGraphicsObject *parent, const QString &id); }; @@ -312,6 +315,20 @@ void tst_QDeclarativeRepeater::dataModel() testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + // Check that model changes are propagated + QDeclarativeText *text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("two")); + + testModel.modifyItem(1, "Item two", "_2"); + text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("Item two")); + + text = findItem<QDeclarativeText>(canvas->rootObject(), "myNumber", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("_2")); + delete testObject; delete canvas; } @@ -387,6 +404,33 @@ QDeclarativeView *tst_QDeclarativeRepeater::createView() } template<typename T> +T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName, int index) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->childItems().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QDeclarativeExpression e(qmlContext(item), item, "index"); + if (e.evaluate().toInt() == index) + return static_cast<T*>(item); + } else { + return static_cast<T*>(item); + } + } + item = findItem<T>(item, objectName, index); + if (item) + return static_cast<T*>(item); + } + + return 0; +} + +template<typename T> T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 3143580..a55b42e 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -396,7 +396,6 @@ void tst_qdeclarativetextinput::positionAt() #endif // Check without autoscroll... - QEXPECT_FAIL("", "QTBUG-11127", Abort); textinputObject->setAutoScroll(false); pos = textinputObject->positionAt(textinputObject->width()/2); diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2); diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml index 69f57c6..e863262 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml @@ -30,13 +30,14 @@ Item { y: 5 //Below function implements all scrolling logic onCursorPositionChanged: { - if(cursorRect.x < leftMargin - textInp.x){//Cursor went off the front - textInp.x = leftMargin - Math.max(0, cursorRect.x); - }else if(cursorRect.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end - textInp.x = leftMargin - Math.max(0, cursorRect.x - (parent.width - leftMargin - rightMargin)); + if(cursorRectangle.x < leftMargin - textInp.x){//Cursor went off the front + textInp.x = leftMargin - Math.max(0, cursorRectangle.x); + }else if(cursorRectangle.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end + textInp.x = leftMargin - Math.max(0, cursorRectangle.x - (parent.width - leftMargin - rightMargin)); } } + autoScroll: false //It is preferable to implement your own scrolling text:"" horizontalAlignment: TextInput.AlignLeft font.pixelSize:15 diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 8127f84..b9a5c66 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -741,31 +741,73 @@ void tst_QGraphicsGridLayout::setColumnFixedWidth() // public qreal columnSpacing(int column) const void tst_QGraphicsGridLayout::columnSpacing() { - QGraphicsScene scene; - QGraphicsView view(&scene); - QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); - QGraphicsGridLayout *layout = new QGraphicsGridLayout(); - scene.addItem(widget); - widget->setLayout(layout); - populateLayout(layout, 3, 2); - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - QCOMPARE(layout->columnSpacing(0), 0.0); + { + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(); + scene.addItem(widget); + widget->setLayout(layout); + populateLayout(layout, 3, 2); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + QCOMPARE(layout->columnSpacing(0), 0.0); + + layout->setColumnSpacing(0, 20); + view.show(); + widget->show(); + widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); + QApplication::processEvents(); - layout->setColumnSpacing(0, 20); - view.show(); - widget->show(); - widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); - QApplication::processEvents(); + QCOMPARE(layout->itemAt(0,0)->geometry().left(), 0.0); + QCOMPARE(layout->itemAt(0,0)->geometry().right(), 25.0); + QCOMPARE(layout->itemAt(0,1)->geometry().left(), 45.0); + QCOMPARE(layout->itemAt(0,1)->geometry().right(), 70.0); + QCOMPARE(layout->itemAt(0,2)->geometry().left(), 70.0); + QCOMPARE(layout->itemAt(0,2)->geometry().right(), 95.0); - QCOMPARE(layout->itemAt(0,0)->geometry().left(), 0.0); - QCOMPARE(layout->itemAt(0,0)->geometry().right(), 25.0); - QCOMPARE(layout->itemAt(0,1)->geometry().left(), 45.0); - QCOMPARE(layout->itemAt(0,1)->geometry().right(), 70.0); - QCOMPARE(layout->itemAt(0,2)->geometry().left(), 70.0); - QCOMPARE(layout->itemAt(0,2)->geometry().right(), 95.0); + delete widget; + } + + { + // don't include items and spacings that was previously part of the layout + // (horizontal) + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + populateLayout(layout, 3, 1); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->setColumnSpacing(0, 10); + layout->setColumnSpacing(1, 10); + layout->setColumnSpacing(2, 10); + layout->setColumnSpacing(3, 10); + QCOMPARE(layout->preferredSize(), QSizeF(95, 25)); + layout->removeAt(2); + QCOMPARE(layout->preferredSize(), QSizeF(60, 25)); + layout->removeAt(1); + QCOMPARE(layout->preferredSize(), QSizeF(25, 25)); + delete layout; + } + { + // don't include items and spacings that was previously part of the layout + // (vertical) + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + populateLayout(layout, 2, 2); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->setColumnSpacing(0, 10); + layout->setColumnSpacing(1, 10); + layout->setRowSpacing(0, 10); + layout->setRowSpacing(1, 10); + QCOMPARE(layout->preferredSize(), QSizeF(60, 60)); + layout->removeAt(3); + QCOMPARE(layout->preferredSize(), QSizeF(60, 60)); + layout->removeAt(2); + QCOMPARE(layout->preferredSize(), QSizeF(60, 25)); + layout->removeAt(1); + QCOMPARE(layout->preferredSize(), QSizeF(25, 25)); + delete layout; + } - delete widget; } // public int columnStretchFactor(int column) const diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 5bbe8f6..245a5c6 100644 --- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -642,7 +642,7 @@ void tst_QNetworkDiskCache::crashWhenParentingCache() QNetworkAccessManager *manager = new QNetworkAccessManager(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(manager); // parent to qnam! // we expect the temp dir to be cleaned at some point anyway - diskCache->setCacheDirectory(QDir::tempPath() + "/cacheDir_" + QCoreApplication::applicationPid()); + diskCache->setCacheDirectory(QString("%1/cacheDir_%2").arg(QDir::tempPath()).arg(QCoreApplication::applicationPid())); manager->setCache(diskCache); QUrl url("http://127.0.0.1:" + QString::number(server.serverPort())); diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo.cpp index 7948e2a..443edc8 100644 --- a/tools/qml/deviceorientation_maemo.cpp +++ b/tools/qml/deviceorientation_maemo.cpp @@ -40,100 +40,87 @@ ****************************************************************************/ #include "deviceorientation.h" -#include <stdio.h> -#include <stdlib.h> +#include <QtDBus> + +#include <mce/mode-names.h> +#include <mce/dbus-names.h> class MaemoOrientation : public DeviceOrientation { Q_OBJECT public: MaemoOrientation() - : DeviceOrientation(),m_current(Portrait), m_lastSeen(Portrait), m_lastSeenCount(0) + : o(UnknownOrientation) { - m_current = get(); - if (m_current == UnknownOrientation) - m_current = Portrait; + // enable the orientation sensor + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ)); + + // query the initial orientation + QDBusMessage reply = QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET)); + if (reply.type() == QDBusMessage::ErrorMessage) { + qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage())); + } else { + o = toOrientation(reply.arguments().value(0).toString()); + } - startTimer(100); + // connect to the orientation change signal + QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF, + MCE_DEVICE_ORIENTATION_SIG, + this, + SLOT(deviceOrientationChanged(QString))); } - Orientation orientation() const { - return m_current; + ~MaemoOrientation() + { + // disable the orientation sensor + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ)); } - void setOrientation(Orientation) { } - -protected: - virtual void timerEvent(QTimerEvent *) + inline Orientation orientation() const { - Orientation c = get(); - - if (c == m_lastSeen) { - m_lastSeenCount++; - } else { - m_lastSeenCount = 0; - m_lastSeen = c; - } - - if (m_lastSeen != UnknownOrientation && m_lastSeen != m_current && m_lastSeenCount > 4) { - m_current = m_lastSeen; - emit orientationChanged(); - printf("%d\n", m_current); - } + return o; } -signals: - void changed(); - -private: - Orientation m_current; - Orientation m_lastSeen; - int m_lastSeenCount; - - Orientation get() + void setOrientation(Orientation o) { - Orientation o = UnknownOrientation; - - int ax, ay, az; - - read(&ax, &ay, &az); + } - if (abs(az) > 850) { - o = UnknownOrientation; - } else if (ax < -750) { - o = Portrait; - } else if (ax > 750) { - o = PortraitInverted; - } else if (ay < -750) { - o = Landscape; - } else if (ay > 750) { - o = LandscapeInverted; - } +private Q_SLOTS: + void deviceOrientationChanged(const QString &newOrientation) + { + o = toOrientation(newOrientation); - return o; + emit orientationChanged(); +// printf("%d\n", o); } - int read(int *ax,int *ay,int *az) +private: + static Orientation toOrientation(const QString &nativeOrientation) { - static const char *accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; - - FILE *fd; - int rs; - fd = fopen(accel_filename, "r"); - if(fd==NULL){ printf("liqaccel, cannot open for reading\n"); return -1;} - rs=fscanf((FILE*) fd,"%i %i %i",ax,ay,az); - fclose(fd); - if(rs != 3){ printf("liqaccel, cannot read information\n"); return -2;} - return 0; + if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE) + return Landscape; + else if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE_INVERTED) + return LandscapeInverted; + else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT) + return Portrait; + else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT_INVERTED) + return PortraitInverted; + return UnknownOrientation; } -}; +private: + Orientation o; +}; DeviceOrientation* DeviceOrientation::instance() { - static MaemoOrientation *o = 0; - if (!o) - o = new MaemoOrientation; + static MaemoOrientation *o = new MaemoOrientation; return o; } diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 0cce1cc..a75023b 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -347,8 +347,9 @@ int main(int argc, char ** argv) wflags |= Qt::WindowStaysOnTopHint; QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags); + viewer->setAttribute(Qt::WA_DeleteOnClose, true); if (!scriptopts.isEmpty()) { - QStringList options = + QStringList options = scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); QDeclarativeViewer::ScriptOptions scriptOptions = 0; @@ -451,7 +452,5 @@ int main(int argc, char ** argv) viewer->setUseGL(useGL); viewer->raise(); - int rv = app.exec(); - delete viewer; - exit(rv); + return app.exec(); } diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index cff65be..58d8cc1 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -18,6 +18,7 @@ SOURCES += $$PWD/qmlruntime.cpp \ RESOURCES = $$PWD/qmlruntime.qrc maemo5 { + QT += dbus SOURCES += $$PWD/deviceorientation_maemo.cpp } else { SOURCES += $$PWD/deviceorientation.cpp |