aboutsummaryrefslogtreecommitdiff
path: root/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m
diff options
context:
space:
mode:
Diffstat (limited to 'Liquid Glass Bezel/BBLiquidGlassBezelInterface.m')
-rw-r--r--Liquid Glass Bezel/BBLiquidGlassBezelInterface.m46
1 files changed, 44 insertions, 2 deletions
diff --git a/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m b/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m
index 335eacd..1df5f7e 100644
--- a/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m
+++ b/Liquid Glass Bezel/BBLiquidGlassBezelInterface.m
@@ -7,6 +7,13 @@
@implementation BBLiquidGlassBezelInterface
+- (void)dealloc {
+ // Remove KVO observers
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"QSLiquidGlassBezelApplyTint"];
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"QSAppearance1A"];
+ [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"QSAppearance1T"];
+}
+
- (id)init {
return [self initWithWindowNibName:@"BBLiquidGlassBezelInterface"];
}
@@ -42,17 +49,52 @@
[theCell setFont:[NSFont systemFontOfSize:11 weight:NSFontWeightLight]];
[theCell setCellRadiusFactor:32];
- [theCell setHighlightColor:[NSColor colorWithRed:1 green:1 blue:1 alpha:.15]];
- [theCell setTextColor:[NSColor textColor]];
+ BOOL shouldApplyTint = [[NSUserDefaults standardUserDefaults] boolForKey:@"QSLiquidGlassBezelApplyTint"];
+ NSColor *userHighlightColor = [[NSUserDefaults standardUserDefaults] colorForKey:@"QSAppearance1A"];
+ NSColor *userTextColor = shouldApplyTint ? [[NSUserDefaults standardUserDefaults] colorForKey:@"QSAppearance1T"] : [NSColor textColor];
+
+ [theCell setHighlightColor: userHighlightColor ? userHighlightColor : [NSColor colorWithRed:1 green:1 blue:1 alpha:.15]];
+ [theCell setTextColor: userTextColor ? userTextColor : [NSColor textColor]];
[theCell setShowDetails:NO];
[theCell setState:NSControlStateValueOn];
[theCell setIconSize:QSSize128];
[theCell setImagePosition:NSImageAbove];
+
+
}
+ // Add KVO observers for preference changes
+ [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"QSLiquidGlassBezelApplyTint" options:NSKeyValueObservingOptionNew context:nil];
+ [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"QSAppearance1A" options:NSKeyValueObservingOptionNew context:nil];
+ [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"QSAppearance1T" options:NSKeyValueObservingOptionNew context:nil];
+
[self contractWindow:nil];
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
+ [self updateColors];
+}
+
+- (void)updateColors {
+ NSArray *theControls = [NSArray arrayWithObjects:dSelector, aSelector, iSelector, nil];
+BOOL shouldApplyTint = [[NSUserDefaults standardUserDefaults] boolForKey:@"QSLiquidGlassBezelApplyTint"];
+NSColor *userHighlightColor = [[NSUserDefaults standardUserDefaults] colorForKey:@"QSAppearance1A"];
+NSColor *userTextColor = shouldApplyTint ? [[NSUserDefaults standardUserDefaults] colorForKey:@"QSAppearance1T"] : [NSColor textColor];
+ for(QSSearchObjectView *theControl in theControls) {
+ QSObjectCell *theCell = [theControl cell];
+ [theCell setHighlightColor: userHighlightColor ? userHighlightColor : [NSColor colorWithRed:1 green:1 blue:1 alpha:.15]];
+ [theCell setTextColor: userTextColor ? userTextColor : [NSColor textColor]];
+
+ @try {
+ [theCell setValue:@(NO) forKey:@"stylesLoaded"];
+ } @catch (NSException *exception) {
+ // We couldn't update. Ignore for now.p
+ }
+
+ [theControl setNeedsDisplay:YES];
+ }
+}
+
- (NSSize) maxIconSize {
return QSSize32;
}