Skip to content

Commit

Permalink
Merge branch 'main' into add-finnish-localisations
Browse files Browse the repository at this point in the history
  • Loading branch information
osy authored Aug 30, 2022
2 parents 57efb45 + 9a3a02f commit 217826e
Show file tree
Hide file tree
Showing 79 changed files with 4,273 additions and 1,630 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@

NS_ASSUME_NONNULL_BEGIN

@interface UTMViewState : NSObject
@interface UTMLegacyViewState : NSObject

@property (nonatomic, weak, readonly) NSDictionary *dictRepresentation;

@property (nonatomic, assign) double displayScale;
@property (nonatomic, assign) double displayOriginX;
@property (nonatomic, assign) double displayOriginY;
@property (nonatomic, assign) BOOL hasSaveState;
@property (nonatomic, copy, nullable) NSData *sharedDirectory;
@property (nonatomic, copy, nullable) NSString *sharedDirectoryPath;
@property (nonatomic, copy, nullable) NSData *shortcutBookmark;
@property (nonatomic, copy, nullable) NSString *shortcutBookmarkPath;

- (instancetype)init NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly) CGFloat displayScale;
@property (nonatomic, readonly) CGFloat displayOriginX;
@property (nonatomic, readonly) CGFloat displayOriginY;
@property (nonatomic, readonly) BOOL isKeyboardShown;
@property (nonatomic, readonly) BOOL isToolbarShown;
@property (nonatomic, readonly) BOOL hasSaveState;
@property (nonatomic, readonly, nullable) NSData *sharedDirectory;
@property (nonatomic, readonly, nullable) NSString *sharedDirectoryPath;
@property (nonatomic, readonly, nullable) NSData *shortcutBookmark;
@property (nonatomic, readonly, nullable) NSString *shortcutBookmarkPath;

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;

- (void)setBookmark:(NSData *)bookmark path:(NSString *)path forRemovableDrive:(NSString *)drive persistent:(BOOL)persistent;
- (void)removeBookmarkForRemovableDrive:(NSString *)drive;
- (nullable NSData *)bookmarkForRemovableDrive:(NSString *)drive persistent:(out BOOL *)persistent;
- (NSArray<NSString *> *)allDrives;
- (nullable NSData *)bookmarkForRemovableDrive:(NSString *)drive;
- (nullable NSString *)pathForRemovableDrive:(NSString *)drive;

@end
Expand Down
118 changes: 118 additions & 0 deletions Configuration/Legacy/UTMLegacyViewState.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// Copyright © 2020 osy. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "UTMLegacyViewState.h"

const NSString *const kUTMViewStateDisplayScaleKey = @"DisplayScale";
const NSString *const kUTMViewStateDisplayOriginXKey = @"DisplayOriginX";
const NSString *const kUTMViewStateDisplayOriginYKey = @"DisplayOriginY";
const NSString *const kUTMViewStateShowToolbarKey = @"ShowToolbar";
const NSString *const kUTMViewStateShowKeyboardKey = @"ShowKeyboard";
const NSString *const kUTMViewStateSuspendedKey = @"Suspended";
const NSString *const kUTMViewStateSharedDirectoryKey = @"SharedDirectory";
const NSString *const kUTMViewStateSharedDirectoryPathKey = @"SharedDirectoryPath";
const NSString *const kUTMViewStateShortcutBookmarkKey = @"ShortcutBookmark";
const NSString *const kUTMViewStateShortcutBookmarkPathKey = @"ShortcutBookmarkPath";
const NSString *const kUTMViewStateRemovableDrivesKey = @"RemovableDrives";
const NSString *const kUTMViewStateRemovableDrivesPathKey = @"RemovableDrivesPath";

@implementation UTMLegacyViewState {
NSMutableDictionary *_rootDict;
NSMutableDictionary<NSString *, NSData *> *_removableDrives;
NSMutableDictionary<NSString *, NSString *> *_removableDrivesPath;
}

#pragma mark - Properties

- (NSDictionary *)dictRepresentation {
return (NSDictionary *)_rootDict;
}

- (CGFloat)displayScale {
return [_rootDict[kUTMViewStateDisplayScaleKey] floatValue];
}

- (CGFloat)displayOriginX {
return [_rootDict[kUTMViewStateDisplayOriginXKey] floatValue];
}

- (CGFloat)displayOriginY {
return [_rootDict[kUTMViewStateDisplayOriginYKey] floatValue];
}

- (BOOL)isKeyboardShown {
return [_rootDict[kUTMViewStateShowToolbarKey] boolValue];
}

- (BOOL)isToolbarShown {
return [_rootDict[kUTMViewStateShowToolbarKey] boolValue];
}

- (BOOL)hasSaveState {
return [_rootDict[kUTMViewStateSuspendedKey] boolValue];
}

- (NSData *)sharedDirectory {
return _rootDict[kUTMViewStateSharedDirectoryKey];
}

- (NSString *)sharedDirectoryPath {
return _rootDict[kUTMViewStateSharedDirectoryPathKey];
}

- (NSData *)shortcutBookmark {
return _rootDict[kUTMViewStateShortcutBookmarkKey];
}

- (NSString *)shortcutBookmarkPath {
return _rootDict[kUTMViewStateShortcutBookmarkPathKey];
}

#pragma mark - Removable drives

- (NSArray<NSString *> *)allDrives {
return [_removableDrives allKeys];
}

- (nullable NSData *)bookmarkForRemovableDrive:(NSString *)drive {
return _removableDrives[drive];
}

- (nullable NSString *)pathForRemovableDrive:(NSString *)drive {
return _removableDrivesPath[drive];
}

#pragma mark - Init

- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
self = [super init];
if (self) {
_rootDict = CFBridgingRelease(CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (__bridge CFDictionaryRef)dictionary, kCFPropertyListMutableContainers));
_removableDrives = _rootDict[kUTMViewStateRemovableDrivesKey];
_removableDrivesPath = _rootDict[kUTMViewStateRemovableDrivesPathKey];
if (!_removableDrives) {
_removableDrives = [NSMutableDictionary dictionary];
_rootDict[kUTMViewStateRemovableDrivesKey] = _removableDrives;
}
if (!_removableDrivesPath) {
_removableDrivesPath = [NSMutableDictionary dictionary];
_rootDict[kUTMViewStateRemovableDrivesPathKey] = _removableDrivesPath;
}
}
return self;
}

@end
4 changes: 2 additions & 2 deletions Configuration/QEMUConstant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ enum QEMUFileShareMode: String, CaseIterable, QEMUConstant {
var prettyValue: String {
switch self {
case .none: return NSLocalizedString("None", comment: "UTMQemuConstants")
case .webdav: return NSLocalizedString("SPICE WebDAV (Legacy)", comment: "UTMQemuConstants")
case .virtfs: return NSLocalizedString("VirtFS (Recommended)", comment: "UTMQemuConstants")
case .webdav: return NSLocalizedString("SPICE WebDAV", comment: "UTMQemuConstants")
case .virtfs: return NSLocalizedString("VirtFS", comment: "UTMQemuConstants")
}
}
}
Expand Down
Loading

0 comments on commit 217826e

Please sign in to comment.