Accessibility description for images (#4149)

This commit is contained in:
A Cœur
2022-11-14 11:39:34 +08:00
committed by GitHub
parent 67e992ddf0
commit 855b782604
2 changed files with 39 additions and 17 deletions

View File

@@ -94,21 +94,30 @@ typedef NS_ENUM(unsigned int, tabTag) {
//https://github.com/transmission/transmission/issues/3486
[[window standardWindowButton:NSWindowZoomButton] setEnabled:NO];
//set tab tooltips
[self.fTabs.cell setToolTip:NSLocalizedString(@"General Info", "Inspector -> tab") forSegment:TAB_GENERAL_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Activity", "Inspector -> tab") forSegment:TAB_ACTIVITY_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Trackers", "Inspector -> tab") forSegment:TAB_TRACKERS_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Peers", "Inspector -> tab") forSegment:TAB_PEERS_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Files", "Inspector -> tab") forSegment:TAB_FILE_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Options", "Inspector -> tab") forSegment:TAB_OPTIONS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"info.circle" withFallback:@"InfoGeneral"] forSegment:TAB_GENERAL_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"square.grid.3x3.fill.square" withFallback:@"InfoActivity"] forSegment:TAB_ACTIVITY_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"antenna.radiowaves.left.and.right" withFallback:@"InfoTracker"]
forSegment:TAB_TRACKERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"person.2" withFallback:@"InfoPeers"] forSegment:TAB_PEERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"doc.on.doc" withFallback:@"InfoFiles"] forSegment:TAB_FILE_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"gearshape" withFallback:@"InfoOptions"] forSegment:TAB_OPTIONS_TAG];
//set tab images and tooltips
void (^setImageAndToolTipForSegment)(NSImage*, NSString*, NSInteger) = ^(NSImage* image, NSString* toolTip, NSInteger segment) {
image.accessibilityDescription = toolTip;
[self.fTabs setImage:image forSegment:segment];
[self.fTabs.cell setToolTip:toolTip forSegment:segment];
};
setImageAndToolTipForSegment(
[NSImage systemSymbol:@"info.circle" withFallback:@"InfoGeneral"],
NSLocalizedString(@"General Info", "Inspector -> tab"),
TAB_GENERAL_TAG);
setImageAndToolTipForSegment(
[NSImage systemSymbol:@"square.grid.3x3.fill.square" withFallback:@"InfoActivity"],
NSLocalizedString(@"Activity", "Inspector -> tab"),
TAB_ACTIVITY_TAG);
setImageAndToolTipForSegment(
[NSImage systemSymbol:@"antenna.radiowaves.left.and.right" withFallback:@"InfoTracker"],
NSLocalizedString(@"Trackers", "Inspector -> tab"),
TAB_TRACKERS_TAG);
setImageAndToolTipForSegment([NSImage systemSymbol:@"person.2" withFallback:@"InfoPeers"], NSLocalizedString(@"Peers", "Inspector -> tab"), TAB_PEERS_TAG);
setImageAndToolTipForSegment([NSImage systemSymbol:@"doc.on.doc" withFallback:@"InfoFiles"], NSLocalizedString(@"Files", "Inspector -> tab"), TAB_FILE_TAG);
setImageAndToolTipForSegment(
[NSImage systemSymbol:@"gearshape" withFallback:@"InfoOptions"],
NSLocalizedString(@"Options", "Inspector -> tab"),
TAB_OPTIONS_TAG);
//set selected tab
self.fCurrentTabTag = kInvalidTag;