Skip to content

Commit

Permalink
Enable HDR sliders per display in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Oct 8, 2024
1 parent 624dac6 commit c24eac6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/BrightnessPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ export default class BrightnessPanel extends PureComponent {
}
})
}

let showHDRSliders = false
if(window.settings?.hdrDisplays?.[monitor.key]) {
// Has HDR slider enabled
hasFeatures = true
showHDRSliders = true
}

const powerOff = () => {
window.ipc.send("sleep-display", monitor.hwid.join("#"))
monitor.features["0xD6"][0] = (monitor.features["0xD6"][0] >= 4 ? 1 : settings.ddcPowerOffValue)
Expand All @@ -101,7 +109,7 @@ export default class BrightnessPanel extends PureComponent {
}
}

if ((!useFeatures || !hasFeatures) && false) {
if (!useFeatures || !hasFeatures) {
return (
<div className="monitor-sliders" key={monitor.key}>
<Slider name={this.getMonitorName(monitor, this.state.names)} id={monitor.id} level={monitor.brightness} min={0} max={100} num={monitor.num} monitortype={monitor.type} hwid={monitor.key} key={monitor.key} onChange={this.handleChange} afterName={showPowerButton()} scrollAmount={window.settings?.scrollFlyoutAmount} />
Expand All @@ -122,7 +130,7 @@ export default class BrightnessPanel extends PureComponent {
<Slider id={monitor.id} level={monitor.brightness} min={0} max={100} num={monitor.num} monitortype={monitor.type} hwid={monitor.key} key={monitor.key} onChange={this.handleChange} scrollAmount={window.settings?.scrollFlyoutAmount} />
</div>
<DDCCISliders monitor={monitor} monitorFeatures={monitorFeatures} scrollAmount={window.settings?.scrollFlyoutAmount} />
<HDRSliders monitor={monitor} scrollAmount={window.settings?.scrollFlyoutAmount} />
{ showHDRSliders ? <HDRSliders monitor={monitor} scrollAmount={window.settings?.scrollFlyoutAmount} /> : null }
</div>
)
}
Expand Down
31 changes: 31 additions & 0 deletions src/components/SettingsWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,34 @@ export default class SettingsWindow extends PureComponent {
}
}

getHDRMonitors = () => {
try {
if (this.state.monitors == undefined || Object.keys(this.state.monitors).length == 0) {
return (<SettingsChild title={T.t("GENERIC_NO_COMPATIBLE_DISPLAYS")} />)
} else {
return Object.values(this.state.monitors).map((monitor, index) => {

return (
<SettingsChild key={monitor.key} icon="E7F4" title={getMonitorName(monitor, this.state.names)} input={
<div className="inputToggle-generic">
<input onChange={(e) => { this.setHDRMonitor(e.target.checked, monitor) }} checked={(this.state.rawSettings?.hdrDisplays?.[monitor.key] ? true : false)} data-checked={(this.state.rawSettings?.hdrDisplays?.[monitor.key] ? true : false)} type="checkbox" />
</div>
} />
)

})
}
} catch (e) {
console.log(e)
}
}

setHDRMonitor = (value, monitor) => {
const hdrDisplays = Object.assign({}, this.state.rawSettings?.hdrDisplays)
hdrDisplays[monitor.key] = value
this.setSetting("hdrDisplays", hdrDisplays)
}

getHideMonitors = () => {
try {
if (this.state.monitors == undefined || Object.keys(this.state.monitors).length == 0) {
Expand Down Expand Up @@ -1208,6 +1236,9 @@ export default class SettingsWindow extends PureComponent {
<option value="2000">{T.t("SETTINGS_MONITORS_RATE_4")}</option>
</select>
)} />
<SettingsOption title={T.t("SETTINGS_MONITORS_HDR_DISPLAYS_TITLE")} description={T.t("SETTINGS_MONITORS_HDR_DISPLAYS_DESC")} expandable={true}>
{this.getHDRMonitors()}
</SettingsOption>
<SettingsOption title={T.t("SETTINGS_MONITORS_HIDE_DISPLAYS_TITLE")} description={T.t("SETTINGS_MONITORS_HIDE_DISPLAYS_DESC")} expandable={true}>
{this.getHideMonitors()}
</SettingsOption>
Expand Down
1 change: 1 addition & 0 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ const defaultSettings = {
monitorFeatures: {},
monitorFeaturesSettings: {},
hideDisplays: {},
hdrDisplays: {},
checkForUpdates: !isDev,
dismissedUpdate: '',
language: "system",
Expand Down
2 changes: 2 additions & 0 deletions src/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
"SETTINGS_MONITORS_HIDE_INTERNAL_DESC": "When the lid is closed or the internal display has been disabled in Windows, hide the brightness slider in the panel.",
"SETTINGS_MONITORS_HIDE_DISPLAYS_TITLE": "Hide Displays",
"SETTINGS_MONITORS_HIDE_DISPLAYS_DESC": "If you would like to hide specific displays from the flyout, you can toggle them off here.",
"SETTINGS_MONITORS_HDR_DISPLAYS_TITLE": "Show HDR Settings",
"SETTINGS_MONITORS_HDR_DISPLAYS_DESC": "Enable HDR brightness sliders for specific monitors.",
"SETTINGS_FEATURES_DESCRIPTION": "Enable or disable specific DDC/CI features in the brightness panel. At least one feature must be enabled for your monitor to show up in the brightness panel. Not all displays support these features, such as laptop/tablet displays.",
"SETTINGS_FEATURES_UNSUPPORTED": "This monitor does not support DDC/CI features.",
"SETTINGS_FEATURES_CUR_BRIGHTNESS_TITLE": "Check Current Values",
Expand Down

0 comments on commit c24eac6

Please sign in to comment.