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
68bcb8d3
Commit
68bcb8d3
authored
Mar 11, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Mar 11, 2021
Browse files
Create a single fixedview in pluginView
Signed-off-by:
Waqar Ahmed
<
waqar.17a@gmail.com
>
parent
cd6e34ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectpluginview.h
View file @
68bcb8d3
...
...
@@ -14,6 +14,7 @@
#include "kateprojectview.h"
#include <QComboBox>
#include <QMenu>
#include <QPointer>
#include <QStackedWidget>
#include <QToolButton>
...
...
@@ -100,6 +101,39 @@ public:
return
m_plugin
;
}
/**
* @brief Shows diff in a fixed view, i.e., the view is recycled instead
* of creating new view every time
* @param contents diff contents
*/
void
showDiffInFixedView
(
const
QByteArray
&
contents
)
{
if
(
!
m_fixedView
.
view
)
{
m_fixedView
.
view
=
mainWindow
()
->
openUrl
(
QUrl
());
m_fixedView
.
defaultMenu
=
m_fixedView
.
view
->
contextMenu
();
}
if
(
m_fixedView
.
view
->
document
())
{
m_fixedView
.
view
->
document
()
->
setText
(
QString
::
fromUtf8
(
contents
));
m_fixedView
.
view
->
document
()
->
setHighlightingMode
(
QStringLiteral
(
"Diff"
));
m_fixedView
.
restoreMenu
();
}
}
/**
* Same as above with call back for setting a context menu
*
* @param cb Callback on the view. This should always take KTextEditor::View*
* as a parameter. This is mainly used to plug-in context-menu actions.
*/
template
<
typename
ViewCallback
>
void
showDiffInFixedView
(
const
QByteArray
&
contents
,
ViewCallback
cb
)
{
showDiffInFixedView
(
contents
);
cb
(
m_fixedView
.
view
);
}
public
Q_SLOTS
:
/**
* Create views for given project.
...
...
@@ -319,6 +353,25 @@ private:
*/
QAction
*
m_gotoSymbolAction
;
QAction
*
m_gotoSymbolActionAppMenu
;
class
FixedView
{
public:
QPointer
<
KTextEditor
::
View
>
view
;
QPointer
<
QMenu
>
defaultMenu
;
void
restoreMenu
()
{
if
(
view
&&
defaultMenu
)
{
view
->
setContextMenu
(
defaultMenu
);
}
}
};
/**
* Fixed view for viewing diffs
*/
FixedView
m_fixedView
;
};
#endif
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