Merge pull request #905 from jian10au/scaleslider

Zoom factor slider
pull/945/head
Vince 5 years ago committed by GitHub
commit 67e3846787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1474,6 +1474,10 @@
"Warning! Lowering the TTL could result in messages being lost if the recipient doesn't collect them in time!", "Warning! Lowering the TTL could result in messages being lost if the recipient doesn't collect them in time!",
"description": "Warning for the time to live setting" "description": "Warning for the time to live setting"
}, },
"zoomFactorSettingTitle": {
"message": "Zoom Factor",
"description": "Title of the Zoom Factor setting"
},
"notificationSettingsDialog": { "notificationSettingsDialog": {
"message": "When messages arrive, display notifications that reveal...", "message": "When messages arrive, display notifications that reveal...",
"description": "Explain the purpose of the notification settings" "description": "Explain the purpose of the notification settings"

@ -286,6 +286,9 @@
} }
first = false; first = false;
// Update zoom
window.updateZoomFactor();
const currentPoWDifficulty = storage.get('PoWDifficulty', null); const currentPoWDifficulty = storage.get('PoWDifficulty', null);
if (!currentPoWDifficulty) { if (!currentPoWDifficulty) {
storage.put('PoWDifficulty', window.getDefaultPoWDifficulty()); storage.put('PoWDifficulty', window.getDefaultPoWDifficulty());

@ -1026,6 +1026,7 @@ ipc.on('password-window-login', async (event, passPhrase) => {
const passwordAttempt = true; const passwordAttempt = true;
await showMainWindow(passPhrase, passwordAttempt); await showMainWindow(passPhrase, passwordAttempt);
sendResponse(); sendResponse();
if (passwordWindow) { if (passwordWindow) {
passwordWindow.close(); passwordWindow.close();
passwordWindow = null; passwordWindow = null;

@ -2,6 +2,8 @@
/* global window: false */ /* global window: false */
const path = require('path'); const path = require('path');
const electron = require('electron'); const electron = require('electron');
const { webFrame } = electron;
const semver = require('semver'); const semver = require('semver');
const { deferredToPromise } = require('./js/modules/deferred_to_promise'); const { deferredToPromise } = require('./js/modules/deferred_to_promise');
@ -85,6 +87,19 @@ window.wrapDeferred = deferredToPromise;
const ipc = electron.ipcRenderer; const ipc = electron.ipcRenderer;
const localeMessages = ipc.sendSync('locale-data'); const localeMessages = ipc.sendSync('locale-data');
window.updateZoomFactor = () => {
const zoomFactor = window.getSettingValue('zoom-factor-setting') || 100;
window.setZoomFactor(zoomFactor / 100);
};
window.setZoomFactor = number => {
webFrame.setZoomFactor(number);
};
window.getZoomFactor = () => {
webFrame.getZoomFactor();
};
window.setBadgeCount = count => ipc.send('set-badge-count', count); window.setBadgeCount = count => ipc.send('set-badge-count', count);
// Set the password for the database // Set the password for the database
@ -218,6 +233,10 @@ window.getSettingValue = (settingID, comparisonValue = null) => {
window.setSettingValue = (settingID, value) => { window.setSettingValue = (settingID, value) => {
window.storage.put(settingID, value); window.storage.put(settingID, value);
if (settingID === 'zoom-factor-setting') {
window.updateZoomFactor();
}
}; };
installGetter('device-name', 'getDeviceName'); installGetter('device-name', 'getDeviceName');

@ -40,7 +40,6 @@ export class SessionSettingListItem extends React.Component<Props, State> {
public render(): JSX.Element { public render(): JSX.Element {
const { title, description, type, value, content } = this.props; const { title, description, type, value, content } = this.props;
const inline = const inline =
!!type && !!type &&
![SessionSettingType.Options, SessionSettingType.Slider].includes(type); ![SessionSettingType.Options, SessionSettingType.Slider].includes(type);
@ -92,16 +91,17 @@ export class SessionSettingListItem extends React.Component<Props, State> {
<div className="slider-wrapper"> <div className="slider-wrapper">
<Slider <Slider
dots={true} dots={true}
step={6} step={content.step}
min={12} min={content.min}
max={96} max={content.max}
defaultValue={currentSliderValue} defaultValue={currentSliderValue}
onChange={sliderValue => { onChange={sliderValue => {
this.handleSlider(sliderValue); this.handleSlider(sliderValue);
}} }}
/> />
<div className="slider-info"> <div className="slider-info">
<p>{`${currentSliderValue} Hours`}</p> <p>{content.info(currentSliderValue)}</p>
</div> </div>
</div> </div>
)} )}

@ -231,6 +231,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
showLinkDeviceButton={!shouldRenderPasswordLock} showLinkDeviceButton={!shouldRenderPasswordLock}
category={category} category={category}
/> />
<div className="session-settings-view"> <div className="session-settings-view">
{shouldRenderPasswordLock ? ( {shouldRenderPasswordLock ? (
this.renderPasswordLock() this.renderPasswordLock()
@ -440,7 +441,32 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
comparisonValue: undefined, comparisonValue: undefined,
onClick: undefined, onClick: undefined,
content: { content: {
dotsEnabled: true,
step: 6,
min: 12,
max: 96,
defaultValue: 24, defaultValue: 24,
info: (value: number) => `${value} Hours`,
},
confirmationDialogParams: undefined,
},
{
id: 'zoom-factor-setting',
title: window.i18n('zoomFactorSettingTitle'),
description: undefined,
hidden: false,
type: SessionSettingType.Slider,
category: SessionSettingCategory.Appearance,
setFn: undefined,
comparisonValue: undefined,
onClick: undefined,
content: {
dotsEnabled: true,
step: 20,
min: 60,
max: 200,
defaultValue: 100,
info: (value: number) => `${value}%`,
}, },
confirmationDialogParams: undefined, confirmationDialogParams: undefined,
}, },

Loading…
Cancel
Save