Commit 5bd52a55 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

Revert "Create filebrowser on demand"

This reverts commit 7caed268.
parent 2c2ec073
Pipeline #177304 passed with stage
in 19 minutes and 50 seconds
......@@ -52,10 +52,7 @@ KTextEditor::ConfigPage *KateFileBrowserPlugin::configPage(int number, QWidget *
if (number != 0) {
return nullptr;
}
if (!m_views[0]->m_fileBrowser) {
m_views[0]->createFileBrowser(true);
}
return new KateFileBrowserConfigPage(parent, m_views[0]->m_fileBrowser.get());
return new KateFileBrowserConfigPage(parent, m_views[0]->m_fileBrowser);
}
// END KateFileBrowserPlugin
......@@ -67,50 +64,34 @@ KateFileBrowserPluginView::KateFileBrowserPluginView(KTextEditor::Plugin *plugin
KTextEditor::MainWindow::Left,
QIcon::fromTheme(QStringLiteral("document-open")),
i18n("Filesystem")))
, m_fileBrowser(new KateFileBrowser(mainWindow, m_toolView))
, m_mainWindow(mainWindow)
{
m_toolView->installEventFilter(this);
connect(m_toolView.get(), SIGNAL(toolVisibleChanged(bool)), this, SLOT(createFileBrowser(bool)));
}
void KateFileBrowserPluginView::readSessionConfig(const KConfigGroup &config)
KateFileBrowserPluginView::~KateFileBrowserPluginView()
{
if (m_fileBrowser) {
m_fileBrowser->readSessionConfig(config);
} else {
cg.reset(new KConfigGroup(config));
}
// cleanup, kill toolview + console
delete m_fileBrowser->parentWidget();
}
void KateFileBrowserPluginView::writeSessionConfig(KConfigGroup &config)
void KateFileBrowserPluginView::readSessionConfig(const KConfigGroup &config)
{
if (m_fileBrowser) {
m_fileBrowser->writeSessionConfig(config);
}
m_fileBrowser->readSessionConfig(config);
}
void KateFileBrowserPluginView::createFileBrowser(bool visible)
void KateFileBrowserPluginView::writeSessionConfig(KConfigGroup &config)
{
if (!visible) {
return;
}
// we must not have a filebrowser
Q_ASSERT(!m_fileBrowser);
disconnect(m_toolView.get(), SIGNAL(toolVisibleChanged(bool)), this, SLOT(createFileBrowser(bool)));
m_fileBrowser = std::make_unique<KateFileBrowser>(m_mainWindow, m_toolView.get());
m_fileBrowser->readSessionConfig(*cg);
// delete the config now
cg.reset();
m_fileBrowser->writeSessionConfig(config);
}
bool KateFileBrowserPluginView::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if ((obj == m_toolView.get()) && (ke->key() == Qt::Key_Escape)) {
m_mainWindow->hideToolView(m_toolView.get());
if ((obj == m_toolView) && (ke->key() == Qt::Key_Escape)) {
m_mainWindow->hideToolView(m_toolView);
event->accept();
return true;
}
......
......@@ -11,15 +11,12 @@
#ifndef KATE_FILEBROWSER_PLUGIN_H
#define KATE_FILEBROWSER_PLUGIN_H
#include <KConfigGroup>
#include <KTextEditor/SessionConfigInterface>
#include <ktexteditor/configpage.h>
#include <ktexteditor/document.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/plugin.h>
#include <memory>
class KateFileBrowser;
class KateFileBrowserPluginView;
......@@ -56,16 +53,19 @@ public:
*/
KateFileBrowserPluginView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow);
/**
* Virtual destructor.
*/
~KateFileBrowserPluginView() override;
void readSessionConfig(const KConfigGroup &config) override;
void writeSessionConfig(KConfigGroup &config) override;
private:
bool eventFilter(QObject *, QEvent *) override;
Q_SLOT void createFileBrowser(bool visible);
std::unique_ptr<QWidget> m_toolView;
std::unique_ptr<KateFileBrowser> m_fileBrowser = nullptr;
std::unique_ptr<KConfigGroup> cg;
QWidget *m_toolView;
KateFileBrowser *m_fileBrowser;
KTextEditor::MainWindow *m_mainWindow;
friend class KateFileBrowserPlugin;
};
......
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