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
cd940be9
Commit
cd940be9
authored
Feb 15, 2021
by
Waqar Ahmed
Browse files
Add refresh + checkout option to gitwidget-menu
parent
ac383bea
Changes
4
Hide whitespace changes
Inline
Side-by-side
addons/project/CMakeLists.txt
View file @
cd940be9
...
...
@@ -69,6 +69,7 @@ target_sources(
tools/kateprojectcodeanalysisselector.cpp
git/gitutils.cpp
git/gitstatus.cpp
plugin.qrc
)
...
...
addons/project/gitwidget.cpp
View file @
cd940be9
...
...
@@ -14,6 +14,7 @@
#include <QProcess>
#include <QPushButton>
#include <QStringListModel>
#include <QToolButton>
#include <QTreeView>
#include <QVBoxLayout>
#include <QtConcurrentRun>
...
...
@@ -30,10 +31,16 @@ GitWidget::GitWidget(KateProject *project, QWidget *parent, KTextEditor::MainWin
,
m_project
(
project
)
,
m_mainWin
(
mainWindow
)
{
m_menuBtn
=
new
Q
Push
Button
(
this
);
m_menuBtn
=
new
Q
Tool
Button
(
this
);
m_commitBtn
=
new
QPushButton
(
this
);
m_treeView
=
new
QTreeView
(
this
);
buildMenu
();
m_menuBtn
->
setMenu
(
m_gitMenu
);
connect
(
m_menuBtn
,
&
QToolButton
::
clicked
,
this
,
[
this
](
bool
)
{
m_menuBtn
->
showMenu
();
});
m_menuBtn
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"application-menu"
)));
m_commitBtn
->
setIcon
(
QIcon
(
QStringLiteral
(
":/kxmlgui5/kateproject/git-commit-dark.svg"
)));
m_commitBtn
->
setText
(
i18n
(
"Commit"
));
...
...
@@ -265,6 +272,17 @@ bool GitWidget::eventFilter(QObject *o, QEvent *e)
return
QWidget
::
eventFilter
(
o
,
e
);
}
void
GitWidget
::
buildMenu
()
{
m_gitMenu
=
new
QMenu
(
this
);
m_gitMenu
->
addAction
(
i18n
(
"Refresh"
),
this
,
[
this
]
{
if
(
m_project
)
{
getStatus
(
m_project
->
baseDir
());
}
});
m_gitMenu
->
addAction
(
i18n
(
"Checkout Branch"
),
this
,
&
GitWidget
::
checkoutBranch
);
}
void
GitWidget
::
treeViewContextMenuEvent
(
QContextMenuEvent
*
e
)
{
// discard=>git checkout -q -- /home/waqar/Projects/syntest/App.js
...
...
addons/project/gitwidget.h
View file @
cd940be9
...
...
@@ -13,6 +13,8 @@ class QStringListModel;
class
GitStatusModel
;
class
KateProject
;
class
QItemSelection
;
class
QMenu
;
class
QToolButton
;
namespace
KTextEditor
{
...
...
@@ -28,8 +30,7 @@ public:
bool
eventFilter
(
QObject
*
o
,
QEvent
*
e
)
override
;
private:
QPushButton
*
m_menuBtn
;
QToolButton
*
m_menuBtn
;
QPushButton
*
m_commitBtn
;
QTreeView
*
m_treeView
;
GitStatusModel
*
m_model
;
...
...
@@ -38,7 +39,9 @@ private:
QFutureWatcher
<
GitUtils
::
GitParsedStatus
>
m_gitStatusWatcher
;
QString
m_commitMessage
;
KTextEditor
::
MainWindow
*
m_mainWin
;
QMenu
*
m_gitMenu
;
void
buildMenu
();
void
getStatus
(
const
QString
&
repo
,
bool
untracked
=
true
,
bool
submodules
=
false
);
void
stage
(
const
QStringList
&
files
,
bool
=
false
);
void
unstage
(
const
QStringList
&
files
);
...
...
@@ -52,6 +55,10 @@ private:
Q_SLOT
void
gitStatusReady
(
int
exit
,
QProcess
::
ExitStatus
);
Q_SLOT
void
parseStatusReady
();
Q_SLOT
void
opencommitChangesDialog
();
// signals
public:
Q_SIGNAL
void
checkoutBranch
();
};
#endif // GITWIDGET_H
addons/project/kateprojectview.cpp
View file @
cd940be9
...
...
@@ -113,6 +113,9 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
connect
(
&
m_branchChangedWatcher
,
&
QFileSystemWatcher
::
fileChanged
,
this
,
[
this
]
{
m_project
->
reload
(
true
);
});
connect
(
m_gitWidget
,
&
GitWidget
::
checkoutBranch
,
this
,
[
this
]
{
m_branchesDialog
->
openDialog
();
});
}
KateProjectView
::~
KateProjectView
()
...
...
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