Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

KisViewManager.h 7.79 KB
Newer Older
1
/*
2
 *  Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

19 20
#ifndef KIS_GUI_CLIENT_H
#define KIS_GUI_CLIENT_H
21 22 23

#include <QDockWidget>
#include <QQueue>
24 25 26 27 28
#include <QPointer>

#include <KisMainWindow.h>
#include <KoToolManager.h>

29
#include <kritaui_export.h>
30
#include <kis_types.h>
31

32
#include "kis_floating_message.h"
33

34
class QPoint;
35
class KisView;
36

37
class KisCanvas2;
38
class KisCanvasResourceProvider;
39
class KisDocument;
40
class KisFilterManager;
41
class KisGridManager;
42
class KisGuidesManager;
43 44
class KisImageManager;
class KisNodeManager;
45
class KisDecorationsManager;
46
class KisPaintopBox;
47
class KisSelectionManager;
48
class KisStatusBar;
49 50
class KisUndoAdapter;
class KisZoomManager;
51
class KisPaintopBox;
52
class KisActionManager;
53
class KisInputManager;
54 55
class KoUpdater;
class KoProgressUpdater;
56

57
/**
58
 * KisViewManager manages the collection of views shown in a single mainwindow.
59
 */
60
class KRITAUI_EXPORT KisViewManager : public QObject
Boudewijn Rempt's avatar
Boudewijn Rempt committed
61
{
62

Boudewijn Rempt's avatar
Boudewijn Rempt committed
63
    Q_OBJECT
64 65

public:
66 67
    /**
     * Construct a new view on the krita document.
68 69
     * @param document   the document we show.
     * @param parent   a parent widget we show ourselves in.
70
     */
71
    KisViewManager(QWidget *parent, KActionCollection *actionCollection);
72
    ~KisViewManager() override;
73

74 75 76 77
    /**
     * Retrieves the entire action collection.
     */
    virtual KActionCollection* actionCollection() const;
78

79
public:  // Krita specific interfaces
80

81 82
    void setCurrentView(KisView *view);

83
    /// Return the image this view is displaying
Boudewijn Rempt's avatar
Boudewijn Rempt committed
84
    KisImageWSP image() const;
85

86 87
    KoZoomController *zoomController() const;

88 89
    /// The resource provider contains all per-view settings, such as
    /// current color, current paint op etc.
90
    KisCanvasResourceProvider *resourceProvider();
91

92
    /// Return the canvasbase class
93
    KisCanvas2 *canvasBase() const;
94

95
    /// Return the actual widget that is displaying the current image
96
    QWidget* canvas() const;
97

98
    /// Return the wrapper class around the statusbar
99
    KisStatusBar *statusBar() const;
100

101 102
    KisPaintopBox* paintOpBox() const;

103
    /// create a new progress updater
104 105
    QPointer<KoUpdater> createUnthreadedUpdater(const QString &name);
    QPointer<KoUpdater> createThreadedUpdater(const QString &name);
106

107
    /// The selection manager handles everything action related to
108
    /// selections.
Boudewijn Rempt's avatar
Boudewijn Rempt committed
109
    KisSelectionManager *selectionManager();
110

111
    /// The node manager handles everything about nodes
Boudewijn Rempt's avatar
Boudewijn Rempt committed
112
    KisNodeManager *nodeManager() const;
113

Boudewijn Rempt's avatar
Boudewijn Rempt committed
114
    KisActionManager *actionManager() const;
115 116 117 118 119 120 121

    /**
     * Convenience method to get at the active node, which may be
     * a layer or a mask or a selection
     */
    KisNodeSP activeNode();

Boudewijn Rempt's avatar
Boudewijn Rempt committed
122 123 124 125 126 127
    /// Convenience method to get at the active layer
    KisLayerSP activeLayer();

    /// Convenience method to get at the active paint device
    KisPaintDeviceSP activeDevice();

128
    /// The filtermanager handles everything action-related to filters
Boudewijn Rempt's avatar
Boudewijn Rempt committed
129
    KisFilterManager *filterManager();
130

Boudewijn Rempt's avatar
Boudewijn Rempt committed
131 132
    /// The image manager handles everything action-related to the
    /// current image
Boudewijn Rempt's avatar
Boudewijn Rempt committed
133
    KisImageManager *imageManager();
Boudewijn Rempt's avatar
Boudewijn Rempt committed
134

135
    /// Filters events and sends them to canvas actions
Boudewijn Rempt's avatar
Boudewijn Rempt committed
136
    KisInputManager *inputManager() const;
137

138 139 140 141 142
    /// Convenience method to get at the active selection (the
    /// selection of the current layer, or, if that does not exist,
    /// the global selection.
    KisSelectionSP selection();

143 144 145
    /// Checks if the current global or local selection is editable
    bool selectionEditable();

146
    /// The undo adapter is used to add commands to the undo stack
Boudewijn Rempt's avatar
Boudewijn Rempt committed
147
    KisUndoAdapter *undoAdapter();
148

Boudewijn Rempt's avatar
Boudewijn Rempt committed
149
    KisDocument *document() const;
Boudewijn Rempt's avatar
Boudewijn Rempt committed
150

151 152
    int viewCount() const;

153
    /**
154
     * @brief blockUntilOperationsFinished blocks the GUI of the application until execution
155 156 157 158 159
     *        of actions on \p image is finished
     * @param image the image which we should wait for
     * @return true if the image has finished execution of the actions, false if
     *         the user cancelled operation
     */
Boudewijn Rempt's avatar
Boudewijn Rempt committed
160
    bool blockUntilOperationsFinished(KisImageSP image);
161 162 163


    /**
164
     * @brief blockUntilOperationsFinished blocks the GUI of the application until execution
165 166 167 168
     *        of actions on \p image is finished. Does *not* provide a "Cancel" button. So the
     *        user is forced to wait.
     * @param image the image which we should wait for
     */
169
    void blockUntilOperationsFinishedForced(KisImageSP image);
170

171
public:
172

173
    KisGridManager * gridManager() const;
174
    KisGuidesManager * guidesManager() const;
175

176 177 178 179
    /// disable and enable toolbar controls. used for disabling them during painting.
    void enableControls();
    void disableControls();

180

181
    /// shows a floating message in the top right corner of the canvas
182
    void showFloatingMessage(const QString &message, const QIcon& icon, int timeout = 4500,
183 184
                             KisFloatingMessage::Priority priority = KisFloatingMessage::Medium,
                             int alignment = Qt::AlignCenter | Qt::TextWordWrap);
185

186 187 188
    /// @return the KoMaindow this view is in, or 0
    KisMainWindow *mainWindow() const;

189 190
    /// The QMainWindow associated with this view. This is most likely going to be shell(), but
    /// when running as Gemini or Sketch, this will be set to the applications' own QMainWindow.
191 192 193
    /// This can be checked by qobject_casting to KisMainWindow to check the difference.
    QMainWindow* qtMainWindow() const;

194 195 196 197
    /// The mainWindow function will return the shell() value, unless this function is called
    /// with a non-null value. To make it return shell() again, simply pass null to this function.
    void setQtMainWindow(QMainWindow* newMainWindow);

198 199
    static void initializeResourceManager(KoCanvasResourceManager *resourceManager);

200
public Q_SLOTS:
201

Boudewijn Rempt's avatar
Boudewijn Rempt committed
202
    void switchCanvasOnly(bool toggled);
203
    void setShowFloatingMessage(bool show);
204 205
    void showHideScrollbars();

206 207
    /// Visit all managers to update gui elements, e.g. enable / disable actions.
    /// This is heavy-duty call, so it uses a compressor.
208
    void updateGUI();
209

210 211 212
    /// Update the style of all the icons
    void updateIcons();

213 214 215
    void slotViewAdded(KisView *view);
    void slotViewRemoved(KisView *view);

216
Q_SIGNALS:
217

218
    void floatingMessageRequested(const QString &message, const QString &iconName);
219 220 221 222 223
    /**
     * @brief viewChanged
     * sent out when the view has changed.
     */
    void viewChanged();
224

225
private Q_SLOTS:
226

227
    void slotBlacklistCleanup();
228
    void slotCreateTemplate();
229
    void slotCreateCopy();
230
    void slotDocumentSaved();
231
    void slotSaveIncremental();
232
    void slotSaveIncrementalBackup();
Boudewijn Rempt's avatar
Boudewijn Rempt committed
233
    void showStatusBar(bool toggled);
234
    void toggleTabletLogger();
235
    void openResourcesDirectory();
236
    void initializeStatusBarVisibility();
237
    void guiUpdateTimeout();
238 239
    void changeAuthorProfile(const QString &profileName);
    void slotUpdateAuthorProfileActions();
240
    void slotUpdatePixelGridAction();
241 242
    void slotSaveShowRulersState(bool value);
    void slotSaveRulersTrackMouseState(bool value);
243

244
private:
245
    void createActions();
246
    void setupManagers();
247

248 249 250
    /// The zoommanager handles everything action-related to zooming
    KisZoomManager * zoomManager();

251
private:
252 253
    class KisViewManagerPrivate;
    KisViewManagerPrivate * const d;
254 255 256
};

#endif