2013-02-14 17:59:12 +04:00
|
|
|
/*
|
|
|
|
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/.
|
2013-02-14 17:59:12 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import "PerformanceEditorController.h"
|
|
|
|
#import "ConnectionParams.h"
|
|
|
|
#import "Utils.h"
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
@interface PerformanceEditorController (Private)
|
|
|
|
- (NSString *)keyPathForKey:(NSString *)key;
|
2013-02-14 17:59:12 +04:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation PerformanceEditorController
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
- (id)initWithConnectionParams:(ConnectionParams *)params
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2016-08-05 14:14:55 +03:00
|
|
|
return [self initWithConnectionParams:params keyPath:nil];
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
- (id)initWithConnectionParams:(ConnectionParams *)params keyPath:(NSString *)keyPath;
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
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;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2016-08-05 14:14:55 +03:00
|
|
|
[super viewDidLoad];
|
2013-02-14 17:59:12 +04:00
|
|
|
// 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.
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2016-08-05 14:14:55 +03:00
|
|
|
return YES;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
- (NSString *)keyPathForKey:(NSString *)key
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2016-08-05 14:14:55 +03:00
|
|
|
if (_keyPath)
|
|
|
|
return [_keyPath stringByAppendingFormat:@".%@", key];
|
|
|
|
|
|
|
|
return key;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-02-14 17:59:12 +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;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
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;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// set section headers
|
2019-11-06 17:24:51 +03:00
|
|
|
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2016-08-05 14:14:55 +03:00
|
|
|
return NSLocalizedString(@"Performance Settings",
|
|
|
|
@"'Performance Settings': performance settings header");
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|