MPToolbarDelegate now takes care of the toolbar manipulation.

Toolbar is shown when search is started if it was hidden. If search revealed the toolbar, it will be hidden after the search is exited
If the toolbar was using text only mode, it switches to icon/text mode and then back to text mode after the search - there might be a better way to deal with this by simply using a menu for the search.
This commit is contained in:
michael starke
2014-02-28 20:36:10 +01:00
parent 7f03985eff
commit 0c4ddf3127
3 changed files with 48 additions and 26 deletions

View File

@@ -33,7 +33,6 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
@private
id _firstResponder;
BOOL _saveAfterPasswordChange;
BOOL _didShowToolbarForSearch;
}
@property (strong) IBOutlet NSSplitView *splitView;
@@ -58,7 +57,6 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
if( self ) {
_firstResponder = nil;
_saveAfterPasswordChange = NO;
_didShowToolbarForSearch = NO;
_toolbarDelegate = [[MPToolbarDelegate alloc] init];
_outlineViewController = [[MPOutlineViewController alloc] init];
_entryViewController = [[MPEntryViewController alloc] init];
@@ -83,8 +81,6 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotifiation object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showEntries) name:MPDocumentDidUnlockDatabaseNotification object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didExitSearch:) name:MPDocumentDidExitSearchNotification object:document];
[_entryViewController regsiterNotificationsForDocument:document];
[_inspectorViewController regsiterNotificationsForDocument:document];
@@ -95,9 +91,10 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
_toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainWindowToolbar"];
[_toolbar setAutosavesConfiguration:YES];
[self.toolbar setAllowsUserCustomization:NO];
[self.toolbar setAllowsUserCustomization:YES];
[self.toolbar setDelegate:self.toolbarDelegate];
[self.window setToolbar:self.toolbar];
self.toolbarDelegate.toolbar = _toolbar;
[self.splitView setTranslatesAutoresizingMaskIntoConstraints:NO];
@@ -168,26 +165,6 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
[self showPasswordInput];
}
- (void)_didEnterSearch:(NSNotificationCenter *)notification {
/* Hide again after search ? */
NSWindow *window = [self window];
NSToolbar *toolbar = [window toolbar];
if(![toolbar isVisible]) {
_didShowToolbarForSearch = YES;
[toolbar setVisible:YES];
}
}
- (void)_didExitSearch:(NSNotification *)notification {
/* Hide again after search ? */
NSWindow *window = [self window];
NSToolbar *toolbar = [window toolbar];
if(_didShowToolbarForSearch && [toolbar isVisible]) {
_didShowToolbarForSearch = NO;
[toolbar setVisible:NO];
}
}
#pragma mark Actions
- (void)saveDocument:(id)sender {
_saveAfterPasswordChange = NO;