feat: notifications
This commit is contained in:
@@ -138,7 +138,7 @@ const NSPasteboardType dragReorder = @"de.relikd.baRSS.drag-reorder";
|
||||
if (selection.count > 0)
|
||||
[self.dataStore setSelectionIndexPaths:[selection sortedArrayUsingSelector:@selector(compare:)]];
|
||||
|
||||
[UpdateScheduler downloadList:feedsList userInitiated:YES finally:^{
|
||||
[UpdateScheduler downloadList:feedsList userInitiated:YES notifications:NO finally:^{
|
||||
[self endCoreDataChangeUndoEmpty:NO forceUndo:NO];
|
||||
for (Feed *f in feedsList)
|
||||
[moc refreshObject:f.group mergeChanges:NO]; // fixes blank icon if imported with no inet conn
|
||||
|
||||
@@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface SettingsGeneral : NSViewController
|
||||
- (void)clickHowToDefaults:(NSButton *)sender;
|
||||
- (void)changeHttpApplication:(NSPopUpButton *)sender;
|
||||
- (void)changeNotificationType:(NSPopUpButton *)sender;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#import "StoreCoordinator.h"
|
||||
#import "Constants.h"
|
||||
#import "SettingsGeneralView.h"
|
||||
#import "NotifyEndpoint.h"
|
||||
|
||||
@interface SettingsGeneral()
|
||||
@property (strong) IBOutlet SettingsGeneralView *view; // override
|
||||
@@ -28,6 +29,23 @@
|
||||
defaultApp.lastItem.representedObject = bundleID;
|
||||
}
|
||||
[defaultApp selectItemAtIndex:[defaultApp indexOfItemWithRepresentedObject:UserPrefsString(Pref_defaultHttpApplication)]];
|
||||
|
||||
// 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”"),
|
||||
]];
|
||||
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())]];
|
||||
}
|
||||
|
||||
/// Get human readable application name such as 'Safari' or 'baRSS'
|
||||
@@ -65,4 +83,9 @@
|
||||
UserPrefsSet(Pref_defaultHttpApplication, sender.selectedItem.representedObject);
|
||||
}
|
||||
|
||||
- (void)changeNotificationType:(NSPopUpButton *)sender {
|
||||
UserPrefsSet(Pref_notificationType, sender.selectedItem.representedObject);
|
||||
[NotifyEndpoint activate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface SettingsGeneralView : NSView
|
||||
@property (strong) IBOutlet NSTextField *defaultReader;
|
||||
@property (strong) IBOutlet NSPopUpButton* popupHttpApplication;
|
||||
@property (strong) IBOutlet NSPopUpButton* popupNotificationType;
|
||||
|
||||
- (instancetype)initWithController:(SettingsGeneral*)controller NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
|
||||
|
||||
@@ -6,15 +6,23 @@
|
||||
|
||||
- (instancetype)initWithController:(SettingsGeneral*)controller {
|
||||
self = [super initWithFrame:NSMakeRect(0, 0, 320, 327)];
|
||||
|
||||
// Change default feed reader application
|
||||
NSTextField *l1 = [[NSView label:NSLocalizedString(@"Default feed reader:", nil)] placeIn:self x:PAD_WIN yTop:PAD_WIN + 3];
|
||||
NSButton *help = [[[NSView helpButton] action:@selector(clickHowToDefaults:) target:controller] placeIn:self xRight:PAD_WIN yTop:PAD_WIN];
|
||||
self.defaultReader = [[[[NSView label:@""] bold] placeIn:self x:NSMaxX(l1.frame) + PAD_S yTop:PAD_WIN + 3] sizeToRight:NSWidth(help.frame) + PAD_WIN];
|
||||
|
||||
// Popup button 'Open URLs with:'
|
||||
CGFloat y = YFromTop(help) + PAD_M;
|
||||
NSTextField *l2 = [[NSView label:NSLocalizedString(@"Open URLs with:", nil)] placeIn:self x:PAD_WIN yTop:y + 1];
|
||||
self.popupHttpApplication = [[[[NSView popupButton:0] placeIn:self x:NSMaxX(l2.frame) + PAD_S yTop:y] sizeToRight:PAD_WIN]
|
||||
action:@selector(changeHttpApplication:) target:controller];
|
||||
|
||||
// Notification type
|
||||
y = YFromTop(self.popupHttpApplication) + PAD_M;
|
||||
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];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user