mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
Searchbar should work better with wrong selections
This commit is contained in:
@@ -103,7 +103,7 @@
|
|||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aPQ-t2-bgz">
|
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aPQ-t2-bgz">
|
||||||
<rect key="frame" x="493" y="5" width="63" height="19"/>
|
<rect key="frame" x="491" y="5" width="65" height="19"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<popUpButtonCell key="cell" type="recessed" title="Item 1" bezelStyle="recessed" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="LRm-iZ-XrA" id="faz-pC-uGX">
|
<popUpButtonCell key="cell" type="recessed" title="Item 1" bezelStyle="recessed" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="LRm-iZ-XrA" id="faz-pC-uGX">
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
|||||||
[specialMenu addItemWithTitle:NSLocalizedString(@"SELECT_FILTER_WITH_DOTS", "") action:NULL keyEquivalent:@""];
|
[specialMenu addItemWithTitle:NSLocalizedString(@"SELECT_FILTER_WITH_DOTS", "") action:NULL keyEquivalent:@""];
|
||||||
[[specialMenu itemAtIndex:0] setEnabled:NO];
|
[[specialMenu itemAtIndex:0] setEnabled:NO];
|
||||||
[[specialMenu itemAtIndex:0] setTag:MPEntrySearchNone];
|
[[specialMenu itemAtIndex:0] setTag:MPEntrySearchNone];
|
||||||
|
[[specialMenu itemAtIndex:0] setAction:@selector(toggleSearchFlags:)];
|
||||||
for(NSInteger iIndex = 0; iIndex < [titles count]; iIndex++) {
|
for(NSInteger iIndex = 0; iIndex < [titles count]; iIndex++) {
|
||||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:titles[iIndex] action:@selector(toggleSearchFlags:) keyEquivalent:@""];
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:titles[iIndex] action:@selector(toggleSearchFlags:) keyEquivalent:@""];
|
||||||
[item setTag:specialTags[iIndex]];
|
[item setTag:specialTags[iIndex]];
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleSearchFlags:(id)sender {
|
- (void)toggleSearchFlags:(id)sender {
|
||||||
static MPEntrySearchFlags oldFlags;
|
|
||||||
if(![sender respondsToSelector:@selector(tag)]) {
|
if(![sender respondsToSelector:@selector(tag)]) {
|
||||||
return; // We need to read the button tag
|
return; // We need to read the button tag
|
||||||
}
|
}
|
||||||
@@ -79,23 +78,21 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
|
|||||||
}
|
}
|
||||||
MPEntrySearchFlags toggleFlag = [sender tag];
|
MPEntrySearchFlags toggleFlag = [sender tag];
|
||||||
MPEntrySearchFlags newFlags = MPEntrySearchNone;
|
MPEntrySearchFlags newFlags = MPEntrySearchNone;
|
||||||
BOOL isDoublePasswordFlag = (toggleFlag == MPEntrySearchDoublePasswords);
|
BOOL isSingleFlag = toggleFlag & MPEntrySearchSingleFlags;
|
||||||
BOOL isExpiredFlag = (toggleFlag == MPEntrySearchExpiredEntries);
|
|
||||||
NSButton *button = sender;
|
NSButton *button = sender;
|
||||||
switch([button state]) {
|
switch([button state]) {
|
||||||
case NSOffState:
|
case NSOffState:
|
||||||
toggleFlag ^= MPEntrySearchAllFlags;
|
toggleFlag ^= MPEntrySearchAllCombineableFlags;
|
||||||
newFlags = isDoublePasswordFlag ? oldFlags : (self.searchContext.searchFlags & toggleFlag);
|
newFlags = isSingleFlag ? MPEntrySearchNone : (self.searchContext.searchFlags & toggleFlag);
|
||||||
break;
|
break;
|
||||||
case NSOnState:
|
case NSOnState:
|
||||||
if(isDoublePasswordFlag || isExpiredFlag ) {
|
if(isSingleFlag ) {
|
||||||
oldFlags = self.searchContext.searchFlags;
|
newFlags = toggleFlag; // This has to be either expired or double passwords
|
||||||
newFlags = toggleFlag;//MPEntrySearchDoublePasswords;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* always mask the double passwords in case another button was pressed */
|
/* always mask the double passwords in case another button was pressed */
|
||||||
self.searchContext.searchFlags &= ((MPEntrySearchDoublePasswords | MPEntrySearchExpiredEntries) ^ MPEntrySearchAllFlags);
|
|
||||||
newFlags = self.searchContext.searchFlags | toggleFlag;
|
newFlags = self.searchContext.searchFlags | toggleFlag;
|
||||||
|
newFlags &= (MPEntrySearchSingleFlags ^ MPEntrySearchAllFlags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,29 +9,30 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
|
typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
|
||||||
MPEntrySearchNone = 0,
|
MPEntrySearchNone = 0,
|
||||||
MPEntrySearchUrls = (1<<0),
|
MPEntrySearchUrls = (1<<0),
|
||||||
MPEntrySearchUsernames = (1<<1),
|
MPEntrySearchUsernames = (1<<1),
|
||||||
MPEntrySearchTitles = (1<<2),
|
MPEntrySearchTitles = (1<<2),
|
||||||
MPEntrySearchPasswords = (1<<3),
|
MPEntrySearchPasswords = (1<<3),
|
||||||
MPEntrySearchNotes = (1<<4),
|
MPEntrySearchNotes = (1<<4),
|
||||||
MPEntrySearchAllAttributes = (1<<5),
|
MPEntrySearchAllAttributes = (1<<5),
|
||||||
/* The following two flags should be used like enums.
|
/* The following two flags should be used like enums.
|
||||||
They are not intented to be used in conjunktion with any other flag */
|
They are not intented to be used in conjunktion with any other flag */
|
||||||
MPEntrySearchDoublePasswords = (1<<6),
|
MPEntrySearchDoublePasswords = (1<<6),
|
||||||
MPEntrySearchExpiredEntries = (1<<7),
|
MPEntrySearchExpiredEntries = (1<<7),
|
||||||
/* All search flags that are combineable combined */
|
/* All combinebale search flags combined */
|
||||||
MPEntrySearchAllFlags = (MPEntrySearchDoublePasswords |
|
MPEntrySearchAllCombineableFlags = (MPEntrySearchDoublePasswords |
|
||||||
MPEntrySearchExpiredEntries |
|
MPEntrySearchExpiredEntries |
|
||||||
MPEntrySearchNotes |
|
MPEntrySearchNotes |
|
||||||
MPEntrySearchPasswords |
|
MPEntrySearchPasswords |
|
||||||
MPEntrySearchTitles |
|
MPEntrySearchTitles |
|
||||||
MPEntrySearchUrls |
|
MPEntrySearchUrls |
|
||||||
MPEntrySearchUsernames |
|
MPEntrySearchUsernames |
|
||||||
MPEntrySearchAllAttributes )
|
MPEntrySearchAllAttributes),
|
||||||
|
MPEntrySearchSingleFlags = (MPEntrySearchDoublePasswords | MPEntrySearchExpiredEntries),
|
||||||
|
MPEntrySearchAllFlags = (MPEntrySearchAllCombineableFlags | MPEntrySearchSingleFlags )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Wrap serach criteria to be able to store them */
|
/* Wrap serach criteria to be able to store them */
|
||||||
@interface MPEntrySearchContext : NSObject <NSSecureCoding,NSCopying>
|
@interface MPEntrySearchContext : NSObject <NSSecureCoding,NSCopying>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user