Loïc Siret | fcb4ca6 | 2016-09-21 17:12:09 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
| 3 | * Author: Loïc Siret <loic.siret@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #import "RingWizardChooseVC.h" |
| 21 | |
| 22 | @interface RingWizardChooseVC() |
| 23 | |
| 24 | @end |
| 25 | |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 26 | @implementation RingWizardChooseVC { |
| 27 | |
| 28 | __unsafe_unretained IBOutlet NSButton* createSIPAccount; |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 29 | __unsafe_unretained IBOutlet NSLayoutConstraint* buttonTopConstraint; |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 30 | |
| 31 | } |
Loïc Siret | fcb4ca6 | 2016-09-21 17:12:09 -0400 | [diff] [blame] | 32 | |
| 33 | @synthesize delegate; |
| 34 | |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 35 | #define heightWithAdvanced 220 |
| 36 | #define heightWithCancel 148 |
| 37 | #define heightWithCancelAndAdvanced 168 |
| 38 | #define defaultHeight 128 |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 39 | |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 40 | - (void)showCancelButton:(BOOL)showCancel { |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 41 | [createSIPAccount setHidden: YES]; |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 42 | buttonTopConstraint.constant = showCancel ? 25 : 0; |
| 43 | self.isCancelable = showCancel; |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | - (void)showAdvancedButton:(BOOL)showAdvanced { |
| 47 | self.withAdvancedOptions = showAdvanced; |
Loïc Siret | fcb4ca6 | 2016-09-21 17:12:09 -0400 | [diff] [blame] | 48 | } |
| 49 | |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 50 | - (void)updateFrame { |
| 51 | NSRect viewFrame = self.view.frame; |
| 52 | viewFrame.size.height = (self.isCancelable && self.withAdvancedOptions) ? heightWithCancelAndAdvanced : self.isCancelable ? heightWithCancel : defaultHeight; |
| 53 | self.view.frame = viewFrame; |
| 54 | } |
| 55 | |
Loïc Siret | fcb4ca6 | 2016-09-21 17:12:09 -0400 | [diff] [blame] | 56 | - (IBAction)createRingAccount:(id)sender |
| 57 | { |
| 58 | if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){ |
| 59 | [delegate didCompleteWithAction:WizardAction::WIZARD_ACTION_NEW]; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | - (IBAction)linkExistingRingAccount:(id)sender |
| 64 | { |
| 65 | if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){ |
| 66 | [delegate didCompleteWithAction:WizardAction::WIZARD_ACTION_LINK]; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | - (IBAction)onCancel:(id)sender |
| 71 | { |
| 72 | if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){ |
| 73 | [delegate didCompleteWithAction:WIZARD_ACTION_INVALID]; |
| 74 | } |
| 75 | } |
| 76 | |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 77 | - (IBAction)showCreateSIP:(id)sender |
| 78 | { |
| 79 | if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){ |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 80 | buttonTopConstraint.constant = 57; |
| 81 | NSRect viewFrame = self.view.frame; |
| 82 | viewFrame.size.height = heightWithAdvanced; |
| 83 | self.view.frame = viewFrame; |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 84 | [delegate didCompleteWithAction:WIZARD_ACTION_ADVANCED]; |
Kateryna Kostiuk | 23222fe | 2018-11-16 14:28:02 -0500 | [diff] [blame] | 85 | [createSIPAccount setHidden: NO]; |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 86 | } |
Kateryna Kostiuk | ecaa395 | 2018-07-13 16:00:34 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | - (IBAction)addSIPAccount:(id)sender |
| 90 | { |
| 91 | if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){ |
| 92 | [delegate didCompleteWithAction:WIZARD_ACTION_SIP_ACCOUNT]; |
| 93 | } |
| 94 | } |
| 95 | |
Loïc Siret | fcb4ca6 | 2016-09-21 17:12:09 -0400 | [diff] [blame] | 96 | @end |