People: Add an About panel and a menu bar visibility toggle that persists across reloads

This commit is contained in:
David Richardson committed 2026-11-25 15:55:10 -06:00
1 parent 229808dc7d
commit 4467e0a663
4 files changed
+56 -8

No files matched your search

@@ -51,7 +51,7 @@
[SettingsWindowController applySavedAppearance];
[self _buildMainMenu];
[CPMenu setMenuBarVisible:YES];
[MainWindowController applySavedMenuBarVisibility];
_mainWindowController = [[MainWindowController alloc] initWithLibrary:_library];
[_mainWindowController showWindow:self];
@@ -96,6 +96,15 @@
var commandOption = CPCommandKeyMask | CPAlternateKeyMask;
/*
The application menu, named after the application. About People opens the standard
About panel, which takes the name, version and copyright from Info.plist.
*/
var applicationMenu = [self _addSubmenu:@"People" to:mainMenu];
[self _addItem:@"About People" action:@selector(orderFrontStandardAboutPanel:) key:nil modifiers:0 to:applicationMenu];
[applicationMenu addItem:[CPMenuItem separatorItem]];
[self _addItem:@"Settings…" action:@selector(showSettings:) key:@"," modifiers:0 to:applicationMenu];
// File
var fileMenu = [self _addSubmenu:@"File" to:mainMenu];
[self _addItem:@"New Smart Folder…" action:@selector(newSmartFolder:) key:@"n" modifiers:commandOption to:fileMenu];
@@ -107,8 +116,6 @@
[self _addItem:@"Delete Group or Smart Folder" action:@selector(deleteSelectedSourceItem:) key:nil modifiers:0 to:fileMenu];
[fileMenu addItem:[CPMenuItem separatorItem]];
[self _addItem:@"Reset Application…" action:@selector(resetApplication:) key:nil modifiers:0 to:fileMenu];
[fileMenu addItem:[CPMenuItem separatorItem]];
[self _addItem:@"Settings…" action:@selector(showSettings:) key:@"," modifiers:0 to:fileMenu];
// Edit
var editMenu = [self _addSubmenu:@"Edit" to:mainMenu];
@@ -130,6 +137,7 @@
[viewMenu addItem:[CPMenuItem separatorItem]];
[self _addItem:@"Hide Toolbar" action:@selector(toggleToolbarShown:) key:@"t" modifiers:commandOption to:viewMenu];
[self _addItem:@"Customize Toolbar…" action:@selector(runToolbarCustomizationPalette:) key:nil modifiers:0 to:viewMenu];
[self _addItem:@"Hide Menu Bar" action:@selector(toggleMenuBar:) key:@"m" modifiers:CPCommandKeyMask | CPControlKeyMask to:viewMenu];
[viewMenu addItem:[CPMenuItem separatorItem]];
[self _addItem:@"Show All People" action:@selector(showAllPeople:) key:@"1" modifiers:0 to:viewMenu];
}
+6
View File
@@ -12,6 +12,12 @@
<string>AppController</string>
<key>CPBundleName</key>
<string>People</string>
<key>CPBundleShortVersionString</key>
<string>1.0</string>
<key>CPBundleVersion</key>
<string>1</string>
<key>CPHumanReadableCopyright</key>
<string>Copyright 2026, The Cappuccino Project.</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
@@ -15,6 +15,8 @@
* - CPPasteboard copy / paste
* - CPUndoManager: the window's undo manager undoes and redoes the removal of people, and
* the Edit menu names the change
* - CPMenu menu bar visibility: View ▸ Hide Menu Bar hides the main menu, and the window
* takes the space; the main menu's key equivalents still work
*/
@import <AppKit/AppKit.j>
@@ -36,7 +38,8 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
ToolbarAllPeopleIdentifier = @"ShowAllPeopleItem",
ToolbarItemImageSize = CGSizeMake(32.0, 32.0),
ResetAlertResetTag = 1001,
ResetAlertCancelTag = 1002;
ResetAlertCancelTag = 1002,
MenuBarHiddenKey = @"People.MenuBarHidden";
@implementation MainWindowController : CPWindowController
{
@@ -483,6 +486,27 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
[_splitViewController toggleDetail:sender];
}
/*
Shows the menu bar unless the user hid it in an earlier session. The application delegate
calls this at launch, before the main window opens.
*/
+ (void)applySavedMenuBarVisibility
{
[CPMenu setMenuBarVisible:![[CPUserDefaults standardUserDefaults] boolForKey:MenuBarHiddenKey]];
}
/*
Hides or shows the main menu, and keeps the choice. While the menu bar is hidden, the key
equivalents of its items still work, so ⌃⌘M shows it again.
*/
- (void)toggleMenuBar:(id)sender
{
var shouldHide = [CPMenu menuBarVisible];
[CPMenu setMenuBarVisible:!shouldHide];
[[CPUserDefaults standardUserDefaults] setBool:shouldHide forKey:MenuBarHiddenKey];
}
- (void)showAllPeople:(id)sender
{
[self _selectSourceItem:[_library allPeopleItem]];
@@ -497,7 +521,7 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
[alert setAlertStyle:CPWarningAlertStyle];
[alert setMessageText:@"Reset the application?"];
[alert setInformativeText:@"All people, groups and smart folders will be replaced by the sample data. The toolbar, the table columns, the sidebar, the detail pane, the recent searches and the appearance return to their defaults. This cannot be undone."];
[alert setInformativeText:@"All people, groups and smart folders will be replaced by the sample data. The menu bar, the toolbar, the table columns, the sidebar, the detail pane, the recent searches and the appearance return to their defaults. This cannot be undone."];
[alert addButtonWithTitle:@"Reset"];
[alert addButtonWithTitle:@"Cancel"];
@@ -544,6 +568,9 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
[_splitViewController restoreDefaultLayout];
[_peopleController restoreDefaultColumns];
[[CPUserDefaults standardUserDefaults] removeObjectForKey:MenuBarHiddenKey];
[CPMenu setMenuBarVisible:YES];
[SettingsWindowController resetAppearance];
}
@@ -609,6 +636,10 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
case @selector(toggleDetail:):
[anItem setTitle:[_splitViewController isDetailVisible] ? @"Hide Details" : @"Show Details"];
break;
case @selector(toggleMenuBar:):
[anItem setTitle:[CPMenu menuBarVisible] ? @"Hide Menu Bar" : @"Show Menu Bar"];
break;
}
return [self validateUserInterfaceItem:anItem];
+6 -3
View File
@@ -64,7 +64,7 @@ spaces, because the legacy toolchain does not accept them.
toolbar stays (autosave). While the sheet is open, the toolbar items do not act.
The standard Colors item opens the colour panel. In both appearances its labels, the boxes
around the preview and the swatches, and the opacity slider's track and knob show.
13. File ▸ Reset Application…: alert sheet, then sample data, default toolbar (items, Icon and Text, regular size), default table columns (order and widths, Notes first), sidebar width, detail pane, empty recent searches and Auto appearance restored at once, without a reload. Cancel changes nothing.
13. File ▸ Reset Application…: alert sheet, then sample data, the menu bar shown, default toolbar (items, Icon and Text, regular size), default table columns (order and widths, Notes first), sidebar width, detail pane, empty recent searches and Auto appearance restored at once, without a reload. Cancel changes nothing.
## Items to exercise
@@ -115,7 +115,10 @@ to build with a web component framework.
8. In edit mode, Hide Details is disabled everywhere: menu, toolbar and button bar.
9. The navigation button bar has a pop-up menu on its right side. When the menu bar is hidden,
it holds every main menu item that no other control offers.
10. An About dialog.
11. An action hides and shows the main menu. This shows both styles of application menu use.
10. An About dialog: People ▸ About People opens the standard About panel. Its name, version
and copyright come from Info.plist.
11. An action hides and shows the main menu: View ▸ Hide Menu Bar (⌃⌘M). The main window takes
the freed space at once, and ⌃⌘M shows the menu bar again. The choice survives a reload.
This shows both styles of application menu use.
12. A search field shows at the top of the navigation sidebar only while the toolbar is hidden.
An animated move between the two places is optional.