FreeRDP
Loading...
Searching...
No Matches
PerformanceEditorController.m
1/*
2 controller for performance settings selection
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11#import "PerformanceEditorController.h"
12#import "ConnectionParams.h"
13#import "Utils.h"
14
15@interface PerformanceEditorController (Private)
16- (NSString *)keyPathForKey:(NSString *)key;
17@end
18
19@implementation PerformanceEditorController
20
21- (id)initWithConnectionParams:(ConnectionParams *)params
22{
23 return [self initWithConnectionParams:params keyPath:nil];
24}
25
26- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
27{
28 self = [super initWithStyle:UITableViewStyleInsetGrouped];
29
30 if (self)
31 {
32 _params = [params retain];
33 _keyPath = (keyPath != nil ? [keyPath retain] : nil);
34 }
35
36 return self;
37}
38
39- (void)viewDidLoad
40{
41 [super viewDidLoad];
42 // Do any additional setup after loading the view.
43}
44
45- (void)viewDidUnload
46{
47 [super viewDidUnload];
48 // Release any retained subviews of the main view.
49}
50
51- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
52{
53 return YES;
54}
55
56- (NSString *)keyPathForKey:(NSString *)key
57{
58 if (_keyPath)
59 return [_keyPath stringByAppendingFormat:@".%@", key];
60
61 return key;
62}
63
64- (void)dealloc
65{
66 [super dealloc];
67 [_params release];
68}
69
70#pragma mark -
71#pragma mark Table view data source
72
73- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
74{
75 // Return the number of sections.
76 return 1;
77}
78
79- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
80{
81 return 7;
82}
83
84// set section headers
85- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
86{
87 return NSLocalizedString(@"Performance Settings",
88 @"'Performance Settings': performance settings header");
89}
90
91// Customize the appearance of table view cells.
92- (UITableViewCell *)tableView:(UITableView *)tableView
93 cellForRowAtIndexPath:(NSIndexPath *)indexPath
94{
95 // get the table view cell
97 (EditFlagTableViewCell *)[self tableViewCellFromIdentifier:TableCellIdentifierYesNo];
98 NSAssert(cell, @"Invalid cell");
99
100 switch ([indexPath row])
101 {
102 case 0:
103 {
104 [cell setTitle:NSLocalizedString(@"RemoteFX", @"RemoteFX performance setting")];
105 [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_remotefx"]]];
106 break;
107 }
108
109 case 1:
110 {
111 [cell setTitle:NSLocalizedString(@"GFX", @"GFX performance setting")];
112 [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_gfx"]]];
113 break;
114 }
115
116 case 2:
117 {
118 [cell setTitle:NSLocalizedString(@"H264", @"H264 performance setting")];
119 [[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_h264"]]];
120 break;
121 }
122
123 case 3:
124 {
125 [cell setTitle:NSLocalizedString(@"Desktop Background",
126 @"Desktop background performance setting")];
127 [[cell toggle]
128 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_show_desktop"]]];
129 break;
130 }
131
132 case 4:
133 {
134 [cell setTitle:NSLocalizedString(@"Font Smoothing",
135 @"Font smoothing performance setting")];
136 [[cell toggle]
137 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_font_smoothing"]]];
138 break;
139 }
140
141 case 5:
142 {
143 [cell setTitle:NSLocalizedString(@"Desktop Composition",
144 @"Desktop composition performance setting")];
145 [[cell toggle]
146 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_desktop_composition"]]];
147 break;
148 }
149
150 case 6:
151 {
152 [cell setTitle:NSLocalizedString(@"Window contents while dragging",
153 @"Window Dragging performance setting")];
154 [[cell toggle]
155 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_window_dragging"]]];
156 break;
157 }
158
159 case 7:
160 {
161 [cell setTitle:NSLocalizedString(@"Menu Animation",
162 @"Menu Animations performance setting")];
163 [[cell toggle]
164 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_menu_animation"]]];
165 break;
166 }
167
168 case 8:
169 {
170 [cell setTitle:NSLocalizedString(@"Visual Styles", @"Use Themes performance setting")];
171 [[cell toggle]
172 setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_windows_themes"]]];
173 break;
174 }
175
176 default:
177 break;
178 }
179
180 [[cell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
181 [[cell toggle] addTarget:self
182 action:@selector(togglePerformanceSetting:)
183 forControlEvents:UIControlEventValueChanged];
184 return cell;
185}
186
187#pragma mark -
188#pragma mark Action Handlers
189
190- (void)togglePerformanceSetting:(id)sender
191{
192 UISwitch *valueSwitch = (UISwitch *)sender;
193
194 switch (valueSwitch.tag)
195 {
196 case GET_TAG(0, 0):
197 [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_remotefx"]];
198 break;
199
200 case GET_TAG(0, 1):
201 [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_gfx"]];
202 break;
203
204 case GET_TAG(0, 2):
205 [_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_h264"]];
206 break;
207
208 case GET_TAG(0, 3):
209 [_params setBool:[valueSwitch isOn]
210 forKeyPath:[self keyPathForKey:@"perf_show_desktop"]];
211 break;
212
213 case GET_TAG(0, 4):
214 [_params setBool:[valueSwitch isOn]
215 forKeyPath:[self keyPathForKey:@"perf_font_smoothing"]];
216 break;
217
218 case GET_TAG(0, 5):
219 [_params setBool:[valueSwitch isOn]
220 forKeyPath:[self keyPathForKey:@"perf_desktop_composition"]];
221 break;
222
223 case GET_TAG(0, 6):
224 [_params setBool:[valueSwitch isOn]
225 forKeyPath:[self keyPathForKey:@"perf_window_dragging"]];
226 break;
227
228 case GET_TAG(0, 7):
229 [_params setBool:[valueSwitch isOn]
230 forKeyPath:[self keyPathForKey:@"perf_menu_animation"]];
231 break;
232
233 case GET_TAG(0, 8):
234 [_params setBool:[valueSwitch isOn]
235 forKeyPath:[self keyPathForKey:@"perf_windows_themes"]];
236 break;
237
238 default:
239 break;
240 }
241}
242
243@end