From 76d59690cf71a0c6fcc8cd91fcaa860735582161 Mon Sep 17 00:00:00 2001 From: Alexandre Lision Date: Wed, 20 Jan 2016 18:06:05 -0500 Subject: [PATCH] wizard: fix wizard cancellation wrong redirection to main window if user do not create his account Tuleap: #255 Change-Id: Ib984525610ede06084c2625de819b3112604dfde --- src/AppDelegate.h | 1 + src/AppDelegate.mm | 20 +++++++++++--------- src/RingWizardWC.mm | 20 ++++++-------------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/AppDelegate.h b/src/AppDelegate.h index 790f7c42..d202039a 100644 --- a/src/AppDelegate.h +++ b/src/AppDelegate.h @@ -26,5 +26,6 @@ - (void) showWizard; - (void) showMainWindow; +- (BOOL) checkForRingAccount; @end diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm index 111de1ce..2c469a15 100644 --- a/src/AppDelegate.mm +++ b/src/AppDelegate.mm @@ -140,7 +140,7 @@ if(self.wizard == nil) { self.wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"]; } - [self.wizard.window orderFront:self]; + [self.wizard.window makeKeyAndOrderFront:self]; } - (void) showMainWindow @@ -148,9 +148,6 @@ if(self.ringWindowController == nil) { self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"]; } - - self.wizard = nil; - [self.ringWindowController.window makeKeyAndOrderFront:self]; } @@ -160,7 +157,7 @@ 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) { + if(acc->protocol() == Account::Protocol::RING && !acc->isNew()) { if (acc->displayName().isEmpty()) acc->setDisplayName(acc->alias()); foundRingAcc = YES; @@ -222,20 +219,25 @@ - (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent { - delete CallModel::instance().QObject::parent(); - [[NSApplication sharedApplication] terminate:self]; + [self cleanExit]; } -(void)applicationWillTerminate:(NSNotification *)notification { + [self cleanExit]; +} + +- (void) cleanExit +{ + [self.wizard close]; + [self.ringWindowController close]; delete CallModel::instance().QObject::parent(); [[NSApplication sharedApplication] terminate:self]; } #if ENABLE_SPARKLE -#pragma mark - -#pragma mark Sparkle delegate +#pragma mark - Sparkle delegate - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update { diff --git a/src/RingWizardWC.mm b/src/RingWizardWC.mm index abd5d3e5..0043a7f0 100644 --- a/src/RingWizardWC.mm +++ b/src/RingWizardWC.mm @@ -61,7 +61,9 @@ NSInteger const NICKNAME_TAG = 1; [self.window makeKeyAndOrderFront:nil]; [self.window setLevel:NSStatusWindowLevel]; [self.window makeMainWindow]; - if(![self checkForRingAccount]) { + AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; + + if(![appDelegate checkForRingAccount]) { accountToCreate = AccountModel::instance().add("", Account::Protocol::RING); } else { [indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work", @@ -75,18 +77,6 @@ NSInteger const NICKNAME_TAG = 1; [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 { [nickname setFrameSize:NSMakeSize(400, nickname.frame.size.height)]; @@ -323,7 +313,9 @@ NSInteger const NICKNAME_TAG = 1; - (void)windowWillClose:(NSNotification *)notification { AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; - [appDelegate showMainWindow]; + if ([appDelegate checkForRingAccount]) { + [appDelegate showMainWindow]; + } } @end -- GitLab