wizard: fix wizard cancellation
wrong redirection to main window if user do not create his account
Tuleap: #255
Change-Id: Ib984525610ede06084c2625de819b3112604dfde
diff --git a/src/RingWizardWC.mm b/src/RingWizardWC.mm
index abd5d3e..0043a7f 100644
--- a/src/RingWizardWC.mm
+++ b/src/RingWizardWC.mm
@@ -61,7 +61,9 @@
[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 @@
[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 @@
- (void)windowWillClose:(NSNotification *)notification
{
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
- [appDelegate showMainWindow];
+ if ([appDelegate checkForRingAccount]) {
+ [appDelegate showMainWindow];
+ }
}
@end