Skip to content

Commit 44120f7

Browse files
committed
Added settings UI for userSkipReapply setting
1 parent 322defe commit 44120f7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/components/SettingsWindow.jsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,39 @@ export default class SettingsWindow extends PureComponent {
861861
}
862862
}
863863

864+
getSkipRestoreMonitors = () => {
865+
try {
866+
if (this.state.monitors == undefined || Object.keys(this.state.monitors).length == 0) {
867+
return (<SettingsChild title={T.t("GENERIC_NO_COMPATIBLE_DISPLAYS")} />)
868+
} else {
869+
return Object.values(this.state.monitors).map((monitor, index) => {
870+
871+
return (
872+
<SettingsChild key={monitor.key} icon="E7F4" title={getMonitorName(monitor, this.state.names)} input={
873+
<div className="inputToggle-generic">
874+
<input onChange={(e) => { this.setSkipRestoreMonitor(e.target.checked, monitor) }} checked={(this.state.rawSettings?.userSkipReapply?.indexOf(monitor.hwid[1]) >= 0 ? true : false)} data-checked={(this.state.rawSettings?.userSkipReapply?.indexOf(monitor.hwid[1]) >= 0 ? true : false)} type="checkbox" />
875+
</div>
876+
} />
877+
)
878+
879+
})
880+
}
881+
} catch (e) {
882+
console.log(e)
883+
}
884+
}
885+
886+
setSkipRestoreMonitor = (value, monitor) => {
887+
const userSkipReapply = this.state.rawSettings?.userSkipReapply
888+
const index = this.state.rawSettings?.userSkipReapply?.indexOf(monitor.hwid[1])
889+
if(index >= 0 && !value) {
890+
userSkipReapply.splice(index, 1)
891+
} else if(index === -1 && value) {
892+
userSkipReapply.push(monitor.hwid[1])
893+
}
894+
this.setSetting("userSkipReapply", userSkipReapply)
895+
}
896+
864897

865898

866899

@@ -1081,6 +1114,10 @@ export default class SettingsWindow extends PureComponent {
10811114

10821115
<SettingsOption title={"Auto-apply brightness"} description={"If your monitor responds strangely after turning it off/or or disconnecting/connecting hardware, disabling this may help."} input={this.renderToggle("disableAutoApply", undefined, undefined, true)} />
10831116

1117+
<SettingsOption title={"Skip auto-apply to specific monitors"} description={"Disable auto-applying known brightness after all hardware/power events for specific monitors. This include the idle detection feature."} expandable={true}>
1118+
{this.getSkipRestoreMonitors()}
1119+
</SettingsOption>
1120+
10841121
<SettingsOption title={T.t("SETTINGS_GENERAL_RESET_TITLE")} description={T.t("SETTINGS_GENERAL_RESET_DESC")} input={<a className="button" onClick={window.resetSettings}>{T.t("SETTINGS_GENERAL_RESET_BUTTON")}</a>} />
10851122

10861123
</div>

0 commit comments

Comments
 (0)