diff options
author | Liang Qi <liang.qi@qt.io> | 2016-06-13 09:01:02 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-13 12:46:46 +0200 |
commit | 511790fd1af1e2886a0e2e8dd4308099705cd815 (patch) | |
tree | b42aee537a6103cd064f9f41ae2889b09b79fd23 /src/plugins/platforms/ios/qiostextinputoverlay.mm | |
parent | 1542d8881fc5ccbc5918cd4acbe4091ebbd24508 (diff) | |
parent | cbe332405aa22257d432f1797b325f5e57007c20 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
config_help.txt
configure
mkspecs/features/uikit/sdk.prf
src/corelib/global/qhooks.cpp
src/corelib/io/qfilesystemwatcher.cpp
src/corelib/io/qlockfile_unix.cpp
src/corelib/tools/qalgorithms.h
src/gui/kernel/qwindowsysteminterface.h
src/gui/text/qtextdocument_p.cpp
src/network/access/access.pri
src/network/access/qnetworkaccessmanager.cpp
src/network/access/qnetworkreplynsurlconnectionimpl.mm
src/src.pro
src/testlib/qtestcase.cpp
src/widgets/kernel/qwidgetbackingstore_p.h
src/widgets/styles/qwindowscestyle.cpp
src/widgets/styles/qwindowsmobilestyle.cpp
tests/auto/corelib/io/qdiriterator/qdiriterator.pro
tests/auto/corelib/io/qfileinfo/qfileinfo.pro
tests/auto/gui/kernel/qwindow/BLACKLIST
tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
tools/configure/configureapp.cpp
Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
Diffstat (limited to 'src/plugins/platforms/ios/qiostextinputoverlay.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiostextinputoverlay.mm | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index 655e457664..94d82c3eb9 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -45,6 +45,7 @@ #include "qiostextinputoverlay.h" typedef QPair<int, int> SelectionPair; +typedef void (^Block)(void); static const CGFloat kKnobWidth = 10; @@ -68,7 +69,7 @@ static bool hasSelection() return selection.first != selection.second; } -static void executeBlockWithoutAnimation(void (^block)(void)) +static void executeBlockWithoutAnimation(Block block) { [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; @@ -306,6 +307,7 @@ static void executeBlockWithoutAnimation(void (^block)(void)) @property (nonatomic, assign) CGRect cursorRectangle; @property (nonatomic, assign) CGFloat handleScale; @property (nonatomic, assign) BOOL visible; +@property (nonatomic, copy) Block onAnimationDidStop; @end @implementation QIOSHandleLayer @@ -359,7 +361,8 @@ static void executeBlockWithoutAnimation(void (^block)(void)) [NSNumber numberWithFloat:1], nil]; return animation; } else { - CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:key]; + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; + [animation setDelegate:self]; animation.fromValue = [self valueForKey:key]; [animation setDuration:0.2]; return animation; @@ -368,6 +371,14 @@ static void executeBlockWithoutAnimation(void (^block)(void)) return [super actionForKey:key]; } +- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag +{ + Q_UNUSED(animation); + Q_UNUSED(flag); + if (self.onAnimationDidStop) + self.onAnimationDidStop(); +} + - (void)setVisible:(BOOL)visible { if (visible == _visible) @@ -679,7 +690,7 @@ static void executeBlockWithoutAnimation(void (^block)(void)) if (enabled) { // Create a layer that clips the handles inside the input field - _clipRectLayer = [[CALayer new] autorelease]; + _clipRectLayer = [CALayer new]; _clipRectLayer.masksToBounds = YES; [self.focusView.layer addSublayer:_clipRectLayer]; @@ -705,7 +716,26 @@ static void executeBlockWithoutAnimation(void (^block)(void)) [self updateSelection]; } else { - [_clipRectLayer removeFromSuperlayer]; + // Fade out the handles by setting visible to NO, and wait for the animations + // to finish before removing the clip rect layer, including the handles. + // Create a local variable to hold the clipRectLayer while the animation is + // ongoing to ensure that any subsequent calls to setEnabled does not interfere. + // Also, declare it as __block to stop it from being automatically retained, which + // would cause a cyclic dependency between clipRectLayer and the block. + __block CALayer *clipRectLayer = _clipRectLayer; + __block int handleCount = 2; + Block block = ^{ + if (--handleCount == 0) { + [clipRectLayer removeFromSuperlayer]; + [clipRectLayer release]; + } + }; + + _cursorLayer.onAnimationDidStop = block; + _anchorLayer.onAnimationDidStop = block; + _cursorLayer.visible = NO; + _anchorLayer.visible = NO; + _clipRectLayer = 0; _cursorLayer = 0; _anchorLayer = 0; |