Skip to content

Commit

Permalink
feat: option to use Alt+[0-9] to switch between services (#1972)
Browse files Browse the repository at this point in the history
closes #1971
  • Loading branch information
dxrcy authored Nov 29, 2024
1 parent 1951662 commit 57e41c5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/services/tabs/TabItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ class TabItem extends Component<IProps, IState> {
data-tooltip-id="tooltip-sidebar-button"
data-tooltip-content={`${service.name} ${acceleratorString({
index: shortcutIndex,
keyCombo: cmdOrCtrlShortcutKey(false),
keyCombo: this.props.stores!.settings.all.shortcuts
.activateServiceUsesAlt
? altKey()
: cmdOrCtrlShortcutKey(false),
})}`}
>
<img src={service.icon} className="tab-item__icon" alt="" />
Expand Down
2 changes: 2 additions & 0 deletions src/components/settings/settings/EditSettingsForm.tsx
Original file line number Diff line number Diff line change
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,
};
10 changes: 10 additions & 0 deletions src/containers/settings/EditSettingsScreen.tsx
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"menu.help.tos": "Terms of Service",
"menu.services": "Services",
"menu.services.activatePreviousService": "Activate previous service",
"menu.services.activateServiceUsesAlt": "Use Alt key to activate service",
"menu.services.addNewService": "Add New Service...",
"menu.services.copyToClipboard": "Copy to clipboard",
"menu.services.goHome": "Home",
Expand Down
8 changes: 7 additions & 1 deletion 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 @@ -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 57e41c5

Please sign in to comment.