File indexing completed on 2024-05-05 05:52:18

0001 /*  This file is part of the Kate project.
0002  *
0003  *  SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 
0010 #include <KTextEditor/Editor>
0011 #include <KTextEditor/MainWindow>
0012 #include <KTextEditor/Plugin>
0013 
0014 #include "katesnippetglobal.h"
0015 
0016 class SnippetView;
0017 class KateSnippetsPluginView;
0018 
0019 class KateSnippetsPlugin : public KTextEditor::Plugin
0020 {
0021     Q_OBJECT
0022 
0023     friend class KateSnippetsPluginView;
0024 
0025 public:
0026     explicit KateSnippetsPlugin(QObject *parent = nullptr, const QVariantList & = QVariantList());
0027     ~KateSnippetsPlugin() override;
0028 
0029     QObject *createView(KTextEditor::MainWindow *mainWindow) override;
0030 
0031 private:
0032     KateSnippetGlobal *m_snippetGlobal;
0033 };
0034 
0035 class KateSnippetsPluginView : public QObject, public KXMLGUIClient
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     /**
0041      * Constructor.
0042      */
0043     KateSnippetsPluginView(KateSnippetsPlugin *plugin, KTextEditor::MainWindow *mainWindow);
0044 
0045     /**
0046      * Virtual destructor.
0047      */
0048     ~KateSnippetsPluginView() override;
0049 
0050     void readConfig();
0051 
0052 private Q_SLOTS:
0053     /**
0054      * New view got created, we need to update our connections
0055      * @param view new created view
0056      */
0057     void slotViewCreated(KTextEditor::View *view);
0058 
0059     void createSnippet();
0060 
0061 private:
0062     KateSnippetsPlugin *m_plugin;
0063     KTextEditor::MainWindow *m_mainWindow;
0064     QPointer<QWidget> m_toolView;
0065     SnippetView *m_snippets;
0066 
0067     /**
0068      * remember for which text views we might need to cleanup stuff
0069      */
0070     QList<QPointer<KTextEditor::View>> m_textViews;
0071 };