From b6978662fcca8a98373743cbab989069e8fcb402 Mon Sep 17 00:00:00 2001 From: relikd Date: Sun, 26 Oct 2025 20:34:19 +0100 Subject: [PATCH] feat: notifications help string --- baRSS/Helper/UserPrefs.m | 2 +- .../Preferences/General Tab/SettingsGeneral.m | 29 ++++++++++++++----- .../General Tab/SettingsGeneralView.h | 1 + .../General Tab/SettingsGeneralView.m | 6 ++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/baRSS/Helper/UserPrefs.m b/baRSS/Helper/UserPrefs.m index b580c41..4f75ae1 100644 --- a/baRSS/Helper/UserPrefs.m +++ b/baRSS/Helper/UserPrefs.m @@ -57,9 +57,9 @@ NotificationType UserPrefsNotificationType(void) { /// Convert enum type to storable string NSString* NotificationTypeToString(NotificationType typ) { switch (typ) { + case NotificationTypeDisabled: return nil; case NotificationTypePerArticle: return @"article"; case NotificationTypePerFeed: return @"feed"; case NotificationTypeGlobal: return @"global"; - default: return nil; } } diff --git a/baRSS/Preferences/General Tab/SettingsGeneral.m b/baRSS/Preferences/General Tab/SettingsGeneral.m index 5603df2..8c524a4 100644 --- a/baRSS/Preferences/General Tab/SettingsGeneral.m +++ b/baRSS/Preferences/General Tab/SettingsGeneral.m @@ -33,19 +33,19 @@ // Notification settings (disabled, per article, per feed, total) NSPopUpButton *notify = self.view.popupNotificationType; [notify removeAllItems]; - [notify addItemWithTitle:NSLocalizedString(@"Disabled", @"Disable notifications")]; - notify.lastItem.representedObject = @""; [notify addItemsWithTitles:@[ - NSLocalizedString(@"Disabled", @"Disable notifications"), - NSLocalizedString(@"Article title (per article)", @"Show article title in notification"), - NSLocalizedString(@"Number of articles (per feed)", @"Show “feed X: N new articles”"), - NSLocalizedString(@"Generic “new articles” (over all)", @"Show total “N new article”"), + NSLocalizedString(@"Disabled", @"No notifications"), + NSLocalizedString(@"Per Article", nil), + NSLocalizedString(@"Per Feed", nil), + NSLocalizedString(@"Global “X unread articles”", nil), ]]; notify.itemArray[0].representedObject = NotificationTypeToString(NotificationTypeDisabled); notify.itemArray[1].representedObject = NotificationTypeToString(NotificationTypePerArticle); notify.itemArray[2].representedObject = NotificationTypeToString(NotificationTypePerFeed); notify.itemArray[3].representedObject = NotificationTypeToString(NotificationTypeGlobal); - [notify selectItemAtIndex:[notify indexOfItemWithRepresentedObject:NotificationTypeToString(UserPrefsNotificationType())]]; + NotificationType savedType = UserPrefsNotificationType(); + [notify selectItemAtIndex:[notify indexOfItemWithRepresentedObject:NotificationTypeToString(savedType)]]; + self.view.notificationHelp.stringValue = [self notificationHelpString:savedType]; } /// Get human readable application name such as 'Safari' or 'baRSS' @@ -85,7 +85,22 @@ - (void)changeNotificationType:(NSPopUpButton *)sender { UserPrefsSet(Pref_notificationType, sender.selectedItem.representedObject); + self.view.notificationHelp.stringValue = [self notificationHelpString:UserPrefsNotificationType()]; [NotifyEndpoint activate]; } +/// Help string explaining the different notification settings (for the current configuration) +- (NSString*)notificationHelpString:(NotificationType)typ { + switch (typ) { + case NotificationTypeDisabled: + return NSLocalizedString(@"Notifications are disabled. You will not get any notifications even if you enable them in System Settings.", nil); + case NotificationTypePerArticle: + return NSLocalizedString(@"You will get a notification for each article (“Article Title: Article Content”). A click on the notification banner opens the article link and marks the item as read.", nil); + case NotificationTypePerFeed: + return NSLocalizedString(@"You will get a notification for each feed whenever one or more new articles are published (“Feed Title: X unread articles”). A click on the notification banner will open all unread articles of that feed.", nil); + case NotificationTypeGlobal: + return NSLocalizedString(@"You will get a single notification for all feeds combined (“baRSS: X unread articles”). A click on the notification banner will open all unread articles of all feeds.", nil); + } +} + @end diff --git a/baRSS/Preferences/General Tab/SettingsGeneralView.h b/baRSS/Preferences/General Tab/SettingsGeneralView.h index fb35fd0..d69920c 100644 --- a/baRSS/Preferences/General Tab/SettingsGeneralView.h +++ b/baRSS/Preferences/General Tab/SettingsGeneralView.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN @property (strong) IBOutlet NSTextField *defaultReader; @property (strong) IBOutlet NSPopUpButton* popupHttpApplication; @property (strong) IBOutlet NSPopUpButton* popupNotificationType; +@property (strong) IBOutlet NSTextField* notificationHelp; - (instancetype)initWithController:(SettingsGeneral*)controller NS_DESIGNATED_INITIALIZER; - (instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE; diff --git a/baRSS/Preferences/General Tab/SettingsGeneralView.m b/baRSS/Preferences/General Tab/SettingsGeneralView.m index 48d36c4..738994e 100644 --- a/baRSS/Preferences/General Tab/SettingsGeneralView.m +++ b/baRSS/Preferences/General Tab/SettingsGeneralView.m @@ -23,6 +23,12 @@ NSTextField *l3 = [[NSView label:NSLocalizedString(@"Notifications:", nil)] placeIn:self x:PAD_WIN yTop:y + 1]; self.popupNotificationType = [[[[NSView popupButton:0] placeIn:self x:NSMaxX(l3.frame) + PAD_S yTop:y] sizeToRight:PAD_WIN] action:@selector(changeNotificationType:) target:controller]; + + // Notification help text + y = YFromTop(self.popupNotificationType) + PAD_M; + self.notificationHelp = [[[[[NSView label:@""] gray] + multiline:NSMakeSize(320 - 2*PAD_WIN, HEIGHT_LABEL * 5)] + placeIn:self x:PAD_WIN yTop:y] sizeToRight:PAD_WIN]; return self; }