r14796 by fschmid - Added actions for making external Images inline and vice versa.
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 23 12:50:40 CET 2010
Revision: 14796
Author: fschmid
Date: 2010-02-23T11:48:19.402727Z
Commit message: Added actions for making external Images inline and vice versa.
Changeset:
M /trunk/Scribus/scribus/actionmanager.cpp
M /trunk/Scribus/scribus/pageitem_imageframe.cpp
M /trunk/Scribus/scribus/scribus.cpp
M /trunk/Scribus/scribus/pageitem.cpp
M /trunk/Scribus/scribus/scribus.h
M /trunk/Scribus/scribus/pageitem.h
M /trunk/Scribus/scribus/ui/contextmenu.cpp
Diffs:
Index: scribus/pageitem.h
===================================================================
--- scribus/pageitem.h (revision 14795)
+++ scribus/pageitem.h (revision 14796)
@@ -662,6 +662,8 @@
QString inlineExt;
void setInlineExt(QString val) { inlineExt = val; }
void setInlineData(QString data);
+ void makeImageInline();
+ void makeImageExternal(QString path);
//Text Data - Move to PageItem_TextFrame at some point? --- no, to FrameStyle, av
double textToFrameDistLeft() const { return Extra; }
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp (revision 14795)
+++ scribus/pageitem.cpp (revision 14796)
@@ -6387,4 +6387,27 @@
}
}
+void PageItem::makeImageInline()
+{
+ QFileInfo fi(Pfile);
+ QString ext = fi.suffix();
+ tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
+ tempImageFile->open();
+ QString fileName = getLongPathName(tempImageFile->fileName());
+ tempImageFile->close();
+ isInlineImage = true;
+ copyFile(Pfile, fileName);
+ Pfile = fileName;
+}
+void PageItem::makeImageExternal(QString path)
+{
+ if ((tempImageFile) && (isInlineImage) && (!path.isEmpty()))
+ {
+ copyFile(Pfile, path);
+ Pfile = path;
+ isInlineImage = false;
+ delete tempImageFile;
+ tempImageFile = NULL;
+ }
+}
Index: scribus/actionmanager.cpp
===================================================================
--- scribus/actionmanager.cpp (revision 14795)
+++ scribus/actionmanager.cpp (revision 14796)
@@ -428,6 +428,8 @@
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="itemExtendedImageProperties";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+ name="itemToggleInlineImage";
+ scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="itemPreviewLow";
scrActions->insert(name, new ScrAction(ScrAction::DataInt, QPixmap(), QPixmap(), "", defaultKey(name), mainWindow, 2));
name="itemPreviewNormal";
@@ -449,6 +451,7 @@
(*scrActions)["itemPreviewLow"]->setToggleAction(true);
(*scrActions)["itemPreviewNormal"]->setToggleAction(true);
(*scrActions)["itemPreviewFull"]->setToggleAction(true);
+ (*scrActions)["itemToggleInlineImage"]->setToggleAction(true);
name="itemShapeEdit";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
@@ -483,6 +486,7 @@
connect( (*scrActions)["itemAttributes"], SIGNAL(triggered()), mainWindow, SLOT(objectAttributes()) );
connect( (*scrActions)["itemShapeEdit"], SIGNAL(triggered()), mainWindow, SLOT(toggleNodeEdit()) );
connect( (*scrActions)["itemImageInfo"], SIGNAL(triggered()), mainWindow, SLOT(getImageInfo()) );
+ connect( (*scrActions)["itemToggleInlineImage"], SIGNAL(triggered()), mainWindow, SLOT(toogleInlineState()) );
}
void ActionManager::initInsertMenuActions()
@@ -1367,6 +1371,7 @@
(*scrActions)["itemUpdateImage"]->setTexts( tr("&Update Image"));
(*scrActions)["itemAdjustFrameToImage"]->setTexts( tr("Adjust Frame to Image"));
(*scrActions)["itemAdjustImageToFrame"]->setTexts( tr("Adjust Image to Frame"));
+ (*scrActions)["itemToggleInlineImage"]->setTexts( tr("Image Inline"));
(*scrActions)["itemExtendedImageProperties"]->setTexts( tr("Extended Image Properties"));
(*scrActions)["itemPreviewLow"]->setTexts( tr("&Low Resolution"));
(*scrActions)["itemPreviewNormal"]->setTexts( tr("&Normal Resolution"));
@@ -1758,7 +1763,7 @@
itmenu->second << "typeEffectNormal" << "typeEffectUnderline" << "typeEffectUnderlineWords" << "typeEffectStrikeThrough" << "typeEffectAllCaps" << "typeEffectSmallCaps" << "typeEffectSuperscript" << "typeEffectSubscript" << "typeEffectOutline" << "typeEffectShadow" << "styleImageEffects" << "styleTabulators";
//Item
++itmenu;
- itmenu->second << "itemDuplicate" << "itemMulDuplicate" << "itemDelete" << "itemGroup" << "itemUngroup" << "itemLock" << "itemLockSize" << "itemImageIsVisible" << "itemUpdateImage" << "itemAdjustFrameToImage" << "itemAdjustImageToFrame" << "itemExtendedImageProperties" << "itemPreviewLow" << "itemPreviewNormal" << "itemPreviewFull" << "itemRaise" << "itemLower" << "itemRaiseToTop" << "itemLowerToBottom" << "itemSendToScrapbook" << "itemSendToPattern" << "itemAttributes" << "itemPDFIsAnnotation" << "itemPDFIsBookmark" << "itemPDFAnnotationProps" << "itemPDFFieldProps" << "itemShapeEdit" << "itemConvertToBezierCurve" << "itemConvertToImageFrame" << "itemConvertToOutlines" << "itemConvertToPolygon" << "itemConvertToTextFrame" << "itemAttachTextToPath" << "itemDetachTextFromPath" << "itemCombinePolygons" << "itemSplitPolygons";
+ itmenu->second << "itemDuplicate" << "itemMulDuplicate" << "itemDelete" << "itemGroup" << "itemUngroup" << "itemLock" << "itemLockSize" << "itemImageIsVisible" << "itemUpdateImage" << "itemAdjustFrameToImage" << "itemAdjustImageToFrame" << "itemToggleInlineImage" << "itemExtendedImageProperties" << "itemPreviewLow" << "itemPreviewNormal" << "itemPreviewFull" << "itemRaise" << "itemLower" << "itemRaiseToTop" << "itemLowerToBottom" << "itemSendToScrapbook" << "itemSendToPattern" << "itemAttributes" << "itemPDFIsAnnotation" << "itemPDFIsBookmark" << "itemPDFAnnotationProps" << "itemPDFFieldProps" << "itemShapeEdit" << "itemConvertToBezierCurve" << "itemConvertToImageFrame" << "itemConvertToOutlines" << "itemConvertToPolygon" << "itemConvertToTextFrame" << "itemAttachTextToPath" << "itemDetachTextFromPath" << "itemCombinePolygons" << "itemSplitPolygons";
//Insert
++itmenu;
itmenu->second
Index: scribus/ui/contextmenu.cpp
===================================================================
--- scribus/ui/contextmenu.cpp (revision 14795)
+++ scribus/ui/contextmenu.cpp (revision 14796)
@@ -30,7 +30,7 @@
#include "undomanager.h"
#include "canvasmode_legacy.h"
-#include "util.h" //just for tdebug
+// #include "util.h" //just for tdebug
ContextMenu::ContextMenu(Selection & sel, ScribusMainWindow *actionsParent, ScribusDoc* doc, QWidget * parent) :
QMenu(parent),
@@ -41,9 +41,9 @@
{
if (m_Sel.count()>0)
{
- tDebug("process Selection start");
+// tDebug("process Selection start");
processSelection();
- tDebug("process Selection end");
+// tDebug("process Selection end");
createMenuItems_Selection();
}
}
@@ -192,6 +192,11 @@
addAction(m_AP->scrActions["itemAdjustImageToFrame"]);
if (m_actionList.contains("itemExtendedImageProperties"))
addAction(m_AP->scrActions["itemExtendedImageProperties"]);
+ if (m_actionList.contains("itemAdjustFrameToImage"))
+ {
+ if (currItem->PictureIsAvailable)
+ addAction(m_AP->scrActions["itemToggleInlineImage"]);
+ }
if (m_actionList.contains("itemImageInfo"))
addAction(m_AP->scrActions["itemImageInfo"]);
if (m_actionList.contains("itemUpdateImage"))
Index: scribus/pageitem_imageframe.cpp
===================================================================
--- scribus/pageitem_imageframe.cpp (revision 14795)
+++ scribus/pageitem_imageframe.cpp (revision 14796)
@@ -368,6 +368,7 @@
actionList << "itemUpdateImage";
actionList << "editClearContents";
actionList << "editCopyContents";
+ actionList << "itemToggleInlineImage";
if (isRaster)
{
actionList << "styleImageEffects";
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp (revision 14795)
+++ scribus/scribus.cpp (revision 14796)
@@ -768,6 +768,7 @@
scrMenuMgr->addMenuItem(scrActions["itemUpdateImage"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["styleImageEffects"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemExtendedImageProperties"], "Item", false);
+ scrMenuMgr->addMenuItem(scrActions["itemToggleInlineImage"], "Item", false);
scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Item");
scrMenuMgr->addMenuItem(scrActions["itemImageIsVisible"], "ItemPreviewSettings", false);
scrMenuMgr->addMenuSeparator("ItemPreviewSettings");
@@ -2609,6 +2610,7 @@
scrActions["itemAdjustFrameToImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && !currItem->isTableItem);
scrActions["itemAdjustImageToFrame"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrActions["itemExtendedImageProperties"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->pixm.imgInfo.valid);
+ scrActions["itemToggleInlineImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrMenuMgr->setMenuEnabled("ItemPreviewSettings", SelectedType==PageItem::ImageFrame);
scrActions["itemImageIsVisible"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["itemPreviewLow"]->setEnabled(SelectedType==PageItem::ImageFrame);
@@ -2738,6 +2740,7 @@
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["itemImageIsVisible"]->setChecked(currItem->imageShown());
+ scrActions["itemToggleInlineImage"]->setChecked(currItem->isImageInline());
scrActions["itemPreviewLow"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewLow"]->actionInt());
scrActions["itemPreviewNormal"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewNormal"]->actionInt());
scrActions["itemPreviewFull"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewFull"]->actionInt());
@@ -4178,6 +4181,73 @@
}
}
+void ScribusMainWindow::toogleInlineState()
+{
+ if (doc->m_Selection->count() != 0)
+ {
+ PageItem *currItem = doc->m_Selection->itemAt(0);
+ if (currItem->itemType() == PageItem::ImageFrame)
+ {
+ if (currItem->PictureIsAvailable)
+ {
+ if (currItem->isImageInline())
+ {
+ QFileInfo fiB(currItem->Pfile);
+ QString fna = fiB.fileName();
+ PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false);
+ QString wdir = ".";
+ if (doc->hasName)
+ {
+ QFileInfo fi(doc->DocName);
+ wdir = QDir::fromNativeSeparators( fi.path() );
+ }
+ else
+ {
+ QString prefsDocDir = prefsManager->documentDir();
+ if (!prefsDocDir.isEmpty())
+ wdir = docContext->get("place_as", prefsDocDir);
+ else
+ wdir = docContext->get("place_as", ".");
+ wdir = QDir::fromNativeSeparators( wdir );
+ }
+ QString fileName = CFileDialog(wdir, tr("Filename and Path for Image"), tr("All Files (*)"), fna, fdHidePreviewCheckBox);
+ if (!fileName.isEmpty())
+ {
+ if (ScCore->fileWatcher->files().contains(currItem->Pfile) != 0)
+ ScCore->fileWatcher->removeFile(currItem->Pfile);
+ docContext->set("place_as", fileName.left(fileName.lastIndexOf("/")));
+ if (overwrite(this, fileName))
+ {
+ currItem->makeImageExternal(fileName);
+ ScCore->fileWatcher->addFile(currItem->Pfile);
+ bool fho = currItem->imageFlippedH();
+ bool fvo = currItem->imageFlippedV();
+ doc->loadPict(currItem->Pfile, currItem, true);
+ currItem->setImageFlippedH(fho);
+ currItem->setImageFlippedV(fvo);
+ currItem->AdjustPictScale();
+ }
+ }
+ }
+ else
+ {
+ if (ScCore->fileWatcher->files().contains(currItem->Pfile) != 0)
+ ScCore->fileWatcher->removeFile(currItem->Pfile);
+ currItem->makeImageInline();
+ ScCore->fileWatcher->addFile(currItem->Pfile);
+ bool fho = currItem->imageFlippedH();
+ bool fvo = currItem->imageFlippedV();
+ doc->loadPict(currItem->Pfile, currItem, true);
+ currItem->setImageFlippedH(fho);
+ currItem->setImageFlippedV(fvo);
+ currItem->AdjustPictScale();
+ }
+ scrActions["itemToggleInlineImage"]->setChecked(currItem->isImageInline());
+ }
+ }
+ }
+}
+
void ScribusMainWindow::slotFileAppend()
{
if (doc->m_Selection->count() != 0)
@@ -4282,7 +4352,7 @@
if (saveCompressed)
fna.append(".gz");
- QString fileSpec=tr("Documents (*.sla *.sla.gz);;All Files (*)");
+ QString fileSpec = tr("Documents (*.sla *.sla.gz);;All Files (*)");
int optionFlags = fdCompressFile | fdHidePreviewCheckBox;
QString fn = CFileDialog( wdir, tr("Save As"), fileSpec, fna, optionFlags, &saveCompressed);
if (!fn.isEmpty())
@@ -8605,13 +8675,17 @@
dia->setExtension(f.completeSuffix());
dia->setZipExtension(f.completeSuffix() + ".gz");
dia->setSelection(defNa);
- dia->SaveZip->setChecked(*docom);
+ if (docom != NULL)
+ dia->SaveZip->setChecked(*docom);
}
if (optionFlags & fdDirectoriesOnly)
{
- dia->SaveZip->setChecked(*docom);
- dia->WithFonts->setChecked(*doFont);
- dia->WithProfiles->setChecked(*doProfiles);
+ if (docom != NULL)
+ dia->SaveZip->setChecked(*docom);
+ if (doFont != NULL)
+ dia->WithFonts->setChecked(*doFont);
+ if (doProfiles != NULL)
+ dia->WithProfiles->setChecked(*doProfiles);
}
if (dia->exec() == QDialog::Accepted)
{
@@ -8627,9 +8701,12 @@
}
else
{
- *docom = dia->SaveZip->isChecked();
- *doFont = dia->WithFonts->isChecked();
- *doProfiles = dia->WithProfiles->isChecked();
+ if (docom != NULL)
+ *docom = dia->SaveZip->isChecked();
+ if (doFont != NULL)
+ *doFont = dia->WithFonts->isChecked();
+ if (doProfiles != NULL)
+ *doProfiles = dia->WithProfiles->isChecked();
}
this->repaint();
retval = dia->selectedFile();
Index: scribus/scribus.h
===================================================================
--- scribus/scribus.h (revision 14795)
+++ scribus/scribus.h (revision 14796)
@@ -299,6 +299,7 @@
void slotGetContent();
void slotGetContent2(); // kk2006
void slotGetClipboardImage();
+ void toogleInlineState();
/*!
\author Franz Schmid
\brief Appends a Textfile to the Text in the selected Textframe at the Cursorposition
More information about the scribus-commit
mailing list