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
91990314
Commit
91990314
authored
Oct 28, 2022
by
Christoph Cullmann
🍨
Browse files
better handling of no active view
BUG: 461056
parent
0132b3be
Pipeline
#257107
passed with stage
in 5 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
addons/externaltools/kateexternaltoolsview.cpp
View file @
91990314
...
...
@@ -73,7 +73,7 @@ void KateExternalToolsMenuAction::reload()
a
->
setIcon
(
QIcon
::
fromTheme
(
tool
->
icon
));
a
->
setData
(
QVariant
::
fromValue
(
tool
));
connect
(
a
,
&
QAction
::
triggered
,
[
this
,
a
]()
{
connect
(
a
,
&
QAction
::
triggered
,
a
,
[
this
,
a
]()
{
m_plugin
->
runTool
(
*
a
->
data
().
value
<
KateExternalTool
*>
(),
m_mainwindow
->
activeView
());
});
...
...
@@ -113,11 +113,12 @@ void KateExternalToolsMenuAction::reload()
void
KateExternalToolsMenuAction
::
slotViewChanged
(
KTextEditor
::
View
*
view
)
{
// no active view, oh oh
disconnect
(
m_docUrlChangedConnection
);
if
(
!
view
)
{
updateActionState
(
nullptr
);
return
;
}
disconnect
(
m_docUrlChangedConnection
);
m_docUrlChangedConnection
=
connect
(
view
->
document
(),
&
KTextEditor
::
Document
::
documentUrlChanged
,
this
,
[
this
](
KTextEditor
::
Document
*
doc
)
{
updateActionState
(
doc
);
});
...
...
@@ -127,17 +128,13 @@ void KateExternalToolsMenuAction::slotViewChanged(KTextEditor::View *view)
void
KateExternalToolsMenuAction
::
updateActionState
(
KTextEditor
::
Document
*
activeDoc
)
{
if
(
!
activeDoc
)
{
return
;
}
// try to enable/disable to match current mime type
const
QString
mimeType
=
activeDoc
->
mimeType
();
// try to enable/disable to match current mime type or if we have no doc
const
QString
mimeType
=
activeDoc
?
activeDoc
->
mimeType
()
:
QString
();
const
auto
actions
=
m_actionCollection
->
actions
();
for
(
QAction
*
action
:
actions
)
{
if
(
action
&&
action
->
data
().
value
<
KateExternalTool
*>
())
{
auto
tool
=
action
->
data
().
value
<
KateExternalTool
*>
();
action
->
setEnabled
(
tool
->
matchesMimetype
(
mimeType
)
||
tool
->
mimetypes
.
isEmpty
());
action
->
setEnabled
(
activeDoc
&&
(
tool
->
matchesMimetype
(
mimeType
)
||
tool
->
mimetypes
.
isEmpty
())
)
;
}
}
}
...
...
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