36ede44f.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. From 36ede44fc7bef479e94f76121309a900bee2b29f Mon Sep 17 00:00:00 2001
  2. From: Christoph Cullmann <cullmann@kde.org>
  3. Date: Mon, 16 May 2022 19:49:02 +0200
  4. Subject: [PATCH] Revert "Create filebrowser on demand"
  5. This reverts commit 7caed2681d18d9ea08c35f160e88fb44a2e52769.
  6. BUG: 453795
  7. revert full lazy loading, doesn't work this way
  8. ---
  9. addons/filebrowser/katefilebrowser.cpp | 2 -
  10. addons/filebrowser/katefilebrowserplugin.cpp | 41 ++++++--------------
  11. addons/filebrowser/katefilebrowserplugin.h | 14 +++----
  12. 3 files changed, 18 insertions(+), 39 deletions(-)
  13. diff --git a/addons/filebrowser/katefilebrowser.cpp b/addons/filebrowser/katefilebrowser.cpp
  14. index 54c1fa1fb..a1e5e4eba 100644
  15. --- a/addons/filebrowser/katefilebrowser.cpp
  16. +++ b/addons/filebrowser/katefilebrowser.cpp
  17. @@ -115,8 +115,6 @@ KateFileBrowser::KateFileBrowser(KTextEditor::MainWindow *mainWindow, QWidget *p
  18. connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, &KateFileBrowser::autoSyncFolder);
  19. connect(m_dirOperator, &KDirOperator::contextMenuAboutToShow, this, &KateFileBrowser::contextMenuAboutToShow);
  20. -
  21. - autoSyncFolder();
  22. }
  23. KateFileBrowser::~KateFileBrowser()
  24. diff --git a/addons/filebrowser/katefilebrowserplugin.cpp b/addons/filebrowser/katefilebrowserplugin.cpp
  25. index f03c78698..3e415b025 100644
  26. --- a/addons/filebrowser/katefilebrowserplugin.cpp
  27. +++ b/addons/filebrowser/katefilebrowserplugin.cpp
  28. @@ -52,10 +52,7 @@ KTextEditor::ConfigPage *KateFileBrowserPlugin::configPage(int number, QWidget *
  29. if (number != 0) {
  30. return nullptr;
  31. }
  32. - if (!m_views[0]->m_fileBrowser) {
  33. - m_views[0]->createFileBrowser(true);
  34. - }
  35. - return new KateFileBrowserConfigPage(parent, m_views[0]->m_fileBrowser.get());
  36. + return new KateFileBrowserConfigPage(parent, m_views[0]->m_fileBrowser);
  37. }
  38. // END KateFileBrowserPlugin
  39. @@ -67,50 +64,34 @@ KateFileBrowserPluginView::KateFileBrowserPluginView(KTextEditor::Plugin *plugin
  40. KTextEditor::MainWindow::Left,
  41. QIcon::fromTheme(QStringLiteral("document-open")),
  42. i18n("Filesystem")))
  43. + , m_fileBrowser(new KateFileBrowser(mainWindow, m_toolView))
  44. , m_mainWindow(mainWindow)
  45. {
  46. m_toolView->installEventFilter(this);
  47. - connect(m_toolView.get(), SIGNAL(toolVisibleChanged(bool)), this, SLOT(createFileBrowser(bool)));
  48. }
  49. -void KateFileBrowserPluginView::readSessionConfig(const KConfigGroup &config)
  50. +KateFileBrowserPluginView::~KateFileBrowserPluginView()
  51. {
  52. - if (m_fileBrowser) {
  53. - m_fileBrowser->readSessionConfig(config);
  54. - } else {
  55. - cg.reset(new KConfigGroup(config));
  56. - }
  57. + // cleanup, kill toolview + console
  58. + delete m_fileBrowser->parentWidget();
  59. }
  60. -void KateFileBrowserPluginView::writeSessionConfig(KConfigGroup &config)
  61. +void KateFileBrowserPluginView::readSessionConfig(const KConfigGroup &config)
  62. {
  63. - if (m_fileBrowser) {
  64. - m_fileBrowser->writeSessionConfig(config);
  65. - }
  66. + m_fileBrowser->readSessionConfig(config);
  67. }
  68. -void KateFileBrowserPluginView::createFileBrowser(bool visible)
  69. +void KateFileBrowserPluginView::writeSessionConfig(KConfigGroup &config)
  70. {
  71. - if (!visible) {
  72. - return;
  73. - }
  74. -
  75. - // we must not have a filebrowser
  76. - Q_ASSERT(!m_fileBrowser);
  77. -
  78. - disconnect(m_toolView.get(), SIGNAL(toolVisibleChanged(bool)), this, SLOT(createFileBrowser(bool)));
  79. - m_fileBrowser = std::make_unique<KateFileBrowser>(m_mainWindow, m_toolView.get());
  80. - m_fileBrowser->readSessionConfig(*cg);
  81. - // delete the config now
  82. - cg.reset();
  83. + m_fileBrowser->writeSessionConfig(config);
  84. }
  85. bool KateFileBrowserPluginView::eventFilter(QObject *obj, QEvent *event)
  86. {
  87. if (event->type() == QEvent::KeyPress) {
  88. QKeyEvent *ke = static_cast<QKeyEvent *>(event);
  89. - if ((obj == m_toolView.get()) && (ke->key() == Qt::Key_Escape)) {
  90. - m_mainWindow->hideToolView(m_toolView.get());
  91. + if ((obj == m_toolView) && (ke->key() == Qt::Key_Escape)) {
  92. + m_mainWindow->hideToolView(m_toolView);
  93. event->accept();
  94. return true;
  95. }
  96. diff --git a/addons/filebrowser/katefilebrowserplugin.h b/addons/filebrowser/katefilebrowserplugin.h
  97. index 2517d3453..9fb6610c4 100644
  98. --- a/addons/filebrowser/katefilebrowserplugin.h
  99. +++ b/addons/filebrowser/katefilebrowserplugin.h
  100. @@ -11,15 +11,12 @@
  101. #ifndef KATE_FILEBROWSER_PLUGIN_H
  102. #define KATE_FILEBROWSER_PLUGIN_H
  103. -#include <KConfigGroup>
  104. #include <KTextEditor/SessionConfigInterface>
  105. #include <ktexteditor/configpage.h>
  106. #include <ktexteditor/document.h>
  107. #include <ktexteditor/mainwindow.h>
  108. #include <ktexteditor/plugin.h>
  109. -#include <memory>
  110. -
  111. class KateFileBrowser;
  112. class KateFileBrowserPluginView;
  113. @@ -56,16 +53,19 @@ public:
  114. */
  115. KateFileBrowserPluginView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow);
  116. + /**
  117. + * Virtual destructor.
  118. + */
  119. + ~KateFileBrowserPluginView() override;
  120. +
  121. void readSessionConfig(const KConfigGroup &config) override;
  122. void writeSessionConfig(KConfigGroup &config) override;
  123. private:
  124. bool eventFilter(QObject *, QEvent *) override;
  125. - Q_SLOT void createFileBrowser(bool visible);
  126. - std::unique_ptr<QWidget> m_toolView;
  127. - std::unique_ptr<KateFileBrowser> m_fileBrowser = nullptr;
  128. - std::unique_ptr<KConfigGroup> cg;
  129. + QWidget *m_toolView;
  130. + KateFileBrowser *m_fileBrowser;
  131. KTextEditor::MainWindow *m_mainWindow;
  132. friend class KateFileBrowserPlugin;
  133. };
  134. --
  135. GitLab