File indexing completed on 2024-05-19 05:42:27

0001 // ct_lvtqtw_plugineditor.h                                             -*-C++-*-
0002 
0003 /*
0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk>
0005 // SPDX-License-Identifier: Apache-2.0
0006 //
0007 // Licensed under the Apache License, Version 2.0 (the "License");
0008 // you may not use this file except in compliance with the License.
0009 // You may obtain a copy of the License at
0010 //
0011 //     http://www.apache.org/licenses/LICENSE-2.0
0012 //
0013 // Unless required by applicable law or agreed to in writing, software
0014 // distributed under the License is distributed on an "AS IS" BASIS,
0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 // See the License for the specific language governing permissions and
0017 // limitations under the License.
0018 */
0019 
0020 #ifndef INCLUDED_LVTQTW_PLUGINEDITOR
0021 #define INCLUDED_LVTQTW_PLUGINEDITOR
0022 
0023 #include <QDir>
0024 #include <QWidget>
0025 
0026 #include <memory>
0027 
0028 #include <lvtqtw_export.h>
0029 #include <result/result.hpp>
0030 
0031 #include <result/result.hpp>
0032 
0033 namespace Codethink::lvtplg {
0034 class PluginManager;
0035 }
0036 
0037 namespace Codethink::lvtqtw {
0038 
0039 class LVTQTW_EXPORT PluginEditor : public QWidget {
0040     Q_OBJECT
0041   public:
0042     PluginEditor(QWidget *parent = 0);
0043     ~PluginEditor();
0044 
0045     enum class e_Errors {
0046         Error,
0047     };
0048 
0049     struct Error {
0050         e_Errors errNr;
0051         std::string errStr;
0052     };
0053 
0054     Q_SIGNAL void execute(const QString& plugin);
0055     Q_SIGNAL void sendErrorMsg(const QString& err);
0056 
0057     void setPluginManager(lvtplg::PluginManager *manager);
0058     cpp::result<void, Error> save();
0059     void close();
0060     void loadByPath(const QString& pluginPath);
0061     void load();
0062     void reloadPlugin();
0063 
0064     // Used for testing purposes. defaults to ~/lks-plugins
0065     void setBasePluginPath(const QString& path);
0066     QDir basePluginPath();
0067 
0068     void requestCreatePythonPlugin();
0069 
0070     // TODO: Move this to lvtplg
0071     void createPythonPlugin(const QString& pluginPath);
0072 
0073   private:
0074     struct Private;
0075     std::unique_ptr<Private> d;
0076 };
0077 
0078 } // namespace Codethink::lvtqtw
0079 #endif