Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/restore tab menu item #1993

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions js/menuRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ module.exports = {
browserUI.duplicateTab(tabs.getSelected())
})

ipc.on('restoreTab', function (e) {
if (focusMode.enabled()) {
focusMode.warn()
return
}

var restoredTab = tasks.getSelected().tabHistory.pop()

// The tab history stack is empty
if (!restoredTab) {
return
}

browserUI.addTab(tabs.add(restoredTab), {
enterEditMode: false
})
})

ipc.on('addTab', function (e, data) {
/* new tabs can't be created in modal mode */
if (modalMode.enabled()) {
Expand Down
1 change: 1 addition & 0 deletions localization/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"appMenuDuplicateTab": "Duplicate Tab",
"appMenuNewPrivateTab": "New Private Tab",
"appMenuNewTask": "New Task",
"appMenuRestoreTab": "Restore closed tab",
"appMenuSavePageAs": "Save Page As",
"appMenuPrint": "Print",
"appMenuEdit": "Edit",
Expand Down
1 change: 1 addition & 0 deletions localization/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"appMenuNewPrivateTab": "Nouvel onglet de navigation privée",
"appMenuNewTask": "Nouvelle tâche",
"appMenuSavePageAs": "Enregistrer la page sous",
"appMenuRestoreTab": "Reuvrir l'onglet fermé",
"appMenuPrint": "Imprimer",
"appMenuEdit": "Editer",
"appMenuUndo": "Retour",
Expand Down
1 change: 1 addition & 0 deletions localization/languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"appMenuNewPrivateTab": "Nuova scheda privata",
"appMenuNewTask": "Nuovo task",
"appMenuSavePageAs": "Salva pagina con nome",
"appMenuRestoreTab": "Riapri scheda chiusa",
"appMenuPrint": "Stampa",
"appMenuEdit": "Modifica",
"appMenuUndo": "Annulla",
Expand Down
1 change: 1 addition & 0 deletions localization/languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"appMenuNewPrivateTab": "Nowa karta prywatna",
"appMenuNewTask": "Nowe zadanie",
"appMenuSavePageAs": "Zapisz stronę jako",
"appMenuRestoreTab": "Przywróć zamkniętą kartę",
"appMenuPrint": "Drukuj",
"appMenuEdit": "Edytuj",
"appMenuUndo": "Cofnij",
Expand Down
1 change: 1 addition & 0 deletions localization/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"appMenuNewPrivateTab": "Новая приватная вкладка",
"appMenuNewTask": "Новая задача",
"appMenuSavePageAs": "Сохранить страницу как...",
"appMenuRestoreTab": "Восстановить закрытую вкладку",
"appMenuPrint": "Печать",
"appMenuEdit": "Правка",
"appMenuUndo": "Отменить",
Expand Down
1 change: 1 addition & 0 deletions localization/languages/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"appMenuDuplicateTab": "Дублювати вкладку",
"appMenuNewPrivateTab": "Нова приватна вкладка",
"appMenuNewTask": "Нове завдання",
"appMenuRestoreTab": "Відновити закриту вкладку",
"appMenuSavePageAs": "Зберегти сторінку як",
"appMenuPrint": "Друк",
"appMenuEdit": "Редагувати",
Expand Down
18 changes: 17 additions & 1 deletion main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ function buildAppMenu (options = {}) {
}
]

var closedTabTaskActions = [
{
label: l('appMenuRestoreTab'),
accelerator: getFormattedKeyMapEntry('restoreTab') || 'shift+CmdOrCtrl+t',
click: function (item, window, event) {
if (!event.triggeredByAccelerator) {
sendIPCToWindow(window, 'restoreTab')
}
}
}
]

var personalDataItems = [
{
label: l('appMenuBookmarks'),
Expand Down Expand Up @@ -98,6 +110,8 @@ function buildAppMenu (options = {}) {
var template = [
...(options.secondary ? tabTaskActions : []),
...(options.secondary ? [{ type: 'separator' }] : []),
...(options.secondary ? closedTabTaskActions : []),
...(options.secondary ? [{ type: 'separator' }] : []),
...(options.secondary ? personalDataItems : []),
...(options.secondary ? [{ type: 'separator' }] : []),
...(options.secondary ? [preferencesAction] : []),
Expand Down Expand Up @@ -149,6 +163,8 @@ function buildAppMenu (options = {}) {
submenu: [
...(!options.secondary ? tabTaskActions : []),
...(!options.secondary ? [{ type: 'separator' }] : []),
...(!options.secondary ? closedTabTaskActions : []),
...(!options.secondary ? [{ type: 'separator' }] : []),
{
label: l('appMenuSavePageAs'),
accelerator: 'CmdOrCtrl+s',
Expand Down Expand Up @@ -342,7 +358,7 @@ function buildAppMenu (options = {}) {
}
}
}
// otherwise, this event will be handled in the main window
// otherwise, this event will be handled in the main window
}
},
{
Expand Down