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
062c0d2b
Commit
062c0d2b
authored
Feb 15, 2021
by
Waqar Ahmed
Browse files
Add show in external diff tool
parent
ec47907a
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/project/gitwidget.cpp
View file @
062c0d2b
...
...
@@ -261,6 +261,24 @@ void GitWidget::showDiff(const QString &file, bool staged)
});
}
void
GitWidget
::
launchExternalDiffTool
(
const
QString
&
file
,
bool
staged
)
{
if
(
file
.
isEmpty
())
{
return
;
}
auto
args
=
QStringList
{
QStringLiteral
(
"difftool"
),
QStringLiteral
(
"-y"
)};
if
(
staged
)
{
args
.
append
(
QStringLiteral
(
"--staged"
));
}
args
.
append
(
file
);
git
.
setWorkingDirectory
(
m_project
->
baseDir
());
git
.
setProgram
(
QStringLiteral
(
"git"
));
git
.
setArguments
(
args
);
git
.
start
();
}
void
GitWidget
::
commitChanges
(
const
QString
&
msg
,
const
QString
&
desc
)
{
auto
args
=
QStringList
{
QStringLiteral
(
"commit"
),
QStringLiteral
(
"-m"
),
msg
};
...
...
@@ -450,7 +468,8 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
bool
staged
=
idx
.
internalId
()
==
GitStatusModel
::
NodeStage
;
bool
untracked
=
idx
.
internalId
()
==
GitStatusModel
::
NodeUntrack
;
auto
showDiffAct
=
untracked
?
nullptr
:
menu
.
addAction
(
i18n
(
"Show Diff"
));
auto
showDiffAct
=
untracked
?
nullptr
:
menu
.
addAction
(
i18n
(
"Show raw diff"
));
auto
launchDifftoolAct
=
untracked
?
nullptr
:
menu
.
addAction
(
i18n
(
"Show in external diff tool"
));
auto
openAtHead
=
untracked
?
nullptr
:
menu
.
addAction
(
i18n
(
"Open at HEAD"
));
auto
stageAct
=
staged
?
menu
.
addAction
(
i18n
(
"Unstage file"
))
:
menu
.
addAction
(
i18n
(
"Stage file"
));
auto
discardAct
=
untracked
?
nullptr
:
menu
.
addAction
(
i18n
(
"Discard"
));
...
...
@@ -468,6 +487,8 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
openAtHEAD
(
idx
.
data
().
toString
());
}
else
if
(
act
==
showDiffAct
&&
!
untracked
)
{
showDiff
(
idx
.
data
().
toString
(),
staged
);
}
else
if
(
act
==
launchDifftoolAct
)
{
launchExternalDiffTool
(
idx
.
data
().
toString
(),
staged
);
}
}
else
if
(
type
==
GitStatusModel
::
NodeStage
)
{
QMenu
menu
;
...
...
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