View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009811 | Scribus | Undo/Redo | public | 2011-03-07 14:48 | 2011-03-07 19:07 |
Reporter | cezaryece | Assigned To | cbradney | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | all | ||||
Product Version | 1.4.0svn | ||||
Fixed in Version | 1.4.0svn | ||||
Summary | 0009811: [FIX] undo for changing image scaling type, undo for clear contents of image frame and fix undo loading new image | ||||
Description | Attached patch do this: 1. add undo for switching image scale type (freescale <-> frame size) 2. add undo for clear contents of image frame 3. change undo information saved during loading new image into frame - now more settings for old image (scale settings, image filters, flipping state) can be restored | ||||
Tags | No tags attached. | ||||
Patch | |||||
|
undo_image_clear_load.patch (8,862 bytes)
Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16418) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -2702,7 +2702,18 @@ to += keepRatio ? Um::KeepRatio : Um::BreakRatio; SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling); if (freeScale != ScaleType) + { ss->set("SCALE_TYPE", freeScale); + if (!freeScale) + { + //if switching from free scaling to frame size + //in undo must be offset and scale saved + ss->set("OLD_IMAGEXOFFSET", LocalX); + ss->set("OLD_IMAGEYOFFSET", LocalY); + ss->set("OLD_IMAGEXSCALE", LocalScX); + ss->set("OLD_IMAGEYSCALE", LocalScY); + } + } if (keepRatio != AspectRatio) ss->set("ASPECT_RATIO", keepRatio); undoManager->action(this, ss); @@ -3219,6 +3230,8 @@ restoreImageEffects(ss, isUndo); else if (ss->contains("STEXT")) restoreEditText(ss, isUndo); + else if (ss->contains("CLEAR_IMAGE")) + restoreImageClear(ss,isUndo); } if (!OnMasterPage.isEmpty()) @@ -3525,6 +3538,20 @@ type = !state->getBool("SCALE_TYPE"); else type = state->getBool("SCALE_TYPE"); + //if restoring free scaling + //old offset and scale ratio must be restored + if (type) + { + double oscx = state->getDouble("OLD_IMAGEXSCALE"); + double oscy = state->getDouble("OLD_IMAGEYSCALE"); + double ox = state->getDouble("OLD_IMAGEXOFFSET"); + double oy = state->getDouble("OLD_IMAGEYOFFSET"); + Selection tempSelection(this, false); + tempSelection.addItem(this, true); + m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection); + m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection); + } + } bool ratio=AspectRatio; @@ -3567,6 +3594,35 @@ m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection); } +void PageItem::restoreImageClear(UndoState *state, bool isUndo) +{ + if (!isImageFrame()) + return; + if (isUndo) + { + ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state); + Pfile = is->get("PFILE"); + loadImage(Pfile, false); + effectsInUse = is->getItem(); + setImageFlippedH(is->getBool("FLIPPH")); + setImageFlippedV(is->getBool("FLIPPV")); + setImageScalingMode(is->getBool("SCALING"),is->getBool("ASPECT")); + setImageXOffset(is->getDouble("XOFF")); + setImageXScale(is->getDouble("XSCALE")); + setImageYOffset(is->getDouble("YOFF")); + setImageYScale(is->getDouble("YSCALE")); + setFillTransparency(is->getDouble("FILLT")); + setLineTransparency(is->getDouble("LINET")); + + select(); + m_Doc->updatePic(); + } + else + asImageFrame()->clearContents(); +} + + + void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour) { int mode = state->getInt("MODE"); @@ -3636,11 +3692,12 @@ m_Doc->regionsChanged()->update(QRectF()); } -void PageItem::restoreGetImage(SimpleState *state, bool isUndo) +void PageItem::restoreGetImage(UndoState *state, bool isUndo) { - QString fn = state->get("OLD_IMAGE_PATH"); + ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state); + QString fn = is->get("OLD_IMAGE_PATH"); if (!isUndo) - fn = state->get("NEW_IMAGE_PATH"); + fn = is->get("NEW_IMAGE_PATH"); if (fn.isEmpty()) { Selection tempSelection(this, false); @@ -3648,7 +3705,25 @@ m_Doc->itemSelection_ClearItem(&tempSelection); } else + { loadImage(fn, false); + if (isUndo) + { + //restore old image settings + effectsInUse = is->getItem(); + setImageFlippedH(is->getBool("FLIPPH")); + setImageFlippedV(is->getBool("FLIPPV")); + setImageScalingMode(is->getBool("SCALING"), is->getBool("ASPECT")); + setImageXOffset(is->getDouble("XOFF")); + setImageXScale(is->getDouble("XSCALE")); + setImageYOffset(is->getDouble("YOFF")); + setImageYScale(is->getDouble("YSCALE")); + setFillTransparency(is->getDouble("FILLT")); + setLineTransparency(is->getDouble("LINET")); + } + select(); + m_Doc->updatePic(); + } } void PageItem::restoreGroupsLastItem(SimpleState *state, bool isUndo) @@ -4909,11 +4984,22 @@ QString ext = fi.suffix().toLower(); if (UndoManager::undoEnabled() && !reload) { - SimpleState *ss = new SimpleState(Um::GetImage, filename, Um::IGetImage); - ss->set("GET_IMAGE", "get_image"); - ss->set("OLD_IMAGE_PATH", Pfile); - ss->set("NEW_IMAGE_PATH", filename); - undoManager->action(this, ss); + ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::GetImage, filename, Um::IGetImage); + is->set("GET_IMAGE", "get_image"); + is->set("OLD_IMAGE_PATH", Pfile); + is->set("NEW_IMAGE_PATH", filename); + is->set("FLIPPH",imageFlippedH()); + is->set("FLIPPV",imageFlippedV()); + is->set("SCALING",ScaleType); + is->set("ASPECT",AspectRatio); + is->set("XOFF",imageXOffset()); + is->set("XSCALE",imageXScale()); + is->set("YOFF",imageYOffset()); + is->set("YSCALE",imageYScale()); + is->set("FILLT", fillTransparency()); + is->set("LINET", lineTransparency()); + is->setItem(effectsInUse); + undoManager->action(this, is); } double xres = pixm.imgInfo.xres; double yres = pixm.imgInfo.yres; Index: Scribus/scribus/undomanager.cpp =================================================================== --- Scribus/scribus/undomanager.cpp (wersja 16418) +++ Scribus/scribus/undomanager.cpp (kopia robocza) @@ -965,6 +965,7 @@ UndoManager::CopyPage = tr("Copy page"); UndoManager::ToOutlines = tr("Convert to outlines"); UndoManager::EditText = tr("Edit text"); + UndoManager::ClearImage = tr("Clear image frame content"); } void UndoManager::initIcons() @@ -1166,6 +1167,7 @@ QString UndoManager::CopyPage = ""; QString UndoManager::ToOutlines = ""; QString UndoManager::EditText = ""; +QString UndoManager::ClearImage = ""; /*** Icons for UndoObjects *******************************************/ QPixmap *UndoManager::IImageFrame = 0; Index: Scribus/scribus/undomanager.h =================================================================== --- Scribus/scribus/undomanager.h (wersja 16418) +++ Scribus/scribus/undomanager.h (kopia robocza) @@ -589,6 +589,7 @@ static QString CopyPage; static QString ToOutlines; static QString EditText; + static QString ClearImage; /*@}*/ /** Index: Scribus/scribus/pageitem.h =================================================================== --- Scribus/scribus/pageitem.h (wersja 16418) +++ Scribus/scribus/pageitem.h (kopia robocza) @@ -1073,11 +1073,12 @@ void restoreImageScaleType(SimpleState *state, bool isUndo); void restoreImageScaleChange(SimpleState *state, bool isUndo); void restoreImageOffsetChange(SimpleState *state, bool isUndo); + void restoreImageClear(UndoState *state, bool isUndo); void restorePoly(SimpleState *state, bool isUndo, bool isContour); void restoreContourLine(SimpleState *state, bool isUndo); void restoreShapeType(SimpleState *state, bool isUndo); void restoreLayer(SimpleState *state, bool isUndo); - void restoreGetImage(SimpleState *state, bool isUndo); + void restoreGetImage(UndoState *state, bool isUndo); void restoreGroupsLastItem(SimpleState *state, bool isUndo); void restoreShapeContour(UndoState *state, bool isUndo); Index: Scribus/scribus/pageitem_imageframe.cpp =================================================================== --- Scribus/scribus/pageitem_imageframe.cpp (wersja 16418) +++ Scribus/scribus/pageitem_imageframe.cpp (kopia robocza) @@ -155,6 +155,24 @@ void PageItem_ImageFrame::clearContents() { + if (UndoManager::undoEnabled()) + { + ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::ClearImage + "\n" + Pfile, ""); + is->set("CLEAR_IMAGE", "clear_image"); + is->set("PFILE", Pfile); + is->set("FLIPPH",imageFlippedH()); + is->set("FLIPPV",imageFlippedV()); + is->set("SCALING",ScaleType); + is->set("ASPECT",AspectRatio); + is->set("XOFF",imageXOffset()); + is->set("XSCALE",imageXScale()); + is->set("YOFF",imageYOffset()); + is->set("YSCALE",imageYScale()); + is->set("FILLT", fillTransparency()); + is->set("LINET", lineTransparency()); + is->setItem(effectsInUse); + undoManager->action(this, is); + } effectsInUse.clear(); PictureIsAvailable = false; Pfile = ""; |
|
After this patch it is possible to make 1-step undo for Clear Contents for few selected text and image frames. |
|
I have this one applied locally.. will commit soon enough. making various changes.. |
|
cezaryece, please note I made changes in the text tags per our conversation, please ensure you update your copy to this code |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-03-07 14:48 | cezaryece | New Issue | |
2011-03-07 14:48 | cezaryece | File Added: undo_image_clear_load.patch | |
2011-03-07 14:51 | cbradney | Assigned To | => cbradney |
2011-03-07 14:51 | cbradney | Status | new => assigned |
2011-03-07 14:51 | cezaryece | Note Added: 0025753 | |
2011-03-07 16:27 | cbradney | Note Added: 0025755 | |
2011-03-07 16:36 | cbradney | Relationship added | has duplicate 0009805 |
2011-03-07 16:36 | cbradney | Status | assigned => resolved |
2011-03-07 16:36 | cbradney | Fixed in Version | => 1.4.0svn |
2011-03-07 16:36 | cbradney | Resolution | open => fixed |
2011-03-07 16:37 | cbradney | Issue cloned: 0009813 | |
2011-03-07 16:38 | cbradney | Relationship added | child of 0005745 |
2011-03-07 16:40 | cbradney | Note Added: 0025756 | |
2011-03-07 19:07 | cbradney | Status | resolved => closed |