зеркало из https://github.com/electron/electron.git
feat: add `BrowserWindow.showAllTabs()` for macOS (#38965)
This commit is contained in:
Родитель
040e9a027a
Коммит
56b5c00312
|
@ -1531,6 +1531,10 @@ tabs in the window.
|
|||
Selects the next tab when native tabs are enabled and there are other
|
||||
tabs in the window.
|
||||
|
||||
#### `win.showAllTabs()` _macOS_
|
||||
|
||||
Shows or hides the tab overview when native tabs are enabled.
|
||||
|
||||
#### `win.mergeAllWindows()` _macOS_
|
||||
|
||||
Merges all windows into one window with multiple tabs when native tabs
|
||||
|
|
|
@ -14,7 +14,7 @@ See [`Menu`](menu.md) for examples.
|
|||
* `menuItem` MenuItem
|
||||
* `browserWindow` [BrowserWindow](browser-window.md) | undefined - This will not be defined if no window is open.
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||
`radio`.
|
||||
|
@ -111,6 +111,7 @@ The following additional roles are available on _macOS_:
|
|||
* `toggleTabBar` - Map to the `toggleTabBar` action.
|
||||
* `selectNextTab` - Map to the `selectNextTab` action.
|
||||
* `selectPreviousTab` - Map to the `selectPreviousTab` action.
|
||||
* `showAllTabs` - Map to the `showAllTabs` action.
|
||||
* `mergeAllWindows` - Map to the `mergeAllWindows` action.
|
||||
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
|
||||
* `window` - The submenu is a "Window" menu.
|
||||
|
@ -159,7 +160,7 @@ A `string` indicating the type of the item. Can be `normal`, `separator`, `subme
|
|||
|
||||
#### `menuItem.role`
|
||||
|
||||
A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
|
||||
A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
|
||||
|
||||
#### `menuItem.accelerator`
|
||||
|
||||
|
|
|
@ -915,6 +915,10 @@ void BaseWindow::SelectNextTab() {
|
|||
window_->SelectNextTab();
|
||||
}
|
||||
|
||||
void BaseWindow::ShowAllTabs() {
|
||||
window_->ShowAllTabs();
|
||||
}
|
||||
|
||||
void BaseWindow::MergeAllWindows() {
|
||||
window_->MergeAllWindows();
|
||||
}
|
||||
|
@ -1280,6 +1284,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
#if BUILDFLAG(IS_MAC)
|
||||
.SetMethod("selectPreviousTab", &BaseWindow::SelectPreviousTab)
|
||||
.SetMethod("selectNextTab", &BaseWindow::SelectNextTab)
|
||||
.SetMethod("showAllTabs", &BaseWindow::ShowAllTabs)
|
||||
.SetMethod("mergeAllWindows", &BaseWindow::MergeAllWindows)
|
||||
.SetMethod("moveTabToNewWindow", &BaseWindow::MoveTabToNewWindow)
|
||||
.SetMethod("toggleTabBar", &BaseWindow::ToggleTabBar)
|
||||
|
|
|
@ -210,6 +210,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
|||
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
|
||||
void SelectPreviousTab();
|
||||
void SelectNextTab();
|
||||
void ShowAllTabs();
|
||||
void MergeAllWindows();
|
||||
void MoveTabToNewWindow();
|
||||
void ToggleTabBar();
|
||||
|
|
|
@ -457,6 +457,8 @@ void NativeWindow::SelectPreviousTab() {}
|
|||
|
||||
void NativeWindow::SelectNextTab() {}
|
||||
|
||||
void NativeWindow::ShowAllTabs() {}
|
||||
|
||||
void NativeWindow::MergeAllWindows() {}
|
||||
|
||||
void NativeWindow::MoveTabToNewWindow() {}
|
||||
|
|
|
@ -245,6 +245,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
// Native Tab API
|
||||
virtual void SelectPreviousTab();
|
||||
virtual void SelectNextTab();
|
||||
virtual void ShowAllTabs();
|
||||
virtual void MergeAllWindows();
|
||||
virtual void MoveTabToNewWindow();
|
||||
virtual void ToggleTabBar();
|
||||
|
|
|
@ -139,6 +139,7 @@ class NativeWindowMac : public NativeWindow,
|
|||
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item) override;
|
||||
void SelectPreviousTab() override;
|
||||
void SelectNextTab() override;
|
||||
void ShowAllTabs() override;
|
||||
void MergeAllWindows() override;
|
||||
void MoveTabToNewWindow() override;
|
||||
void ToggleTabBar() override;
|
||||
|
|
|
@ -1535,6 +1535,10 @@ void NativeWindowMac::SelectNextTab() {
|
|||
[window_ selectNextTab:nil];
|
||||
}
|
||||
|
||||
void NativeWindowMac::ShowAllTabs() {
|
||||
[window_ toggleTabOverview:nil];
|
||||
}
|
||||
|
||||
void NativeWindowMac::MergeAllWindows() {
|
||||
[window_ mergeAllWindows:nil];
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ Role kRolesMap[] = {
|
|||
{@selector(toggleFullScreenMode:), "togglefullscreen"},
|
||||
{@selector(toggleTabBar:), "toggletabbar"},
|
||||
{@selector(selectNextTab:), "selectnexttab"},
|
||||
{@selector(toggleTabOverview:), "showalltabs"},
|
||||
{@selector(selectPreviousTab:), "selectprevioustab"},
|
||||
{@selector(mergeAllWindows:), "mergeallwindows"},
|
||||
{@selector(moveTabToNewWindow:), "movetabtonewwindow"},
|
||||
|
|
|
@ -2072,6 +2072,14 @@ describe('BrowserWindow module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('BrowserWindow.showAllTabs()', () => {
|
||||
it('does not throw', () => {
|
||||
expect(() => {
|
||||
w.showAllTabs();
|
||||
}).to.not.throw();
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserWindow.mergeAllWindows()', () => {
|
||||
it('does not throw', () => {
|
||||
expect(() => {
|
||||
|
|
|
@ -824,6 +824,7 @@ Menu.buildFromTemplate([
|
|||
{ role: 'toggleTabBar' },
|
||||
{ role: 'selectNextTab' },
|
||||
{ role: 'selectPreviousTab' },
|
||||
{ role: 'showAllTabs' },
|
||||
{ role: 'mergeAllWindows' },
|
||||
{ role: 'clearRecentDocuments' },
|
||||
{ role: 'moveTabToNewWindow' }
|
||||
|
|
Загрузка…
Ссылка в новой задаче