Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++
1.3 KB
Raw Blame
/*
 * SPDX-FileCopyrightText: 2023 Wolthera van Hövell tot Westerflier <[email protected]>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
#include "SvgSelectTextStrategy.h"
#include "SvgTextCursor.h"
#include <QDebug>

SvgSelectTextStrategy::SvgSelectTextStrategy(KoToolBase *tool, SvgTextCursor *cursor, const QPointF &clicked, Qt::KeyboardModifiers modifiers)
    : KoInteractionStrategy(tool)
    , m_cursor(cursor)
    , m_dragStart(clicked)
{
    m_dragEnd = m_dragStart;
    m_cursor->setPosToPoint(m_dragStart, !(modifiers & Qt::ShiftModifier));
}

void SvgSelectTextStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)
{
    Q_UNUSED(modifiers)
    m_dragEnd = mouseLocation;
    if (!(modifiers & Qt::ShiftModifier)) {
        m_cursor->setPosToPoint(m_dragStart, true);
    }
    m_cursor->setPosToPoint(m_dragEnd, false);
}

KUndo2Command *SvgSelectTextStrategy::createCommand()
{
    return nullptr;
}

void SvgSelectTextStrategy::cancelInteraction()
{
    return;
}

void SvgSelectTextStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
{
    Q_UNUSED(modifiers)
    if (!(modifiers & Qt::ShiftModifier)) {
        m_cursor->setPosToPoint(m_dragStart, true);
    }
    m_cursor->setPosToPoint(m_dragEnd, false);

}