Commit 6db52806 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

settings: recordings folder

-fix path for recordings
-add option to change recordings folder

Change-Id: I2a4cbc9f6a74d977d00071c37f9faadc63043a8f
parent ac0293da
......@@ -20,6 +20,7 @@
//lrc
#import <api/datatransfermodel.h>
#import <api/avmodel.h>
#if ENABLE_SPARKLE
#import <Sparkle/Sparkle.h>
......@@ -35,19 +36,22 @@
__unsafe_unretained IBOutlet NSView* sparkleContainer;
__unsafe_unretained IBOutlet NSButton *downloadFolder;
__unsafe_unretained IBOutlet NSTextField *downloadFolderLabel;
__unsafe_unretained IBOutlet NSButton *recordingFolder;
__unsafe_unretained IBOutlet NSTextField *recordingFolderLabel;
}
@end
@implementation GeneralPrefsVC
@synthesize dataTransferModel;
@synthesize avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(lrc::api::DataTransferModel*) dataTransferModel
{
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(lrc::api::DataTransferModel*) dataTransferModel avModel:(lrc::api::AVModel*) avModel {
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.dataTransferModel = dataTransferModel;
self.avModel = avModel;
}
return self;
}
......@@ -70,11 +74,19 @@
[downloadFolder setHidden:YES];
[downloadFolder setEnabled:NO];
[downloadFolderLabel setHidden: YES];
[recordingFolder setHidden:YES];
[recordingFolder setEnabled:NO];
[recordingFolderLabel setHidden:YES];
return;
}
if (dataTransferModel) {
downloadFolder.title = [@(dataTransferModel->downloadDirectory.c_str()) lastPathComponent];
}
if (avModel) {
auto name1 = avModel->getRecordPath();
auto name = @(avModel->getRecordPath().c_str());
recordingFolder.title = [@(avModel->getRecordPath().c_str()) lastPathComponent];
}
}
- (IBAction)changeDownloadFolder:(id)sender {
......@@ -92,6 +104,20 @@
[[NSUserDefaults standardUserDefaults] setObject:path forKey:Preferences::DownloadFolder];
}
- (IBAction)changeRecordingFolder:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:NO];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:NO];
panel.delegate = self;
if ([panel runModal] != NSFileHandlingPanelOKButton) return;
if ([[panel URLs] lastObject] == nil) return;
NSString * path = [[[[panel URLs] lastObject] path] stringByAppendingString:@"/"];
avModel->setRecordPath([path UTF8String]);
recordingFolder.title = [@(avModel->getRecordPath().c_str()) lastPathComponent];
[[NSUserDefaults standardUserDefaults] setObject:path forKey:Preferences::DownloadFolder];
}
#pragma mark - Startup API
// MIT license by Brian Dunagan
......
......@@ -29,6 +29,7 @@ namespace lrc {
@protocol LrcModelsProtocol
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel avModel:(const lrc::api::AVModel*) avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil avModel:(const lrc::api::AVModel*) avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(const lrc::api::NewAccountModel*) accountModel;
-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel dataTransferModel:(const lrc::api::DataTransferModel*)dataTransferModel behaviourController:(const lrc::api::BehaviorController*) behaviorController;
......
......@@ -71,7 +71,7 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{
[[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil dataTransferModel: self.dataTransferModel];
currentVC = [[GeneralPrefsVC alloc] initWithNibName:@"GeneralPrefs" bundle:nil dataTransferModel: self.dataTransferModel avModel: self.avModel];
[self resizeWindowWithFrame:currentVC.view.frame];
[prefsContainer addSubview:currentVC.view];
......
......@@ -200,6 +200,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
avModel->setRecordPath([[paths objectAtIndex:0] UTF8String]);
} else if (avModel->getRecordPath().empty()) {
avModel->setRecordPath([NSHomeDirectory() UTF8String]);
}
NSToolbar *tb = [[self window] toolbar];
[tb setAllowsUserCustomization:NO];
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment