blob: e836b4bcc464d41c26ec8bc83d034757db766054 [file] [log] [blame]
Alexandre Lision8521baa2015-03-13 11:08:00 -04001/*
2 * Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
3 * Author: Alexandre Lision <alexandre.lision@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 * Additional permission under GNU GPL version 3 section 7:
20 *
21 * If you modify this program, or any covered work, by linking or
22 * combining it with the OpenSSL project's OpenSSL library (or a
23 * modified version of that library), containing parts covered by the
24 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25 * grants you additional permission to convey the resulting work.
26 * Corresponding Source for a non-source form of such a combination
27 * shall include the source code for the parts of OpenSSL used as well
28 * as that of the covered work.
29 */
Alexandre Lision5855b6a2015-02-03 11:31:05 -050030#import "RingWindowController.h"
31
32#import <historymodel.h>
33#import <accountmodel.h>
34#import <callmodel.h>
35#import <account.h>
36#include <call.h>
37
38@interface RingWindowController ()
39
40
41@end
42
43@implementation RingWindowController
Alexandre Lision5855b6a2015-02-03 11:31:05 -050044
45- (void)windowDidLoad {
46 [super windowDidLoad];
Alexandre Lision5855b6a2015-02-03 11:31:05 -050047 [self connectSlots];
Alexandre Lision5855b6a2015-02-03 11:31:05 -050048}
49
50
51- (void) connectSlots
52{
53 CallModel* callModel_ = CallModel::instance();
54 QObject::connect(callModel_, &CallModel::callStateChanged, [](Call*, Call::State) {
55 NSLog(@"callStateChanged");
56 });
57
58 QObject::connect(callModel_, &CallModel::incomingCall, [] (Call*) {
59 NSLog(@"incomingCall");
60 });
61
62}
63
Alexandre Lision4a7b95e2015-02-20 10:06:43 -050064- (IBAction)openPreferences:(id)sender
65{
66
67 if(self.preferencesViewController != nil)
68 return;
69 NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"PreferencesToolbar"];
70
71
72
73 self.preferencesViewController = [[PreferencesViewController alloc] initWithNibName:@"PreferencesScreen" bundle:nil];
74
75 self.myCurrentViewController = self.preferencesViewController;
76
77 NSLayoutConstraint* test = [NSLayoutConstraint constraintWithItem:self.preferencesViewController.view
78 attribute:NSLayoutAttributeWidth
79 relatedBy:NSLayoutRelationEqual
80 toItem:currentView
81 attribute:NSLayoutAttributeWidth
82 multiplier:1.0f
83 constant:0.0f];
84
85 NSLayoutConstraint* test2 = [NSLayoutConstraint constraintWithItem:self.preferencesViewController.view
86 attribute:NSLayoutAttributeHeight
87 relatedBy:NSLayoutRelationEqual
88 toItem:currentView
89 attribute:NSLayoutAttributeHeight
90 multiplier:1.0f
91 constant:0.0f];
92
93 NSLayoutConstraint* test3 = [NSLayoutConstraint constraintWithItem:self.preferencesViewController.view
94 attribute:NSLayoutAttributeCenterX
95 relatedBy:NSLayoutRelationEqual
96 toItem:currentView
97 attribute:NSLayoutAttributeCenterX
98 multiplier:1.0f
99 constant:0.0f];
100
101
102 [currentView addSubview:[self.preferencesViewController view]];
103
104 [tb setDelegate: self.preferencesViewController];
105 [self.window setToolbar: tb];
106
107 [self.window.toolbar setSelectedItemIdentifier:@"GeneralPrefsIdentifier"];
108
109 [currentView addConstraint:test];
110 [currentView addConstraint:test2];
111 [currentView addConstraint:test3];
112 // make sure we automatically resize the controller's view to the current window size
113 [[self.myCurrentViewController view] setFrame:[currentView bounds]];
114
115 // set the view controller's represented object to the number of subviews in that controller
116 // (our NSTextField's value binding will reflect this value)
117 [self.myCurrentViewController setRepresentedObject:[NSNumber numberWithUnsignedInteger:[[[self.myCurrentViewController view] subviews] count]]];
118
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500119}
Alexandre Lision4a7b95e2015-02-20 10:06:43 -0500120
121- (IBAction) closePreferences:(NSToolbarItem *)sender {
122 if(self.myCurrentViewController != nil)
123 {
124 [self.preferencesViewController close];
125 [self.window setToolbar:nil];
126 self.preferencesViewController = nil;
127 }
128}
129
130// FIXME: This is sick, NSWindowController is catching my selectors
131- (void)displayGeneral:(NSToolbarItem *)sender {
132 [self.preferencesViewController displayGeneral:sender];
133}
134
135- (void)displayAudio:(NSToolbarItem *)sender {
136 [self.preferencesViewController displayAudio:sender];
137}
138
139- (void)displayAncrage:(NSToolbarItem *)sender {
140 [self.preferencesViewController displayAncrage:sender];
141}
142
143- (void)displayVideo:(NSToolbarItem *)sender {
144 [self.preferencesViewController displayVideo:sender];
145}
146
Alexandre Lision5855b6a2015-02-03 11:31:05 -0500147@end