Krita Source Code Documentation
Loading...
Searching...
No Matches
Window Class Reference

#include <Window.h>

+ Inheritance diagram for Window:

Classes

struct  Private
 

Public Slots

void activate ()
 activate activates this Window.
 
ViewactiveView () const
 
ViewaddView (Document *document)
 
void close ()
 close the active window and all its Views. If there are no Views left for a given Document, that Document will also be closed.
 
QAction * createAction (const QString &id, const QString &text=QString(), const QString &menuLocation=QString("tools/scripts"))
 createAction creates a QAction object and adds it to the action manager for this Window.
 
QList< QDockWidget * > dockers () const
 dockers
 
QMainWindow * qwindow () const
 
void showView (View *v)
 
QList< View * > views () const
 

Signals

void activeViewChanged ()
 Emitted when the active view changes.
 
void themeChanged ()
 Emitted when we change the color theme.
 
void windowClosed ()
 Emitted when the window is closed.
 

Public Member Functions

bool operator!= (const Window &other) const
 
bool operator== (const Window &other) const
 
 Window (KisMainWindow *window, QObject *parent=0)
 
 ~Window () override
 

Private Attributes

Private *const d
 

Detailed Description

Window represents one Krita mainwindow. A window can have any number of views open on any number of documents.

Definition at line 22 of file Window.h.

Constructor & Destructor Documentation

◆ Window()

Window::Window ( KisMainWindow * window,
QObject * parent = 0 )
explicit

Definition at line 29 of file Window.cpp.

30 : QObject(parent)
31 , d(new Private)
32{
33 d->window = window;
34 connect(window, SIGNAL(destroyed(QObject*)), SIGNAL(windowClosed()));
35 connect(window, SIGNAL(themeChanged()), SIGNAL(themeChanged()));
36 connect(window, SIGNAL(activeViewChanged()), SIGNAL(activeViewChanged()));
37}
void themeChanged()
Emitted when we change the color theme.
void windowClosed()
Emitted when the window is closed.
Private *const d
Definition Window.h:106
void activeViewChanged()
Emitted when the active view changes.
QPointer< KisMainWindow > window
Definition Window.cpp:26

References activeViewChanged(), d, themeChanged(), Window::Private::window, and windowClosed().

◆ ~Window()

Window::~Window ( )
override

Definition at line 39 of file Window.cpp.

40{
41 delete d;
42}

References d.

Member Function Documentation

◆ activate

void Window::activate ( )
slot

activate activates this Window.

Definition at line 112 of file Window.cpp.

113{
114 if (d->window) {
115 d->window->activateWindow();
116 }
117}

References d, and Window::Private::window.

◆ activeView

View * Window::activeView ( ) const
slot
Returns
the currently active view or 0 if no view is active

Definition at line 104 of file Window.cpp.

105{
106 if (d->window) {
107 return new View(d->window->activeView());
108 }
109 return 0;
110}

References d, and Window::Private::window.

◆ activeViewChanged

void Window::activeViewChanged ( )
signal

Emitted when the active view changes.

◆ addView

View * Window::addView ( Document * document)
slot

Open a new view on the given document in this window

Definition at line 82 of file Window.cpp.

83{
84 if (d->window && document) {
85 // Once the document is shown in the ui, it's owned by Krita
86 // If the Document instance goes out of scope, it shouldn't
87 // delete the owned image.
88 document->setOwnsDocument(false);
89 KisView *view = d->window->newView(document->document());
90 return new View(view);
91 }
92 return 0;
93}

References d, and Window::Private::window.

◆ close

void Window::close ( )
slot

close the active window and all its Views. If there are no Views left for a given Document, that Document will also be closed.

Definition at line 119 of file Window.cpp.

120{
121 if (d->window) {
123 d->window->close();
124 }
125}
void removeMainWindow(KisMainWindow *mainWindow)
Definition KisPart.cpp:440
static KisPart * instance()
Definition KisPart.cpp:131

References d, KisPart::instance(), KisPart::removeMainWindow(), and Window::Private::window.

◆ createAction

QAction * Window::createAction ( const QString & id,
const QString & text = QString(),
const QString & menuLocation = QString("tools/scripts") )
slot

createAction creates a QAction object and adds it to the action manager for this Window.

Parameters
idThe unique id for the action. This will be used to propertize the action if any .action file is present
textThe user-visible text of the action. If empty, the text from the .action file is used.
menuLocationa /-separated string that describes which menu the action should be places in. Default is "tools/scripts"
Returns
the new action.

Definition at line 128 of file Window.cpp.

129{
130 KisAction *action = d->window->viewManager()->actionManager()->createAction(id);
131 if (!text.isEmpty()) {
132 action->setText(text);
133 }
134 action->setObjectName(id);
135 action->setProperty("menulocation", menuLocation);
136 return action;
137}

References d, and Window::Private::window.

◆ dockers

QList< QDockWidget * > Window::dockers ( ) const
slot

dockers

Returns
a list of all the dockers belonging to this window

Definition at line 59 of file Window.cpp.

60{
61 KisMainWindow *mainWindow = d->window;
62
63 if (!mainWindow) return {};
64
65 return mainWindow->dockWidgets();
66}
Main window for Krita.
QList< QDockWidget * > dockWidgets() const
Return the list of dock widgets belonging to this main window.

References d, KisMainWindow::dockWidgets(), and Window::Private::window.

◆ operator!=()

bool Window::operator!= ( const Window & other) const

Definition at line 49 of file Window.cpp.

50{
51 return !(operator==(other));
52}
bool operator==(const Window &other) const
Definition Window.cpp:44

References operator==().

◆ operator==()

bool Window::operator== ( const Window & other) const

Definition at line 44 of file Window.cpp.

45{
46 return (d->window == other.d->window);
47}

References d, and Window::Private::window.

◆ qwindow

QMainWindow * Window::qwindow ( ) const
slot

Return a handle to the QMainWindow widget. This is useful to e.g. parent dialog boxes and message box.

Definition at line 54 of file Window.cpp.

55{
56 return d->window;
57}

References d, and Window::Private::window.

◆ showView

void Window::showView ( View * v)
slot

Make the given view active in this window. If the view does not belong to this window, nothing happens.

Definition at line 95 of file Window.cpp.

96{
97 if (v && v->view()) {
98 KisView *view = v->view();
99 view->setVisible(true);
100 d->window->setActiveView(view);
101 }
102}
qreal v

References d, v, and Window::Private::window.

◆ themeChanged

void Window::themeChanged ( )
signal

Emitted when we change the color theme.

◆ views

QList< View * > Window::views ( ) const
slot
Returns
a list of open views in this window

Definition at line 68 of file Window.cpp.

69{
70 QList<View *> ret;
71 if (d->window) {
72 foreach(QPointer<KisView> view, KisPart::instance()->views()) {
73 if (view->mainWindow() == d->window) {
74 ret << new View(view);
75 }
76 }
77 }
78 return ret;
79
80}
QList< View * > views() const
Definition Window.cpp:68

References d, KisPart::instance(), views(), and Window::Private::window.

◆ windowClosed

void Window::windowClosed ( )
signal

Emitted when the window is closed.

Member Data Documentation

◆ d

Private* const Window::d
private

Definition at line 106 of file Window.h.


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