File indexing completed on 2024-05-26 04:26:40

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org>
0003  * SPDX-FileCopyrightText: 2011 Jan Hambrecht <jaham@gmx.net>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #include "KoInteractionStrategy.h"
0009 #include "KoInteractionStrategy_p.h"
0010 #include "KoCanvasBase.h"
0011 #include "KoShapeController.h"
0012 #include "KoDocumentResourceManager.h"
0013 #include "KoCanvasResourceProvider.h"
0014 
0015 #include <kundo2command.h>
0016 
0017 KoInteractionStrategy::KoInteractionStrategy(KoToolBase *parent)
0018     : d_ptr(new KoInteractionStrategyPrivate(parent))
0019 {
0020 }
0021 
0022 void KoInteractionStrategy::cancelInteraction()
0023 {
0024     KUndo2Command *cmd = createCommand();
0025     if (cmd) {
0026         cmd->redo(); //some applications rely an redo being called here
0027         cmd->undo();
0028         delete cmd;
0029     }
0030 }
0031 
0032 KoInteractionStrategy::KoInteractionStrategy(KoInteractionStrategyPrivate &dd)
0033     : d_ptr(&dd)
0034 {
0035 }
0036 
0037 KoInteractionStrategy::~KoInteractionStrategy()
0038 {
0039     delete d_ptr;
0040 }
0041 
0042 void KoInteractionStrategy::paint(QPainter &, const KoViewConverter &)
0043 {
0044 }
0045 
0046 KoToolBase *KoInteractionStrategy::tool() const
0047 {
0048     Q_D(const KoInteractionStrategy);
0049     return d->tool;
0050 }
0051 
0052 uint KoInteractionStrategy::handleRadius() const
0053 {
0054     return tool()->canvas()->resourceManager()->handleRadius();
0055 }
0056 
0057 uint KoInteractionStrategy::decorationThickness() const
0058 {
0059     return tool()->canvas()->resourceManager()->decorationThickness();
0060 }
0061 
0062 uint KoInteractionStrategy::grabSensitivity() const
0063 {
0064     return tool()->canvas()->shapeController()->resourceManager()->grabSensitivity();
0065 }