| 1653 | } |
| 1654 | |
| 1655 | void splitViewWidget::createMenuActions() |
| 1656 | { |
| 1657 | const bool menuActionsCreatedYet = bool(this->actionSplitViewGroup); |
| 1658 | Q_ASSERT_X(!menuActionsCreatedYet, Q_FUNC_INFO, "Only call this initialization function once."); |
| 1659 | |
| 1660 | auto configureAction = [this](QAction & action, |
| 1661 | QActionGroup *const actionGroup, |
| 1662 | const QString & text, |
| 1663 | const bool checkable, |
| 1664 | const bool checked, |
| 1665 | void (splitViewWidget::*func)(bool), |
| 1666 | const QKeySequence &shortcut = {}, |
| 1667 | const bool isEnabled = true) { |
| 1668 | action.setParent(this); |
| 1669 | action.setCheckable(checkable); |
| 1670 | action.setChecked(checked); |
| 1671 | action.setText(text); |
| 1672 | action.setShortcut(shortcut); |
| 1673 | if (actionGroup) |
| 1674 | actionGroup->addAction(&action); |
| 1675 | if (!isEnabled) |
| 1676 | action.setEnabled(false); |
| 1677 | connect(&action, &QAction::triggered, this, func); |
| 1678 | }; |
| 1679 | |
| 1680 | using Checkable = bool; |
| 1681 | using Checked = bool; |
| 1682 | |
| 1683 | this->actionSplitViewGroup.reset(new QActionGroup(this)); |
| 1684 | configureAction(actionSplitView[0], |
| 1685 | this->actionSplitViewGroup.get(), |
| 1686 | "Disabled", |
| 1687 | Checkable(true), |
| 1688 | Checked(this->viewSplitMode == DISABLED), |
| 1689 | &splitViewWidget::splitViewDisable); |
| 1690 | configureAction(actionSplitView[1], |
| 1691 | this->actionSplitViewGroup.get(), |
| 1692 | "Side-by-Side", |
| 1693 | Checkable(true), |
| 1694 | Checked(this->viewSplitMode == SIDE_BY_SIDE), |
| 1695 | &splitViewWidget::splitViewSideBySide); |
| 1696 | configureAction(actionSplitView[2], |
| 1697 | this->actionSplitViewGroup.get(), |
| 1698 | "Comparison", |
| 1699 | Checkable(true), |
| 1700 | Checked(this->viewSplitMode == COMPARISON), |
| 1701 | &splitViewWidget::splitViewComparison); |
| 1702 | this->actionSplitView[0].setToolTip("Show only one single Item."); |
| 1703 | this->actionSplitView[1].setToolTip( |
| 1704 | "Show two items side-by-side so that the same part of each item is visible."); |
| 1705 | this->actionSplitView[2].setToolTip( |
| 1706 | "Show two items at the same position with a split line that can be " |
| 1707 | "moved to reveal either item."); |
| 1708 | |
| 1709 | this->actionGridGroup.reset(new QActionGroup(this)); |
| 1710 | configureAction(this->actionGrid[0], |
| 1711 | this->actionGridGroup.get(), |
| 1712 | "Disabled", |
no test coverage detected