| 107 | } |
| 108 | |
| 109 | void TabBarPrivate::showMenu(QPoint pos) |
| 110 | { |
| 111 | int curIndex = tabBar->tabAt(pos); |
| 112 | DMenu menu; |
| 113 | |
| 114 | menu.addAction(tr("Copy File Path"), [=]() { |
| 115 | auto file = tabBar->tabToolTip(curIndex); |
| 116 | QGuiApplication::clipboard()->setText(file); |
| 117 | }); |
| 118 | menu.addAction(tr("Copy File Name"), [=]() { |
| 119 | auto file = tabBar->tabToolTip(curIndex); |
| 120 | auto fileName = QFileInfo(file).fileName(); |
| 121 | QGuiApplication::clipboard()->setText(fileName); |
| 122 | }); |
| 123 | |
| 124 | menu.addSeparator(); |
| 125 | menu.addAction(tr("Close This File"), [=]() { |
| 126 | auto file = tabBar->tabToolTip(curIndex); |
| 127 | q->removeTab(file); |
| 128 | }); |
| 129 | menu.addAction(tr("Close All Files"), [=]() { |
| 130 | q->closeAllTab({}); |
| 131 | }); |
| 132 | menu.addAction(tr("Close All Files Except This"), [=]() { |
| 133 | auto curFile = tabBar->tabToolTip(curIndex); |
| 134 | QStringList exceptList { curFile }; |
| 135 | q->closeAllTab(exceptList); |
| 136 | }); |
| 137 | |
| 138 | menu.addSeparator(); |
| 139 | menu.addAction(tr("Show Containing Folder"), [=]() { |
| 140 | auto file = tabBar->tabToolTip(curIndex); |
| 141 | DDesktopServices::showFileItem(file); |
| 142 | }); |
| 143 | |
| 144 | menu.exec(QCursor::pos()); |
| 145 | } |
| 146 | |
| 147 | TabBar::TabBar(QWidget *parent) |
| 148 | : QWidget(parent), |
nothing calls this directly
no test coverage detected