48 #include <UIKit/UIKit.h> 50 #include <QtGui/QApplication> 51 #include <QtGui/QWidget> 52 #include <QtGui/QGraphicsView> 53 #include <QtGui/QGraphicsScene> 54 #include <QtGui/QGraphicsItem> 61 - (void)updateOrientation:(NSNotification *)notification;
71 - (void)processEventsAndSchedule;
77 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
81 [
self updateOrientation:nil];
91 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
92 [[NSNotificationCenter defaultCenter] addObserver:self
93 selector:@selector(updateOrientation:)
94 name:UIDeviceOrientationDidChangeNotification
99 - (void)updateOrientation:(NSNotification *)notification
103 NSString *infoValue =
@"";
104 switch ([UIDevice currentDevice].orientation) {
105 case UIDeviceOrientationUnknown:
107 case UIDeviceOrientationPortrait:
108 newOrientation = UIInterfaceOrientationPortrait;
109 infoValue =
@"UIInterfaceOrientationPortrait";
111 case UIDeviceOrientationPortraitUpsideDown:
112 newOrientation = UIInterfaceOrientationPortraitUpsideDown;
113 infoValue =
@"UIInterfaceOrientationPortraitUpsideDown";
115 case UIDeviceOrientationLandscapeLeft:
116 newOrientation = UIInterfaceOrientationLandscapeRight;
117 infoValue =
@"UIInterfaceOrientationLandscapeRight";
119 case UIDeviceOrientationLandscapeRight:
120 newOrientation = UIInterfaceOrientationLandscapeLeft;
121 infoValue =
@"UIInterfaceOrientationLandscapeLeft";
123 case UIDeviceOrientationFaceUp:
124 case UIDeviceOrientationFaceDown:
132 NSBundle *bundle = [NSBundle mainBundle];
133 NSArray *orientations = [bundle objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"];
134 if (![orientations containsObject:infoValue])
138 [UIApplication sharedApplication].statusBarOrientation =
mOrientation;
145 - (void)applicationWillTerminate:(UIApplication *)application
157 if ((
self = [
self init])) {
166 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
167 NSDate *nextDate = [[NSDate date] dateByAddingTimeInterval:((double)mIntegration->nextTimerEvent()/1000.)];
178 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
181 mTimer = [[NSTimer timerWithTimeInterval:0.030 target:mHelper selector:@selector(processEventsAndSchedule) userInfo:nil repeats:YES] retain];
189 delete mInputHandler;
194 qApp->installEventFilter(mInputHandler);
195 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
196 [[NSRunLoop currentRunLoop] addTimer:[
mTimer autorelease] forMode:NSDefaultRunLoopMode];
197 UIApplicationMain(
qApp->argc(),
qApp->argv(), nil,
@"QUIKitAppDelegate");
208 [
mHelper performSelectorOnMainThread:@selector(processEventsAndSchedule) withObject:nil waitUntilDone:NO];
214 return UIReturnKeyDefault;
215 return UIReturnKeyDone;
221 UIReturnKeyType returnKeyType = UIReturnKeyDone;
222 if (
QGraphicsView *declarativeView = qobject_cast<QGraphicsView *>(obj)) {
226 if (mCurrentFocusObject)
227 disconnect(mCurrentFocusObject, 0,
this,
SLOT(activeFocusChanged(
bool)));
229 mCurrentFocusObject = focus;
231 connect(mCurrentFocusObject,
SIGNAL(activeFocusChanged(
bool)),
this,
SLOT(activeFocusChanged(
bool)));
238 mCurrentFocusWidget =
widget;
240 if (platformWindow) {
242 [platformWindow->nativeView() becomeFirstResponder];
248 return closeSoftwareInputPanel(widget);
257 if (platformWindow) {
258 [platformWindow->nativeView() resignFirstResponder];
259 mCurrentFocusWidget = 0;
260 if (mCurrentFocusObject)
261 disconnect(mCurrentFocusObject, 0,
this,
SLOT(activeFocusChanged(
bool)));
262 mCurrentFocusObject = 0;
271 if (!focus && mCurrentFocusWidget && mCurrentFocusObject) {
272 closeSoftwareInputPanel(mCurrentFocusWidget);
T qobject_cast(QObject *object)
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
UIWindow * ensureNativeWindow()
EAGLView * nativeView() const
The QObject class is the base class of all Qt objects.
QList< QPlatformScreen * > screens() const
Accessor function to a list of all the screens on the current system.
static UIReturnKeyType keyTypeForObject(QObject *obj)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene's current focus item, or 0 if no item curr...
const T & at(int i) const
Returns the item at index position i in the list.
void updateInterfaceOrientation()
UIInterfaceOrientation mOrientation
QUIKitEventLoop * mIntegration
void qtNeedsToProcessEvents()
UIReturnKeyType returnKeyType
void processEventsAndSchedule()
static QUIKitIntegration * instance()
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
EventLoopHelper * mHelper
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.