Commit 76d59690 authored by Alexandre Lision's avatar Alexandre Lision

wizard: fix wizard cancellation

wrong redirection to main window if user do not create his account

Tuleap: #255
Change-Id: Ib984525610ede06084c2625de819b3112604dfde
parent c0657f46
...@@ -26,5 +26,6 @@ ...@@ -26,5 +26,6 @@
- (void) showWizard; - (void) showWizard;
- (void) showMainWindow; - (void) showMainWindow;
- (BOOL) checkForRingAccount;
@end @end
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
if(self.wizard == nil) { if(self.wizard == nil) {
self.wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"]; self.wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"];
} }
[self.wizard.window orderFront:self]; [self.wizard.window makeKeyAndOrderFront:self];
} }
- (void) showMainWindow - (void) showMainWindow
...@@ -148,9 +148,6 @@ ...@@ -148,9 +148,6 @@
if(self.ringWindowController == nil) { if(self.ringWindowController == nil) {
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"]; self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"];
} }
self.wizard = nil;
[self.ringWindowController.window makeKeyAndOrderFront:self]; [self.ringWindowController.window makeKeyAndOrderFront:self];
} }
...@@ -160,7 +157,7 @@ ...@@ -160,7 +157,7 @@
for (int i = 0 ; i < AccountModel::instance().rowCount() ; ++i) { for (int i = 0 ; i < AccountModel::instance().rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance().index(i); QModelIndex idx = AccountModel::instance().index(i);
Account* acc = AccountModel::instance().getAccountByModelIndex(idx); Account* acc = AccountModel::instance().getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) { if(acc->protocol() == Account::Protocol::RING && !acc->isNew()) {
if (acc->displayName().isEmpty()) if (acc->displayName().isEmpty())
acc->setDisplayName(acc->alias()); acc->setDisplayName(acc->alias());
foundRingAcc = YES; foundRingAcc = YES;
...@@ -222,20 +219,25 @@ ...@@ -222,20 +219,25 @@
- (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent - (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
{ {
delete CallModel::instance().QObject::parent(); [self cleanExit];
[[NSApplication sharedApplication] terminate:self];
} }
-(void)applicationWillTerminate:(NSNotification *)notification -(void)applicationWillTerminate:(NSNotification *)notification
{ {
[self cleanExit];
}
- (void) cleanExit
{
[self.wizard close];
[self.ringWindowController close];
delete CallModel::instance().QObject::parent(); delete CallModel::instance().QObject::parent();
[[NSApplication sharedApplication] terminate:self]; [[NSApplication sharedApplication] terminate:self];
} }
#if ENABLE_SPARKLE #if ENABLE_SPARKLE
#pragma mark - #pragma mark - Sparkle delegate
#pragma mark Sparkle delegate
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
{ {
......
...@@ -61,7 +61,9 @@ NSInteger const NICKNAME_TAG = 1; ...@@ -61,7 +61,9 @@ NSInteger const NICKNAME_TAG = 1;
[self.window makeKeyAndOrderFront:nil]; [self.window makeKeyAndOrderFront:nil];
[self.window setLevel:NSStatusWindowLevel]; [self.window setLevel:NSStatusWindowLevel];
[self.window makeMainWindow]; [self.window makeMainWindow];
if(![self checkForRingAccount]) { AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
if(![appDelegate checkForRingAccount]) {
accountToCreate = AccountModel::instance().add("", Account::Protocol::RING); accountToCreate = AccountModel::instance().add("", Account::Protocol::RING);
} else { } else {
[indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work", [indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work",
...@@ -75,18 +77,6 @@ NSInteger const NICKNAME_TAG = 1; ...@@ -75,18 +77,6 @@ NSInteger const NICKNAME_TAG = 1;
[pvkPathControl setDelegate:self]; [pvkPathControl setDelegate:self];
} }
- (BOOL) checkForRingAccount
{
for (int i = 0 ; i < AccountModel::instance().rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance().index(i);
Account* acc = AccountModel::instance().getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
return YES;
}
}
return false;
}
- (void) displayHash:(NSString* ) hash - (void) displayHash:(NSString* ) hash
{ {
[nickname setFrameSize:NSMakeSize(400, nickname.frame.size.height)]; [nickname setFrameSize:NSMakeSize(400, nickname.frame.size.height)];
...@@ -323,7 +313,9 @@ NSInteger const NICKNAME_TAG = 1; ...@@ -323,7 +313,9 @@ NSInteger const NICKNAME_TAG = 1;
- (void)windowWillClose:(NSNotification *)notification - (void)windowWillClose:(NSNotification *)notification
{ {
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate showMainWindow]; if ([appDelegate checkForRingAccount]) {
[appDelegate showMainWindow];
}
} }
@end @end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment