File indexing completed on 2024-05-12 16:01:57
0001 /* 0002 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_GUI_CLIENT_H 0008 #define KIS_GUI_CLIENT_H 0009 0010 #include <QDockWidget> 0011 #include <QQueue> 0012 #include <QPointer> 0013 0014 #include <KoToolManager.h> 0015 0016 #include <kritaui_export.h> 0017 #include <kis_types.h> 0018 0019 #include "kis_floating_message.h" 0020 0021 class QPoint; 0022 class KisView; 0023 0024 class KisCanvas2; 0025 class KisCanvasResourceProvider; 0026 class KisDocument; 0027 class KisFilterManager; 0028 class KisGridManager; 0029 class KisGuidesManager; 0030 class KisImageManager; 0031 class KisNodeManager; 0032 class KisDecorationsManager; 0033 class KisPaintopBox; 0034 class KisSelectionManager; 0035 class KisStatusBar; 0036 class KisUndoAdapter; 0037 class KisZoomManager; 0038 class KisPaintopBox; 0039 class KisActionManager; 0040 class KisInputManager; 0041 class KoUpdater; 0042 class KoProgressUpdater; 0043 class KisMainWindow; 0044 class KoZoomController; 0045 class KoCanvasResourceProvider; 0046 0047 /** 0048 * KisViewManager manages the collection of views shown in a single mainwindow. 0049 */ 0050 class KRITAUI_EXPORT KisViewManager : public QObject 0051 { 0052 0053 Q_OBJECT 0054 0055 public: 0056 /** 0057 * Construct a new view on the krita document. 0058 * @param parent a parent widget we show ourselves in. 0059 * @param actionCollection an action collection. 0060 */ 0061 KisViewManager(QWidget *parent, KisKActionCollection *actionCollection); 0062 ~KisViewManager() override; 0063 0064 /** 0065 * Retrieves the entire action collection. 0066 */ 0067 virtual KisKActionCollection* actionCollection() const; 0068 0069 public: // Krita specific interfaces 0070 0071 void setCurrentView(KisView *view); 0072 0073 /// Return the image this view is displaying 0074 KisImageWSP image() const; 0075 0076 KoZoomController *zoomController() const; 0077 0078 /// The resource provider contains all per-view settings, such as 0079 /// current color, current paint op etc. 0080 KisCanvasResourceProvider *canvasResourceProvider(); 0081 0082 /// Return the canvasbase class 0083 KisCanvas2 *canvasBase() const; 0084 0085 /// Return the actual widget that is displaying the current image 0086 QWidget* canvas() const; 0087 0088 /// Return the wrapper class around the statusbar 0089 KisStatusBar *statusBar() const; 0090 0091 KisPaintopBox* paintOpBox() const; 0092 0093 /// create a new progress updater 0094 QPointer<KoUpdater> createUnthreadedUpdater(const QString &name); 0095 QPointer<KoUpdater> createThreadedUpdater(const QString &name); 0096 0097 /// The selection manager handles everything action related to 0098 /// selections. 0099 KisSelectionManager *selectionManager(); 0100 0101 /// The node manager handles everything about nodes 0102 KisNodeManager *nodeManager() const; 0103 0104 KisActionManager *actionManager() const; 0105 0106 /** 0107 * Convenience method to get at the active node, which may be 0108 * a layer or a mask or a selection 0109 */ 0110 KisNodeSP activeNode(); 0111 0112 /// Convenience method to get at the active layer 0113 KisLayerSP activeLayer(); 0114 0115 /// Convenience method to get at the active paint device 0116 KisPaintDeviceSP activeDevice(); 0117 0118 /// The filtermanager handles everything action-related to filters 0119 KisFilterManager *filterManager(); 0120 0121 /// The image manager handles everything action-related to the 0122 /// current image 0123 KisImageManager *imageManager(); 0124 0125 /// Filters events and sends them to canvas actions 0126 KisInputManager *inputManager() const; 0127 0128 /// Convenience method to get at the active selection (the 0129 /// selection of the current layer, or, if that does not exist, 0130 /// the global selection. 0131 KisSelectionSP selection(); 0132 0133 /// Checks if the current global or local selection is editable 0134 bool selectionEditable(); 0135 0136 /// The undo adapter is used to add commands to the undo stack 0137 KisUndoAdapter *undoAdapter(); 0138 0139 KisDocument *document() const; 0140 0141 int viewCount() const; 0142 0143 /** 0144 * @brief blockUntilOperationsFinished blocks the GUI of the application until execution 0145 * of actions on \p image is finished 0146 * @param image the image which we should wait for 0147 * @return true if the image has finished execution of the actions, false if 0148 * the user cancelled operation 0149 */ 0150 bool blockUntilOperationsFinished(KisImageSP image); 0151 0152 0153 /** 0154 * @brief blockUntilOperationsFinished blocks the GUI of the application until execution 0155 * of actions on \p image is finished. Does *not* provide a "Cancel" button. So the 0156 * user is forced to wait. 0157 * @param image the image which we should wait for 0158 */ 0159 void blockUntilOperationsFinishedForced(KisImageSP image); 0160 0161 public: 0162 0163 KisGridManager * gridManager() const; 0164 KisGuidesManager * guidesManager() const; 0165 0166 /// disable and enable toolbar controls. used for disabling them during painting. 0167 void enableControls(); 0168 void disableControls(); 0169 0170 0171 /// shows a floating message in the top right corner of the canvas 0172 void showFloatingMessage(const QString &message, const QIcon& icon, int timeout = 4500, 0173 KisFloatingMessage::Priority priority = KisFloatingMessage::Medium, 0174 int alignment = Qt::AlignCenter | Qt::TextWordWrap); 0175 0176 /// @return the KisMainWindow this view is in, or 0 0177 KisMainWindow *mainWindow() const; 0178 0179 /** 0180 * Gets the KisMainWindow as a QWidget, useful when you just need it to 0181 * be used as a parent to a dialog or window without needing to include 0182 * `KisMainWindow.h`. 0183 */ 0184 QWidget *mainWindowAsQWidget() const; 0185 0186 /// The QMainWindow associated with this view. This is most likely going to be shell(), but 0187 /// when running as Gemini or Sketch, this will be set to the applications' own QMainWindow. 0188 /// This can be checked by qobject_casting to KisMainWindow to check the difference. 0189 QMainWindow* qtMainWindow() const; 0190 0191 /// The mainWindow function will return the shell() value, unless this function is called 0192 /// with a non-null value. To make it return shell() again, simply pass null to this function. 0193 void setQtMainWindow(QMainWindow* newMainWindow); 0194 0195 static void initializeResourceManager(KoCanvasResourceProvider *resourceManager); 0196 0197 public Q_SLOTS: 0198 0199 void switchCanvasOnly(bool toggled); 0200 void setShowFloatingMessage(bool show); 0201 void showHideScrollbars(); 0202 0203 /// Visit all managers to update gui elements, e.g. enable / disable actions. 0204 /// This is heavy-duty call, so it uses a compressor. 0205 void updateGUI(); 0206 0207 /// Update the style of all the icons 0208 void updateIcons(); 0209 0210 void slotViewAdded(KisView *view); 0211 void slotViewRemoved(KisView *view); 0212 0213 void slotActivateTransformTool(); 0214 0215 // Change and update author 0216 void changeAuthorProfile(const QString &profileName); 0217 void slotUpdateAuthorProfileActions(); 0218 0219 void slotToggleFgBg(); 0220 void slotResetFgBg(); 0221 0222 // Enable the last set brush outline, or disable it if already enabled 0223 void slotToggleBrushOutline(); 0224 0225 Q_SIGNALS: 0226 0227 void floatingMessageRequested(const QString &message, const QString &iconName); 0228 /** 0229 * @brief viewChanged 0230 * sent out when the view has changed. 0231 */ 0232 void viewChanged(); 0233 0234 void brushOutlineToggled(); 0235 0236 private Q_SLOTS: 0237 0238 void slotCreateTemplate(); 0239 void slotCreateCopy(); 0240 void slotDocumentSaved(); 0241 void slotSaveIncremental(); 0242 void slotSaveIncrementalBackup(); 0243 void showStatusBar(bool toggled); 0244 void toggleTabletLogger(); 0245 void openResourcesDirectory(); 0246 void initializeStatusBarVisibility(); 0247 void guiUpdateTimeout(); 0248 void slotUpdatePixelGridAction(); 0249 void slotSaveShowRulersState(bool value); 0250 void slotSaveRulersTrackMouseState(bool value); 0251 void slotResetRotation(); 0252 void slotToggleFullscreen(); 0253 private: 0254 void createActions(); 0255 void setupManagers(); 0256 0257 QString canonicalPath(); 0258 0259 /// The zoommanager handles everything action-related to zooming 0260 KisZoomManager * zoomManager(); 0261 0262 private: 0263 class KisViewManagerPrivate; 0264 KisViewManagerPrivate * const d; 0265 }; 0266 0267 #endif