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
c51e7af0
Commit
c51e7af0
authored
Feb 22, 2021
by
Kåre Särs
Browse files
De-singletonify the GitBlameTooltip
parent
d6f10efa
Changes
4
Hide whitespace changes
Inline
Side-by-side
addons/git-blame/gitblametooltip.cpp
View file @
c51e7af0
...
...
@@ -11,7 +11,6 @@
#include <QDebug>
#include <QEvent>
#include <QFontMetrics>
#include <QLabel>
#include <QMouseEvent>
#include <QScreen>
#include <QString>
...
...
@@ -127,16 +126,11 @@ private:
QTextStream
out
;
};
class
Tooltip
:
public
QTextBrowser
class
GitBlameTooltip
::
Private
:
public
QTextBrowser
{
Q_OBJECT
public:
static
Tooltip
*
self
()
{
static
Tooltip
instance
;
return
&
instance
;
}
void
setTooltipText
(
const
QString
&
text
)
{
...
...
@@ -168,13 +162,13 @@ public:
}
}
Tooltip
(
QWidget
*
parent
=
nullptr
)
Private
(
QWidget
*
parent
=
nullptr
)
:
QTextBrowser
(
parent
)
{
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
BypassGraphicsProxyWidget
|
Qt
::
ToolTip
);
document
()
->
setDocumentMargin
(
5
);
setFrameStyle
(
QFrame
::
Box
|
QFrame
::
Raised
);
connect
(
&
m_hideTimer
,
&
QTimer
::
timeout
,
this
,
&
Tooltip
::
hideTooltip
);
connect
(
&
m_hideTimer
,
&
QTimer
::
timeout
,
this
,
&
Private
::
hideTooltip
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
...
...
@@ -281,23 +275,27 @@ protected:
private:
bool
inContextMenu
=
false
;
KTextEditor
::
View
*
m_view
;
QPointer
<
KTextEditor
::
View
>
m_view
;
QTimer
m_hideTimer
;
HtmlHl
m_htmlHl
;
KSyntaxHighlighting
::
Repository
m_syntaxHlRepo
;
};
void
GitBlameTooltip
::
show
(
const
QString
&
text
,
KTextEditor
::
View
*
v
)
GitBlameTooltip
::
GitBlameTooltip
()
:
d
(
new
GitBlameTooltip
::
Private
())
{}
GitBlameTooltip
::~
GitBlameTooltip
()
{
delete
d
;
}
void
GitBlameTooltip
::
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
v
)
{
if
(
text
.
isEmpty
()
||
!
v
||
!
v
->
document
())
{
return
;
}
Tooltip
::
self
()
->
setView
(
v
);
Tooltip
::
self
()
->
setTooltipText
(
text
);
Tooltip
::
self
()
->
fixGeometry
();
Tooltip
::
self
()
->
raise
();
Tooltip
::
self
()
->
show
();
d
->
setView
(
v
);
d
->
setTooltipText
(
text
);
d
->
fixGeometry
();
d
->
raise
();
d
->
show
();
}
#include "gitblametooltip.moc"
addons/git-blame/gitblametooltip.h
View file @
c51e7af0
...
...
@@ -5,14 +5,12 @@
SPDX-License-Identifier: MIT
*/
#ifndef
LSPTOOLTIP_H
#define
LSPTOOLTIP_H
#ifndef
GitBlameTooltip_h
#define
GitBlameTooltip_h
#include <QPoint>
#include <QPoint
er
>
class
QWidget
;
class
QString
;
class
Tooltip
;
namespace
KTextEditor
{
...
...
@@ -21,8 +19,16 @@ class View;
class
GitBlameTooltip
{
public:
static
void
show
(
const
QString
&
text
,
KTextEditor
::
View
*
v
);
GitBlameTooltip
();
~
GitBlameTooltip
();
void
show
(
const
QString
&
text
,
QPointer
<
KTextEditor
::
View
>
v
);
private:
class
Private
;
Private
*
const
d
;
};
#endif //
LSPTOOLTIP_H
#endif //
GitBlameTooltip_h
addons/git-blame/kategitblameplugin.cpp
View file @
c51e7af0
...
...
@@ -242,7 +242,7 @@ void KateGitBlamePlugin::showFinished(int exitCode, QProcess::ExitStatus exitSta
return
;
}
GitBlameT
ooltip
::
show
(
stdOut
,
m_mainWindow
->
activeView
());
m_t
ooltip
.
show
(
stdOut
,
m_mainWindow
->
activeView
());
}
bool
KateGitBlamePlugin
::
hasBlameInfo
()
const
...
...
addons/git-blame/kategitblameplugin.h
View file @
c51e7af0
...
...
@@ -5,8 +5,10 @@
*/
#ifndef KATE_COLORPICKER_H
#define KATE_COLORPICKER_H
#ifndef KateGitBlamePlugin_h
#define KateGitBlamePlugin_h
#include "gitblametooltip.h"
#include <KTextEditor/ConfigPage>
#include <KTextEditor/InlineNoteProvider>
...
...
@@ -29,6 +31,7 @@ struct KateGitBlameInfo {
};
class
KateGitBlamePlugin
;
class
GitBlameTooltip
;
class
GitBlameInlineNoteProvider
:
public
KTextEditor
::
InlineNoteProvider
{
...
...
@@ -82,6 +85,8 @@ private:
QVector
<
KateGitBlameInfo
>
m_blameInfo
;
KTextEditor
::
View
*
m_blameInfoView
=
nullptr
;
int
m_lineOffset
{
0
};
GitBlameTooltip
m_tooltip
;
};
#endif // K
ATE_COLORPICKER_H
#endif // K
ateGitBlamePlugin_h
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