summaryrefslogtreecommitdiffstats
path: root/tests/manual/cocoa/qt_on_cocoa
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2018-02-01 10:32:07 -0800
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-02-20 10:02:12 +0000
commitba871065e0f40e9197fa4ee0ffe76530bb6fca11 (patch)
treed4361d26260ef3bd96d9f89450893b7c9e99fbeb /tests/manual/cocoa/qt_on_cocoa
parent34017a8c5aaca2723fb62e79ea177b5579040ad3 (diff)
Clean up our Objective-C usage
- Move ivars into @implementation - Use instancetype where applicable - Use dot notation for property access - Use subscript operator for dictionaries and arrays - Format selectors consistently - Use proper style for init methods - Use generics instead of void pointers where possible - Use "range for" loops instead of indexing - Replace or replace IBAction/IBOutlet with void Change-Id: I1667812a51d4dfe44ae80fe337cb1f4bc9699d92 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/manual/cocoa/qt_on_cocoa')
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/main.mm32
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm
index 805ef0d7c2..e6218e48ac 100644
--- a/tests/manual/cocoa/qt_on_cocoa/main.mm
+++ b/tests/manual/cocoa/qt_on_cocoa/main.mm
@@ -50,31 +50,30 @@
}
@end
-@interface AppDelegate : NSObject <NSApplicationDelegate> {
+@interface AppDelegate : NSObject <NSApplicationDelegate>
+@end
+
+@implementation AppDelegate {
QGuiApplication *m_app;
QWindow *m_window;
}
-- (AppDelegate *) initWithArgc:(int)argc argv:(const char **)argv;
-- (void) applicationWillFinishLaunching: (NSNotification *)notification;
-- (void)applicationWillTerminate:(NSNotification *)notification;
-@end
-
-@implementation AppDelegate
-- (AppDelegate *) initWithArgc:(int)argc argv:(const char **)argv
+- (instancetype)initWithArgc:(int)argc argv:(const char **)argv
{
- m_app = new QGuiApplication(argc, const_cast<char **>(argv));
+ if ((self = [self init])) {
+ m_app = new QGuiApplication(argc, const_cast<char **>(argv));
+ }
return self;
}
-- (void) applicationWillFinishLaunching: (NSNotification *)notification
+- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
Q_UNUSED(notification);
// Create the NSWindow
NSRect frame = NSMakeRect(500, 500, 500, 500);
- NSWindow* window = [[NSWindow alloc] initWithContentRect:frame
- styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:frame
+ styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO];
@@ -100,7 +99,7 @@
childWindow->setGeometry(50, 50, 100, 100);
NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, 80, 25)];
- [(NSView*)childWindow->winId() addSubview:textField];
+ [reinterpret_cast<NSView *>(childWindow->winId()) addSubview:textField];
[contentView addSubview:reinterpret_cast<NSView *>(m_window->winId())];
@@ -125,10 +124,7 @@
int main(int argc, const char *argv[])
{
// Create NSApplicaiton with delgate
- NSApplication *app =[NSApplication sharedApplication];
+ NSApplication *app = [NSApplication sharedApplication];
app.delegate = [[AppDelegate alloc] initWithArgc:argc argv:argv];
- return NSApplicationMain (argc, argv);
+ return NSApplicationMain(argc, argv);
}
-
-
-