File indexing completed on 2024-05-19 04:26:58

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      * @brief dockers
0043      * @return a list of all the dockers belonging to this window
0044      */
0045     QList<QDockWidget *> dockers() const;
0046 
0047     /**
0048      * @return a list of open views in this window
0049      */
0050     QList<View*> views() const;
0051 
0052     /**
0053      * Open a new view on the given document in this window
0054      */
0055     View *addView(Document *document);
0056 
0057     /**
0058      * Make the given view active in this window. If the view
0059      * does not belong to this window, nothing happens.
0060      */
0061     void showView(View *view);
0062 
0063 
0064     /**
0065      * @return the currently active view or 0 if no view is active
0066      */
0067     View *activeView() const;
0068 
0069     /**
0070      * @brief activate activates this Window.
0071      */
0072     void activate();
0073 
0074     /**
0075      * @brief close the active window and all its Views. If there
0076      * are no Views left for a given Document, that Document will
0077      * also be closed.
0078      */
0079     void close();
0080 
0081     /**
0082      * @brief createAction creates a QAction object and adds it to the action
0083      * manager for this Window.
0084      * @param id The unique id for the action. This will be used to
0085      *     propertize the action if any .action file is present
0086      * @param text The user-visible text of the action. If empty, the text from the
0087      *    .action file is used.
0088      * @param menuLocation a /-separated string that describes which menu the action should
0089      *     be places in. Default is "tools/scripts"
0090      * @return the new action.
0091      */
0092     QAction *createAction(const QString &id, const QString &text = QString(), const QString &menuLocation = QString("tools/scripts"));
0093 
0094 Q_SIGNALS:
0095     /// Emitted when the window is closed.
0096     void windowClosed();
0097 
0098     ///  Emitted when we change the color theme
0099     void themeChanged();
0100 
0101     /// Emitted when the active view changes
0102     void activeViewChanged();
0103 
0104 private:
0105     struct Private;
0106     Private *const d;
0107 
0108 };
0109 
0110 #endif // LIBKIS_WINDOW_H