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
960737da
Commit
960737da
authored
Mar 01, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Mar 04, 2021
Browse files
Add signal-slot connections from plugin to mainwindow for registering jumps
parent
ab16331f
Changes
3
Hide whitespace changes
Inline
Side-by-side
kate/katemainwindow.cpp
View file @
960737da
...
...
@@ -1181,6 +1181,13 @@ QObject *KateMainWindow::pluginView(const QString &name)
return
m_pluginViews
.
contains
(
plugin
)
?
m_pluginViews
.
value
(
plugin
)
:
nullptr
;
}
void
KateMainWindow
::
addJumpLocation
(
QUrl
url
,
int
line
,
int
col
)
{
m_locations
.
push_back
({
url
,
line
,
col
});
// set to last
currentLocation
=
m_locations
.
size
()
-
1
;
}
void
KateMainWindow
::
mousePressEvent
(
QMouseEvent
*
e
)
{
switch
(
e
->
button
())
{
...
...
@@ -1242,6 +1249,52 @@ void KateMainWindow::slotCommandBarOpen()
m_lastUsedCmdBarActions
=
commandBar
.
lastUsedCmdBarActions
();
}
void
KateMainWindow
::
goBack
()
{
if
(
m_locations
.
isEmpty
()
||
currentLocation
==
0
)
{
return
;
}
auto
location
=
m_locations
.
at
(
currentLocation
-
1
);
currentLocation
--
;
if
(
!
location
.
url
.
isValid
())
{
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
QStringLiteral
(
"Error"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
i18n
(
"Failed to jump to: %1 %2 %3"
,
location
.
url
.
toDisplayString
(),
location
.
line
,
location
.
col
));
m_outputView
->
slotMessage
(
genericMessage
);
return
;
}
auto
v
=
openUrl
(
location
.
url
);
v
->
setCursorPosition
({
location
.
line
,
location
.
col
});
}
void
KateMainWindow
::
goForward
()
{
if
(
m_locations
.
isEmpty
())
{
return
;
}
if
(
currentLocation
==
m_locations
.
size
()
-
1
)
{
return
;
}
auto
location
=
m_locations
.
at
(
currentLocation
+
1
);
currentLocation
--
;
if
(
!
location
.
url
.
isValid
())
{
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
QStringLiteral
(
"Error"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
i18n
(
"Failed to jump to: %1 %2 %3"
,
location
.
url
.
toDisplayString
(),
location
.
line
,
location
.
col
));
m_outputView
->
slotMessage
(
genericMessage
);
return
;
}
auto
v
=
openUrl
(
location
.
url
);
v
->
setCursorPosition
({
location
.
line
,
location
.
col
});
}
QWidget
*
KateMainWindow
::
createToolView
(
KTextEditor
::
Plugin
*
plugin
,
const
QString
&
identifier
,
KTextEditor
::
MainWindow
::
ToolViewPosition
pos
,
...
...
kate/katemainwindow.h
View file @
960737da
...
...
@@ -172,6 +172,10 @@ public Q_SLOTS:
void
slotCommandBarOpen
();
void
goBack
();
void
goForward
();
/**
* Overwrite size hint for better default window sizes
* @return size hint
...
...
@@ -515,6 +519,11 @@ public Q_SLOTS:
*/
QObject
*
pluginView
(
const
QString
&
name
);
/**
* Add a jump location for jumping back and forth between history
*/
void
addJumpLocation
(
QUrl
url
,
int
line
,
int
col
);
private
Q_SLOTS
:
void
slotUpdateBottomViewBar
();
...
...
@@ -569,6 +578,15 @@ private:
QVector
<
QString
>
m_lastUsedCmdBarActions
;
struct
Location
{
QUrl
url
;
int
line
;
int
col
;
};
QVector
<
Location
>
m_locations
;
int
currentLocation
=
0
;
class
BarState
{
public:
...
...
kate/katepluginmanager.cpp
View file @
960737da
...
...
@@ -70,6 +70,7 @@ void KatePluginManager::setupPluginList()
// handle all install KTextEditor plugins
m_pluginList
.
clear
();
QSet
<
QString
>
unique
;
const
QVector
<
KPluginMetaData
>
plugins
=
KPluginLoader
::
findPlugins
(
QStringLiteral
(
"ktexteditor"
),
[](
const
KPluginMetaData
&
md
)
{
return
md
.
serviceTypes
().
contains
(
QLatin1String
(
"KTextEditor/Plugin"
));
});
...
...
@@ -228,6 +229,11 @@ void KatePluginManager::enablePluginGUI(KatePluginInfo *item, KateMainWindow *wi
connect
(
item
->
plugin
,
SIGNAL
(
message
(
const
QVariantMap
&
)),
win
->
outputView
(),
SLOT
(
slotMessage
(
const
QVariantMap
&
)),
Qt
::
UniqueConnection
);
}
// ensure jumping is connected for plugin if available
if
(
item
->
plugin
->
metaObject
()
->
indexOfSignal
(
"jumped(QUrl,int,int)"
)
!=
-
1
)
{
connect
(
item
->
plugin
,
SIGNAL
(
jumped
(
const
QUrl
&
,
int
,
int
)),
win
,
SLOT
(
addJumpLocation
(
const
QUrl
&
,
int
,
int
)),
Qt
::
UniqueConnection
);
}
// create the view + try to correctly load shortcuts, if it's a GUI Client
createdView
=
item
->
plugin
->
createView
(
win
->
wrapper
());
if
(
createdView
)
{
...
...
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