Skip to content

Commit

Permalink
Added a preference for hiding Non-ProMotion refresh rates
Browse files Browse the repository at this point in the history
  • Loading branch information
newmarcel committed Apr 16, 2022
1 parent af4b684 commit c744b8f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface DPLGeneralPreferencesViewController : DPLPreferencesContentViewController
@property (nonatomic, nullable) IBOutlet NSButton *showNonRetinaResolutionsCheckbox;
@property (nonatomic, nullable) IBOutlet NSButton *hideNonProMotionRefreshRatesCheckbox;
@property (nonatomic, nullable) IBOutlet SRRecorderControl *increaseRecorderControl;
@property (nonatomic, nullable) IBOutlet SRRecorderControl *decreaseRecorderControl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ - (void)configureBindings
{
self.defaultsController = [[NSUserDefaultsController alloc] initWithDefaults:DPLAppGroupGetUserDefaults() initialValues:nil];

Auto keyPath = [NSString stringWithFormat:@"values.%@", DPLNonRetinaDisplayModesEnabledDefaultsKey];
Auto retinaKeyPath = [NSString stringWithFormat:@"values.%@", DPLNonRetinaDisplayModesEnabledDefaultsKey];
[self.showNonRetinaResolutionsCheckbox bind:NSValueBinding
toObject:self.defaultsController
withKeyPath:keyPath
withKeyPath:retinaKeyPath
options:nil];
Auto proMotionKeyPath = [NSString stringWithFormat:@"values.%@", DPLHideNonProMotionRefreshRatesEnabledDefaultsKey];
[self.hideNonProMotionRefreshRatesCheckbox bind:NSValueBinding
toObject:self.defaultsController
withKeyPath:proMotionKeyPath
options:nil];

[self.increaseRecorderControl bind:NSValueBinding
toObject:self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<capability name="NSView safe area layout guides" minToolsVersion="12.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="DPLGeneralPreferencesViewController">
<connections>
<outlet property="decreaseRecorderControl" destination="dAF-gT-YKs" id="bx7-oC-J2Y"/>
<outlet property="hideNonProMotionRefreshRatesCheckbox" destination="sbt-xc-rcg" id="Iln-wE-zyw"/>
<outlet property="increaseRecorderControl" destination="Sjc-oR-y7z" id="Qh0-rl-Nz8"/>
<outlet property="showNonRetinaResolutionsCheckbox" destination="bMa-8y-ktg" id="aVO-PB-MBk"/>
<outlet property="view" destination="Daq-z8-Htp" id="Y2m-YN-0ga"/>
Expand All @@ -17,10 +19,10 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<view translatesAutoresizingMaskIntoConstraints="NO" id="Daq-z8-Htp">
<rect key="frame" x="0.0" y="0.0" width="450" height="406"/>
<rect key="frame" x="0.0" y="0.0" width="450" height="496"/>
<subviews>
<gridView xPlacement="fill" yPlacement="fill" rowAlignment="firstBaseline" rowSpacing="12" columnSpacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="i53-oP-FEP">
<rect key="frame" x="85" y="212" width="281" height="98"/>
<rect key="frame" x="85" y="322" width="281" height="98"/>
<rows>
<gridRow id="gvt-Mp-5Tf"/>
<gridRow id="Q23-VX-aET"/>
Expand Down Expand Up @@ -85,36 +87,36 @@
</gridCells>
</gridView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="E6N-DG-En9">
<rect key="frame" x="18" y="318" width="133" height="16"/>
<rect key="frame" x="18" y="428" width="133" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Keyboard Shortcuts" id="tWO-UC-goz">
<font key="font" textStyle="headline" name=".SFNS-Bold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="Hvd-ip-01E">
<rect key="frame" x="20" y="189" width="410" height="5"/>
<rect key="frame" x="20" y="299" width="410" height="5"/>
</box>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="XJU-MD-fgk">
<rect key="frame" x="18" y="133" width="414" height="14"/>
<rect key="frame" x="18" y="243" width="414" height="14"/>
<textFieldCell key="cell" selectable="YES" title="Filters the list of display resolutions to only contain Retina display resolutions." id="ykW-Rh-h2z">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bMa-8y-ktg">
<rect key="frame" x="18" y="154" width="412" height="18"/>
<rect key="frame" x="18" y="264" width="412" height="18"/>
<buttonCell key="cell" type="check" title="Show Non-Retina Display Resolutions" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="bKn-md-gjk">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="Tzp-VF-MKL">
<rect key="frame" x="20" y="110" width="410" height="5"/>
<rect key="frame" x="20" y="220" width="410" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aeP-5A-RBT">
<rect key="frame" x="190" y="13" width="247" height="32"/>
<rect key="frame" x="190" y="33" width="247" height="32"/>
<buttonCell key="cell" type="push" title="Save Current Display Configuration" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3qY-QY-aRJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -124,7 +126,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8dc-Nc-NBF">
<rect key="frame" x="13" y="65" width="191" height="32"/>
<rect key="frame" x="13" y="96" width="191" height="32"/>
<buttonCell key="cell" type="push" title="Notification Preferences…" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tny-eB-qCw">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -133,39 +135,66 @@
<action selector="openNotificationPreferences:" target="-2" id="cgT-x5-aLB"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="lHd-kI-rlq">
<rect key="frame" x="18" y="164" width="414" height="14"/>
<textFieldCell key="cell" selectable="YES" title="Filters the list of display resolutions to only show ProMotion refresh rates." id="lu8-R3-wBv">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sbt-xc-rcg">
<rect key="frame" x="18" y="185" width="412" height="18"/>
<buttonCell key="cell" type="check" title="Hide Non-ProMotion Refresh Rates" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Kfs-o0-b2Q">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="rFA-CU-qfa">
<rect key="frame" x="20" y="141" width="410" height="5"/>
</box>
</subviews>
<constraints>
<constraint firstItem="bMa-8y-ktg" firstAttribute="top" secondItem="Hvd-ip-01E" secondAttribute="bottom" constant="20" id="1sn-5V-mBv"/>
<constraint firstItem="Hvd-ip-01E" firstAttribute="leading" secondItem="Daq-z8-Htp" secondAttribute="leading" constant="20" symbolic="YES" id="4OV-OY-ydw"/>
<constraint firstItem="8dc-Nc-NBF" firstAttribute="top" secondItem="rFA-CU-qfa" secondAttribute="bottom" constant="20" id="5hd-A0-sj2"/>
<constraint firstItem="lHd-kI-rlq" firstAttribute="leading" secondItem="Cix-C3-8mG" secondAttribute="leading" id="7qO-Xv-bU5"/>
<constraint firstItem="aeP-5A-RBT" firstAttribute="trailing" secondItem="Cix-C3-8mG" secondAttribute="trailing" id="8EL-3X-G0Y"/>
<constraint firstItem="rFA-CU-qfa" firstAttribute="leading" secondItem="Daq-z8-Htp" secondAttribute="leading" constant="20" symbolic="YES" id="BUA-Vx-ae9"/>
<constraint firstItem="bMa-8y-ktg" firstAttribute="leading" secondItem="Cix-C3-8mG" secondAttribute="leading" id="Bh9-rm-bGN"/>
<constraint firstItem="sbt-xc-rcg" firstAttribute="trailing" secondItem="Cix-C3-8mG" secondAttribute="trailing" id="DJd-pi-gSd"/>
<constraint firstItem="lHd-kI-rlq" firstAttribute="trailing" secondItem="Cix-C3-8mG" secondAttribute="trailing" id="DKE-9Z-k7K"/>
<constraint firstItem="XJU-MD-fgk" firstAttribute="leading" secondItem="Cix-C3-8mG" secondAttribute="leading" id="DlJ-fe-C4G"/>
<constraint firstItem="i53-oP-FEP" firstAttribute="top" secondItem="E6N-DG-En9" secondAttribute="bottom" constant="8" symbolic="YES" id="EJV-wc-sHc"/>
<constraint firstItem="Tzp-VF-MKL" firstAttribute="top" secondItem="XJU-MD-fgk" secondAttribute="bottom" constant="20" id="Khv-vU-eik"/>
<constraint firstItem="XJU-MD-fgk" firstAttribute="top" secondItem="bMa-8y-ktg" secondAttribute="bottom" constant="8" symbolic="YES" id="LRf-8p-tcp"/>
<constraint firstItem="lHd-kI-rlq" firstAttribute="top" secondItem="sbt-xc-rcg" secondAttribute="bottom" constant="8" symbolic="YES" id="MIM-lV-coI"/>
<constraint firstItem="E6N-DG-En9" firstAttribute="top" secondItem="Cix-C3-8mG" secondAttribute="top" id="MgO-YX-u74"/>
<constraint firstItem="i53-oP-FEP" firstAttribute="centerX" secondItem="Daq-z8-Htp" secondAttribute="centerX" id="OWa-Jr-MJa"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="leading" relation="lessThanOrEqual" secondItem="aeP-5A-RBT" secondAttribute="leading" id="Q1Y-40-qtS"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="8dc-Nc-NBF" secondAttribute="trailing" id="Q56-eA-SH7"/>
<constraint firstAttribute="trailing" secondItem="rFA-CU-qfa" secondAttribute="trailing" constant="20" symbolic="YES" id="RoV-I3-lla"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="XJU-MD-fgk" secondAttribute="bottom" id="SDA-20-kZJ"/>
<constraint firstItem="Hvd-ip-01E" firstAttribute="top" secondItem="i53-oP-FEP" secondAttribute="bottom" constant="20" id="SSP-SO-qd8"/>
<constraint firstItem="Tzp-VF-MKL" firstAttribute="leading" secondItem="Daq-z8-Htp" secondAttribute="leading" constant="20" symbolic="YES" id="VAO-uh-yen"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="trailing" secondItem="bMa-8y-ktg" secondAttribute="trailing" id="Wef-r9-qhB"/>
<constraint firstItem="XJU-MD-fgk" firstAttribute="trailing" secondItem="Cix-C3-8mG" secondAttribute="trailing" id="WlV-W0-WDx"/>
<constraint firstItem="8dc-Nc-NBF" firstAttribute="top" secondItem="Tzp-VF-MKL" secondAttribute="bottom" constant="20" id="Wlo-lt-aE0"/>
<constraint firstItem="8dc-Nc-NBF" firstAttribute="leading" secondItem="Cix-C3-8mG" secondAttribute="leading" id="XNT-o5-92K"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="bottom" secondItem="aeP-5A-RBT" secondAttribute="bottom" id="XUy-on-Njj"/>
<constraint firstItem="rFA-CU-qfa" firstAttribute="top" secondItem="lHd-kI-rlq" secondAttribute="bottom" constant="20" id="Z8O-Pi-TtQ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="E6N-DG-En9" secondAttribute="trailing" constant="20" symbolic="YES" id="bf8-i9-Pre"/>
<constraint firstAttribute="trailing" secondItem="Hvd-ip-01E" secondAttribute="trailing" constant="20" symbolic="YES" id="d4a-Jm-gIA"/>
<constraint firstItem="sbt-xc-rcg" firstAttribute="top" secondItem="Tzp-VF-MKL" secondAttribute="bottom" constant="20" id="df2-0U-c7M"/>
<constraint firstAttribute="trailing" secondItem="Tzp-VF-MKL" secondAttribute="trailing" constant="20" symbolic="YES" id="fmo-5W-CX3"/>
<constraint firstItem="sbt-xc-rcg" firstAttribute="leading" secondItem="Cix-C3-8mG" secondAttribute="leading" id="jMO-JW-2oQ"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="i53-oP-FEP" secondAttribute="trailing" id="jcI-B7-BXA"/>
<constraint firstItem="Cix-C3-8mG" firstAttribute="leading" relation="lessThanOrEqual" secondItem="i53-oP-FEP" secondAttribute="leading" id="jlW-4s-v6j"/>
<constraint firstItem="aeP-5A-RBT" firstAttribute="top" relation="greaterThanOrEqual" secondItem="8dc-Nc-NBF" secondAttribute="bottom" constant="20" id="qJp-fN-zJB"/>
<constraint firstItem="E6N-DG-En9" firstAttribute="leading" secondItem="Daq-z8-Htp" secondAttribute="leading" constant="20" symbolic="YES" id="saf-Yz-ncc"/>
</constraints>
<viewLayoutGuide key="safeArea" id="jMq-yQ-GzE"/>
<viewLayoutGuide key="layoutMargins" id="Cix-C3-8mG"/>
<point key="canvasLocation" x="1" y="162.5"/>
<point key="canvasLocation" x="1" y="207"/>
</view>
</objects>
</document>
9 changes: 7 additions & 2 deletions DisplaceKit/Sources/DisplaceKit/DPLDisplayMode.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ - (BOOL)isProMotionRefreshRate

- (NSString *)localizedName
{
Auto preferences = DPLPreferences.sharedPreferences;

Auto string = (NSMutableString *)[self.localizedNameWithoutAttributes mutableCopy];
if([DPLPreferences.sharedPreferences isNonRetinaDisplayModesEnabled] == YES)
if([preferences isNonRetinaDisplayModesEnabled] == YES)
{
Auto retinaAttributeTitle = NSLocalizedString(@"(Retina)", @"(Retina)");
if([self isRetinaResolution]) { [string appendFormat:@" %@", retinaAttributeTitle]; }
Expand All @@ -90,7 +92,10 @@ - (NSString *)localizedName
NSString *refreshRateTitle;
if([self isProMotionRefreshRate])
{
refreshRateTitle = NSLocalizedString(@"(ProMotion)", @"(ProMotion)");
if([preferences isHideNonProMotionRefreshRatesEnabled] == NO)
{
refreshRateTitle = NSLocalizedString(@"(ProMotion)", @"(ProMotion)");
}
}
else if(self.refreshRate > 0.0f)
{
Expand Down

0 comments on commit c744b8f

Please sign in to comment.