Krita

Notifier.cpp
1 /*
2  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #include "Notifier.h"
7 #include <KisApplication.h>
8 #include <KisPart.h>
9 #include <kis_config_notifier.h>
10 #include "View.h"
11 #include "Window.h"
12 #include "Document.h"
13 
14 struct Notifier::Private {
15  Private() {}
16  bool active {true};
17 };
18 
19 Notifier::Notifier(QObject *parent)
20  : QObject(parent)
21  , d(new Private)
22 {
23  connect(qApp, SIGNAL(aboutToQuit()), SIGNAL(applicationClosing()));
24 
25  connect(KisPart::instance(), SIGNAL(sigDocumentAdded(KisDocument*)), SLOT(imageCreated(KisDocument*)));
26  connect(KisPart::instance(), SIGNAL(sigDocumentSaved(QString)), SIGNAL(imageSaved(QString)));
27  connect(KisPart::instance(), SIGNAL(sigDocumentRemoved(QString)), SIGNAL(imageClosed(QString)));
28 
29  connect(KisPart::instance(), SIGNAL(sigViewAdded(KisView*)), SLOT(viewCreated(KisView*)));
30  connect(KisPart::instance(), SIGNAL(sigViewRemoved(KisView*)), SLOT(viewClosed(KisView*)));
31 
32  connect(KisPart::instance(), SIGNAL(sigMainWindowIsBeingCreated(KisMainWindow*)), SLOT(windowIsBeingCreated(KisMainWindow*)));
33 
34  connect(KisPart::instance(), SIGNAL(sigMainWindowCreated()), SIGNAL(windowCreated()));
35 
36  connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SIGNAL(configurationChanged()));
37 
38  blockSignals(false);
39 }
40 
41 
42 Notifier::~Notifier()
43 {
44  delete d;
45 }
46 
47 bool Notifier::active() const
48 {
49  return d->active;
50 }
51 
52 void Notifier::setActive(bool value)
53 {
54  d->active = value;
55  blockSignals(!value);
56 }
57 
58 void Notifier::imageCreated(KisDocument* document)
59 {
60  Document *doc = new Document(document, false);
61  emit imageCreated(doc);
62  delete doc;
63 }
64 
65 void Notifier::viewCreated(KisView *view)
66 {
67  View *v = new View(view);
68  emit viewCreated(v);
69  delete v;
70 }
71 
72 void Notifier::viewClosed(KisView *view)
73 {
74  View *v = new View(view);
75  emit viewClosed(v);
76  delete v;
77 }
78 
79 void Notifier::windowIsBeingCreated(KisMainWindow *window)
80 {
81  Window *w = new Window(window);
82  emit windowIsBeingCreated(w);
83  delete w;
84 }
85 
void viewCreated(View *view)
viewCreated is emitted whenever a new view is created.
Window represents one Krita mainwindow.
Definition: Window.h:22
void imageCreated(Document *image)
imageCreated is emitted whenever a new image is created and registered with the application.
The Document class encapsulates a Krita Document/Image.
Definition: Document.h:33
View represents one view on a document.
Definition: View.h:24
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool blockSignals(bool block)
void setActive(bool value)
Enable or disable the Notifier.
Definition: Notifier.cpp:52
void viewClosed(View *view)
viewClosed is emitted whenever a view is closed
void windowIsBeingCreated(Window *window)
windowCreated is emitted whenever a window is being created
bool active() const
Definition: Notifier.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 04:08:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.