blob: 1cfc7d214c53f2904282f301d0749bebf177ea6f [file] [log] [blame]
Loïc Siretfcb4ca62016-09-21 17:12:09 -04001/*
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 Kostiukecaa3952018-07-13 16:00:34 -040026@implementation RingWizardChooseVC {
27
28__unsafe_unretained IBOutlet NSButton* createSIPAccount;
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050029__unsafe_unretained IBOutlet NSLayoutConstraint* buttonTopConstraint;
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040030
31}
Loïc Siretfcb4ca62016-09-21 17:12:09 -040032
33@synthesize delegate;
34
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050035#define heightWithAdvanced 220
36#define heightWithCancel 148
37#define heightWithCancelAndAdvanced 168
38#define defaultHeight 128
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040039
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050040- (void)showCancelButton:(BOOL)showCancel {
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040041 [createSIPAccount setHidden: YES];
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050042 buttonTopConstraint.constant = showCancel ? 25 : 0;
43 self.isCancelable = showCancel;
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040044}
45
46- (void)showAdvancedButton:(BOOL)showAdvanced {
47 self.withAdvancedOptions = showAdvanced;
Loïc Siretfcb4ca62016-09-21 17:12:09 -040048}
49
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050050- (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 Siretfcb4ca62016-09-21 17:12:09 -040056- (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 Kostiukecaa3952018-07-13 16:00:34 -040077- (IBAction)showCreateSIP:(id)sender
78{
79 if ([self.delegate respondsToSelector:@selector(didCompleteWithAction:)]){
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050080 buttonTopConstraint.constant = 57;
81 NSRect viewFrame = self.view.frame;
82 viewFrame.size.height = heightWithAdvanced;
83 self.view.frame = viewFrame;
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040084 [delegate didCompleteWithAction:WIZARD_ACTION_ADVANCED];
Kateryna Kostiuk23222fe2018-11-16 14:28:02 -050085 [createSIPAccount setHidden: NO];
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040086 }
Kateryna Kostiukecaa3952018-07-13 16:00:34 -040087}
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 Siretfcb4ca62016-09-21 17:12:09 -040096@end