Skip to content

Commit

Permalink
feat: option to use Alt to activate service
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrcy committed Nov 18, 2024
1 parent efc6680 commit b6eb290
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 22 deletions.
40 changes: 21 additions & 19 deletions src/components/settings/settings/EditSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -624,25 +624,25 @@ class EditSettingsForm extends Component<IProps, IState> {
<Select field={form.$('predefinedTodoServer')} />
{form.$('predefinedTodoServer').value ===
'isUsingCustomTodoService' && (
<div>
<Input
placeholder="Todo Server"
onChange={e => this.submit(e)}
{...form.$('customTodoServer').bind()}
/>
<p
className="settings__message"
style={{
borderTop: 0,
marginTop: 0,
paddingTop: 0,
marginBottom: '2rem',
}}
>
{intl.formatMessage(messages.todoServerInfo)}
</p>
</div>
)}
<div>
<Input
placeholder="Todo Server"
onChange={e => this.submit(e)}
{...form.$('customTodoServer').bind()}
/>
<p
className="settings__message"
style={{
borderTop: 0,
marginTop: 0,
paddingTop: 0,
marginBottom: '2rem',
}}
>
{intl.formatMessage(messages.todoServerInfo)}
</p>
</div>
)}
</div>
)}
{isTodosActivated && <Hr />}
Expand Down Expand Up @@ -1235,6 +1235,8 @@ class EditSettingsForm extends Component<IProps, IState> {
onChange={e => this.submit(e)}
{...form.$('shortcutActivatePreviousService').bind()}
/>

<Toggle {...form.$('activateServiceUsesAlt').bind()} />
</div>
</div>
)}
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,5 @@ export const DEFAULT_SERVICE_SETTINGS = {
export const DEFAULT_SHORTCUTS = {
activateNextService: 'Ctrl+tab',
activatePreviousService: `Ctrl+${shiftKey()}+tab`,
activateServiceUsesAlt: false,
};
12 changes: 11 additions & 1 deletion src/containers/settings/EditSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ const messages = defineMessages({
},
});

interface EditSettingsScreenProps extends StoresProps, WrappedComponentProps {}
interface EditSettingsScreenProps extends StoresProps, WrappedComponentProps { }

interface EditSettingsScreenState {
lockedPassword: string;
Expand Down Expand Up @@ -509,6 +509,7 @@ class EditSettingsScreen extends Component<
const newShortcuts = {
activateNextService: settingsData.shortcutActivateNextService,
activatePreviousService: settingsData.shortcutActivatePreviousService,
activateServiceUsesAlt: Boolean(settingsData.activateServiceUsesAlt),
};

const requiredRestartKeys = [
Expand Down Expand Up @@ -1342,6 +1343,15 @@ class EditSettingsScreen extends Component<
default: DEFAULT_SHORTCUTS.activatePreviousService,
placeholder: DEFAULT_SHORTCUTS.activatePreviousService,
},
activateServiceUsesAlt: {
label: intl.formatMessage(menuItems.activateServiceUsesAlt),
value: ifUndefined<boolean>(
settings.all.shortcuts.activateServiceUsesAlt,
DEFAULT_SHORTCUTS.activateServiceUsesAlt,
),
default: DEFAULT_SHORTCUTS.activateServiceUsesAlt,
type: 'checkbox',
},
},
};

Expand Down
10 changes: 8 additions & 2 deletions src/lib/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ export const menuItems = defineMessages({
id: 'menu.services.activatePreviousService',
defaultMessage: 'Activate previous service',
},
activateServiceUsesAlt: {
id: 'menu.services.activateServiceUsesAlt',
defaultMessage: 'Use Alt key to activate service',
},
muteApp: {
id: 'sidebar.muteApp',
defaultMessage: 'Disable notifications & audio',
Expand Down Expand Up @@ -746,7 +750,7 @@ class FranzMenu implements StoresProps {
if (locked) {
const touchIdEnabled = isMac
? this.stores.settings.app.useTouchIdToUnlock &&
systemPreferences.canPromptTouchID()
systemPreferences.canPromptTouchID()
: false;

(tpl[0].submenu as MenuItemConstructorOptions[]).unshift(
Expand Down Expand Up @@ -1145,7 +1149,9 @@ class FranzMenu implements StoresProps {
label: this._getServiceName(service),
accelerator: acceleratorString({
index: i + 1,
keyCombo: cmdOrCtrlShortcutKey(),
keyCombo: this.stores.settings.shortcuts.activateServiceUsesAlt
? altKey()
: cmdOrCtrlShortcutKey(),
prefix: '',
suffix: '',
}),
Expand Down

0 comments on commit b6eb290

Please sign in to comment.