summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-02-04 10:11:39 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-02-06 16:58:45 +0100
commit9cb69a364bb0f840bf4997969c07e8b2118d5dcc (patch)
tree6884860323530cc2481c36d50173b9d1d871b87b
parent662dcd175380e650bf7dfb06adf7f842a0e8cdce (diff)
downloadmullvadvpn-9cb69a364bb0f840bf4997969c07e8b2118d5dcc.tar.xz
mullvadvpn-9cb69a364bb0f840bf4997969c07e8b2118d5dcc.zip
Enable monochrome icons setting for all platforms
-rw-r--r--gui/src/main/index.ts7
-rw-r--r--gui/src/main/tray-icon-controller.ts22
-rw-r--r--gui/src/renderer/components/Preferences.tsx41
-rw-r--r--gui/src/renderer/containers/PreferencesPage.tsx1
4 files changed, 28 insertions, 43 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 6663a5574e..4df3b4c7a2 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -319,7 +319,7 @@ class ApplicationMain {
const trayIconController = new TrayIconController(
tray,
'unsecured',
- process.platform === 'darwin' && this.guiSettings.monochromaticIcon,
+ this.guiSettings.monochromaticIcon,
);
this.registerWindowListener(windowController);
@@ -330,10 +330,7 @@ class ApplicationMain {
this.trayIconController = trayIconController;
this.guiSettings.onChange = (newState, oldState) => {
- if (
- process.platform === 'darwin' &&
- oldState.monochromaticIcon !== newState.monochromaticIcon
- ) {
+ if (oldState.monochromaticIcon !== newState.monochromaticIcon) {
if (this.trayIconController) {
this.trayIconController.useMonochromaticIcon = newState.monochromaticIcon;
}
diff --git a/gui/src/main/tray-icon-controller.ts b/gui/src/main/tray-icon-controller.ts
index f4f3925f75..bb1d4f5868 100644
--- a/gui/src/main/tray-icon-controller.ts
+++ b/gui/src/main/tray-icon-controller.ts
@@ -58,23 +58,19 @@ export default class TrayIconController {
}
private loadImages() {
- const basePath = path.resolve(path.join(__dirname, '../../assets/images/menubar icons'));
const frames = Array.from({ length: 10 }, (_, i) => i + 1);
-
- const suffix = this.imageSuffix();
- const extension = process.platform === 'win32' ? 'ico' : 'png';
-
- this.iconImages = frames.map((frame) =>
- nativeImage.createFromPath(path.join(basePath, `lock-${frame}${suffix}.${extension}`)),
- );
+ this.iconImages = frames.map((frame) => nativeImage.createFromPath(this.getImagePath(frame)));
}
- private imageSuffix() {
- if (this.useMonochromaticIconValue && process.platform === 'darwin') {
- return 'Template';
- } else {
- return '';
+ private getImagePath(frame: number) {
+ const basePath = path.resolve(path.join(__dirname, '../../assets/images/menubar icons'));
+ const extension = process.platform === 'win32' ? 'ico' : 'png';
+ let suffix = '';
+ if (this.useMonochromaticIconValue) {
+ suffix = process.platform === 'darwin' ? 'Template' : '_white';
}
+
+ return path.join(basePath, process.platform, `lock-${frame}${suffix}.${extension}`);
}
private targetFrame(): number {
diff --git a/gui/src/renderer/components/Preferences.tsx b/gui/src/renderer/components/Preferences.tsx
index 715d51e40f..d2d1709abc 100644
--- a/gui/src/renderer/components/Preferences.tsx
+++ b/gui/src/renderer/components/Preferences.tsx
@@ -21,7 +21,6 @@ export interface IProps {
enableSystemNotifications: boolean;
monochromaticIcon: boolean;
startMinimized: boolean;
- enableMonochromaticIconToggle: boolean;
enableStartMinimizedToggle: boolean;
setAutoStart: (autoStart: boolean) => void;
setEnableSystemNotifications: (flag: boolean) => void;
@@ -120,29 +119,23 @@ export default class Preferences extends Component<IProps> {
</Cell.FooterText>
</Cell.Footer>
- {this.props.enableMonochromaticIconToggle ? (
- <React.Fragment>
- <Cell.Container>
- <Cell.Label>
- {messages.pgettext('preferences-view', 'Monochromatic tray icon')}
- </Cell.Label>
- <Cell.Switch
- isOn={this.props.monochromaticIcon}
- onChange={this.props.setMonochromaticIcon}
- />
- </Cell.Container>
- <Cell.Footer>
- <Cell.FooterText>
- {messages.pgettext(
- 'preferences-view',
- 'Use a monochromatic tray icon instead of a colored one.',
- )}
- </Cell.FooterText>
- </Cell.Footer>
- </React.Fragment>
- ) : (
- undefined
- )}
+ <Cell.Container>
+ <Cell.Label>
+ {messages.pgettext('preferences-view', 'Monochromatic tray icon')}
+ </Cell.Label>
+ <Cell.Switch
+ isOn={this.props.monochromaticIcon}
+ onChange={this.props.setMonochromaticIcon}
+ />
+ </Cell.Container>
+ <Cell.Footer>
+ <Cell.FooterText>
+ {messages.pgettext(
+ 'preferences-view',
+ 'Use a monochromatic tray icon instead of a colored one.',
+ )}
+ </Cell.FooterText>
+ </Cell.Footer>
{this.props.enableStartMinimizedToggle ? (
<React.Fragment>
diff --git a/gui/src/renderer/containers/PreferencesPage.tsx b/gui/src/renderer/containers/PreferencesPage.tsx
index 497da2166c..e1b674e0dd 100644
--- a/gui/src/renderer/containers/PreferencesPage.tsx
+++ b/gui/src/renderer/containers/PreferencesPage.tsx
@@ -44,7 +44,6 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext) => {
setMonochromaticIcon: (monochromaticIcon: boolean) => {
props.app.setMonochromaticIcon(monochromaticIcon);
},
- enableMonochromaticIconToggle: process.platform === 'darwin',
};
};