diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-21 05:17:52 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-21 05:17:52 (GMT) |
commit | 86e5445e210f812e3f3059e175cce323c68ac216 (patch) | |
tree | 2240113800482faa397eee49c1b3c6577e11880a /src/plugins | |
parent | ee0a68022a37422c58af95f418e385032ee4fea6 (diff) | |
parent | b930e258a14b851360d08be373c28f912d2242b0 (diff) | |
download | Qt-86e5445e210f812e3f3059e175cce323c68ac216.zip Qt-86e5445e210f812e3f3059e175cce323c68ac216.tar.gz Qt-86e5445e210f812e3f3059e175cce323c68ac216.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging:
Move separator skipping to proper place
Skip shaping for hidden line/paragraph separators
Support interface orientation for uikit.
Add support for opening LinuxInput devices exclusively ('grabbing').
Fixed regression in compilerwarnings.
Properly quit the input event thread in the directfb platform plugin.
Apply 57993ba7 properly to 4.8
Deprecate some QPixmap functions (marked as obsolete already).
Deprecate some functions in QImage (that have been obsolete since 4.1).
Add QLocale::toUpper/Lower
Fix warning for uninitialized variable
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbintegration.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikiteventloop.mm | 65 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitintegration.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitintegration.mm | 9 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitscreen.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitscreen.mm | 26 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitwindow.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/uikit/quikitwindow.mm | 67 |
8 files changed, 157 insertions, 19 deletions
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 61f1d25..06b0b51 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -112,6 +112,8 @@ QDirectFbIntegration::QDirectFbIntegration() QDirectFbIntegration::~QDirectFbIntegration() { mInput->stopInputEventLoop(); + mInputRunner->quit(); + mInputRunner->wait(); delete mInputRunner; delete mInput; } diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm index 7c3e929..01ecf3f 100644 --- a/src/plugins/platforms/uikit/quikiteventloop.mm +++ b/src/plugins/platforms/uikit/quikiteventloop.mm @@ -40,6 +40,8 @@ ****************************************************************************/ #include "quikiteventloop.h" +#include "quikitintegration.h" +#include "quikitscreen.h" #include "quikitwindow.h" #include "quikitwindowsurface.h" @@ -50,7 +52,11 @@ #include <QtDebug> @interface QUIKitAppDelegate : NSObject <UIApplicationDelegate> { + UIInterfaceOrientation mOrientation; } + +- (void)updateOrientation:(NSNotification *)notification; + @end @interface EventLoopHelper : NSObject { @@ -69,14 +75,71 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { Q_UNUSED(launchOptions) - Q_UNUSED(application) + mOrientation = application.statusBarOrientation; + [self updateOrientation:nil]; + if (QUIKitIntegration::instance()->screens().size() > 0) { + QUIKitScreen *screen = static_cast<QUIKitScreen *>(QUIKitIntegration::instance()->screens().at(0)); + screen->updateInterfaceOrientation(); + } foreach (QWidget *widget, qApp->topLevelWidgets()) { QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow()); if (platformWindow) platformWindow->ensureNativeWindow(); } + // orientation support + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(updateOrientation:) + name:UIDeviceOrientationDidChangeNotification + object:nil]; return YES; } +- (void)updateOrientation:(NSNotification *)notification +{ + Q_UNUSED(notification) + UIInterfaceOrientation newOrientation = mOrientation; + NSString *infoValue = @""; + switch ([UIDevice currentDevice].orientation) { + case UIDeviceOrientationUnknown: + break; + case UIDeviceOrientationPortrait: + newOrientation = UIInterfaceOrientationPortrait; + infoValue = @"UIInterfaceOrientationPortrait"; + break; + case UIDeviceOrientationPortraitUpsideDown: + newOrientation = UIInterfaceOrientationPortraitUpsideDown; + infoValue = @"UIInterfaceOrientationPortraitUpsideDown"; + break; + case UIDeviceOrientationLandscapeLeft: + newOrientation = UIInterfaceOrientationLandscapeRight; // as documentated + infoValue = @"UIInterfaceOrientationLandscapeRight"; + break; + case UIDeviceOrientationLandscapeRight: + newOrientation = UIInterfaceOrientationLandscapeLeft; // as documentated + infoValue = @"UIInterfaceOrientationLandscapeLeft"; + break; + case UIDeviceOrientationFaceUp: + case UIDeviceOrientationFaceDown: + break; + } + + if (newOrientation == mOrientation) + return; + + // check against supported orientations + NSBundle *bundle = [NSBundle mainBundle]; + NSArray *orientations = [bundle objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"]; + if (![orientations containsObject:infoValue]) + return; + + mOrientation = newOrientation; + [UIApplication sharedApplication].statusBarOrientation = mOrientation; + if (QUIKitIntegration::instance()->screens().size() > 0) { + QUIKitScreen *screen = static_cast<QUIKitScreen *>(QUIKitIntegration::instance()->screens().at(0)); + screen->updateInterfaceOrientation(); + } +} + - (void)applicationWillTerminate:(UIApplication *)application { Q_UNUSED(application) diff --git a/src/plugins/platforms/uikit/quikitintegration.h b/src/plugins/platforms/uikit/quikitintegration.h index d9844b2..a392f1d 100644 --- a/src/plugins/platforms/uikit/quikitintegration.h +++ b/src/plugins/platforms/uikit/quikitintegration.h @@ -52,6 +52,8 @@ public: QUIKitIntegration(); ~QUIKitIntegration(); + static QUIKitIntegration *instance(); + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm index 21ab38f..ca020c9 100644 --- a/src/plugins/platforms/uikit/quikitintegration.mm +++ b/src/plugins/platforms/uikit/quikitintegration.mm @@ -66,9 +66,18 @@ public: } }; +static QUIKitIntegration *m_instance = 0; + +QUIKitIntegration * QUIKitIntegration::instance() +{ + return m_instance; +} + QUIKitIntegration::QUIKitIntegration() :mFontDb(new QUIKitFontDatabase() ) { + if (!m_instance) + m_instance = this; mScreens << new QUIKitScreen(0); } diff --git a/src/plugins/platforms/uikit/quikitscreen.h b/src/plugins/platforms/uikit/quikitscreen.h index 23e95f6..1b17d60 100644 --- a/src/plugins/platforms/uikit/quikitscreen.h +++ b/src/plugins/platforms/uikit/quikitscreen.h @@ -61,6 +61,7 @@ public: UIScreen *uiScreen() const; + void updateInterfaceOrientation(); private: QRect m_geometry; int m_depth; diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm index ae1c7cf..d7d8207 100644 --- a/src/plugins/platforms/uikit/quikitscreen.mm +++ b/src/plugins/platforms/uikit/quikitscreen.mm @@ -40,6 +40,7 @@ ****************************************************************************/ #include "quikitscreen.h" +#include "quikitwindow.h" #include <QtGui/QApplication> @@ -52,8 +53,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex) m_index(screenIndex) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex]; - CGRect bounds = [screen bounds]; + CGRect bounds = [uiScreen() bounds]; m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); m_format = QImage::Format_ARGB32; @@ -87,4 +87,26 @@ UIScreen *QUIKitScreen::uiScreen() const return [[UIScreen screens] objectAtIndex:m_index]; } +void QUIKitScreen::updateInterfaceOrientation() +{ + CGRect bounds = [uiScreen() bounds]; + switch ([[UIApplication sharedApplication] statusBarOrientation]) { + case UIInterfaceOrientationPortrait: + case UIInterfaceOrientationPortraitUpsideDown: + m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);; + break; + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: + m_geometry = QRect(bounds.origin.x, bounds.origin.y, + bounds.size.height, bounds.size.width); + break; + } + foreach (QWidget *widget, qApp->topLevelWidgets()) { + QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow()); + if (platformWindow && platformWindow->platformScreen() == this) { + platformWindow->updateGeometryAndOrientation(); + } + } +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h index c482dae..c91b751 100644 --- a/src/plugins/platforms/uikit/quikitwindow.h +++ b/src/plugins/platforms/uikit/quikitwindow.h @@ -119,9 +119,13 @@ public: QPlatformGLContext *glContext() const; + QUIKitScreen *platformScreen() const { return mScreen; } + + void updateGeometryAndOrientation(); private: QUIKitScreen *mScreen; UIWindow *mWindow; + CGRect mFrame; EAGLView *mView; mutable EAGLPlatformContext *mContext; }; diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm index ec33cd0..6e018fe 100644 --- a/src/plugins/platforms/uikit/quikitwindow.mm +++ b/src/plugins/platforms/uikit/quikitwindow.mm @@ -320,10 +320,7 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) : mContext(0) { mScreen = static_cast<QUIKitScreen *>(QPlatformScreen::platformScreenForWidget(tlw)); - CGRect screenBounds = [mScreen->uiScreen() bounds]; - QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height); - QPlatformWindow::setGeometry(geom); - mView = [[EAGLView alloc] initWithFrame:CGRectMake(geom.x(), geom.y(), geom.width(), geom.height())]; + mView = [[EAGLView alloc] init]; } QUIKitWindow::~QUIKitWindow() @@ -335,29 +332,23 @@ QUIKitWindow::~QUIKitWindow() void QUIKitWindow::setGeometry(const QRect &rect) { - if (mWindow && rect != geometry()) { - mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); - mView.frame = CGRectMake(0, 0, rect.width(), rect.height()); - [mView deleteFramebuffer]; - [mWindow setNeedsDisplay]; - } + // Not supported. Only a single "full screen" window is supported QPlatformWindow::setGeometry(rect); } UIWindow *QUIKitWindow::ensureNativeWindow() { if (!mWindow) { - // window - CGRect frame = [mScreen->uiScreen() applicationFrame]; - QRect geom = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); - widget()->setGeometry(geom); mWindow = [[UIWindow alloc] init]; + updateGeometryAndOrientation(); + // window mWindow.screen = mScreen->uiScreen(); - mWindow.frame = frame; // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards + // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards + mWindow.frame = mFrame; // view [mView deleteFramebuffer]; - mView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); // fill + mView.frame = CGRectMake(0, 0, mWindow.bounds.size.width, mWindow.bounds.size.height); // fill [mView setMultipleTouchEnabled:YES]; [mView setWindow:this]; [mWindow addSubview:mView]; @@ -367,6 +358,50 @@ UIWindow *QUIKitWindow::ensureNativeWindow() return mWindow; } +void QUIKitWindow::updateGeometryAndOrientation() +{ + if (!mWindow) + return; + mFrame = [mScreen->uiScreen() applicationFrame]; + CGRect screen = [mScreen->uiScreen() bounds]; + QRect geom; + CGFloat angle = 0; + switch ([[UIApplication sharedApplication] statusBarOrientation]) { + case UIInterfaceOrientationPortrait: + geom = QRect(mFrame.origin.x, mFrame.origin.y, mFrame.size.width, mFrame.size.height); + break; + case UIInterfaceOrientationPortraitUpsideDown: + geom = QRect(screen.size.width - mFrame.origin.x - mFrame.size.width, + screen.size.height - mFrame.origin.y - mFrame.size.height, + mFrame.size.width, + mFrame.size.height); + angle = M_PI; + break; + case UIInterfaceOrientationLandscapeLeft: + geom = QRect(screen.size.height - mFrame.origin.y - mFrame.size.height, + mFrame.origin.x, + mFrame.size.height, + mFrame.size.width); + angle = -M_PI/2.; + break; + case UIInterfaceOrientationLandscapeRight: + geom = QRect(mFrame.origin.y, + screen.size.width - mFrame.origin.x - mFrame.size.width, + mFrame.size.height, + mFrame.size.width); + angle = +M_PI/2.; + break; + } + if (angle != 0) { + [mView layer].transform = CATransform3DMakeRotation(angle, 0, 0, 1.); + } else { + [mView layer].transform = CATransform3DIdentity; + } + [mView setNeedsDisplay]; + widget()->setGeometry(geom); + widget()->update(); +} + QPlatformGLContext *QUIKitWindow::glContext() const { if (!mContext) { |