|
@@ -541,34 +541,41 @@ void ViewSplit::createContextMenuOnTabBar(QMenu *p_menu, int p_tabIdx)
|
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseTab));
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseTab));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Close All Tabs.
|
|
|
|
|
+ {
|
|
|
|
|
+ auto closeTabAct = p_menu->addAction(tr("Close All Tabs"),
|
|
|
|
|
+ [this, p_tabIdx]() {
|
|
|
|
|
+ closeMultipleTabs(p_tabIdx, CloseTabMode::CloseAllTabs);
|
|
|
|
|
+ });
|
|
|
|
|
+ WidgetUtils::addActionShortcutText(closeTabAct,
|
|
|
|
|
+ coreConfig.getShortcut(CoreConfig::Shortcut::CloseAllTabs));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Close Other Tabs.
|
|
// Close Other Tabs.
|
|
|
{
|
|
{
|
|
|
auto closeTabAct = p_menu->addAction(tr("Close Other Tabs"),
|
|
auto closeTabAct = p_menu->addAction(tr("Close Other Tabs"),
|
|
|
[this, p_tabIdx]() {
|
|
[this, p_tabIdx]() {
|
|
|
- QVector<ViewWindow *> windowsNeedToClose;
|
|
|
|
|
- int cnt = getViewWindowCount();
|
|
|
|
|
- for (int i = 0; i < cnt; ++i) {
|
|
|
|
|
- if (i != p_tabIdx) {
|
|
|
|
|
- windowsNeedToClose.push_back(getViewWindow(i));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for (auto win : windowsNeedToClose) {
|
|
|
|
|
- emit viewWindowCloseRequested(win);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ closeMultipleTabs(p_tabIdx, CloseTabMode::CloseOtherTabs);
|
|
|
});
|
|
});
|
|
|
WidgetUtils::addActionShortcutText(closeTabAct,
|
|
WidgetUtils::addActionShortcutText(closeTabAct,
|
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseOtherTabs));
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseOtherTabs));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Close Tabs To The Left
|
|
|
|
|
+ {
|
|
|
|
|
+ auto closeTabAct = p_menu->addAction(tr("Close Tabs To The Left"),
|
|
|
|
|
+ [this, p_tabIdx]() {
|
|
|
|
|
+ closeMultipleTabs(p_tabIdx, CloseTabMode::CloseTabsToTheLeft);
|
|
|
|
|
+ });
|
|
|
|
|
+ WidgetUtils::addActionShortcutText(closeTabAct,
|
|
|
|
|
+ coreConfig.getShortcut(CoreConfig::Shortcut::CloseTabsToTheLeft));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Close Tabs To The Right.
|
|
// Close Tabs To The Right.
|
|
|
{
|
|
{
|
|
|
auto closeTabAct = p_menu->addAction(tr("Close Tabs To The Right"),
|
|
auto closeTabAct = p_menu->addAction(tr("Close Tabs To The Right"),
|
|
|
[this, p_tabIdx]() {
|
|
[this, p_tabIdx]() {
|
|
|
- int cnt = getViewWindowCount();
|
|
|
|
|
- for (int i = cnt - 1; i > p_tabIdx; --i) {
|
|
|
|
|
- closeTab(i);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ closeMultipleTabs(p_tabIdx, CloseTabMode::CloseTabsToTheRight);
|
|
|
});
|
|
});
|
|
|
WidgetUtils::addActionShortcutText(closeTabAct,
|
|
WidgetUtils::addActionShortcutText(closeTabAct,
|
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseTabsToTheRight));
|
|
coreConfig.getShortcut(CoreConfig::Shortcut::CloseTabsToTheRight));
|
|
@@ -700,6 +707,46 @@ void ViewSplit::closeTab(int p_idx)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void ViewSplit::closeMultipleTabs(CloseTabMode p_ctm)
|
|
|
|
|
+{
|
|
|
|
|
+ closeMultipleTabs(currentIndex(), p_ctm);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void ViewSplit::closeMultipleTabs(int p_idx, CloseTabMode p_ctm)
|
|
|
|
|
+{
|
|
|
|
|
+ QVector<ViewWindow *> windowsNeedToClose;
|
|
|
|
|
+ int cnt = getViewWindowCount();
|
|
|
|
|
+
|
|
|
|
|
+ switch (p_ctm) {
|
|
|
|
|
+ case CloseTabMode::CloseAllTabs:
|
|
|
|
|
+ for (int i = 0; i < cnt; i++) {
|
|
|
|
|
+ windowsNeedToClose.push_back(getViewWindow(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case CloseTabMode::CloseOtherTabs:
|
|
|
|
|
+ for (int i = 0; i < cnt; i++) {
|
|
|
|
|
+ if (i != p_idx) {
|
|
|
|
|
+ windowsNeedToClose.push_back(getViewWindow(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case CloseTabMode::CloseTabsToTheLeft:
|
|
|
|
|
+ for (int i = 0; i < p_idx; i++) {
|
|
|
|
|
+ windowsNeedToClose.push_back(getViewWindow(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case CloseTabMode::CloseTabsToTheRight:
|
|
|
|
|
+ for (int i = cnt - 1; i > p_idx; i--) {
|
|
|
|
|
+ windowsNeedToClose.push_back(getViewWindow(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (auto win : windowsNeedToClose) {
|
|
|
|
|
+ emit viewWindowCloseRequested(win);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void ViewSplit::mousePressEvent(QMouseEvent *p_event)
|
|
void ViewSplit::mousePressEvent(QMouseEvent *p_event)
|
|
|
{
|
|
{
|
|
|
QTabWidget::mousePressEvent(p_event);
|
|
QTabWidget::mousePressEvent(p_event);
|