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
98d5a079
Commit
98d5a079
authored
Mar 10, 2021
by
Kåre Särs
Browse files
Pass the current active view to showCommitInfo()
parent
be861391
Changes
5
Hide whitespace changes
Inline
Side-by-side
addons/git-blame/gitblametooltip.cpp
View file @
98d5a079
...
...
@@ -159,8 +159,6 @@ public:
const
QColor
normal
=
theme
.
textColor
(
KSyntaxHighlighting
::
Theme
::
Normal
);
pal
.
setColor
(
QPalette
::
Text
,
normal
);
setPalette
(
pal
);
updateFont
();
};
updateColors
(
KTextEditor
::
Editor
::
instance
());
connect
(
KTextEditor
::
Editor
::
instance
(),
&
KTextEditor
::
Editor
::
configChanged
,
this
,
updateColors
);
...
...
@@ -206,17 +204,14 @@ public:
return
false
;
}
void
s
et
Tooltip
Text
(
const
QString
&
text
)
void
s
how
Tooltip
(
const
QString
&
text
,
const
QPointer
<
KTextEditor
::
View
>
view
)
{
if
(
text
.
isEmpty
()
)
if
(
text
.
isEmpty
()
||
!
view
)
{
return
;
}
m_htmlHl
.
setText
(
text
);
setHtml
(
m_htmlHl
.
html
());
}
void
setView
(
QPointer
<
KTextEditor
::
View
>
view
)
{
// view changed?
// => update definition
// => update font
...
...
@@ -224,42 +219,14 @@ public:
if
(
m_view
&&
m_view
->
focusProxy
())
{
m_view
->
focusProxy
()
->
removeEventFilter
(
this
);
}
m_view
=
view
;
updateFont
();
}
if
(
m_view
&&
m_view
->
focusProxy
())
{
// update font
auto
ciface
=
qobject_cast
<
KTextEditor
::
ConfigInterface
*>
(
m_view
);
auto
font
=
ciface
->
configValue
(
QStringLiteral
(
"font"
)).
value
<
QFont
>
();
setFont
(
font
);
m_view
->
focusProxy
()
->
installEventFilter
(
this
);
}
}
void
updateFont
()
{
if
(
!
m_view
)
{
return
;
}
auto
ciface
=
qobject_cast
<
KTextEditor
::
ConfigInterface
*>
(
m_view
);
auto
font
=
ciface
->
configValue
(
QStringLiteral
(
"font"
)).
value
<
QFont
>
();
setFont
(
font
);
}
Q_SLOT
void
hideTooltip
()
{
if
(
m_view
&&
m_view
->
focusProxy
())
{
m_view
->
focusProxy
()
->
removeEventFilter
(
this
);
}
close
();
setText
(
QString
());
m_inContextMenu
=
false
;
}
void
fixGeometry
()
{
if
(
!
m_view
)
{
return
;
}
const
int
scrollBarHeight
=
horizontalScrollBar
()
->
height
();
QFontMetrics
fm
(
font
());
QSize
size
=
fm
.
size
(
Qt
::
TextSingleLine
,
QStringLiteral
(
"m"
));
...
...
@@ -272,6 +239,18 @@ public:
p
.
setY
(
p
.
y
()
+
fontHeight
);
p
.
setX
(
p
.
x
()
+
m_view
->
textAreaRect
().
left
()
+
m_view
->
textAreaRect
().
width
()
-
size
.
width
()
-
fontHeight
);
this
->
move
(
p
);
show
();
}
Q_SLOT
void
hideTooltip
()
{
if
(
m_view
&&
m_view
->
focusProxy
())
{
m_view
->
focusProxy
()
->
removeEventFilter
(
this
);
}
close
();
setText
(
QString
());
m_inContextMenu
=
false
;
}
protected:
...
...
@@ -327,17 +306,13 @@ private:
GitBlameTooltip
::
GitBlameTooltip
()
:
d
(
new
GitBlameTooltip
::
Private
())
{}
GitBlameTooltip
::~
GitBlameTooltip
()
{
delete
d
;
}
void
GitBlameTooltip
::
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
view
)
void
GitBlameTooltip
::
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
view
)
{
if
(
text
.
isEmpty
()
||
!
view
||
!
view
->
document
())
{
return
;
}
d
->
setView
(
view
);
d
->
setTooltipText
(
text
);
d
->
fixGeometry
();
d
->
raise
();
d
->
show
();
d
->
showTooltip
(
text
,
view
);
}
void
GitBlameTooltip
::
setIgnoreKeySequence
(
QKeySequence
sequence
)
...
...
addons/git-blame/gitblametooltip.h
View file @
98d5a079
...
...
@@ -24,7 +24,7 @@ public:
GitBlameTooltip
();
~
GitBlameTooltip
();
void
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
v
);
void
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
v
iew
);
void
setIgnoreKeySequence
(
QKeySequence
sequence
);
...
...
addons/git-blame/kategitblameplugin.cpp
View file @
98d5a079
...
...
@@ -116,7 +116,9 @@ void GitBlameInlineNoteProvider::inlineNoteActivated(const KTextEditor::InlineNo
if
((
buttons
&
Qt
::
LeftButton
)
!=
0
)
{
int
lineNr
=
note
.
position
().
line
();
const
KateGitBlameInfo
&
info
=
m_plugin
->
blameInfo
(
lineNr
,
m_doc
->
line
(
lineNr
));
m_plugin
->
showCommitInfo
(
info
.
commitHash
);
// Hack: view->mainWindow()->view() to de-constify view
m_plugin
->
showCommitInfo
(
info
.
commitHash
,
note
.
view
()
->
mainWindow
()
->
activeView
());
}
}
...
...
@@ -141,6 +143,7 @@ KateGitBlamePluginView::KateGitBlamePluginView(KateGitBlamePlugin *plugin, KText
:
QObject
(
plugin
)
,
m_mainWindow
(
mainwindow
)
{
qDebug
()
<<
"creating new plugin view"
;
KXMLGUIClient
::
setComponentName
(
QStringLiteral
(
"kategitblameplugin"
),
i18n
(
"Git Blame"
));
setXMLFile
(
QStringLiteral
(
"ui.rc"
));
QAction
*
showBlameAction
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"git_blame_show"
));
...
...
@@ -159,7 +162,7 @@ KateGitBlamePluginView::KateGitBlamePluginView(KateGitBlamePlugin *plugin, KText
plugin
->
setToolTipIgnoreKeySequence
(
showBlameAction
->
shortcut
());
int
lineNr
=
kv
->
cursorPosition
().
line
();
const
KateGitBlameInfo
&
info
=
plugin
->
blameInfo
(
lineNr
,
doc
->
line
(
lineNr
));
plugin
->
showCommitInfo
(
info
.
commitHash
);
plugin
->
showCommitInfo
(
info
.
commitHash
,
kv
);
});
m_mainWindow
->
guiFactory
()
->
addClient
(
this
);
}
...
...
@@ -249,18 +252,15 @@ void KateGitBlamePlugin::startShowProcess(const QUrl &url, const QString &hash)
m_showProc
.
start
(
QStringLiteral
(
"git"
),
args
,
QIODevice
::
ReadOnly
);
}
void
KateGitBlamePlugin
::
showCommitInfo
(
const
QString
&
hash
)
void
KateGitBlamePlugin
::
showCommitInfo
(
const
QString
&
hash
,
KTextEditor
::
View
*
view
)
{
if
(
!
m_mainWindow
||
!
m_mainWindow
->
activeView
()
||
!
m_mainWindow
->
activeView
()
->
document
())
{
return
;
}
if
(
hash
==
m_activeCommitInfo
.
m_hash
)
{
m_showHash
.
clear
();
m_tooltip
.
show
(
m_activeCommitInfo
.
m_content
,
m_mainWindow
->
activeV
iew
()
);
m_tooltip
.
show
(
m_activeCommitInfo
.
m_content
,
v
iew
);
}
else
{
m_showHash
=
hash
;
startShowProcess
(
m_mainWindow
->
activeV
iew
()
->
document
()
->
url
(),
hash
);
startShowProcess
(
v
iew
->
document
()
->
url
(),
hash
);
}
}
...
...
addons/git-blame/kategitblameplugin.h
View file @
98d5a079
...
...
@@ -81,7 +81,7 @@ public:
void
readConfig
();
void
showCommitInfo
(
const
QString
&
hash
);
void
showCommitInfo
(
const
QString
&
hash
,
KTextEditor
::
View
*
view
);
void
setToolTipIgnoreKeySequence
(
QKeySequence
sequence
);
...
...
addons/search/plugin_search.cpp
View file @
98d5a079
...
...
@@ -1157,8 +1157,7 @@ void KatePluginSearchView::startSearchWhileTyping()
m_ui
.
searchCombo
->
blockSignals
(
true
);
if
(
m_ui
.
searchCombo
->
count
()
==
0
)
{
m_ui
.
searchCombo
->
insertItem
(
0
,
currentSearchText
);
}
else
{
}
else
{
m_ui
.
searchCombo
->
setItemText
(
0
,
currentSearchText
);
}
m_ui
.
searchCombo
->
setCurrentIndex
(
0
);
...
...
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