Krita

DockWidget.h
1 /*
2  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #ifndef LIBKIS_DOCKWIDGET_H
7 #define LIBKIS_DOCKWIDGET_H
8 
9 #include <QDockWidget>
10 
11 #include "kritalibkis_export.h"
12 #include "libkis.h"
13 
14 #include <KoCanvasObserverBase.h>
15 
16 class KoCanvasBase;
17 
18 /**
19  * DockWidget is the base class for custom Dockers. Dockers are created by a
20  * factory class which needs to be registered by calling Application.addDockWidgetFactory:
21  *
22  * @code
23  * class HelloDocker(DockWidget):
24  * def __init__(self):
25  * super().__init__()
26  * label = QLabel("Hello", self)
27  * self.setWidget(label)
28  * self.label = label
29  * self.setWindowTitle("Hello Docker")
30  *
31  * def canvasChanged(self, canvas):
32  * self.label.setText("Hellodocker: canvas changed");
33  *
34  * Application.addDockWidgetFactory(DockWidgetFactory("hello", DockWidgetFactoryBase.DockRight, HelloDocker))
35  *
36  * @endcode
37  *
38  * One docker per window will be created, not one docker per canvas or view. When the user
39  * switches between views/canvases, canvasChanged will be called. You can override that
40  * method to reset your docker's internal state, if necessary.
41  */
42 class KRITALIBKIS_EXPORT DockWidget : public QDockWidget, public KoCanvasObserverBase
43 {
44  Q_OBJECT
46 
47 public:
48  explicit DockWidget();
49  ~DockWidget() override;
50 
51 protected Q_SLOTS: // Krita API
52 
53  void setCanvas(KoCanvasBase* canvas) override;
54  void unsetCanvas() override;
55 
56 protected Q_SLOTS: // PyKrita API
57 
58  /**
59  * @@return the canvas object that this docker is currently associated with
60  */
61  Canvas* canvas() const;
62 
63  /**
64  * @brief canvasChanged is called whenever the current canvas is changed
65  * in the mainwindow this dockwidget instance is shown in.
66  * @param canvas The new canvas.
67  */
68  virtual void canvasChanged(Canvas *canvas) = 0;
69 
70 private:
71  struct Private;
72  Private *const d;
73 
74 };
75 
76 #endif // LIBKIS_DOCKWIDGET_H
Q_SLOTSQ_SLOTS
DockWidget is the base class for custom Dockers.
Definition: DockWidget.h:42
Canvas wraps the canvas inside a view on an image/document.
Definition: Canvas.h:22
Q_DISABLE_COPY(Class)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:58:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.