File indexing completed on 2024-05-12 15:56:52
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef KO_TOOL_MANAGER_P 0007 #define KO_TOOL_MANAGER_P 0008 0009 #include <QList> 0010 #include <QObject> 0011 #include <QString> 0012 #include <QHash> 0013 0014 #include <QKeySequence> 0015 #include <QAction> 0016 0017 #include "KoInputDevice.h" 0018 #include "KoToolManager.h" 0019 0020 class KoToolFactoryBase; 0021 class KoShapeManager; 0022 class KoCanvasBase; 0023 class KoToolBase; 0024 class KoShape; 0025 class KoToolManager; 0026 class KoCanvasController; 0027 class KoShapeLayer; 0028 class CanvasData; 0029 class KoToolProxy; 0030 0031 class Q_DECL_HIDDEN KoToolManager::Private 0032 { 0033 public: 0034 Private(KoToolManager *qq); 0035 ~Private(); 0036 0037 void setup(); 0038 0039 void connectActiveTool(); 0040 void disconnectActiveTool(); 0041 void switchTool(const QString &id); 0042 void postSwitchTool(); 0043 void switchCanvasData(CanvasData *cd); 0044 0045 bool eventFilter(QObject *object, QEvent *event); 0046 0047 void detachCanvas(KoCanvasController *controller); 0048 void attachCanvas(KoCanvasController *controller); 0049 void movedFocus(QWidget *from, QWidget *to); 0050 void updateCursor(const QCursor &cursor); 0051 void switchBackRequested(); 0052 void selectionChanged(const QList<KoShape*> &shapes); 0053 void currentLayerChanged(const KoShapeLayer *layer); 0054 void updateToolForProxy(); 0055 void switchToolTemporaryRequested(const QString &id); 0056 CanvasData *createCanvasData(KoCanvasController *controller, const KoInputDevice &device); 0057 KoToolBase* createTool(KoCanvasController *controller, KoToolAction *toolAction); 0058 0059 /** 0060 * Request a switch from to the param input device. 0061 * This will cause the tool for that device to be selected. 0062 */ 0063 void switchInputDevice(const KoInputDevice &device); 0064 0065 /** 0066 * Whenever a new tool proxy class is instantiated, it will use this method to register itself 0067 * so the toolManager can update it to the latest active tool. 0068 * @param proxy the proxy to register. 0069 * @param canvas which canvas the proxy is associated with; whenever a new tool is selected for that canvas, 0070 * the proxy gets an update. 0071 */ 0072 void registerToolProxy(KoToolProxy *proxy, KoCanvasBase *canvas); 0073 0074 KoToolManager *q; 0075 0076 QList<KoToolAction*> toolActionList; // list of all available tools via their actions. 0077 0078 QHash<KoCanvasController*, QList<CanvasData*> > canvasses; 0079 QHash<KoCanvasBase*, KoToolProxy*> proxies; 0080 0081 CanvasData *canvasData; // data about the active canvas. 0082 0083 KoInputDevice inputDevice; 0084 0085 bool layerExplicitlyDisabled; 0086 }; 0087 0088 /// \internal 0089 /// Helper class to transform a simple signal selection changed into a signal with a parameter 0090 class Connector : public QObject 0091 { 0092 Q_OBJECT 0093 public: 0094 explicit Connector(KoShapeManager *parent); 0095 0096 public Q_SLOTS: 0097 void selectionChanged(); 0098 0099 Q_SIGNALS: 0100 void selectionChanged(const QList<KoShape*> &shape); 0101 0102 private: 0103 KoShapeManager *m_shapeManager; 0104 }; 0105 0106 #endif