mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Desktop: Fixes #1664: Disable certain menu items when no note or multiple notes are selected, and fixed menu item to set tag
This commit is contained in:
parent
035b9c6d1a
commit
6a031857ba
@ -239,6 +239,10 @@ class Application extends BaseApplication {
|
||||
Setting.setValue('sidebarVisibility', newState.sidebarVisibility);
|
||||
}
|
||||
|
||||
if (action.type.indexOf('NOTE_SELECT') === 0 || action.type.indexOf('FOLDER_SELECT') === 0) {
|
||||
this.updateMenuItemStates();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -618,20 +622,25 @@ class Application extends BaseApplication {
|
||||
|
||||
const rootMenus = {
|
||||
edit: {
|
||||
id: 'edit',
|
||||
label: _('&Edit'),
|
||||
submenu: [{
|
||||
id: 'edit:copy',
|
||||
label: _('Copy'),
|
||||
role: 'copy',
|
||||
accelerator: 'CommandOrControl+C',
|
||||
}, {
|
||||
id: 'edit:cut',
|
||||
label: _('Cut'),
|
||||
role: 'cut',
|
||||
accelerator: 'CommandOrControl+X',
|
||||
}, {
|
||||
id: 'edit:paste',
|
||||
label: _('Paste'),
|
||||
role: 'paste',
|
||||
accelerator: 'CommandOrControl+V',
|
||||
}, {
|
||||
id: 'edit:selectAll',
|
||||
label: _('Select all'),
|
||||
role: 'selectall',
|
||||
accelerator: 'CommandOrControl+A',
|
||||
@ -639,6 +648,7 @@ class Application extends BaseApplication {
|
||||
type: 'separator',
|
||||
screens: ['Main'],
|
||||
}, {
|
||||
id: 'edit:bold',
|
||||
label: _('Bold'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+B',
|
||||
@ -649,6 +659,7 @@ class Application extends BaseApplication {
|
||||
});
|
||||
},
|
||||
}, {
|
||||
id: 'edit:italic',
|
||||
label: _('Italic'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+I',
|
||||
@ -659,6 +670,7 @@ class Application extends BaseApplication {
|
||||
});
|
||||
},
|
||||
}, {
|
||||
id: 'edit:link',
|
||||
label: _('Link'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+K',
|
||||
@ -669,6 +681,7 @@ class Application extends BaseApplication {
|
||||
});
|
||||
},
|
||||
}, {
|
||||
id: 'edit:code',
|
||||
label: _('Code'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+`',
|
||||
@ -682,6 +695,7 @@ class Application extends BaseApplication {
|
||||
type: 'separator',
|
||||
screens: ['Main'],
|
||||
}, {
|
||||
id: 'edit:insertDateTime',
|
||||
label: _('Insert Date Time'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+Shift+T',
|
||||
@ -695,6 +709,7 @@ class Application extends BaseApplication {
|
||||
type: 'separator',
|
||||
screens: ['Main'],
|
||||
}, {
|
||||
id: 'edit:commandStartExternalEditing',
|
||||
label: _('Edit in external editor'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+E',
|
||||
@ -705,29 +720,36 @@ class Application extends BaseApplication {
|
||||
});
|
||||
},
|
||||
}, {
|
||||
id: 'edit:setTags',
|
||||
label: _('Tags'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+Alt+T',
|
||||
click: () => {
|
||||
const selectedNoteIds = this.store().getState().selectedNoteIds;
|
||||
if (selectedNoteIds.length !== 1) return;
|
||||
|
||||
this.dispatch({
|
||||
type: 'WINDOW_COMMAND',
|
||||
name: 'setTags',
|
||||
noteId: selectedNoteIds[0],
|
||||
});
|
||||
},
|
||||
}, {
|
||||
type: 'separator',
|
||||
screens: ['Main'],
|
||||
}, {
|
||||
id: 'edit:focusSearch',
|
||||
label: _('Search in all the notes'),
|
||||
screens: ['Main'],
|
||||
accelerator: shim.isMac() ? 'Shift+Command+F' : 'F6',
|
||||
click: () => {
|
||||
this.dispatch({
|
||||
type: 'WINDOW_COMMAND',
|
||||
name: 'focus_search',
|
||||
name: 'focusSearch',
|
||||
});
|
||||
},
|
||||
}, {
|
||||
id: 'edit:showLocalSearch',
|
||||
label: _('Search in current note'),
|
||||
screens: ['Main'],
|
||||
accelerator: 'CommandOrControl+F',
|
||||
@ -924,6 +946,19 @@ class Application extends BaseApplication {
|
||||
this.lastMenuScreen_ = screen;
|
||||
}
|
||||
|
||||
updateMenuItemStates() {
|
||||
if (!this.lastMenuScreen_) return;
|
||||
if (!this.store()) return;
|
||||
|
||||
const selectedNoteIds = this.store().getState().selectedNoteIds;
|
||||
|
||||
for (const itemId of ['copy', 'paste', 'cut', 'selectAll', 'bold', 'italic', 'link', 'code', 'insertDateTime', 'commandStartExternalEditing', 'setTags', 'showLocalSearch']) {
|
||||
const menuItem = Menu.getApplicationMenu().getMenuItemById('edit:' + itemId);
|
||||
if (!menuItem) continue;
|
||||
menuItem.enabled = selectedNoteIds.length === 1;
|
||||
}
|
||||
}
|
||||
|
||||
updateTray() {
|
||||
const app = bridge().electronApp();
|
||||
|
||||
@ -1092,6 +1127,8 @@ class Application extends BaseApplication {
|
||||
|
||||
RevisionService.instance().runInBackground();
|
||||
|
||||
this.updateMenuItemStates();
|
||||
|
||||
// Make it available to the console window - useful to call revisionService.collectRevisions()
|
||||
window.revisionService = RevisionService.instance();
|
||||
window.migrationService = MigrationService.instance();
|
||||
|
@ -96,7 +96,7 @@ class HeaderComponent extends React.Component {
|
||||
|
||||
let commandProcessed = true;
|
||||
|
||||
if (command.name === 'focus_search' && this.searchElement_) {
|
||||
if (command.name === 'focusSearch' && this.searchElement_) {
|
||||
this.searchElement_.focus();
|
||||
} else {
|
||||
commandProcessed = false;
|
||||
|
Loading…
Reference in New Issue
Block a user