mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-17 07:39:27 +00:00
Work in progress on drop-down filter selection
This commit is contained in:
@@ -70,8 +70,8 @@
|
|||||||
<outlet property="delegate" destination="-2" id="Y78-7K-e9c"/>
|
<outlet property="delegate" destination="-2" id="Y78-7K-e9c"/>
|
||||||
</connections>
|
</connections>
|
||||||
</searchField>
|
</searchField>
|
||||||
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9ZN-yB-Aiq">
|
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="9ZN-yB-Aiq">
|
||||||
<rect key="frame" x="57" y="6" width="100" height="17"/>
|
<rect key="frame" x="57" y="6" width="24" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<popUpButtonCell key="cell" type="roundRect" bezelStyle="roundedRect" alignment="center" controlSize="small" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oir-UN-bNS">
|
<popUpButtonCell key="cell" type="roundRect" bezelStyle="roundedRect" alignment="center" controlSize="small" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oir-UN-bNS">
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
@@ -86,7 +86,10 @@
|
|||||||
<constraint firstAttribute="centerY" secondItem="61" secondAttribute="centerY" id="69"/>
|
<constraint firstAttribute="centerY" secondItem="61" secondAttribute="centerY" id="69"/>
|
||||||
<constraint firstItem="61" firstAttribute="leading" secondItem="80" secondAttribute="trailing" constant="8" symbolic="YES" id="83"/>
|
<constraint firstItem="61" firstAttribute="leading" secondItem="80" secondAttribute="trailing" constant="8" symbolic="YES" id="83"/>
|
||||||
<constraint firstAttribute="centerY" secondItem="80" secondAttribute="centerY" id="86"/>
|
<constraint firstAttribute="centerY" secondItem="80" secondAttribute="centerY" id="86"/>
|
||||||
|
<constraint firstAttribute="centerY" secondItem="9ZN-yB-Aiq" secondAttribute="centerY" id="4wF-MI-Az7"/>
|
||||||
|
<constraint firstItem="80" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="9ZN-yB-Aiq" secondAttribute="trailing" constant="8" symbolic="YES" id="O7v-9o-6vB"/>
|
||||||
<constraint firstAttribute="centerY" secondItem="6" secondAttribute="centerY" id="OTP-Xc-T5f"/>
|
<constraint firstAttribute="centerY" secondItem="6" secondAttribute="centerY" id="OTP-Xc-T5f"/>
|
||||||
|
<constraint firstItem="9ZN-yB-Aiq" firstAttribute="leading" secondItem="6" secondAttribute="trailing" constant="8" symbolic="YES" id="xah-WD-k5q"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</customView>
|
</customView>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
|||||||
@@ -13,12 +13,15 @@
|
|||||||
|
|
||||||
#import "NSButton+HNHTextColor.h"
|
#import "NSButton+HNHTextColor.h"
|
||||||
|
|
||||||
|
NSUInteger const MPContextBarViewControllerActiveFilterMenuItemTag = 1000;
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, MPContextTab) {
|
typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||||
MPContextTabFilter,
|
MPContextTabFilter,
|
||||||
MPContextTabTrash,
|
MPContextTabTrash,
|
||||||
MPContextTabHistory
|
MPContextTabHistory
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@interface MPContextBarViewController () {
|
@interface MPContextBarViewController () {
|
||||||
@private
|
@private
|
||||||
BOOL _delegateRespondsToDidChangeFilter;
|
BOOL _delegateRespondsToDidChangeFilter;
|
||||||
@@ -233,6 +236,11 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
|||||||
- (NSMenu *)_allocFilterMenu {
|
- (NSMenu *)_allocFilterMenu {
|
||||||
NSMenu *searchMenu = [[NSMenu alloc] init];
|
NSMenu *searchMenu = [[NSMenu alloc] init];
|
||||||
|
|
||||||
|
NSMenuItem *activeFilterItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SEARCH_IN", "") action:NULL keyEquivalent:@""];
|
||||||
|
[activeFilterItem setTag:MPContextBarViewControllerActiveFilterMenuItemTag];
|
||||||
|
[searchMenu addItem:activeFilterItem];
|
||||||
|
[searchMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
NSArray *titles = @[NSLocalizedString(@"TITLE", ""),
|
NSArray *titles = @[NSLocalizedString(@"TITLE", ""),
|
||||||
NSLocalizedString(@"PASSWORD", ""),
|
NSLocalizedString(@"PASSWORD", ""),
|
||||||
NSLocalizedString(@"URL", ""),
|
NSLocalizedString(@"URL", ""),
|
||||||
@@ -251,7 +259,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
|||||||
}
|
}
|
||||||
[searchMenu addItem:[NSMenuItem separatorItem]];
|
[searchMenu addItem:[NSMenuItem separatorItem]];
|
||||||
/* Special Search */
|
/* Special Search */
|
||||||
NSMenuItem *doublePasswordsItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"", "") action:NULL keyEquivalent:@""];
|
NSMenuItem *doublePasswordsItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DUPLICTE_PASSWORDS", "") action:NULL keyEquivalent:@""];
|
||||||
[doublePasswordsItem setTag:MPFilterDoublePasswords];
|
[doublePasswordsItem setTag:MPFilterDoublePasswords];
|
||||||
|
|
||||||
[searchMenu addItem:doublePasswordsItem];
|
[searchMenu addItem:doublePasswordsItem];
|
||||||
@@ -264,9 +272,21 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
|||||||
NSArray *allItems = [menu itemArray];
|
NSArray *allItems = [menu itemArray];
|
||||||
NSArray *enabledItems = [self _filterItemsForMode:self.filterMode];
|
NSArray *enabledItems = [self _filterItemsForMode:self.filterMode];
|
||||||
for(NSMenuItem *item in allItems) {
|
for(NSMenuItem *item in allItems) {
|
||||||
BOOL isEnabeld = [enabledItems containsObject:item];
|
BOOL isSelected = [enabledItems containsObject:item];
|
||||||
[item setEnabled:isEnabeld];
|
[item setState:(isSelected ? NSOnState : NSOffState)];
|
||||||
}
|
}
|
||||||
|
NSMenuItem *activeFilterItem = [menu itemWithTag:MPContextBarViewControllerActiveFilterMenuItemTag];
|
||||||
|
__block NSMutableString *activeFilterTitle;
|
||||||
|
[enabledItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
if(activeFilterTitle == nil) {
|
||||||
|
activeFilterTitle = [[NSMutableString alloc] initWithString:[obj title]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[activeFilterTitle appendFormat:@", %@", [obj title]];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[activeFilterItem setTitle:activeFilterTitle];
|
||||||
|
[self.filterTypePopupButton selectItem:activeFilterItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)_filterItemsForMode:(MPFilterMode)mode {
|
- (NSArray *)_filterItemsForMode:(MPFilterMode)mode {
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user