Commit c64bd22b authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Move action up in context-menu + show commit msg in diff

parent 0eccf4c3
......@@ -215,6 +215,7 @@ FileHistoryWidget::FileHistoryWidget(const QString &file, QWidget *parent)
setLayout(new QVBoxLayout);
m_backBtn.setText(i18n("Back"));
m_backBtn.setIcon(QIcon::fromTheme(QStringLiteral("draw-arrow-back.svg")));
connect(&m_backBtn, &QPushButton::clicked, this, &FileHistoryWidget::backClicked);
layout()->addWidget(&m_backBtn);
......@@ -235,13 +236,18 @@ void FileHistoryWidget::itemClicked(const QModelIndex &idx)
QProcess git;
QFileInfo fi(m_file);
git.setWorkingDirectory(fi.absolutePath());
QStringList args{QStringLiteral("diff"), QString::fromUtf8(idx.data(CommitListModel::CommitHash).toByteArray()), QStringLiteral("--"), m_file};
const auto commit = idx.data(CommitListModel::CommitRole).value<Commit>();
QStringList args{QStringLiteral("diff"), QString::fromUtf8(commit.hash), QStringLiteral("--"), m_file};
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
return;
}
QByteArray contents = git.readAll();
QByteArray contents = commit.msg.toUtf8();
contents.append("\n\n");
contents.append(git.readAllStandardOutput());
// we send this signal to the parent, which will pass it on to
// the GitWidget from where a temporary file is opened
Q_EMIT commitClicked(fi.fileName(), QStringLiteral("XXXXXX %1.diff"), contents);
......
......@@ -103,6 +103,8 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
*/
auto filePropertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("dialog-object-properties")), i18n("Properties"));
auto history = menu.addAction(i18n("Show File History"));
/**
* Git menu
*/
......@@ -128,8 +130,6 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
auto rename = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18n("&Rename"));
auto history = menu.addAction(i18n("Show File History"));
/**
* run menu and handle the triggered action
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment