File indexing completed on 2024-04-28 11:20:48

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2010 Alexander Rieder <alexanderrieder@gmail.com>
0004 */
0005 
0006 #ifndef _PANEL_PLUGIN_H
0007 #define _PANEL_PLUGIN_H
0008 
0009 #include <QObject>
0010 class KPluginMetaData;
0011 
0012 #include "backend.h"
0013 
0014 #include "cantor_export.h"
0015 
0016 namespace Cantor
0017 {
0018 class Session;
0019 class PanelPluginPrivate;
0020 
0021 /**
0022  * A plugin provides some additional features for the worksheet
0023  */
0024 class CANTOR_EXPORT PanelPlugin : public QObject
0025 {
0026   Q_OBJECT
0027   public:
0028     struct State {
0029         Session* session{nullptr};
0030         QVector<QVariant> inners;
0031     };
0032 
0033 
0034     /**
0035      * Create a new PanelPlugin
0036      * @param parent the parent Object @see QObject
0037      **/
0038     PanelPlugin( QObject* parent );
0039     /**
0040      * Destructor
0041      */
0042     ~PanelPlugin() override;
0043 
0044     /**
0045      * Sets the properties of this PanelPlugin
0046      * according to KPluginMetaData
0047      * @param info KPluginMetaData
0048      */
0049     void setPluginInfo(const KPluginMetaData&);
0050 
0051     /**
0052      * Returns a list of all extensions, the current backend
0053      * must provide to make this PanelPlugin work. If it doesn't
0054      * this PanelPlugin won't be enabled
0055      * @return list of required extensions
0056     */
0057     QStringList requiredExtensions();
0058 
0059 
0060     /**
0061      * Returns the capabilities, the current backend
0062      * must provide to make this PanelPlugin work. If it doesn't
0063      * this PanelPlugin won't be enabled
0064      * @return the required capabilities
0065     */
0066     virtual Backend::Capabilities requiredCapabilities();
0067 
0068 
0069     /**
0070      * Returns the name of the plugin
0071      * @return name of the plugin
0072      */
0073     QString name();
0074 
0075     /**
0076      * returns the widget, provided by this plugin
0077      * @return the widget, provided by this plugin
0078      **/
0079     virtual QWidget* widget() = 0;
0080 
0081     void setParentWidget(QWidget* widget);
0082     QWidget* parentWidget();
0083 
0084     /**
0085      * Save state of panel to storable form
0086      *
0087      **/
0088     virtual State saveState();
0089 
0090     /**
0091      * Restore state
0092      * Can contains only session - this is init state from Cantor shell
0093      */
0094     virtual void restoreState(const State& state);
0095 
0096     /**
0097      * For proper connection to Cantor shell. All connections should be done here
0098      */
0099     virtual void connectToShell(QObject* cantorShell);
0100 
0101     /**
0102      * Show on worksheet startup or not
0103      * Default returns true
0104      */
0105     virtual bool showOnStartup();
0106 
0107   protected:
0108     Session* session();
0109 
0110   Q_SIGNALS:
0111     void requestRunCommand(const QString& cmd);
0112     void visibilityRequested();
0113 
0114   private:
0115     PanelPluginPrivate* d;
0116 };
0117 
0118 }
0119 
0120 #endif /* _PANEL_PLUGIN_H */