r19433 by fschmid - Fixed Bug #12576: [PATCH] limit the "size" of dropped vectors (Applied patch with some corrections)
scribus-commit
scribus-commit at lists.scribus.net
Tue Aug 19 08:31:08 UTC 2014
Author: fschmid
Date: Tue Aug 19 08:31:08 2014
New Revision: 19433
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19433
Log:
Fixed Bug #12576: [PATCH] limit the "size" of dropped vectors (Applied patch with some corrections)
Modified:
trunk/Scribus/scribus/canvasmode_normal.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/ui/customfdialog.cpp
trunk/Scribus/scribus/ui/customfdialog.h
Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Tue Aug 19 08:31:08 2014
@@ -1848,7 +1848,7 @@
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString wdir = dirs->get("pastefile", ".");
FPoint pastePoint = m_mouseCurrentPoint;
- CustomFDialog dia(m_view, wdir, tr("Open"), allFormats, fdExistingFiles);
+ CustomFDialog dia(m_view, wdir, tr("Open"), allFormats, fdExistingFiles | fdShowImportOptions);
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
else
@@ -1880,19 +1880,29 @@
fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
}
}
- if (m_doc->m_Selection->count() > 0)
- {
- double x2, y2, w, h;
- m_doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
- m_doc->moveGroup(pastePoint.x() - x2, pastePoint.y() - y2);
- m_ScMW->requestUpdate(reqColorsUpdate | reqSymbolsUpdate | reqLineStylesUpdate | reqTextStylesUpdate);
- }
m_doc->dontResize = false;
}
for (int a = 0; a < m_doc->m_Selection->count(); ++a)
{
PageItem *currItem = m_doc->m_Selection->itemAt(a);
currItem->LayerID = m_doc->activeLayer();
+ }
+ if (m_doc->m_Selection->count() > 0)
+ {
+ PageItem *newItem = m_doc->m_Selection->itemAt(0);
+ if (dia.TxCodeM->currentIndex() == 1)
+ {
+ if ((newItem->width() > m_doc->currentPage()->width()) || (newItem->height() > m_doc->currentPage()->height()))
+ m_doc->rescaleGroup(newItem, qMin(qMin(m_doc->currentPage()->width() / newItem->width(), m_doc->currentPage()->height() / newItem->height()), 1.0));
+ }
+ else if (dia.TxCodeM->currentIndex() == 2)
+ {
+ m_doc->rescaleGroup(newItem, qMax(qMin(m_doc->currentPage()->width() / newItem->width(), m_doc->currentPage()->height() / newItem->height()), 1.0));
+ }
+ double x2, y2, w, h;
+ m_doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
+ m_doc->moveGroup(pastePoint.x() - x2, pastePoint.y() - y2);
+ m_ScMW->requestUpdate(reqColorsUpdate | reqSymbolsUpdate | reqLineStylesUpdate | reqTextStylesUpdate);
}
m_doc->SnapGrid = savedAlignGrid;
m_doc->SnapGuides = savedAlignGuides;
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Aug 19 08:31:08 2014
@@ -15452,6 +15452,21 @@
setRedrawBounding(item);
}
+void ScribusDoc::rescaleGroup(PageItem* group, double scale)
+{
+ group->PoLine.scale(scale, scale);
+ group->setWidthHeight(group->width() * scale, group->height() * scale);
+ group->ClipEdited = true;
+ group->FrameType = 3;
+ AdjustItemSize(group, true);
+ group->OldB2 = group->width();
+ group->OldH2 = group->height();
+ if (group->isGroup())
+ group->asGroupFrame()->adjustXYPosition();
+ group->updateClip();
+ setRedrawBounding(group);
+}
+
void ScribusDoc::resizeGroupToContents(PageItem* group)
{
PageItem_Group* currItem = group->asGroupFrame();
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Aug 19 08:31:08 2014
@@ -1043,6 +1043,7 @@
void itemSelection_UnGroupObjects(Selection* customSelection=0);
void addToGroup(PageItem* group, PageItem* item);
void removeFromGroup(PageItem* item);
+ void rescaleGroup(PageItem* group, double scale);
void resizeGroupToContents(PageItem* group);
void itemSelection_resizeGroupToContents(Selection *customSelection=0);
void itemSelection_convertItemsTo(const PageItem::ItemType newType, Selection* restoredSelection=0, Selection* customSelection=0);
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Aug 19 08:31:08 2014
@@ -921,7 +921,6 @@
activeTransaction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create, "", Um::ICreate);
if (fi.exists())
{
- QString data;
if (fi.suffix().toLower() == "sce")
{
emit LoadElem(url.toLocalFile(), dropPosDoc.x(), dropPosDoc.y(), true, false, Doc, this);
@@ -988,6 +987,23 @@
emit AddBM(currItem);
}
Doc->m_Selection->copy(tmpSelection, false);
+ if (Doc->m_Selection->count() == 1)
+ {
+ PageItem *newItem = Doc->m_Selection->itemAt(0);
+ if ((newItem->width() > Doc->currentPage()->width()) || (newItem->height() > Doc->currentPage()->height()))
+ {
+ // QMenu *pmen = new QMenu();
+ // pmen->addAction( tr("Keep original Size"));
+ // pmen->addAction( tr("Scale to Page Size"));
+ // re = pmen->actions().indexOf(pmen->exec(QCursor::pos()));
+ // delete pmen;
+ // if (re == 1)
+ // {
+ Doc->rescaleGroup(newItem, qMin(qMin(Doc->currentPage()->width() / newItem->width(), Doc->currentPage()->height() / newItem->height()), 1.0));
+ newItem->update();
+ // }
+ }
+ }
activeTransaction.commit();
activeTransaction.reset();
}
Modified: trunk/Scribus/scribus/ui/customfdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/ui/customfdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/customfdialog.cpp Tue Aug 19 08:31:08 2014
@@ -445,6 +445,27 @@
Layout1C->addItem( spacer2 );
vboxLayout->addWidget(LayoutC);
}
+ if (flags & fdShowImportOptions)
+ {
+ LayoutC = new QFrame(this);
+ Layout1C = new QHBoxLayout(LayoutC);
+ Layout1C->setSpacing( 0 );
+ Layout1C->setContentsMargins(9, 0, 0, 0);
+ TxCodeT = new QLabel(this);
+ TxCodeT->setText( tr("Import Option:"));
+ Layout1C->addWidget(TxCodeT);
+ TxCodeM = new ScComboBox(LayoutC);
+ TxCodeM->setEditable(false);
+ TxCodeM->addItem("Keep original size");
+ TxCodeM->addItem("Downscale to page size");
+ TxCodeM->addItem("Upscale to page size");
+ TxCodeM->setCurrentIndex(0);
+ TxCodeM->setMinimumSize(QSize(200, 0));
+ Layout1C->addWidget(TxCodeM);
+ QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ Layout1C->addItem( spacer2 );
+ vboxLayout->addWidget(LayoutC);
+ }
bool setter2 = flags & fdHidePreviewCheckBox;
if (!setter2)
{
Modified: trunk/Scribus/scribus/ui/customfdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19433&path=/trunk/Scribus/scribus/ui/customfdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.h (original)
+++ trunk/Scribus/scribus/ui/customfdialog.h Tue Aug 19 08:31:08 2014
@@ -76,7 +76,8 @@
fdShowCodecs = 8, // Show and handle text codecs and ComboBox (true)
fdDirectoriesOnly = 16, // Show only directories
fdHidePreviewCheckBox = 32, // Hide preview Checkbox
- fdExistingFilesI = 64 // For multiple files
+ fdExistingFilesI = 64, // For multiple files
+ fdShowImportOptions = 128 // Show Vector Images Import Options
} fdFlags;
/*! \brief A Scribus own file dialog.
More information about the scribus-commit
mailing list