File indexing completed on 2024-05-12 15:59:09

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 #ifndef LIBKIS_WINDOW_H
0007 #define LIBKIS_WINDOW_H
0008 
0009 #include <QObject>
0010 #include <QAction>
0011 #include <QMainWindow>
0012 
0013 #include "kritalibkis_export.h"
0014 #include "libkis.h"
0015 
0016 class KisMainWindow;
0017 
0018 /**
0019  * Window represents one Krita mainwindow. A window can have any number
0020  * of views open on any number of documents.
0021  */
0022 class KRITALIBKIS_EXPORT Window : public QObject
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit Window(KisMainWindow *window, QObject *parent = 0);
0028     ~Window() override;
0029 
0030     bool operator==(const Window &other) const;
0031     bool operator!=(const Window &other) const;
0032 
0033 public Q_SLOTS:
0034 
0035     /**
0036      * Return a handle to the QMainWindow widget. This is useful
0037      * to e.g. parent dialog boxes and message box.
0038      */
0039     QMainWindow *qwindow() const;
0040 
0041     /**
0042      * @return a list of open views in this window
0043      */
0044     QList<View*> views() const;
0045 
0046     /**
0047      * Open a new view on the given document in this window
0048      */
0049     View *addView(Document *document);
0050 
0051     /**
0052      * Make the given view active in this window. If the view
0053      * does not belong to this window, nothing happens.
0054      */
0055     void showView(View *view);
0056 
0057 
0058     /**
0059      * @return the currently active view or 0 if no view is active
0060      */
0061     View *activeView() const;
0062 
0063     /**
0064      * @brief activate activates this Window.
0065      */
0066     void activate();
0067 
0068     /**
0069      * @brief close the active window and all its Views. If there
0070      * are no Views left for a given Document, that Document will
0071      * also be closed.
0072      */
0073     void close();
0074 
0075     /**
0076      * @brief createAction creates a QAction object and adds it to the action
0077      * manager for this Window.
0078      * @param id The unique id for the action. This will be used to
0079      *     propertize the action if any .action file is present
0080      * @param text The user-visible text of the action. If empty, the text from the
0081      *    .action file is used.
0082      * @param menuLocation a /-separated string that describes which menu the action should
0083      *     be places in. Default is "tools/scripts"
0084      * @return the new action.
0085      */
0086     QAction *createAction(const QString &id, const QString &text = QString(), const QString &menuLocation = QString("tools/scripts"));
0087 
0088 Q_SIGNALS:
0089     /// Emitted when the window is closed.
0090     void windowClosed();
0091 
0092     ///  Emitted when we change the color theme
0093     void themeChanged();
0094 
0095     /// Emitted when the active view changes
0096     void activeViewChanged();
0097 
0098 private:
0099     struct Private;
0100     Private *const d;
0101 
0102 };
0103 
0104 #endif // LIBKIS_WINDOW_H