1 | #include "FileContextMenu.h" |
2 | |
3 | #include <QApplication> |
4 | #include <QClipboard> |
5 | |
6 | FileContextMenu::(const QString &file, bool editionAllowed, QWidget *parent) |
7 | : QMenu(parent) |
8 | { |
9 | setAttribute(Qt::WA_DeleteOnClose); |
10 | |
11 | const auto fileHistoryAction = addAction(tr("History" )); |
12 | fileHistoryAction->setEnabled(false); |
13 | |
14 | connect(addAction(tr("Blame" )), &QAction::triggered, this, &FileContextMenu::signalShowFileHistory); |
15 | |
16 | const auto fileDiffAction = addAction(tr("Diff" )); |
17 | connect(fileDiffAction, &QAction::triggered, this, &FileContextMenu::signalOpenFileDiff); |
18 | |
19 | addSeparator(); |
20 | |
21 | if (editionAllowed) |
22 | { |
23 | connect(addAction(tr("Edit file" )), &QAction::triggered, this, &FileContextMenu::signalEditFile); |
24 | |
25 | addSeparator(); |
26 | } |
27 | |
28 | const auto copyPathAction = addAction(tr("Copy path" )); |
29 | connect(copyPathAction, &QAction::triggered, this, [file]() { QApplication::clipboard()->setText(file); }); |
30 | } |
31 | |