mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 05:52:58 +00:00
Added cancel button to icon selection view
This commit is contained in:
@@ -125,11 +125,6 @@
|
|||||||
</CommandLineArgument>
|
</CommandLineArgument>
|
||||||
</CommandLineArguments>
|
</CommandLineArguments>
|
||||||
<AdditionalOptions>
|
<AdditionalOptions>
|
||||||
<AdditionalOption
|
|
||||||
key = "NSZombieEnabled"
|
|
||||||
value = "YES"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</AdditionalOption>
|
|
||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
|
|||||||
@@ -55,6 +55,17 @@
|
|||||||
<action selector="useDefault:" target="-2" id="129"/>
|
<action selector="useDefault:" target="-2" id="129"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
|
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="His-4A-hcY">
|
||||||
|
<rect key="frame" x="199" y="18" width="56" height="25"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1kM-cI-P1o">
|
||||||
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
</buttonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="cancel:" target="-2" id="cRO-8u-npC"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="57" firstAttribute="top" secondItem="1" secondAttribute="top" constant="10" id="88"/>
|
<constraint firstItem="57" firstAttribute="top" secondItem="1" secondAttribute="top" constant="10" id="88"/>
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ extern NSInteger const kMPDefaultIcon;
|
|||||||
* Is the selected Icon, kMPDefaultIcon if the default icons was selected
|
* Is the selected Icon, kMPDefaultIcon if the default icons was selected
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, assign) NSInteger selectedIcon;
|
@property (nonatomic, assign) NSInteger selectedIcon;
|
||||||
|
@property (nonatomic, assign) BOOL didCancel;
|
||||||
|
|
||||||
@property (weak) IBOutlet NSCollectionView *iconCollectionView;
|
@property (weak) IBOutlet NSCollectionView *iconCollectionView;
|
||||||
@property (weak) IBOutlet NSButton *imageButton;
|
@property (weak) IBOutlet NSButton *imageButton;
|
||||||
@property (weak) NSPopover *popover;
|
@property (weak) NSPopover *popover;
|
||||||
|
|
||||||
- (void)reset;
|
- (void)reset;
|
||||||
|
- (IBAction)cancel:(id)sender;
|
||||||
- (IBAction)useDefault:(id)sender;
|
- (IBAction)useDefault:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ NSInteger const kMPDefaultIcon = -1;
|
|||||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||||
if (self) {
|
if (self) {
|
||||||
|
_didCancel = NO;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -43,7 +44,13 @@ NSInteger const kMPDefaultIcon = -1;
|
|||||||
[self.popover performClose:self];
|
[self.popover performClose:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)cancel:(id)sender {
|
||||||
|
self.didCancel = YES;
|
||||||
|
[self.popover performClose:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)reset {
|
- (void)reset {
|
||||||
|
self.didCancel = NO;
|
||||||
self.selectedIcon = kMPDefaultIcon;
|
self.selectedIcon = kMPDefaultIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,19 +175,22 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
|
|
||||||
- (void)popoverDidClose:(NSNotification *)notification {
|
- (void)popoverDidClose:(NSNotification *)notification {
|
||||||
MPIconSelectViewController *viewController = (MPIconSelectViewController *)_popover.contentViewController;
|
MPIconSelectViewController *viewController = (MPIconSelectViewController *)_popover.contentViewController;
|
||||||
MPDocument *document = [[self windowController] document];
|
if(!viewController.didCancel) {
|
||||||
BOOL useDefault = (viewController.selectedIcon == -1);
|
|
||||||
switch (self.activeTab) {
|
MPDocument *document = [[self windowController] document];
|
||||||
case MPGroupTab:
|
BOOL useDefault = (viewController.selectedIcon == -1);
|
||||||
document.selectedGroup.iconId = useDefault ? [KPKGroup defaultIcon] : viewController.selectedIcon;
|
switch (self.activeTab) {
|
||||||
break;
|
case MPGroupTab:
|
||||||
|
document.selectedGroup.iconId = useDefault ? [KPKGroup defaultIcon] : viewController.selectedIcon;
|
||||||
case MPEntryTab:
|
break;
|
||||||
document.selectedEntry.iconId = useDefault ? [KPKEntry defaultIcon]: viewController.selectedIcon;
|
|
||||||
break;
|
case MPEntryTab:
|
||||||
|
document.selectedEntry.iconId = useDefault ? [KPKEntry defaultIcon]: viewController.selectedIcon;
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_popover = nil;
|
_popover = nil;
|
||||||
}
|
}
|
||||||
@@ -207,10 +210,10 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
[self.itemNameTextField setHidden:YES];
|
[self.itemNameTextField setHidden:YES];
|
||||||
[self.itemImageView unbind:NSValueBinding];
|
[self.itemImageView unbind:NSValueBinding];
|
||||||
[self.itemImageView setHidden:YES];
|
[self.itemImageView setHidden:YES];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.itemImageView bind:NSValueBinding toObject:item withKeyPath:@"iconImage" options:nil];
|
[self.itemImageView bind:NSValueBinding toObject:item withKeyPath:@"iconImage" options:nil];
|
||||||
|
|
||||||
if([item respondsToSelector:@selector(title)]) {
|
if([item respondsToSelector:@selector(title)]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user