Krita Source Code Documentation
Loading...
Searching...
No Matches
DockWidget Class Referenceabstract

#include <DockWidget.h>

+ Inheritance diagram for DockWidget:

Public Member Functions

 DockWidget ()
 
 ~DockWidget () override
 
- Public Member Functions inherited from KoCanvasObserverBase
 KoCanvasObserverBase ()
 
KoCanvasBaseobservedCanvas () const
 
virtual QString observerName ()
 
void setObservedCanvas (KoCanvasBase *canvas)
 
void unsetObservedCanvas ()
 
virtual ~KoCanvasObserverBase ()
 

Protected Slots

Canvascanvas () const
 
virtual void canvasChanged (Canvas *canvas)=0
 canvasChanged is called whenever the current canvas is changed in the mainwindow this dockwidget instance is shown in.
 
void setCanvas (KoCanvasBase *canvas) override
 
void unsetCanvas () override
 

Private Attributes

Private *const d
 

Additional Inherited Members

- Protected Member Functions inherited from KoCanvasObserverBase
virtual void setCanvas (KoCanvasBase *canvas)=0
 
virtual void unsetCanvas ()=0
 

Detailed Description

DockWidget is the base class for custom Dockers. Dockers are created by a factory class which needs to be registered by calling Application.addDockWidgetFactory:

class HelloDocker(DockWidget):
def __init__(self):
super().__init__()
label = QLabel("Hello", self)
self.setWidget(label)
self.label = label
self.setWindowTitle("Hello Docker")
def canvasChanged(self, canvas):
self.label.setText("Hellodocker: canvas changed");
Application.addDockWidgetFactory(DockWidgetFactory("hello", DockWidgetFactoryBase.DockRight, HelloDocker))

One docker per window will be created, not one docker per canvas or view. When the user switches between views/canvases, canvasChanged will be called. You can override that method to reset your docker's internal state, if necessary.

Definition at line 42 of file DockWidget.h.

Constructor & Destructor Documentation

◆ DockWidget()

DockWidget::DockWidget ( )
explicit

Definition at line 19 of file DockWidget.cpp.

20 : QDockWidget()
21 , d(new Private)
22{
23}
Private *const d
Definition DockWidget.h:72

◆ ~DockWidget()

DockWidget::~DockWidget ( )
override

Definition at line 25 of file DockWidget.cpp.

26{
27 delete d;
28}

References d.

Member Function Documentation

◆ canvas

Canvas * DockWidget::canvas ( ) const
protectedslot

@return the canvas object that this docker is currently associated with

Definition at line 30 of file DockWidget.cpp.

31{
32 return d->canvas;
33}

References krita::DockWidget::Private::canvas, and d.

◆ canvasChanged

virtual void DockWidget::canvasChanged ( Canvas * canvas)
protectedpure virtualslot

canvasChanged is called whenever the current canvas is changed in the mainwindow this dockwidget instance is shown in.

Parameters
canvasThe new canvas.

◆ setCanvas

void DockWidget::setCanvas ( KoCanvasBase * canvas)
overrideprotectedslot

Definition at line 35 of file DockWidget.cpp.

36{
37 delete d->canvas;
38 d->canvas = new Canvas(canvas);
40}
Canvas * canvas() const
virtual void canvasChanged(Canvas *canvas)=0
canvasChanged is called whenever the current canvas is changed in the mainwindow this dockwidget inst...

References krita::DockWidget::Private::canvas, canvas(), canvasChanged(), and d.

◆ unsetCanvas

void DockWidget::unsetCanvas ( )
overrideprotectedslot

Definition at line 42 of file DockWidget.cpp.

43{
45 delete d->canvas;
46 d->canvas = 0;
47}

References krita::DockWidget::Private::canvas, canvasChanged(), and d.

Member Data Documentation

◆ d

Private* const DockWidget::d
private

Definition at line 72 of file DockWidget.h.


The documentation for this class was generated from the following files: