| 92 | } |
| 93 | |
| 94 | void GitMenuManager::setupFileMenu(const QString &filePath) |
| 95 | { |
| 96 | QString file = filePath; |
| 97 | if (file.isEmpty()) { |
| 98 | if (!editSrv) |
| 99 | editSrv = dpfGetService(EditorService); |
| 100 | |
| 101 | file = editSrv->currentFile(); |
| 102 | } |
| 103 | |
| 104 | auto mCurFile = ActionManager::instance()->actionContainer(M_GIT_FILE); |
| 105 | if (file.isEmpty() || !GitClient::instance()->checkRepositoryExist(file)) { |
| 106 | mCurFile->containerAction()->setEnabled(false); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | mCurFile->containerAction()->setEnabled(true); |
| 111 | QFileInfo info(file); |
| 112 | |
| 113 | auto fileLogAct = ActionManager::instance()->command(A_GIT_LOG_FILE); |
| 114 | fileLogAct->setProperty(GitFilePath, file); |
| 115 | fileLogAct->action()->setText(tr("Log of \"%1\"").arg(info.fileName())); |
| 116 | |
| 117 | auto fileBlameAct = ActionManager::instance()->command(A_GIT_BLAME_FILE); |
| 118 | fileBlameAct->setProperty(GitFilePath, file); |
| 119 | fileBlameAct->action()->setText(tr("Blame of \"%1\"").arg(info.fileName())); |
| 120 | |
| 121 | auto fileDiffAct = ActionManager::instance()->command(A_GIT_DIFF_FILE); |
| 122 | fileDiffAct->setProperty(GitFilePath, file); |
| 123 | fileDiffAct->action()->setText(tr("Diff of \"%1\"").arg(info.fileName())); |
| 124 | } |
| 125 | |
| 126 | QAction *GitMenuManager::gitAction() const |
| 127 | { |
no test coverage detected