mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +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"/>
|
||||
</connections>
|
||||
</searchField>
|
||||
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9ZN-yB-Aiq">
|
||||
<rect key="frame" x="57" y="6" width="100" height="17"/>
|
||||
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="9ZN-yB-Aiq">
|
||||
<rect key="frame" x="57" y="6" width="24" height="17"/>
|
||||
<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">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@@ -86,7 +86,10 @@
|
||||
<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 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 firstItem="9ZN-yB-Aiq" firstAttribute="leading" secondItem="6" secondAttribute="trailing" constant="8" symbolic="YES" id="xah-WD-k5q"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
</subviews>
|
||||
|
||||
@@ -13,12 +13,15 @@
|
||||
|
||||
#import "NSButton+HNHTextColor.h"
|
||||
|
||||
NSUInteger const MPContextBarViewControllerActiveFilterMenuItemTag = 1000;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
MPContextTabFilter,
|
||||
MPContextTabTrash,
|
||||
MPContextTabHistory
|
||||
};
|
||||
|
||||
|
||||
@interface MPContextBarViewController () {
|
||||
@private
|
||||
BOOL _delegateRespondsToDidChangeFilter;
|
||||
@@ -232,6 +235,11 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
|
||||
- (NSMenu *)_allocFilterMenu {
|
||||
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", ""),
|
||||
NSLocalizedString(@"PASSWORD", ""),
|
||||
@@ -251,7 +259,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
}
|
||||
[searchMenu addItem:[NSMenuItem separatorItem]];
|
||||
/* 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];
|
||||
|
||||
[searchMenu addItem:doublePasswordsItem];
|
||||
@@ -264,9 +272,21 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
NSArray *allItems = [menu itemArray];
|
||||
NSArray *enabledItems = [self _filterItemsForMode:self.filterMode];
|
||||
for(NSMenuItem *item in allItems) {
|
||||
BOOL isEnabeld = [enabledItems containsObject:item];
|
||||
[item setEnabled:isEnabeld];
|
||||
BOOL isSelected = [enabledItems containsObject:item];
|
||||
[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 {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user