Krita

Notifier.cpp
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
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
14struct Notifier::Private {
15 Private() {}
16 bool active {true};
17};
18
19Notifier::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
42Notifier::~Notifier()
43{
44 delete d;
45}
46
47bool Notifier::active() const
48{
49 return d->active;
50}
51
52void Notifier::setActive(bool value)
53{
54 d->active = value;
55 blockSignals(!value);
56}
57
58void Notifier::imageCreated(KisDocument* document)
59{
60 Document *doc = new Document(document, false);
62 delete doc;
63}
64
65void Notifier::viewCreated(KisView *view)
66{
67 View *v = new View(view);
69 delete v;
70}
71
72void Notifier::viewClosed(KisView *view)
73{
74 View *v = new View(view);
76 delete v;
77}
78
79void Notifier::windowIsBeingCreated(KisMainWindow *window)
80{
81 Window *w = new Window(window);
83 delete w;
84}
85
The Document class encapsulates a Krita Document/Image.
Definition Document.h:37
bool active() const
Definition Notifier.cpp:47
void viewCreated(View *view)
viewCreated is emitted whenever a new view is created.
void imageCreated(Document *image)
imageCreated is emitted whenever a new image is created and registered with the application.
void viewClosed(View *view)
viewClosed is emitted whenever a view is closed
void setActive(bool value)
Enable or disable the Notifier.
Definition Notifier.cpp:52
void windowIsBeingCreated(Window *window)
windowCreated is emitted whenever a window is being created
View represents one view on a document.
Definition View.h:25
Window represents one Krita mainwindow.
Definition Window.h:23
Q_EMITQ_EMIT
bool blockSignals(bool block)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:13:07 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.