File indexing completed on 2024-05-12 15:59:07
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "Notifier.h" 0007 #include <KisApplication.h> 0008 #include <KisPart.h> 0009 #include <kis_config_notifier.h> 0010 #include "View.h" 0011 #include "Window.h" 0012 #include "Document.h" 0013 0014 struct Notifier::Private { 0015 Private() {} 0016 bool active {true}; 0017 }; 0018 0019 Notifier::Notifier(QObject *parent) 0020 : QObject(parent) 0021 , d(new Private) 0022 { 0023 connect(qApp, SIGNAL(aboutToQuit()), SIGNAL(applicationClosing())); 0024 0025 connect(KisPart::instance(), SIGNAL(sigDocumentAdded(KisDocument*)), SLOT(imageCreated(KisDocument*))); 0026 connect(KisPart::instance(), SIGNAL(sigDocumentSaved(QString)), SIGNAL(imageSaved(QString))); 0027 connect(KisPart::instance(), SIGNAL(sigDocumentRemoved(QString)), SIGNAL(imageClosed(QString))); 0028 0029 connect(KisPart::instance(), SIGNAL(sigViewAdded(KisView*)), SLOT(viewCreated(KisView*))); 0030 connect(KisPart::instance(), SIGNAL(sigViewRemoved(KisView*)), SLOT(viewClosed(KisView*))); 0031 0032 connect(KisPart::instance(), SIGNAL(sigMainWindowIsBeingCreated(KisMainWindow*)), SLOT(windowIsBeingCreated(KisMainWindow*))); 0033 0034 connect(KisPart::instance(), SIGNAL(sigMainWindowCreated()), SIGNAL(windowCreated())); 0035 0036 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SIGNAL(configurationChanged())); 0037 0038 blockSignals(false); 0039 } 0040 0041 0042 Notifier::~Notifier() 0043 { 0044 delete d; 0045 } 0046 0047 bool Notifier::active() const 0048 { 0049 return d->active; 0050 } 0051 0052 void Notifier::setActive(bool value) 0053 { 0054 d->active = value; 0055 blockSignals(!value); 0056 } 0057 0058 void Notifier::imageCreated(KisDocument* document) 0059 { 0060 Document *doc = new Document(document, false); 0061 emit imageCreated(doc); 0062 delete doc; 0063 } 0064 0065 void Notifier::viewCreated(KisView *view) 0066 { 0067 View *v = new View(view); 0068 emit viewCreated(v); 0069 delete v; 0070 } 0071 0072 void Notifier::viewClosed(KisView *view) 0073 { 0074 View *v = new View(view); 0075 emit viewClosed(v); 0076 delete v; 0077 } 0078 0079 void Notifier::windowIsBeingCreated(KisMainWindow *window) 0080 { 0081 Window *w = new Window(window); 0082 emit windowIsBeingCreated(w); 0083 delete w; 0084 } 0085