Commit dafc55ce authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

GitWidget: Initialize on show

Avoids slowing down kate startup especially when there are multiple
projects.
parent 8ab870c0
Pipeline #252486 passed with stage
in 47 minutes and 44 seconds
......@@ -200,6 +200,22 @@ GitWidget::GitWidget(KateProject *project, KTextEditor::MainWindow *mainWindow,
, m_mainView(new QWidget(this))
, m_stackWidget(new QStackedWidget(this))
{
// We init delayed when the widget will be shown
}
void GitWidget::showEvent(QShowEvent *e)
{
init();
QWidget::showEvent(e);
}
void GitWidget::init()
{
if (m_initialized) {
return;
}
m_initialized = true;
setDotGitPath();
m_treeView = new GitWidgetTreeView(this);
......@@ -479,7 +495,9 @@ QProcess *GitWidget::gitp(const QStringList &arguments)
void GitWidget::updateStatus()
{
m_updateTrigger.start();
if (m_initialized) {
m_updateTrigger.start();
}
}
void GitWidget::slotUpdateStatus()
......
......@@ -45,8 +45,12 @@ public:
explicit GitWidget(KateProject *project, KTextEditor::MainWindow *mainWindow = nullptr, KateProjectPluginView *pluginView = nullptr);
~GitWidget() override;
void init();
bool eventFilter(QObject *o, QEvent *e) override;
void showEvent(QShowEvent *e) override;
/**
* Trigger the GitWidget to update itself.
* It is safe to call it repeatedly in a short time, due to delayed update after the last call.
......@@ -103,6 +107,7 @@ private:
KTextEditor::MainWindow *m_mainWin;
QMenu *m_gitMenu;
KateProjectPluginView *m_pluginView;
bool m_initialized = false;
QWidget *m_mainView;
QStackedWidget *m_stackWidget;
......
......@@ -14,7 +14,6 @@ class StashFilterModel;
class KActionCollection;
class QStandardItemModel;
class QProcess;
class GitWidget;
namespace KTextEditor
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment