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 #ifndef LIBKIS_NOTIFIER_H
0007 #define LIBKIS_NOTIFIER_H
0008 
0009 #include <QObject>
0010 
0011 #include "kritalibkis_export.h"
0012 #include <kis_types.h>
0013 #include "libkis.h"
0014 #include <KisView.h>
0015 
0016 class KisMainWindow;
0017 class KisDocument;
0018 
0019 /**
0020  * The Notifier can be used to be informed of state changes in the Krita application.
0021  */
0022 class KRITALIBKIS_EXPORT Notifier : public QObject
0023 {
0024     Q_OBJECT
0025     Q_DISABLE_COPY(Notifier)
0026 
0027     Q_PROPERTY(bool Active READ active WRITE setActive)
0028 
0029 public:
0030     explicit Notifier(QObject *parent = 0);
0031     ~Notifier() override;
0032 
0033     /**
0034      * @return true if the Notifier is active.
0035      */
0036     bool active() const;
0037     
0038     /**
0039      * Enable or disable the Notifier
0040      */
0041     void setActive(bool value);
0042 
0043 Q_SIGNALS:
0044 
0045     /**
0046      * @brief applicationClosing is emitted when the application is about to close. This
0047      * happens after any documents and windows are closed.
0048      */
0049     void applicationClosing();
0050 
0051     /**
0052      * @brief imageCreated is emitted whenever a new image is created and registered with
0053      * the application.
0054      */
0055     void imageCreated(Document *image);
0056 
0057     /**
0058      * @brief imageSaved is emitted whenever a document is saved.
0059      * @param filename the filename of the document that has been saved.
0060      */
0061     void imageSaved(const QString &filename);
0062 
0063     /**
0064      * @brief imageClosed is emitted whenever the last view on an image is closed. The image
0065      * does not exist anymore in Krita
0066      * @param filename the filename of the image.
0067      */
0068     void imageClosed(const QString &filename);
0069 
0070     /**
0071      * @brief viewCreated is emitted whenever a new view is created.
0072      * @param view the view
0073      */
0074     void viewCreated(View *view);
0075 
0076     /**
0077      * @brief viewClosed is emitted whenever a view is closed
0078      * @param view the view
0079      */
0080     void viewClosed(View *view);
0081 
0082     /**
0083      * @brief windowCreated is emitted whenever a window is being created
0084      * @param window the window; this is called from the constructor of the window, before the xmlgui file is loaded
0085      */
0086     void windowIsBeingCreated(Window *window);
0087 
0088     /**
0089      * @brief windowIsCreated is emitted after main window is completely created
0090      */
0091     void windowCreated();
0092 
0093     /**
0094      * @brief configurationChanged is emitted every time Krita's configuration
0095      * has changed.
0096      */
0097     void configurationChanged();
0098 
0099 private Q_SLOTS:
0100 
0101     void imageCreated(KisDocument *document);
0102 
0103     void viewCreated(KisView *view);
0104     void viewClosed(KisView *view);
0105 
0106     void windowIsBeingCreated(KisMainWindow *window);
0107 
0108 
0109 private:
0110     struct Private;
0111     Private *const d;
0112 
0113 };
0114 
0115 #endif // LIBKIS_NOTIFIER_H