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 @@ ...@@ -20,6 +20,7 @@
//lrc //lrc
#import <api/datatransfermodel.h> #import <api/datatransfermodel.h>
#import <api/avmodel.h>
#if ENABLE_SPARKLE #if ENABLE_SPARKLE
#import <Sparkle/Sparkle.h> #import <Sparkle/Sparkle.h>
...@@ -35,19 +36,22 @@ ...@@ -35,19 +36,22 @@
__unsafe_unretained IBOutlet NSView* sparkleContainer; __unsafe_unretained IBOutlet NSView* sparkleContainer;
__unsafe_unretained IBOutlet NSButton *downloadFolder; __unsafe_unretained IBOutlet NSButton *downloadFolder;
__unsafe_unretained IBOutlet NSTextField *downloadFolderLabel; __unsafe_unretained IBOutlet NSTextField *downloadFolderLabel;
__unsafe_unretained IBOutlet NSButton *recordingFolder;
__unsafe_unretained IBOutlet NSTextField *recordingFolderLabel;
} }
@end @end
@implementation GeneralPrefsVC @implementation GeneralPrefsVC
@synthesize dataTransferModel; @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]) if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{ {
self.dataTransferModel = dataTransferModel; self.dataTransferModel = dataTransferModel;
self.avModel = avModel;
} }
return self; return self;
} }
...@@ -70,11 +74,19 @@ ...@@ -70,11 +74,19 @@
[downloadFolder setHidden:YES]; [downloadFolder setHidden:YES];
[downloadFolder setEnabled:NO]; [downloadFolder setEnabled:NO];
[downloadFolderLabel setHidden: YES]; [downloadFolderLabel setHidden: YES];
[recordingFolder setHidden:YES];
[recordingFolder setEnabled:NO];
[recordingFolderLabel setHidden:YES];
return; return;
} }
if (dataTransferModel) { if (dataTransferModel) {
downloadFolder.title = [@(dataTransferModel->downloadDirectory.c_str()) lastPathComponent]; 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 { - (IBAction)changeDownloadFolder:(id)sender {
...@@ -92,6 +104,20 @@ ...@@ -92,6 +104,20 @@
[[NSUserDefaults standardUserDefaults] setObject:path forKey:Preferences::DownloadFolder]; [[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 #pragma mark - Startup API
// MIT license by Brian Dunagan // MIT license by Brian Dunagan
......
...@@ -29,6 +29,7 @@ namespace lrc { ...@@ -29,6 +29,7 @@ namespace lrc {
@protocol LrcModelsProtocol @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;
-(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 avModel:(const lrc::api::AVModel*) avModel;
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(const lrc::api::NewAccountModel*) accountModel; -(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; -(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"; ...@@ -71,7 +71,7 @@ static auto const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
{ {
[[prefsContainer subviews] [[prefsContainer subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)]; 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]; [self resizeWindowWithFrame:currentVC.view.frame];
[prefsContainer addSubview:currentVC.view]; [prefsContainer addSubview:currentVC.view];
......
...@@ -200,6 +200,8 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -200,6 +200,8 @@ typedef NS_ENUM(NSInteger, ViewState) {
if(appSandboxed()) { if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
avModel->setRecordPath([[paths objectAtIndex:0] UTF8String]); avModel->setRecordPath([[paths objectAtIndex:0] UTF8String]);
} else if (avModel->getRecordPath().empty()) {
avModel->setRecordPath([NSHomeDirectory() UTF8String]);
} }
NSToolbar *tb = [[self window] toolbar]; NSToolbar *tb = [[self window] toolbar];
[tb setAllowsUserCustomization:NO]; [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