All Classes Namespaces Functions Variables Enumerations Properties Pages
toolmanager.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef TOOLMANAGER_H
19 #define TOOLMANAGER_H
20 
21 #include <QObject>
22 #include <QHash>
23 #include "basetool.h"
24 #include "basemanager.h"
25 
26 class ScribbleArea;
27 
28 class ToolManager : public BaseManager
29 {
30  Q_OBJECT
31 public:
32  explicit ToolManager(Editor* editor);
33 
34  bool init() override;
35  Status load(Object*) override;
36  Status save(Object*) override;
37 
38  BaseTool* currentTool() { return mCurrentTool; }
39  BaseTool* getTool(ToolType eToolType);
40  void setDefaultTool();
41  void setCurrentTool(ToolType eToolType);
42  void cleanupAllToolsData();
43  bool leavingThisTool();
44 
45  void tabletSwitchToEraser();
46  void tabletRestorePrevTool();
47  int propertySwitch(bool condition, int property);
48 
49 signals:
50  void penWidthValueChanged(float);
51  void penFeatherValueChanged(float);
52  void toleranceValueChanged(qreal);
53 
54  void toolChanged(ToolType);
55  void toolPropertyChanged(ToolType, ToolPropertyType);
56 
57 public slots:
58  void resetAllTools();
59 
60  void setWidth(float);
61  void setFeather(float);
62  void setUseFeather(bool);
63  void setInvisibility(bool);
64  void setPreserveAlpha(bool);
65  void setVectorMergeEnabled(bool);
66  void setBezier(bool);
67  void setPressure(bool);
68  void setAA(int);
69  void setStabilizerLevel(int);
70  void setTolerance(int);
71  void setUseFillContour(bool);
72 
73 private:
74  BaseTool* mCurrentTool = nullptr;
75  ToolType meTabletBackupTool = PENCIL;
76  bool mIsSwitchedToEraser = false;
77  QHash<ToolType, BaseTool*> mToolSetHash;
78 
79  int mOldValue = 0;
80 
81 };
82 
83 #endif // TOOLMANAGER_H
QVariant property(const char *name) const const
Q_OBJECTQ_OBJECT
Definition: object.h:54
Definition: editor.h:51