File indexing completed on 2024-05-12 15:59:05
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef LIBKIS_EXTENSION_H 0008 #define LIBKIS_EXTENSION_H 0009 0010 #include "kritalibkis_export.h" 0011 0012 #include <QObject> 0013 #include <Window.h> 0014 0015 /** 0016 * An Extension is the base for classes that extend Krita. An Extension 0017 * is loaded on startup, when the setup() method will be executed. 0018 * 0019 * The extension instance should be added to the Krita Application object 0020 * using Krita.instance().addViewExtension or Application.addViewExtension 0021 * or Scripter.addViewExtension. 0022 * 0023 * Example: 0024 * 0025 * @code 0026 * import sys 0027 * from PyQt5.QtGui import * 0028 * from PyQt5.QtWidgets import * 0029 * from krita import * 0030 * class HelloExtension(Extension): 0031 * 0032 * def __init__(self, parent): 0033 * super().__init__(parent) 0034 * 0035 * def hello(self): 0036 * QMessageBox.information(QWidget(), "Test", "Hello! This is Krita " + Application.version()) 0037 * 0038 * def setup(self): 0039 * qDebug("Hello Setup") 0040 * 0041 * def createActions(self, window) 0042 * action = window.createAction("hello") 0043 * action.triggered.connect(self.hello) 0044 * 0045 * Scripter.addExtension(HelloExtension(Krita.instance())) 0046 * 0047 * @endcode 0048 */ 0049 class KRITALIBKIS_EXPORT Extension : public QObject 0050 { 0051 Q_OBJECT 0052 public: 0053 0054 /** 0055 * Create a new extension. The extension will be 0056 * owned by @p parent. 0057 */ 0058 explicit Extension(QObject *parent = 0); 0059 ~Extension() override; 0060 0061 /** 0062 * Override this function to setup your Extension. You can use it to integrate 0063 * with the Krita application instance. 0064 */ 0065 virtual void setup() = 0; 0066 0067 virtual void createActions(Window *window) = 0; 0068 0069 }; 0070 0071 0072 0073 0074 #endif