Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
c64bd22b
Commit
c64bd22b
authored
Feb 26, 2021
by
Waqar Ahmed
Browse files
Move action up in context-menu + show commit msg in diff
parent
0eccf4c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/project/filehistorywidget.cpp
View file @
c64bd22b
...
...
@@ -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
);
...
...
addons/project/kateprojecttreeviewcontextmenu.cpp
View file @
c64bd22b
...
...
@@ -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
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment