All Classes Namespaces Functions Variables Enumerations Properties Pages
clipboardmanager.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 #ifndef CLIPBOARDMANAGER_H
18 #define CLIPBOARDMANAGER_H
19 
20 #include "basemanager.h"
21 
22 #include "bitmapimage.h"
23 #include "vectorimage.h"
24 #include "layer.h"
25 
26 class Editor;
27 class QClipboard;
28 class KeyFrame;
29 
31 {
32  Q_OBJECT
33 public:
34  explicit ClipboardManager(Editor* editor);
35  ~ClipboardManager() override;
36 
37  bool init() override { return true; }
38  Status load(Object*) override { return Status::OK; }
39  Status save(Object*) override { return Status::OK; }
40  void workingLayerChanged(Layer*) override { }
41 
42  void setFromSystemClipboard(const QPointF& pos, const Layer* layer);
43 
49  void copyBitmapImage(BitmapImage* image, QRectF selectionRect);
50 
55  void copyVectorImage(const VectorImage* vectorImage);
56 
60  void copySelectedFrames(const Layer* currentLayer);
61 
62  const BitmapImage& getBitmapClipboard() const { return mBitmapImage; }
63  const VectorImage& getVectorClipboard() const { return mVectorImage; }
64  std::map<int, KeyFrame*> getClipboardFrames() { return mFrames; }
65 
66  Layer::LAYER_TYPE framesLayerType() const { return mFramesType; }
67  bool framesIsEmpty() const { return mFrames.empty(); }
68 
69 private:
70 
72  void resetStates();
73 
74  BitmapImage mBitmapImage;
75  VectorImage mVectorImage;
76  std::map<int, KeyFrame*> mFrames;
77  Layer::LAYER_TYPE mFramesType = Layer::LAYER_TYPE::UNDEFINED;
78 
79  QClipboard* mClipboard = nullptr;
80 };
81 
82 #endif // CLIPBOARDMANAGER_H
void copyBitmapImage(BitmapImage *image, QRectF selectionRect)
Copy bitmap image to clipboard and save its latest position Additionally only a part of the image wil...
Q_OBJECTQ_OBJECT
Definition: layer.h:38
void copySelectedFrames(const Layer *currentLayer)
Copy selected keyframes of any given layer and remember its type.
void resetStates()
This should be called before copying and updating the clipboard to ensure no previous state is saved...
Definition: object.h:41
Definition: editor.h:55
void copyVectorImage(const VectorImage *vectorImage)
Copy the entire vector image to clipboard, this operation does not yet support partial selections...