Refactoring Status Menu

This commit is contained in:
relikd
2019-02-10 19:39:51 +01:00
parent cd0a1a3fd7
commit f2cca57fbb
39 changed files with 1491 additions and 1254 deletions

View File

@@ -29,8 +29,6 @@
#import "Statistics.h"
#import "NSDate+Ext.h"
#import <QuartzCore/QuartzCore.h>
#pragma mark - ModalEditDialog -
@@ -106,7 +104,7 @@
self.url.objectValue = fg.feed.meta.url;
self.previousURL = self.url.stringValue;
self.warningIndicator.image = [fg.feed iconImage16];
[NSDate setInterval:fg.feed.meta.refresh forPopup:self.refreshUnit andField:self.refreshNum];
[NSDate setInterval:fg.feed.meta.refresh forPopup:self.refreshUnit andField:self.refreshNum animate:NO];
[self statsForCoreDataObject];
}
@@ -288,29 +286,7 @@
/// Callback method for @c Statistics @c +viewForRefreshInterval:articleCount:callback:
- (void)refreshIntervalButtonClicked:(NSButton *)sender {
NSInteger num = (sender.tag >> 3);
NSInteger unit = (sender.tag & 0x7);
if (self.refreshNum.integerValue != num) {
[self animateControlAttention:self.refreshNum];
self.refreshNum.integerValue = num;
}
if (self.refreshUnit.indexOfSelectedItem != unit) {
[self animateControlAttention:self.refreshUnit];
[self.refreshUnit selectItemAtIndex:unit];
}
}
/// Helper method to animate @c NSControl to draw user attention. View will be scalled up in a fraction of a second.
- (void)animateControlAttention:(NSView*)control {
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D tr = CATransform3DIdentity;
tr = CATransform3DTranslate(tr, NSMidX(control.bounds), NSMidY(control.bounds), 0);
tr = CATransform3DScale(tr, 1.1, 1.1, 1);
tr = CATransform3DTranslate(tr, -NSMidX(control.bounds), -NSMidY(control.bounds), 0);
scale.toValue = [NSValue valueWithCATransform3D:tr];
scale.duration = 0.15f;
scale.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[control.layer addAnimation:scale forKey:scale.keyPath];
[NSDate setInterval:(Interval)sender.tag forPopup:self.refreshUnit andField:self.refreshNum animate:YES];
}

View File

@@ -64,7 +64,7 @@
[sp beginSheetModalForWindow:window completionHandler:^(NSModalResponse result) {
if (result == NSModalResponseOK) {
BOOL flattened = ([self radioGroupSelection:radioView] == 1);
NSArray<FeedGroup*> *list = [StoreCoordinator sortedListOfRootObjectsInContext:moc];
NSArray<FeedGroup*> *list = [StoreCoordinator sortedFeedGroupsWithParent:nil inContext:moc];
NSXMLDocument *doc = [self xmlDocumentForFeeds:list hierarchical:!flattened];
NSData *xml = [doc XMLDataWithOptions:NSXMLNodePreserveAttributeOrder | NSXMLNodePrettyPrint];
NSError *error;
@@ -115,12 +115,12 @@
int32_t idx = 0;
if (select == 1) { // overwrite selected
for (FeedGroup *fg in [StoreCoordinator sortedListOfRootObjectsInContext:moc]) {
for (FeedGroup *fg in [StoreCoordinator sortedFeedGroupsWithParent:nil inContext:moc]) {
[moc deleteObject:fg]; // Not a batch delete request to support undo
}
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountReset object:@(0)];
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountReset object:@0];
} else {
idx = (int32_t)[StoreCoordinator numberRootItemsInContext:moc];
idx = (int32_t)[StoreCoordinator countRootItemsInContext:moc];
}
NSMutableArray<Feed*> *list = [NSMutableArray array];

View File

@@ -61,8 +61,8 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
self.dataStore.managedObjectContext.undoManager = self.undoManager;
// Register for notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateIcon:) name:kNotificationFeedUpdated object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateIcon:) name:kNotificationFeedIconUpdated object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedUpdated:) name:kNotificationFeedUpdated object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(feedUpdated:) name:kNotificationFeedIconUpdated object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInProgress:) name:kNotificationBackgroundUpdateInProgress object:nil];
}
@@ -132,8 +132,8 @@ static NSString *dragNodeType = @"baRSS-feed-drag";
#pragma mark - Notification callback methods
/// Callback method fired when feeds have been updated in the background.
- (void)updateIcon:(NSNotification*)notify {
/// Callback method fired when feed (or icon) has been updated in the background.
- (void)feedUpdated:(NSNotification*)notify {
NSManagedObjectID *oid = notify.object;
NSManagedObjectContext *moc = self.dataStore.managedObjectContext;
Feed *feed = [moc objectRegisteredForID:oid];

View File

@@ -178,6 +178,7 @@
<string key="keyEquivalent" base64-UTF8="YES">
CA
</string>
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</buttonCell>
<connections>
<action selector="remove:" target="-2" id="JeR-iq-Gjb"/>

View File

@@ -22,7 +22,7 @@
#import "SettingsGeneral.h"
#import "AppHook.h"
#import "BarMenu.h"
#import "BarStatusItem.h"
#import "UserPrefs.h"
#import "StoreCoordinator.h"
#import "Constants.h"
@@ -62,13 +62,13 @@
- (IBAction)fixCache:(NSButton *)sender {
NSUInteger deleted = [StoreCoordinator deleteUnreferenced];
[StoreCoordinator restoreFeedCountsAndIndexPaths];
[StoreCoordinator restoreFeedIndexPaths];
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountReset object:nil];
NSLog(@"Removed %lu unreferenced core data entries.", deleted);
}
- (IBAction)changeMenuBarIconSetting:(NSButton*)sender {
[[(AppHook*)NSApp barMenu] updateBarIcon];
[[(AppHook*)NSApp statusItem] updateBarIcon];
}
- (IBAction)changeHttpApplication:(NSPopUpButton *)sender {

View File

@@ -28,6 +28,7 @@
+ (NSString*)getHttpApplication;
+ (void)setHttpApplication:(NSString*)bundleID;
+ (void)openURLsWithPreferredBrowser:(NSArray<NSURL*>*)urls;
+ (NSUInteger)openFewLinksLimit; // Change with: 'defaults write de.relikd.baRSS openFewLinksLimit -int 10'
+ (NSUInteger)shortArticleNamesLimit; // Change with: 'defaults write de.relikd.baRSS shortArticleNamesLimit -int 50'

View File

@@ -21,6 +21,7 @@
// SOFTWARE.
#import "UserPrefs.h"
#import <Cocoa/Cocoa.h>
@implementation UserPrefs
@@ -54,6 +55,16 @@
[[NSUserDefaults standardUserDefaults] setObject:bundleID forKey:@"defaultHttpApplication"];
}
/**
Open web links in default browser or a browser the user selected in the preferences.
@param urls A list of @c NSURL objects that will be opened immediatelly in bulk.
*/
+ (void)openURLsWithPreferredBrowser:(NSArray<NSURL*>*)urls {
if (urls.count == 0) return;
[[NSWorkspace sharedWorkspace] openURLs:urls withAppBundleIdentifier:[self getHttpApplication] options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifiers:nil];
}
#pragma mark - Hidden Plist Properties -
/// @return The limit on how many links should be opened at the same time, if user holds the option key.