Skip to content
GitLab
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
c022bf99
Commit
c022bf99
authored
Sep 18, 2022
by
Eric Armbruster
🍁
Browse files
Ensure consistent behavior for compare actions
- Use same icon - Show as enabled in the same cases
parent
d4fd27ce
Pipeline
#234140
passed with stage
in 8 minutes and 35 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
apps/lib/kateviewspace.cpp
View file @
c022bf99
...
...
@@ -929,7 +929,7 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
auto
*
doc
=
m_tabBar
->
tabDocument
(
idx
);
auto
activeDocument
=
KTextEditor
::
Editor
::
instance
()
->
application
()
->
activeMainWindow
()
->
activeView
()
->
document
();
// used for
mC
ompare
WithActive
which is used with another
KTextEditor
::
Editor
::
instance
()
->
application
()
->
activeMainWindow
()
->
activeView
()
->
document
();
// used for
c
ompare
Using
which is used with another
if
(
!
doc
)
{
// This tab is holding some other widget
// Show only "close tab" for now
...
...
@@ -965,16 +965,17 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
QAction
*
aDeleteFile
=
addActionFromCollection
(
&
menu
,
"file_delete"
);
menu
.
addSeparator
();
QAction
*
compare
=
menu
.
addAction
(
i18n
(
"Compare with Active Document"
));
compare
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"vcs-diff"
)));
connect
(
compare
,
&
QAction
::
triggered
,
this
,
[
this
,
activeDocument
,
doc
]
{
auto
w
=
new
DiffWidget
({},
this
);
w
->
setWindowTitle
(
i18n
(
"Diff %1 .. %2"
,
activeDocument
->
documentName
(),
doc
->
documentName
()));
w
->
diffDocs
(
activeDocument
,
doc
);
m_viewManager
->
mainWindow
()
->
addWidget
(
w
);
});
compare
->
setVisible
(
doc
!=
activeDocument
);
QMenu
*
mC
ompare
WithActive
=
new
QMenu
(
i18n
(
"Compare with Active Document Using"
),
&
menu
);
mC
ompare
WithActive
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"vcs-diff"
)));
menu
.
addMenu
(
mC
ompare
WithActive
);
QMenu
*
c
ompare
Using
=
new
QMenu
(
i18n
(
"Compare with Active Document Using"
),
&
menu
);
c
ompare
Using
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"vcs-diff"
)));
menu
.
addMenu
(
c
ompare
Using
);
if
(
KateApp
::
self
()
->
documentManager
()
->
documentList
().
size
()
<
2
)
{
aCloseOthers
->
setEnabled
(
false
);
...
...
@@ -986,17 +987,18 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
aRenameFile
->
setEnabled
(
false
);
aDeleteFile
->
setEnabled
(
false
);
aFileProperties
->
setEnabled
(
false
);
mC
ompare
WithActive
->
setEnabled
(
false
);
c
ompare
Using
->
setEnabled
(
false
);
}
// tab which is not active
// both documents must have urls and must not be the same to have the compare feature enabled
if
(
activeDocument
->
url
().
isEmpty
()
||
activeDocument
==
doc
)
{
mCompareWithActive
->
setEnabled
(
false
);
compare
->
setEnabled
(
false
);
compareUsing
->
setEnabled
(
false
);
}
if
(
mC
ompare
WithActive
->
isEnabled
())
{
if
(
c
ompare
Using
->
isEnabled
())
{
for
(
auto
&&
diffTool
:
KateFileActions
::
supportedDiffTools
())
{
QAction
*
compareAction
=
mC
ompare
WithActive
->
addAction
(
diffTool
.
first
);
QAction
*
compareAction
=
c
ompare
Using
->
addAction
(
diffTool
.
first
);
// we use the full path to safely execute the tool, disable action if no full path => tool not found
compareAction
->
setData
(
diffTool
.
second
);
...
...
@@ -1032,7 +1034,7 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
KateFileActions
::
renameDocumentFile
(
this
,
doc
);
}
else
if
(
choice
==
aDeleteFile
)
{
KateFileActions
::
deleteDocumentFile
(
this
,
doc
);
}
else
if
(
choice
->
parent
()
==
mC
ompare
WithActive
)
{
}
else
if
(
choice
->
parent
()
==
c
ompare
Using
)
{
QString
actionData
=
choice
->
data
().
toString
();
// name of the executable of the diff program
if
(
!
KateFileActions
::
compareWithExternalProgram
(
activeDocument
,
doc
,
actionData
))
{
QMessageBox
::
information
(
this
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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