FreeRDP/client/iOS/Controllers/PerformanceEditorController.m

245 lines
6.1 KiB
Mathematica
Raw Normal View History

/*
controller for performance settings selection
2016-08-05 14:14:55 +03:00
2013-12-04 14:37:57 +04:00
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
2016-08-05 14:14:55 +03:00
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
2019-11-06 17:24:51 +03:00
If a copy of the MPL was not distributed with this file, You can obtain one at
http://mozilla.org/MPL/2.0/.
*/
#import "PerformanceEditorController.h"
#import "ConnectionParams.h"
#import "Utils.h"
2019-11-06 17:24:51 +03:00
@interface PerformanceEditorController (Private)
- (NSString *)keyPathForKey:(NSString *)key;
@end
@implementation PerformanceEditorController
2019-11-06 17:24:51 +03:00
- (id)initWithConnectionParams:(ConnectionParams *)params
{
2016-08-05 14:14:55 +03:00
return [self initWithConnectionParams:params keyPath:nil];
}
2019-11-06 17:24:51 +03:00
- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
{
2016-08-05 14:14:55 +03:00
self = [super initWithStyle:UITableViewStyleGrouped];
if (self)
{
_params = [params retain];
_keyPath = (keyPath != nil ? [keyPath retain] : nil);
}
return self;
}
- (void)viewDidLoad
{
2016-08-05 14:14:55 +03:00
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
2016-08-05 14:14:55 +03:00
[super viewDidUnload];
// Release any retained subviews of the main view.
}
2019-11-06 17:24:51 +03:00
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
2016-08-05 14:14:55 +03:00
return YES;
}
2019-11-06 17:24:51 +03:00
- (NSString *)keyPathForKey:(NSString *)key
{
2016-08-05 14:14:55 +03:00
if (_keyPath)
return [_keyPath stringByAppendingFormat:@".%@", key];
return key;
}
2013-05-08 16:50:29 +04:00
- (void)dealloc
{
2016-08-05 14:14:55 +03:00
[super dealloc];
[_params release];
2013-05-08 16:50:29 +04:00
}
#pragma mark -
#pragma mark Table view data source
2019-11-06 17:24:51 +03:00
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
2016-08-05 14:14:55 +03:00
{
// Return the number of sections.
return 1;
}
2019-11-06 17:24:51 +03:00
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
2016-08-05 14:14:55 +03:00
{
return 7;
}
// set section headers
2019-11-06 17:24:51 +03:00
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
2016-08-05 14:14:55 +03:00
return NSLocalizedString(@"Performance Settings",
@"'Performance Settings': performance settings header");
}
// Customize the appearance of table view cells.
2019-11-06 17:24:51 +03:00
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
2016-08-05 14:14:55 +03:00
{
// get the table view cell
2019-11-06 17:24:51 +03:00
EditFlagTableViewCell *cell =
(EditFlagTableViewCell *)[self tableViewCellFromIdentifier:TableCellIdentifierYesNo];
2016-08-05 14:14:55 +03:00
NSAssert(cell, @"Invalid cell");
switch ([indexPath row])
{
case 0:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"RemoteFX", @"RemoteFX performance setting")];
[[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_remotefx"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 1:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"GFX", @"GFX performance setting")];
[[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_gfx"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 2:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"H264", @"H264 performance setting")];
[[cell toggle] setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_h264"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 3:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"Desktop Background",
@"Desktop background performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_show_desktop"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 4:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"Font Smoothing",
@"Font smoothing performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_font_smoothing"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 5:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"Desktop Composition",
@"Desktop composition performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_desktop_composition"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 6:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"Window contents while dragging",
@"Window Dragging performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_window_dragging"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 7:
2019-11-06 17:24:51 +03:00
{
[[cell label] setText:NSLocalizedString(@"Menu Animation",
@"Menu Animations performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_menu_animation"]]];
break;
}
2016-08-05 14:14:55 +03:00
case 8:
2019-11-06 17:24:51 +03:00
{
[[cell label]
setText:NSLocalizedString(@"Visual Styles", @"Use Themes performance setting")];
[[cell toggle]
setOn:[_params boolForKeyPath:[self keyPathForKey:@"perf_windows_themes"]]];
break;
}
2016-08-05 14:14:55 +03:00
default:
break;
}
[[cell toggle] setTag:GET_TAG_FROM_PATH(indexPath)];
2019-11-06 17:24:51 +03:00
[[cell toggle] addTarget:self
action:@selector(togglePerformanceSetting:)
forControlEvents:UIControlEventValueChanged];
2016-08-05 14:14:55 +03:00
return cell;
}
#pragma mark -
#pragma mark Action Handlers
- (void)togglePerformanceSetting:(id)sender
{
2019-11-06 17:24:51 +03:00
UISwitch *valueSwitch = (UISwitch *)sender;
2016-08-05 14:14:55 +03:00
switch (valueSwitch.tag)
{
case GET_TAG(0, 0):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_remotefx"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 1):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_gfx"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 2):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn] forKeyPath:[self keyPathForKey:@"perf_h264"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 3):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_show_desktop"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 4):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_font_smoothing"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 5):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_desktop_composition"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 6):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_window_dragging"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 7):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_menu_animation"]];
2016-08-05 14:14:55 +03:00
break;
case GET_TAG(0, 8):
2019-11-06 17:24:51 +03:00
[_params setBool:[valueSwitch isOn]
forKeyPath:[self keyPathForKey:@"perf_windows_themes"]];
2016-08-05 14:14:55 +03:00
break;
default:
break;
}
}
@end