mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 08:12:28 +00:00
Searchbar should work better with wrong selections
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
||||
@@ -82,6 +82,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) {
|
||||
[specialMenu addItemWithTitle:NSLocalizedString(@"SELECT_FILTER_WITH_DOTS", "") action:NULL keyEquivalent:@""];
|
||||
[[specialMenu itemAtIndex:0] setEnabled:NO];
|
||||
[[specialMenu itemAtIndex:0] setTag:MPEntrySearchNone];
|
||||
[[specialMenu itemAtIndex:0] setAction:@selector(toggleSearchFlags:)];
|
||||
for(NSInteger iIndex = 0; iIndex < [titles count]; iIndex++) {
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:titles[iIndex] action:@selector(toggleSearchFlags:) keyEquivalent:@""];
|
||||
[item setTag:specialTags[iIndex]];
|
||||
|
||||
@@ -70,7 +70,6 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
|
||||
}
|
||||
|
||||
- (void)toggleSearchFlags:(id)sender {
|
||||
static MPEntrySearchFlags oldFlags;
|
||||
if(![sender respondsToSelector:@selector(tag)]) {
|
||||
return; // We need to read the button tag
|
||||
}
|
||||
@@ -79,23 +78,21 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
|
||||
}
|
||||
MPEntrySearchFlags toggleFlag = [sender tag];
|
||||
MPEntrySearchFlags newFlags = MPEntrySearchNone;
|
||||
BOOL isDoublePasswordFlag = (toggleFlag == MPEntrySearchDoublePasswords);
|
||||
BOOL isExpiredFlag = (toggleFlag == MPEntrySearchExpiredEntries);
|
||||
BOOL isSingleFlag = toggleFlag & MPEntrySearchSingleFlags;
|
||||
NSButton *button = sender;
|
||||
switch([button state]) {
|
||||
case NSOffState:
|
||||
toggleFlag ^= MPEntrySearchAllFlags;
|
||||
newFlags = isDoublePasswordFlag ? oldFlags : (self.searchContext.searchFlags & toggleFlag);
|
||||
toggleFlag ^= MPEntrySearchAllCombineableFlags;
|
||||
newFlags = isSingleFlag ? MPEntrySearchNone : (self.searchContext.searchFlags & toggleFlag);
|
||||
break;
|
||||
case NSOnState:
|
||||
if(isDoublePasswordFlag || isExpiredFlag ) {
|
||||
oldFlags = self.searchContext.searchFlags;
|
||||
newFlags = toggleFlag;//MPEntrySearchDoublePasswords;
|
||||
if(isSingleFlag ) {
|
||||
newFlags = toggleFlag; // This has to be either expired or double passwords
|
||||
}
|
||||
else {
|
||||
/* always mask the double passwords in case another button was pressed */
|
||||
self.searchContext.searchFlags &= ((MPEntrySearchDoublePasswords | MPEntrySearchExpiredEntries) ^ MPEntrySearchAllFlags);
|
||||
newFlags = self.searchContext.searchFlags | toggleFlag;
|
||||
newFlags &= (MPEntrySearchSingleFlags ^ MPEntrySearchAllFlags);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -9,29 +9,30 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, MPEntrySearchFlags) {
|
||||
MPEntrySearchNone = 0,
|
||||
MPEntrySearchUrls = (1<<0),
|
||||
MPEntrySearchUsernames = (1<<1),
|
||||
MPEntrySearchTitles = (1<<2),
|
||||
MPEntrySearchPasswords = (1<<3),
|
||||
MPEntrySearchNotes = (1<<4),
|
||||
MPEntrySearchAllAttributes = (1<<5),
|
||||
MPEntrySearchNone = 0,
|
||||
MPEntrySearchUrls = (1<<0),
|
||||
MPEntrySearchUsernames = (1<<1),
|
||||
MPEntrySearchTitles = (1<<2),
|
||||
MPEntrySearchPasswords = (1<<3),
|
||||
MPEntrySearchNotes = (1<<4),
|
||||
MPEntrySearchAllAttributes = (1<<5),
|
||||
/* The following two flags should be used like enums.
|
||||
They are not intented to be used in conjunktion with any other flag */
|
||||
MPEntrySearchDoublePasswords = (1<<6),
|
||||
MPEntrySearchExpiredEntries = (1<<7),
|
||||
/* All search flags that are combineable combined */
|
||||
MPEntrySearchAllFlags = (MPEntrySearchDoublePasswords |
|
||||
MPEntrySearchExpiredEntries |
|
||||
MPEntrySearchNotes |
|
||||
MPEntrySearchPasswords |
|
||||
MPEntrySearchTitles |
|
||||
MPEntrySearchUrls |
|
||||
MPEntrySearchUsernames |
|
||||
MPEntrySearchAllAttributes )
|
||||
MPEntrySearchDoublePasswords = (1<<6),
|
||||
MPEntrySearchExpiredEntries = (1<<7),
|
||||
/* All combinebale search flags combined */
|
||||
MPEntrySearchAllCombineableFlags = (MPEntrySearchDoublePasswords |
|
||||
MPEntrySearchExpiredEntries |
|
||||
MPEntrySearchNotes |
|
||||
MPEntrySearchPasswords |
|
||||
MPEntrySearchTitles |
|
||||
MPEntrySearchUrls |
|
||||
MPEntrySearchUsernames |
|
||||
MPEntrySearchAllAttributes),
|
||||
MPEntrySearchSingleFlags = (MPEntrySearchDoublePasswords | MPEntrySearchExpiredEntries),
|
||||
MPEntrySearchAllFlags = (MPEntrySearchAllCombineableFlags | MPEntrySearchSingleFlags )
|
||||
};
|
||||
|
||||
|
||||
/* Wrap serach criteria to be able to store them */
|
||||
@interface MPEntrySearchContext : NSObject <NSSecureCoding,NSCopying>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user