From f3f41f55e4e83ecbd18da6dcea3c69ebb2d1fc85 Mon Sep 17 00:00:00 2001 From: Mike Piatek-Jimenez Date: Fri, 7 Feb 2020 01:16:04 -0500 Subject: [PATCH] Add a reset graph contextual menu to the temperature graph. --- Data Miners/XRGTemperatureMiner.h | 1 + Data Miners/XRGTemperatureMiner.m | 7 +++++++ Graph Views/XRGTemperatureView.m | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/Data Miners/XRGTemperatureMiner.h b/Data Miners/XRGTemperatureMiner.h index 957c1a9..1e8728b 100644 --- a/Data Miners/XRGTemperatureMiner.h +++ b/Data Miners/XRGTemperatureMiner.h @@ -69,6 +69,7 @@ @property NSDate *fanCacheCreated; - (void)setDataSize:(int)newNumSamples; +- (void)reset; - (int)numberOfCPUs; - (void)setCurrentTemperatures; // Tries 3 different methods of gathering temperature statistics. diff --git a/Data Miners/XRGTemperatureMiner.m b/Data Miners/XRGTemperatureMiner.m index 29af793..4501383 100644 --- a/Data Miners/XRGTemperatureMiner.m +++ b/Data Miners/XRGTemperatureMiner.m @@ -58,6 +58,13 @@ - (instancetype)init { return self; } +- (void)reset { + int width = numSamples; + + [self setDataSize:0]; + [self setDataSize:width]; +} + - (int)numberOfCPUs { processor_cpu_load_info_t newCPUInfo; kern_return_t kr; diff --git a/Graph Views/XRGTemperatureView.m b/Graph Views/XRGTemperatureView.m index 46ee2ad..cdb9e34 100644 --- a/Graph Views/XRGTemperatureView.m +++ b/Graph Views/XRGTemperatureView.m @@ -392,12 +392,21 @@ - (NSMenu *)menuForEvent:(NSEvent *)theEvent { [myMenu addItem:[NSMenuItem separatorItem]]; + tMI = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset Graph" action:@selector(clearData:) keyEquivalent:@""]; + [myMenu addItem:tMI]; + + [myMenu addItem:[NSMenuItem separatorItem]]; + tMI = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"Open XRG Temperature Preferences..." action:@selector(openTemperaturePreferences:) keyEquivalent:@""]; [myMenu addItem:tMI]; return myMenu; } +- (void)clearData:(NSEvent *)theEvent { + [TemperatureMiner reset]; +} + - (void)emptyEvent:(NSEvent *)theEvent { }