| 512 | } |
| 513 | |
| 514 | void DockManager::newLayoutClicked() |
| 515 | { |
| 516 | // The plus button has just been made the current tab, so set it back to the |
| 517 | // one corresponding to the current layout again. |
| 518 | if (m_menu_bar) |
| 519 | m_menu_bar->onCurrentLayoutChanged(m_current_layout); |
| 520 | |
| 521 | const auto name_validator = [this](const QString& name) { |
| 522 | return !hasNameConflict(name, DockLayout::INVALID_INDEX); |
| 523 | }; |
| 524 | |
| 525 | const bool can_clone_current_layout = m_current_layout != DockLayout::INVALID_INDEX; |
| 526 | |
| 527 | LayoutEditorDialog* dialog = new LayoutEditorDialog(name_validator, can_clone_current_layout, g_debugger_window); |
| 528 | dialog->setAttribute(Qt::WA_DeleteOnClose); |
| 529 | |
| 530 | connect(dialog, &QDialog::accepted, this, [this, dialog, name_validator]() { |
| 531 | if (!name_validator(dialog->name())) |
| 532 | return; |
| 533 | |
| 534 | DockLayout::Index new_layout = DockLayout::INVALID_INDEX; |
| 535 | |
| 536 | const auto [mode, index] = dialog->initialState(); |
| 537 | switch (mode) |
| 538 | { |
| 539 | case LayoutEditorDialog::DEFAULT_LAYOUT: |
| 540 | { |
| 541 | const DockTables::DefaultDockLayout& default_layout = DockTables::DEFAULT_DOCK_LAYOUTS.at(index); |
| 542 | new_layout = createLayout(dialog->name(), dialog->cpu(), false, default_layout.name); |
| 543 | break; |
| 544 | } |
| 545 | case LayoutEditorDialog::BLANK_LAYOUT: |
| 546 | { |
| 547 | new_layout = createLayout(dialog->name(), dialog->cpu(), false); |
| 548 | break; |
| 549 | } |
| 550 | case LayoutEditorDialog::CLONE_LAYOUT: |
| 551 | { |
| 552 | if (m_current_layout == DockLayout::INVALID_INDEX) |
| 553 | break; |
| 554 | |
| 555 | DockLayout::Index old_layout = m_current_layout; |
| 556 | |
| 557 | // Freeze the current layout so we can copy the geometry. |
| 558 | switchToLayout(DockLayout::INVALID_INDEX); |
| 559 | |
| 560 | new_layout = createLayout(dialog->name(), dialog->cpu(), false, m_layouts.at(old_layout)); |
| 561 | break; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | if (new_layout != DockLayout::INVALID_INDEX) |
| 566 | { |
| 567 | updateLayoutSwitcher(); |
| 568 | switchToLayout(new_layout); |
| 569 | } |
| 570 | }); |
| 571 |
nothing calls this directly
no test coverage detected