17#include "clipboardmanager.h"
20#include <QGuiApplication>
24ClipboardManager::ClipboardManager(
Editor* editor) :
BaseManager(editor,
"ClipboardManager")
29ClipboardManager::~ClipboardManager()
31 for (
auto it : mFrames)
38void ClipboardManager::setFromSystemClipboard(
const QPointF& pos,
const Layer* layer)
46 if (layer->type() != Layer::BITMAP || clipboard->
ownsClipboard()) {
59 Q_ASSERT(bitmapImage !=
nullptr && bitmapImage->isLoaded());
63 mBitmapImage = bitmapImage->copy(selectionRect.
toRect());
67 mBitmapImage = bitmapImage->copy();
76 if (vectorImage ==
nullptr || vectorImage->isEmpty()) {
return; }
79 mVectorImage = *vectorImage->clone();
87 KeyFrame* keyframe = currentLayer->getKeyFrameAt(pos);
88 Q_ASSERT(keyframe !=
nullptr);
90 KeyFrame* newKeyframe = keyframe->clone();
93 newKeyframe->unloadFile();
95 mFrames.insert(std::make_pair(keyframe->pos(), newKeyframe));
97 mFramesType = currentLayer->type();
102 std::map<int, KeyFrame*> resultMap;
103 for (
auto it : mFrames)
105 resultMap.insert(std::make_pair(it.first, it.second->clone()));
112 for (
auto it : mFrames)
121 mFramesType = Layer::LAYER_TYPE::UNDEFINED;
std::map< int, KeyFrame * > getClipboardFrames()
Return a copy of all clipboard frames keyed by their position.
void copySelectedFrames(const Layer *currentLayer)
Copy selected keyframes of any given layer and remember its type.
void copyVectorImage(const VectorImage *vectorImage)
Copy the entire vector image to clipboard, this operation does not yet support partial selections.
void resetStates()
This should be called before copying and updating the clipboard to ensure no previous state is saved.
void copyBitmapImage(BitmapImage *image, QRectF selectionRect)
Copy bitmap image to clipboard and save its latest position Additionally only a part of the image wil...
QList< int > selectedKeyFramesPositions() const
Get selected keyframe positions sorted by position.
QImage image(QClipboard::Mode mode) const const
bool ownsClipboard() const const
void setImage(const QImage &image, QClipboard::Mode mode)
bool isNull() const const
QPoint toPoint() const const
bool isEmpty() const const
QRect toRect() const const