Cleaner no high-contrast mode implementation

This commit is contained in:
Mr. Stallion 2021-12-29 14:21:00 -06:00
parent 1d4ad49faf
commit 0b2aca9cca
12 changed files with 38 additions and 28 deletions

View File

@ -4,7 +4,7 @@
* Fixed ad fields becoming uneditable after an ad is removed * Fixed ad fields becoming uneditable after an ad is removed
* Fixed ads attempting to send after leaving a channel * Fixed ads attempting to send after leaving a channel
* Linux users now get automatic updates * Linux users now get automatic updates
* Added configuration option to opt out from Windows High Contrast setting * Added configuration option to opt out from Windows high-contrast setting (Menu > F-Chat > Rising > Disable high-contrast mode)
## 1.16.0 ## 1.16.0
* Upgraded to Electron 14.x * Upgraded to Electron 14.x

View File

@ -199,13 +199,6 @@
</label> </label>
</div> </div>
<div class="form-group">
<label class="control-label" for="risingDisableWindowsHighContrast">
<input type="checkbox" id="risingDisableWindowsHighContrast" v-model="risingDisableWindowsHighContrast"/>
Disable high-contrast mode (Windows)
</label>
</div>
</div> </div>
<div v-show="selectedTab === '3'"> <div v-show="selectedTab === '3'">
<template v-if="hidden.length"> <template v-if="hidden.length">
@ -275,7 +268,6 @@
risingShowUnreadOfflineCount!: boolean; risingShowUnreadOfflineCount!: boolean;
risingColorblindMode!: boolean; risingColorblindMode!: boolean;
risingDisableWindowsHighContrast!: boolean;
async load(): Promise<void> { async load(): Promise<void> {
@ -313,7 +305,6 @@
this.risingShowUnreadOfflineCount = settings.risingShowUnreadOfflineCount; this.risingShowUnreadOfflineCount = settings.risingShowUnreadOfflineCount;
this.risingColorblindMode = settings.risingColorblindMode; this.risingColorblindMode = settings.risingColorblindMode;
this.risingDisableWindowsHighContrast = settings.risingDisableWindowsHighContrast;
} }
async doImport(): Promise<void> { async doImport(): Promise<void> {
@ -369,7 +360,6 @@
risingShowUnreadOfflineCount: this.risingShowUnreadOfflineCount, risingShowUnreadOfflineCount: this.risingShowUnreadOfflineCount,
risingColorblindMode: this.risingColorblindMode, risingColorblindMode: this.risingColorblindMode,
risingDisableWindowsHighContrast: this.risingDisableWindowsHighContrast
}; };
if(this.notifications) await core.notifications.requestPermission(); if(this.notifications) await core.notifications.requestPermission();
} }

View File

@ -54,7 +54,6 @@ export class Settings implements ISettings {
risingShowUnreadOfflineCount = true; risingShowUnreadOfflineCount = true;
risingColorblindMode = false; risingColorblindMode = false;
risingDisableWindowsHighContrast = false;
} }

View File

@ -221,7 +221,6 @@ export namespace Settings {
readonly risingShowUnreadOfflineCount: boolean; readonly risingShowUnreadOfflineCount: boolean;
readonly risingColorblindMode: boolean; readonly risingColorblindMode: boolean;
readonly risingDisableWindowsHighContrast: boolean;
} }
} }

View File

@ -490,7 +490,7 @@
return { return {
[`theme-${this.settings.theme}`]: true, [`theme-${this.settings.theme}`]: true,
colorblindMode: core.state.settings.risingColorblindMode, colorblindMode: core.state.settings.risingColorblindMode,
disableWindowsHighContrast: core.state.settings.risingDisableWindowsHighContrast disableWindowsHighContrast: core.state.generalSettings.risingDisableWindowsHighContrast
}; };
} catch(err) { } catch(err) {
return { [`theme-${this.settings.theme}`]: true }; return { [`theme-${this.settings.theme}`]: true };
@ -729,4 +729,8 @@
} }
} }
} }
.disableWindowsHighContrast, .disableWindowsHighContrast * {
forced-color-adjust: none;
}
</style> </style>

View File

@ -1,5 +1,5 @@
<template> <template>
<div style="display: flex;flex-direction:column;height:100%" :class="'platform-' + platform" @auxclick.prevent> <div style="display: flex;flex-direction:column;height:100%" :class="getThemeClass()" @auxclick.prevent>
<div v-html="styling"></div> <div v-html="styling"></div>
<div style="display:flex;align-items:stretch;border-bottom-width:1px" class="border-bottom" id="window-tabs"> <div style="display:flex;align-items:stretch;border-bottom-width:1px" class="border-bottom" id="window-tabs">
<h4 style="padding:2px 0">F-Chat</h4> <h4 style="padding:2px 0">F-Chat</h4>
@ -47,7 +47,8 @@
import l from '../chat/localize'; import l from '../chat/localize';
import {GeneralSettings} from './common'; import {GeneralSettings} from './common';
import { getSafeLanguages, updateSupportedLanguages } from './language'; import { getSafeLanguages, updateSupportedLanguages } from './language';
import log from 'electron-log'; // tslint:disable-line: match-default-export-name import log from 'electron-log';
import core from '../chat/core'; // tslint:disable-line: match-default-export-name
const browserWindow = remote.getCurrentWindow(); const browserWindow = remote.getCurrentWindow();
@ -378,6 +379,19 @@
openMenu(): void { openMenu(): void {
remote.Menu.getApplicationMenu()!.popup({}); remote.Menu.getApplicationMenu()!.popup({});
} }
getThemeClass() {
try {
return {
['platform-' + this.platform]: true,
disableWindowsHighContrast: core.state.generalSettings.risingDisableWindowsHighContrast
};
} catch (err) {
return {
['platform-' + this.platform]: true
};
}
}
} }
</script> </script>
@ -451,4 +465,8 @@
} }
} }
} }
.disableWindowsHighContrast, .disableWindowsHighContrast * {
forced-color-adjust: none;
}
</style> </style>

View File

@ -28,6 +28,7 @@ export class GeneralSettings {
hwAcceleration = true; hwAcceleration = true;
risingCacheExpiryDays = 30; risingCacheExpiryDays = 30;
risingSystemLogLevel: log.LevelOption = 'info'; risingSystemLogLevel: log.LevelOption = 'info';
risingDisableWindowsHighContrast = false;
} }
//tslint:disable //tslint:disable

View File

@ -519,6 +519,16 @@ function onReady(): void {
type: <'radio'>'radio' type: <'radio'>'radio'
} }
)) ))
},
{
visible: process.platform === 'win32',
label: 'Disable Windows high-contrast mode',
type: 'checkbox',
checked: settings.risingDisableWindowsHighContrast,
click: (item: electron.MenuItem) => {
settings.risingDisableWindowsHighContrast = item.checked;
setGeneralSettings(settings);
}
} }
] ]
}, },

View File

@ -4,6 +4,7 @@ export class Dialog {
static confirmDialog(message: string): boolean { static confirmDialog(message: string): boolean {
const result = remote.dialog.showMessageBoxSync({ const result = remote.dialog.showMessageBoxSync({
message, message,
title: 'F-Chat Rising',
type: 'question', type: 'question',
buttons: ['Yes', 'No'], buttons: ['Yes', 'No'],
defaultId: 1, defaultId: 1,

View File

@ -40,7 +40,3 @@
--#{$varName}: #{$value}; --#{$varName}: #{$value};
} }
} }
.disableWindowsHighContrast {
forced-colors-adjust: none !important;
}

View File

@ -41,11 +41,6 @@
} }
} }
.disableWindowsHighContrast {
forced-colors-adjust: none !important;
}
//@import "../../util/accecss"; //@import "../../util/accecss";
// //
//@include accecss( //@include accecss(

View File

@ -41,6 +41,3 @@
} }
} }
.disableWindowsHighContrast {
forced-colors-adjust: none !important;
}