Exemple #1
0
ClipCommand::ClipCommand(PictureShape *shape, bool clip)
    : KUndo2Command(0)
    , m_pictureShape(shape)
    , m_clip(clip)
{
    if (clip) {
        setText(kundo2_i18n("Contour image (by image analysis)"));
    } else {
        setText(kundo2_i18n("Remove image contour"));
    }
}
Exemple #2
0
KoPADisplayMasterBackgroundCommand::KoPADisplayMasterBackgroundCommand( KoPAPage * page, bool display )
: m_page( page )
, m_display( display )
{
    if ( m_display ) {
        setText( kundo2_i18n( "Display master background" ) );
    }
    else {
        if ( m_page->pageType() == KoPageApp::Slide ) {
            setText( kundo2_i18n( "Display slide background" ) );
        }
        else {
            setText( kundo2_i18n( "Display page background" ) );
        }
    }
}
ChangeListLevelCommand::ChangeListLevelCommand(const QTextCursor &cursor, ChangeListLevelCommand::CommandType type,
                                               int coef, KUndo2Command *parent)
    : KoTextCommandBase(parent),
      m_type(type),
      m_coefficient(coef),
      m_first(true)
{
    setText(kundo2_i18n("Change List Level"));

    int selectionStart = qMin(cursor.anchor(), cursor.position());
    int selectionEnd = qMax(cursor.anchor(), cursor.position());

    QTextBlock block = cursor.block().document()->findBlock(selectionStart);

    bool oneOf = (selectionStart == selectionEnd); //ensures the block containing the cursor is selected in that case

    while (block.isValid() && ((block.position() < selectionEnd) || oneOf)) {
        m_blocks.append(block);
        if (block.textList()) {
            m_lists.insert(m_blocks.size() - 1, KoTextDocument(block.document()).list(block.textList()));
            Q_ASSERT(m_lists.value(m_blocks.size() - 1));
            m_levels.insert(m_blocks.size() - 1, effectiveLevel(m_lists.value(m_blocks.size() - 1)->level(block)));
        }
        oneOf = false;
        block = block.next();
    }
}
void KisSelectAllActionFactory::run(KisViewManager *view)
{
    KisImageWSP image = view->image();
    if (!image) return;

    KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Select All"));

    if (!image->globalSelection()) {
        ap->applyCommand(new KisSetEmptyGlobalSelectionCommand(image),
                         KisStrokeJobData::SEQUENTIAL,
                         KisStrokeJobData::EXCLUSIVE);
    }

    struct SelectAll : public KisTransactionBasedCommand {
        SelectAll(KisImageSP image) : m_image(image) {}
        KisImageSP m_image;
        KUndo2Command* paint() {
            KisSelectionSP selection = m_image->globalSelection();
            KisSelectionTransaction transaction(selection->pixelSelection());
            selection->pixelSelection()->select(m_image->bounds());
            return transaction.endAndTake();
        }
    };

    ap->applyCommand(new SelectAll(image),
                     KisStrokeJobData::SEQUENTIAL,
                     KisStrokeJobData::EXCLUSIVE);

    endAction(ap, KisOperationConfiguration(id()).toXML());
}
Exemple #5
0
FilterRemoveCommand::FilterRemoveCommand(int filterEffectIndex, KoFilterEffectStack * filterStack, KoShape * shape, KUndo2Command *parent)
        : KUndo2Command(parent), m_filterEffect(0), m_filterStack(filterStack), m_shape(shape)
        , m_isRemoved(false), m_filterEffectIndex(filterEffectIndex)
{
    Q_ASSERT(filterStack);
    setText(kundo2_i18n("Remove filter effect"));
}
KisSwitchCurrentTimeCommand::KisSwitchCurrentTimeCommand(KisImageAnimationInterface *animation, int oldTime, int newTime, KUndo2Command *parent)
    : KUndo2Command(kundo2_i18n("Switch current time"), parent),
      m_animation(animation),
      m_oldTime(oldTime),
      m_newTime(newTime)
{
}
KPrAnimationRemoveCommand::KPrAnimationRemoveCommand(KPrDocument *doc, KPrShapeAnimation *animation)
    : m_doc(doc)
    , m_animation(animation)
    , m_deleteAnimation(true)
{
    setText(kundo2_i18n("Remove shape animation"));
}
void RoundCornersPlugin::slotRoundCorners()
{
    KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController();
    KoSelection *selection = canvasController->canvas()->shapeManager()->selection();
    KoShape * shape = selection->firstSelectedShape();
    if (! shape)
        return;

    // check if we have a path based shape
    KoPathShape * path = dynamic_cast<KoPathShape*>(shape);
    if (! path)
        return;

    m_roundCornersDlg->setUnit(canvasController->canvas()->unit());
    if (QDialog::Rejected == m_roundCornersDlg->exec())
        return;

    KUndo2Command * cmd = new KUndo2Command(kundo2_i18n("Round Corners"));

    // convert to path before if we have a parametric shape
    KoParameterShape * ps = dynamic_cast<KoParameterShape*>(shape);
    if (ps && ps->isParametricShape())
        new KoParameterToPathCommand(ps, cmd);

    new RoundCornersCommand(path, m_roundCornersDlg->radius(), cmd);
    canvasController->canvas()->addCommand(cmd);
}
TransformStrokeStrategy::TransformStrokeStrategy(KisNodeSP rootNode,
                                                 KisSelectionSP selection,
                                                 KisPostExecutionUndoAdapter *undoAdapter)
    : KisStrokeStrategyUndoCommandBased(kundo2_i18n("Transform"), false, undoAdapter),
      m_selection(selection)
{
    if (rootNode->childCount() || !rootNode->paintDevice()) {
        KisPaintDeviceSP device;

        if (KisTransformMask* tmask =
            dynamic_cast<KisTransformMask*>(rootNode.data())) {

            device = tmask->buildPreviewDevice();

            /**
             * When working with transform mask, selections are not
             * taken into account.
             */
            m_selection = 0;
        } else {
            rootNode->projectionLeaf()->explicitlyRegeneratePassThroughProjection();
            device = rootNode->projection();
        }

        m_previewDevice = createDeviceCache(device);

    } else {
        m_previewDevice = createDeviceCache(rootNode->paintDevice());
        putDeviceCache(rootNode->paintDevice(), m_previewDevice);
    }

    Q_ASSERT(m_previewDevice);
    m_savedRootNode = rootNode;
}
bool CalendarItemModel::setName( Calendar *a, const QVariant &value, int role )
{
    switch ( role ) {
        case Qt::EditRole:
            if ( value.toString() != a->name() ) {
                emit executeCommand( new CalendarModifyNameCmd( a, value.toString(), kundo2_i18n( "Modify calendar name" ) ) );
                return true;
            }
            break;
        case Qt::CheckStateRole: {
            switch ( value.toInt() ) {
                case Qt::Unchecked:
                    if ( a->isDefault() ) {
                        emit executeCommand( new ProjectModifyDefaultCalendarCmd( m_project, 0, kundo2_i18n( "De-select as default calendar" ) ) );
                        return true;
                    }
                    break;
                case Qt::Checked:
                    if ( ! a->isDefault() ) {
                        emit executeCommand( new ProjectModifyDefaultCalendarCmd( m_project, a, kundo2_i18n( "Select as default calendar" ) ) );
                        return true;
                    }
                    break;
                default: break;
            }
        }
        default: break;
    }
    return false;
}
Exemple #11
0
KUndo2Command* KoPathSegmentChangeStrategy::createCommand()
{
    m_tool->canvas()->updateCanvas(m_tool->canvas()->snapGuide()->boundingRect());

    bool hasControlPoint1 = m_segment.second()->activeControlPoint1();
    bool hasControlPoint2 = m_segment.first()->activeControlPoint2();

    KUndo2Command * cmd = new KUndo2Command(kundo2_i18n("Change Segment"));
    if (m_originalSegmentDegree == 1) {
        m_segment.first()->removeControlPoint2();
        m_segment.second()->removeControlPoint1();
        new KoPathSegmentTypeCommand(m_pointData1, KoPathSegmentTypeCommand::Curve, cmd);
    }

    if (hasControlPoint2) {
        QPointF oldCtrlPointPos = m_segment.first()->controlPoint2()-m_ctrlPoint2Move;
        m_segment.first()->setControlPoint2(oldCtrlPointPos);
        new KoPathControlPointMoveCommand(m_pointData1, m_ctrlPoint2Move, KoPathPoint::ControlPoint2, cmd);
    }
    if (hasControlPoint1) {
        QPointF oldCtrlPointPos = m_segment.second()->controlPoint1()-m_ctrlPoint1Move;
        m_segment.second()->setControlPoint1(oldCtrlPointPos);
        new KoPathControlPointMoveCommand(m_pointData2, m_ctrlPoint1Move, KoPathPoint::ControlPoint1, cmd);
    }

    return cmd;
}
Exemple #12
0
KWFrameCreateCommand::KWFrameCreateCommand(KoShapeBasedDocumentBase *shapeController, KWFrame *frame, KUndo2Command *parent)
    : KUndo2Command(kundo2_i18n("Create Frame"), parent),
      m_frame(frame),
      m_frameSet(frame->frameSet())
{
    new KoShapeCreateCommand(shapeController, frame->shape(), this);
}
void KisSelectionToVectorActionFactory::run(KisViewManager *view)
{
    KisSelectionSP selection = view->selection();

    if (selection->hasShapeSelection() ||
        !selection->outlineCacheValid()) {

        return;
    }

    QPainterPath selectionOutline = selection->outlineCache();
    QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();

    KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(selectionOutline));
    shape->setShapeId(KoPathShapeId);

    /**
     * Mark a shape that it belongs to a shape selection
     */
    if(!shape->userData()) {
        shape->setUserData(new KisShapeSelectionMarker);
    }

    KisProcessingApplicator *ap = beginAction(view, kundo2_i18n("Convert to Vector Selection"));

    ap->applyCommand(view->canvasBase()->shapeController()->addShape(shape),
                     KisStrokeJobData::SEQUENTIAL,
                     KisStrokeJobData::EXCLUSIVE);

    endAction(ap, KisOperationConfiguration(id()).toXML());
}
MacroCommand *SummaryTaskGeneralPanel::buildCommand() {
    MacroCommand *cmd = new MacroCommand(kundo2_i18n("Modify task"));
    bool modified = false;

    if (!namefield->isHidden() && m_task.name() != namefield->text()) {
        cmd->addCommand(new NodeModifyNameCmd(m_task, namefield->text()));
        modified = true;
    }
    if (!leaderfield->isHidden() && m_task.leader() != leaderfield->text()) {
        cmd->addCommand(new NodeModifyLeaderCmd(m_task, leaderfield->text()));
        modified = true;
    }
/*    if (!descriptionfield->isHidden() && 
        m_task.description() != descriptionfield->text()) {
        cmd->addCommand(new NodeModifyDescriptionCmd(m_task, descriptionfield->text()));
        modified = true;
    }*/
    MacroCommand *m = m_description->buildCommand();
    if ( m ) {
        cmd->addCommand( m );
        modified = true;
    }
    if (!modified) {
        delete cmd;
        return 0;
    }
    return cmd;
}
Exemple #15
0
KWShapeCreateCommand::KWShapeCreateCommand(KWDocument *doc, KoShape *shape, KUndo2Command *parent):
    KUndo2Command(parent),
    m_document(doc),
    m_shape(shape),
    m_deleteShape(true)
{
    setText(kundo2_i18n("Create shape"));
}
KWChangePageStyleCommand::KWChangePageStyleCommand(KWDocument *document, KWPage &page, const KWPageStyle &newStyle, KUndo2Command *parent)
    : KUndo2Command(kundo2_i18n("Set Page Style"), parent),
    m_document(document),
    m_newStyle(newStyle),
    m_oldStyle(page.pageStyle()),
    m_page(page)
{
    Q_ASSERT(m_page.isValid());
}
RenameSectionCommand::RenameSectionCommand(KoSection *section, const QString &newName, QTextDocument *document)
    : KUndo2Command()
    , m_sectionModel(KoTextDocument(document).sectionModel())
    , m_section(section)
    , m_newName(newName)
    , m_first(true)
{
    setText(kundo2_i18n("Rename Section"));
}
Exemple #18
0
KisImageResizeCommand::KisImageResizeCommand(KisImageWSP image,
                                             const QSize& newSize)
    : KUndo2Command(kundo2_i18n("Resize Image")),
      m_image(image)
{
    // do we really need a translatable name for the command?
    m_sizeBefore = image->size();
    m_sizeAfter = newSize;
}
KUndo2Command *PackageSettingsPanel::buildCommand()
{
    //kDebug(planworkDbg());
    WorkPackageSettings s = settings();
    if ( s == m_package.settings() ) {
        return 0;
    }
    return new ModifyPackageSettingsCmd( &m_package, s, kundo2_i18n( "Modify package settings" ) );
}
Exemple #20
0
KoPAPageDeleteCommand::KoPAPageDeleteCommand( KoPADocument *document, KoPAPageBase *page, KUndo2Command *parent )
: KUndo2Command( parent )
, m_document( document )
, m_deletePages(false)
{
    Q_ASSERT(m_document);
    Q_ASSERT(page);
    int index = m_document->pageIndex(page);
    Q_ASSERT(index != -1);
    m_pages.insert(index, page);

    if ( page->pageType() == KoPageApp::Slide ) {
        setText( kundo2_i18n( "Delete slide" ) );
    }
    else {
        setText( kundo2_i18n( "Delete page" ) );
    }
}
KPrReorderAnimationCommand::KPrReorderAnimationCommand(KPrShapeAnimations *shapeAnimationsModel, KPrShapeAnimation *oldAnimation,
                                                       KPrShapeAnimation *newAnimation, KUndo2Command *parent)
    : KUndo2Command(parent)
    , m_shapeAnimationsModel(shapeAnimationsModel)
    , m_oldAnimation(oldAnimation)
    , m_newAnimation(newAnimation)
{
    setText(kundo2_i18n("Reorder animations"));
}
Exemple #22
0
KoShapeKeepAspectRatioCommand::KoShapeKeepAspectRatioCommand(const QList<KoShape*>& shapes,
        const QList<bool>& oldKeepAspectRatio,
        const QList<bool>& newKeepAspectRatio,
        KUndo2Command* parent)
        : KUndo2Command(kundo2_i18n("Keep Aspect Ratio"), parent)
{
    m_shapes = shapes;
    m_oldKeepAspectRatio = oldKeepAspectRatio;
    m_newKeepAspectRatio = newKeepAspectRatio;
}
KPrEditCustomSlideShowsCommand::KPrEditCustomSlideShowsCommand(
    KPrDocument *doc, const QString &name, QList<KoPAPageBase *> newCustomShow, KUndo2Command *parent)
: KUndo2Command(parent)
, m_doc(doc)
, m_name(name)
, m_newCustomShow(newCustomShow)
, m_oldCustomShow(doc->customSlideShows()->getByName(name))
{
    setText(kundo2_i18n("Edit custom slide show"));
}
MacroCommand *MainProjectDialog::buildCommand() {
    MacroCommand *m = 0;
    KUndo2MagicString c = kundo2_i18n("Modify main project");
    MacroCommand *cmd = panel->buildCommand();
    if (cmd) {
        if (!m) m = new MacroCommand(c);
        m->addCommand(cmd);
    }
    return m;
}
Exemple #25
0
KoShapeReorderCommand::KoShapeReorderCommand(const QList<KoShape*> &shapes, QList<int> &newIndexes, KUndo2Command *parent)
    : KUndo2Command(parent),
    d(new KoShapeReorderCommandPrivate(shapes, newIndexes))
{
    Q_ASSERT(shapes.count() == newIndexes.count());
    foreach (KoShape *shape, shapes)
        d->previousIndexes.append(shape->zIndex());

    setText(kundo2_i18n("Reorder shapes"));
}
KisImportExportFilter::ConversionStatus KisAnimationImporter::import(QStringList files, int firstFrame, int step)
{
    Q_ASSERT(step > 0);

    bool batchMode;

    if (m_d->document) {
        batchMode= m_d->document->fileBatchMode();

        if (!batchMode) {
            emit m_d->document->statusBarMessage(i18n("Import frames"));
            emit m_d->document->sigProgress(0);
            connect(m_d->document, SIGNAL(sigProgressCanceled()), this, SLOT(cancel()));
        }
    } else batchMode = false;

    m_d->image->lock();
    KisUndoAdapter *undo = m_d->image->undoAdapter();
    undo->beginMacro(kundo2_i18n("Import animation"));

    QScopedPointer<KisDocument> importDoc(KisPart::instance()->createDocument());
    importDoc->setFileBatchMode(true);

    KisImportExportFilter::ConversionStatus status = KisImportExportFilter::OK;
    int frame = firstFrame;

    KisRasterKeyframeChannel *contentChannel = 0;

    Q_FOREACH(QString file, files) {
        bool successfullyLoaded = importDoc->openUrl(QUrl::fromLocalFile(file), KisDocument::OPEN_URL_FLAG_DO_NOT_ADD_TO_RECENT_FILES);
        if (!successfullyLoaded) {
            status = KisImportExportFilter::InternalError;
            break;
        }

        if (m_d->stop) {
            status = KisImportExportFilter::ProgressCancelled;
            break;
        }

        if (frame == firstFrame) {
            const KoColorSpace *cs = importDoc->image()->colorSpace();
            KisPaintLayerSP paintLayer = new KisPaintLayer(m_d->image, m_d->image->nextLayerName(), OPACITY_OPAQUE_U8, cs);
            undo->addCommand(new KisImageLayerAddCommand(m_d->image, paintLayer, m_d->image->rootLayer(), m_d->image->rootLayer()->childCount()));

            paintLayer->enableAnimation();
            contentChannel = qobject_cast<KisRasterKeyframeChannel*>(paintLayer->getKeyframeChannel(KisKeyframeChannel::Content.id()));
        }

        if (!batchMode) {
            emit m_d->document->sigProgress((frame - firstFrame) * 100 / (step * files.size()));
        }
        contentChannel->importFrame(frame, importDoc->image()->projection(), NULL);
        frame += step;
    }
Exemple #27
0
KisNodePropertyListCommand::KisNodePropertyListCommand(KisNodeSP node, KoDocumentSectionModel::PropertyList newPropertyList)
    : KisNodeCommand(kundo2_i18n("Property Changes"), node),
      m_newPropertyList(newPropertyList),
      m_oldPropertyList(node->sectionModelProperties())
/**
 * TODO instead of "Property Changes" check which property
 * has been changed and display either lock/unlock, visible/hidden
 * or "Property Changes" (this require new strings)
 */
{
}
Exemple #28
0
TextPasteCommand::TextPasteCommand(const QMimeData *mimeData,
                                   QTextDocument *document,
                                   KoShapeController *shapeController,
                                   KoCanvasBase *canvas, KUndo2Command *parent, bool pasteAsText)
    : KUndo2Command (parent),
      m_mimeData(mimeData),
      m_document(document),
      m_rdf(0),
      m_shapeController(shapeController),
      m_canvas(canvas),
      m_pasteAsText(pasteAsText),
      m_first(true)
{
    m_rdf = qobject_cast<KoDocumentRdfBase*>(shapeController->resourceManager()->resource(KoText::DocumentRdf).value<QObject*>());

    if (m_pasteAsText)
        setText(kundo2_i18n("Paste As Text"));
    else
        setText(kundo2_i18n("Paste"));
}
KUndo2Command *LocaleConfigMoneyDialog::buildCommand( Project &project ) {
    MacroCommand *m = new ModifyProjectLocaleCmd( project, kundo2_i18n( "Modify currency settings" ) );
    MacroCommand *cmd = m_panel->buildCommand();
    if (cmd) {
        m->addCommand(cmd);
    }
    if ( m->isEmpty() ) {
        delete m;
        return 0;
    }
    return m;
}
KisImageLayerMoveCommand::KisImageLayerMoveCommand(KisImageWSP image, KisNodeSP node, KisNodeSP newParent, quint32 index)
        : KisImageCommand(kundo2_i18n("Move Layer"), image)
{
    m_layer = node;
    m_newParent = newParent;
    m_newAbove = 0;
    m_prevParent = node->parent();
    m_prevAbove = node->prevSibling();
    m_index = index;
    m_useIndex = true;
    m_doUpdates = true;
}