View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011626 | Scribus | Import / Export | public | 2013-06-24 13:29 | 2018-04-30 14:37 |
Reporter | Chelen | Assigned To | Chelen | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | assigned | Resolution | open | ||
Product Version | 1.5.0svn | ||||
Summary | 0011626: [PATCH] Improve Import management | ||||
Description | This patch come next to image loader. To be more uniform, all files can be import with a single option instead of : "import image", "import text", "append text", "import vector file", there is just an "Import" option Through preference, we can select if we want: For oneclick frame creation: ask for a dimension, insert with doc size, insert with a default dimension Undo/redo are added too. This is tested by jluc | ||||
Tags | #rottenpatch | ||||
Patch | Yes | ||||
|
patch.diff (135,046 bytes)
diff --git a/Scribus/Scribus.pro b/Scribus/Scribus.pro index 6e42599..b01e1e8 100644 --- a/Scribus/Scribus.pro +++ b/Scribus/Scribus.pro @@ -596,7 +596,6 @@ HEADERS += scribus/actionmanager.h \ scribus/ui/gradientpreview.h \ scribus/ui/gradientvectordialog.h \ scribus/ui/gtdialogs.h \ - scribus/ui/gtfiledialog.h \ scribus/ui/guidemanager.h \ scribus/ui/helpbrowser.h \ scribus/ui/helpnavigation.h \ @@ -1129,7 +1128,8 @@ HEADERS += scribus/actionmanager.h \ scribus/styles/cellstyle.attrdefs.cxx \ scribus/main_nix.cpp \ scribus/main_win32.cpp \ - scribus/styles/linestyle.attrdefs.cxx + scribus/styles/linestyle.attrdefs.cxx \ + scribus/canvasmode_importdata.h FORMS += scribus/ui/aboutplugins.ui \ scribus/ui/aligndistribute.ui \ scribus/ui/arcvectorbase.ui \ @@ -1143,7 +1143,6 @@ FORMS += scribus/ui/aboutplugins.ui \ scribus/ui/gradientaddedit.ui \ scribus/ui/gradienteditor.ui \ scribus/ui/gradientvectorbase.ui \ - scribus/ui/gtfiledialog.ui \ scribus/ui/guidemanager.ui \ scribus/ui/helpbrowser.ui \ scribus/ui/helpbrowsernavigation.ui \ @@ -1607,7 +1606,6 @@ SOURCES += scribus/actionmanager.cpp \ scribus/ui/gradientpreview.cpp \ scribus/ui/gradientvectordialog.cpp \ scribus/ui/gtdialogs.cpp \ - scribus/ui/gtfiledialog.cpp \ scribus/ui/guidemanager.cpp \ scribus/ui/helpbrowser.cpp \ scribus/ui/helpnavigation.cpp \ @@ -2178,7 +2176,8 @@ SOURCES += scribus/actionmanager.cpp \ scribus/plugins/tools/2geomtools/meshdistortion/meshdistortion.cpp \ scribus/plugins/tools/2geomtools/meshdistortion/meshdistortiondialog.cpp \ scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp \ - scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp + scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp \ + scribus/canvasmode_importdata.cpp RESOURCES += scribus/plugins/scripter/python/sceditor/dockwidget_icons.qrc TRANSLATIONS += resources/translations/po/scribus.af.ts \ resources/translations/po/scribus.ar.ts \ diff --git a/Scribus/scribus/CMakeLists.txt b/Scribus/scribus/CMakeLists.txt index 0e2ddb6..01997ad 100644 --- a/Scribus/scribus/CMakeLists.txt +++ b/Scribus/scribus/CMakeLists.txt @@ -84,7 +84,6 @@ SET(SCRIBUS_UI_SRC ui/gradientaddedit.ui ui/gradienteditor.ui ui/gradientvectorbase.ui - ui/gtfiledialog.ui ui/guidemanager.ui ui/insertaframe.ui ui/inserttablecolumnsdialog.ui @@ -316,7 +315,6 @@ SET(SCRIBUS_MOC_CLASSES ui/gradientvectordialog.h ui/gradientpreview.h ui/gtdialogs.h - ui/gtfiledialog.h ui/guidemanager.h ui/helpbrowser.h ui/hruler.h @@ -520,7 +518,7 @@ SET(SCRIBUS_SOURCES canvasmode_drawfreehand.cpp canvasmode_eyedropper.cpp canvasmode_framelinks.cpp - canvasmode_imageimport.cpp + canvasmode_importdata.cpp canvasmode_edit.cpp canvasmode_editarc.cpp canvasmode_editgradient.cpp @@ -761,7 +759,6 @@ SET(SCRIBUS_SOURCES ui/gradientvectordialog.cpp ui/gradientpreview.cpp ui/gtdialogs.cpp - ui/gtfiledialog.cpp ui/guidemanager.cpp ui/helpbrowser.cpp ui/hruler.cpp diff --git a/Scribus/scribus/actionmanager.cpp b/Scribus/scribus/actionmanager.cpp index 4a7f806..595c86d 100644 --- a/Scribus/scribus/actionmanager.cpp +++ b/Scribus/scribus/actionmanager.cpp @@ -118,15 +118,7 @@ void ActionManager::initFileMenuActions() name="fileCollect"; scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); //File Import Menu - name="fileImportText"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportText2"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportAppendText"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportImage"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportVector"; + name="fileImport"; scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); //File Export Menu @@ -171,11 +163,7 @@ void ActionManager::initFileMenuActions() connect( (*scrActions)["fileCollect"], SIGNAL(triggered()), mainWindow, SLOT(fileCollect()) ); connect( (*scrActions)["fileQuit"], SIGNAL(triggered()), mainWindow, SLOT(slotFileQuit()) ); //File Import Menu - connect( (*scrActions)["fileImportText"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); - connect( (*scrActions)["fileImportText2"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent2()) ); - connect( (*scrActions)["fileImportAppendText"], SIGNAL(triggered()), mainWindow, SLOT(slotFileAppend()) ); - connect( (*scrActions)["fileImportImage"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); - connect( (*scrActions)["fileImportVector"], SIGNAL(triggered()), mainWindow, SLOT(importVectorFile()) ); + connect( (*scrActions)["fileImport"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); //File Export Menu connect( (*scrActions)["fileExportText"], SIGNAL(triggered()), mainWindow, SLOT(SaveText()) ); connect( (*scrActions)["fileExportAsEPS"], SIGNAL(triggered()), mainWindow, SLOT(SaveAsEps()) ); @@ -1424,10 +1412,7 @@ void ActionManager::languageChange() (*scrActions)["fileSaveAs"]->setTexts( tr("Save &As...")); (*scrActions)["fileRevert"]->setTexts( tr("Re&vert to Saved")); (*scrActions)["fileCollect"]->setTexts( tr("Collect for O&utput...")); - (*scrActions)["fileImportText"]->setTexts( tr("Get Text...")); - (*scrActions)["fileImportAppendText"]->setTexts( tr("Append &Text...")); - (*scrActions)["fileImportImage"]->setTexts( tr("Get Image...")); - (*scrActions)["fileImportVector"]->setTexts( tr("Get Vector File...")); + (*scrActions)["fileImport"]->setTexts( tr("Get File...")); (*scrActions)["fileExportText"]->setTexts( tr("Save &Text...")); (*scrActions)["fileExportAsEPS"]->setTexts( tr("Save as &EPS...")); @@ -1766,8 +1751,7 @@ void ActionManager::createDefaultShortcuts() defKeys.insert("fileClose", QKeySequence::Close); defKeys.insert("fileSave", QKeySequence::Save); defKeys.insert("fileSaveAs", Qt::CTRL+Qt::SHIFT+Qt::Key_S); - defKeys.insert("fileImportText", Qt::CTRL+Qt::Key_I); - defKeys.insert("fileImportImage", Qt::CTRL+Qt::Key_I); + defKeys.insert("fileImport", Qt::CTRL+Qt::Key_I); defKeys.insert("filePrint", QKeySequence::Print); defKeys.insert("fileExportAsPDF", Qt::CTRL+Qt::SHIFT+Qt::Key_P); defKeys.insert("fileQuit", Qt::CTRL+Qt::Key_Q); @@ -1926,10 +1910,7 @@ void ActionManager::createDefaultMenus() << "fileSaveAs" << "fileRevert" << "fileCollect" - << "fileImportText" - << "fileImportAppendText" - << "fileImportImage" - << "fileImportVector" + << "fileImport" << "fileExportText" << "fileExportAsEPS" << "fileExportAsPDF" diff --git a/Scribus/scribus/canvas.h b/Scribus/scribus/canvas.h index 3f34b38..518a414 100644 --- a/Scribus/scribus/canvas.h +++ b/Scribus/scribus/canvas.h @@ -101,7 +101,7 @@ public: friend class CanvasMode_EditTable; friend class CanvasMode_EyeDropper; friend class CanvasMode_FrameLinks; - friend class CanvasMode_ImageImport; + friend class CanvasMode_ImportData; friend class CanvasMode_Magnifier; friend class CanvasMode_NodeEdit; friend class CanvasMode_ObjImport; diff --git a/Scribus/scribus/canvasgesture_resize.cpp b/Scribus/scribus/canvasgesture_resize.cpp index 6e2f646..b0ad5f6 100644 --- a/Scribus/scribus/canvasgesture_resize.cpp +++ b/Scribus/scribus/canvasgesture_resize.cpp @@ -268,7 +268,7 @@ void ResizeGesture::doResize(bool scaleContent) double imgScX = (newBounds.width() - m_extraWidth) / divX * currItem->imageXScale(); double imgScY = (newBounds.height() - m_extraHeight) / divY * currItem->imageYScale(); // The aspect ratio has been fixed, so make the modification in the direction of the larger movement. - if (currItem->keepAspectRatio() && currItem->fitImageToFrame()) + if (currItem->keepAspectRatio() && currItem->fitImageToFrame()) { if (qAbs((newBounds.width() - m_extraWidth) - currItem->width()) > qAbs((newBounds.height() - m_extraHeight) - currItem->height())) imgScY = imgScX; @@ -305,10 +305,10 @@ void ResizeGesture::doResize(bool scaleContent) } // We do not want to scale the text of a linked frame // as it would alter text in other frames of the string - else if((currItem->itemType() == PageItem::TextFrame) - && (currItem->nextInChain() == 0) - && (currItem->prevInChain() == 0) - && scaleContent) + else if((currItem->itemType() == PageItem::TextFrame) + && (currItem->nextInChain() == 0) + && (currItem->prevInChain() == 0) + && scaleContent) { double divX = (currItem->width() != 0) ? currItem->width() : 1.0; double divY = (currItem->height() != 0) ? currItem->height() : 1.0; @@ -331,7 +331,7 @@ void ResizeGesture::doResize(bool scaleContent) #endif // We need to scale the linespacing _only once_ per paragraph. - if((aa == 0) + if((aa == 0) || ( SpecialChars::isBreak(currItem->itemText.itemText(aa - 1).at(0)))) { ParagraphStyle ps(currItem->itemText.paragraphStyle(aa)); @@ -353,8 +353,8 @@ void ResizeGesture::doResize(bool scaleContent) if (mm.m22() < 0) dy *= -1; currItem->moveBy(-dx, -dy, true); - currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth); - currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight); + currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth + currItem->lineWidth()); + currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight + currItem->lineWidth()); if (mm.m11() < 0) currItem->moveBy(-currItem->width(), 0); if (mm.m22() < 0) diff --git a/Scribus/scribus/canvasgesture_rulermove.cpp b/Scribus/scribus/canvasgesture_rulermove.cpp index 1ed6642..67fd876 100644 --- a/Scribus/scribus/canvasgesture_rulermove.cpp +++ b/Scribus/scribus/canvasgesture_rulermove.cpp @@ -158,14 +158,20 @@ void RulerGesture::mouseSelectGuide(QMouseEvent *m) void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) { FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); - const int page = m_doc->OnPage(mousePointDoc.x(), mousePointDoc.y()); + double x = mousePointDoc.x(), y = mousePointDoc.y(); + double dx = -x, dy = -y; + m_doc->ApplyGuides(&x,&y,true); + dx += x; + dy += y; + const int page = m_doc->OnPage(x, y); QRect viewport(m_view->viewport()->mapToGlobal(QPoint(0,0)), QSize(m_view->visibleWidth(), m_view->visibleHeight())); - QPoint newMousePoint = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0))); + QPointF newMousePoint = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0))); + newMousePoint += QPointF(dx,dy)*m_canvas->scale(); switch (m_mode) { case ORIGIN: m_canvas->repaint(); - m_canvas->displayCorrectedXYHUD(m->globalPos(), mousePointDoc.x(), mousePointDoc.y()); + m_canvas->displayCorrectedXYHUD(m->globalPos(), x, y); break; case HORIZONTAL: if (!m_ScMW->doc->guidesPrefs().guidesShown) @@ -179,8 +185,8 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) qApp->changeOverrideCursor(QCursor(Qt::SplitVCursor)); if (mouseRelease) { - m_doc->Pages->at(page)->guides.addHorizontal(mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); - m_guide = mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(); + m_doc->Pages->at(page)->guides.addHorizontal(y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_guide = y - m_doc->Pages->at(page)->yOffset(); m_page = page; m_haveGuide = true; m_doc->changed(); @@ -189,11 +195,11 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) else if (mouseRelease) { if (page == m_page) - m_doc->Pages->at(page)->guides.moveHorizontal( m_guide, mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.moveHorizontal( m_guide, y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); else { m_doc->Pages->at(m_page)->guides.deleteHorizontal( m_guide, GuideManagerCore::Standard); - m_doc->Pages->at(page)->guides.addHorizontal(mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.addHorizontal(y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); m_page = page; } if (m_doc->currentPage() != m_doc->Pages->at(m_page)) @@ -206,7 +212,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) if (cursor && (cursor->shape() != Qt::SplitVCursor)) qApp->changeOverrideCursor(QCursor(Qt::SplitVCursor)); } - m_currentGuide = mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(); + m_currentGuide = y - m_doc->Pages->at(page)->yOffset(); } else { @@ -221,7 +227,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) } } } - m_canvas->displayCorrectedSingleHUD(m->globalPos(), mousePointDoc.y(), false); + m_canvas->displayCorrectedSingleHUD(m->globalPos(),y, false); break; case VERTICAL: if (!m_ScMW->doc->guidesPrefs().guidesShown) @@ -235,8 +241,8 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) qApp->changeOverrideCursor(QCursor(Qt::SplitHCursor)); if (mouseRelease) { - m_doc->Pages->at(page)->guides.addVertical(mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); - m_guide = mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(); + m_doc->Pages->at(page)->guides.addVertical(x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_guide = x - m_doc->Pages->at(page)->xOffset(); m_page = page; m_haveGuide = true; m_doc->changed(); @@ -245,11 +251,11 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) else if (mouseRelease) { if (page == m_page) - m_doc->Pages->at(page)->guides.moveVertical( m_guide, mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.moveVertical( m_guide,x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); else { m_doc->Pages->at(m_page)->guides.deleteVertical( m_guide, GuideManagerCore::Standard); - m_doc->Pages->at(page)->guides.addVertical(mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.addVertical(x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); m_page = page; } if (m_doc->currentPage() != m_doc->Pages->at(m_page)) @@ -262,7 +268,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) if (cursor && (cursor->shape() != Qt::SplitHCursor)) qApp->changeOverrideCursor(QCursor(Qt::SplitHCursor)); } - m_currentGuide = mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(); + m_currentGuide = x - m_doc->Pages->at(page)->xOffset(); } else { @@ -277,7 +283,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) } } } - m_canvas->displayCorrectedSingleHUD(m->globalPos(), mousePointDoc.x(), true); + m_canvas->displayCorrectedSingleHUD(m->globalPos(), x, true); break; } m_xy = newMousePoint; diff --git a/Scribus/scribus/canvasgesture_rulermove.h b/Scribus/scribus/canvasgesture_rulermove.h index 42eaf17..c2cd312 100644 --- a/Scribus/scribus/canvasgesture_rulermove.h +++ b/Scribus/scribus/canvasgesture_rulermove.h @@ -88,7 +88,7 @@ private: double m_currentGuide; bool m_haveCursor; QCursor m_cursor; - QPoint m_xy; + QPointF m_xy; void movePoint(QMouseEvent *m, bool mouseRelease); signals: diff --git a/Scribus/scribus/canvasmode.cpp b/Scribus/scribus/canvasmode.cpp index 26153b9..c9e38a4 100644 --- a/Scribus/scribus/canvasmode.cpp +++ b/Scribus/scribus/canvasmode.cpp @@ -34,7 +34,7 @@ #include "canvasmode_editweldpoint.h" #include "canvasmode_eyedropper.h" #include "canvasmode_framelinks.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "canvasmode_magnifier.h" #include "canvasmode_measurements.h" #include "canvasmode_nodeedit.h" @@ -177,8 +177,8 @@ CanvasMode* CanvasMode::createForAppMode(ScribusView* view, int appMode) case modeUnlinkFrames: result = new CanvasMode_FrameLinks(view); break; - case modeImportImage: - result = new CanvasMode_ImageImport(view); + case modeImportData: + result = new CanvasMode_ImportData(view); break; case modeMagnifier: result = new CanvasMode_Magnifier(view); diff --git a/Scribus/scribus/canvasmode_create.cpp b/Scribus/scribus/canvasmode_create.cpp index 6a71ebf..ed3029f 100644 --- a/Scribus/scribus/canvasmode_create.cpp +++ b/Scribus/scribus/canvasmode_create.cpp @@ -596,15 +596,8 @@ PageItem* CreateMode::doCreateNewObject(void) skipOneClick = false; } if (!skipOneClick) - { if ((!m_view->moveTimerElapsed()) || ((fabs(wSize) < 2.0) && (fabs(hSize) < 2.0))) - { - if (!doOneClick(createObjectPos, canvasCurrCoord)) - { - return NULL; - } - } - } + !doOneClick(createObjectPos, canvasCurrCoord); wSize = canvasCurrCoord.x() - createObjectPos.x(); hSize = canvasCurrCoord.y() - createObjectPos.y(); @@ -850,102 +843,78 @@ PageItem* CreateMode::doCreateNewObject(void) bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint) { - bool doCreate = false; double xSize, ySize; int originPoint = 0; if (QApplication::keyboardModifiers() & Qt::ControlModifier) return true; - PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize"); - bool doRemember = sizes->getBool("Remember", true); + ItemToolPrefs sizes = m_doc->prefsData().itemToolPrefs; int lmode = (createObjectMode == modeDrawLine) ? 1 : 0; - if (lmode == 0) - { - xSize = sizes->getDouble("defWidth", 100.0); - ySize = sizes->getDouble("defHeight", 100.0); - originPoint = sizes->getInt("Origin", 0); - } - else - { - xSize = sizes->getDouble("defLength", 100.0); - ySize = sizes->getDouble("defAngle", 0.0); - originPoint = sizes->getInt("OriginL", 0); - } + xSize = sizes.imageDefaultWidth; + ySize = sizes.imageDefaultHeight; + originPoint = sizes.imageDefaultBasePoint; -// qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); - OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, lmode); - if (dia->exec()) + qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); + OneClick *dia = NULL; + if(sizes.imageDefaultSize > 1 && !(view()->ImageAfterDraw && sizes.imageDefaultSize == 2)) { - doRemember = dia->checkRemember->isChecked(); - if (lmode == 0) + dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, originPoint, lmode); + if (dia->exec()) { xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex()); originPoint = dia->RotationGroup->checkedId(); - if (doRemember) - { - sizes->set("defWidth", xSize); - sizes->set("defHeight", ySize); - sizes->set("Origin", originPoint); - } - endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize); - switch (originPoint) - { - case 0: - break; - case 1: - startPoint.setX(startPoint.x() - xSize); - endPoint.setX(endPoint.x() - xSize); - break; - case 2: - startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0); - endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0); - break; - case 3: - startPoint.setY(startPoint.y() - ySize); - endPoint.setY(endPoint.y() - ySize); - break; - case 4: - startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize); - endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize); - break; - } } - else + } + if (lmode == 0) + { + endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize); + switch (originPoint) { - FPoint oldStart = startPoint; - xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); - ySize = dia->spinHeight->value(); - originPoint = dia->RotationGroup->checkedId(); - if (doRemember) - { - sizes->set("defLength", xSize); - sizes->set("defAngle", ySize); - sizes->set("OriginL", originPoint); - } - double angle = -ySize * M_PI / 180.0; - switch (originPoint) - { - case 0: - endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle)); - break; - case 1: - startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle)); - endPoint = oldStart; - break; - case 2: - startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle)); - endPoint = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle)); - break; - } + case 0: + break; + case 1: + startPoint.setX(startPoint.x() - xSize); + endPoint.setX(endPoint.x() - xSize); + break; + case 2: + startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0); + endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0); + break; + case 3: + startPoint.setY(startPoint.y() - ySize); + endPoint.setY(endPoint.y() - ySize); + break; + case 4: + startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize); + endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize); + break; + } + } + else + { + FPoint oldStart = startPoint; + double angle = -ySize * M_PI / 180.0; + switch (originPoint) + { + case 0: + endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle)); + break; + case 1: + startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle)); + endPoint = oldStart; + break; + case 2: + startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle)); + endPoint = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle)); + break; } - sizes->set("Remember", doRemember); - doCreate = true; } - delete dia; - return doCreate; + if(dia) + delete dia; + return true; } FRect CreateMode::adjustedRect(FPoint &firstPoint, FPoint &secondPoint) diff --git a/Scribus/scribus/canvasmode_imageimport.cpp b/Scribus/scribus/canvasmode_imageimport.cpp deleted file mode 100644 index 5c88ea5..0000000 --- a/Scribus/scribus/canvasmode_imageimport.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - For general Scribus (>=1.3.2) copyright and licensing information please refer - to the COPYING file provided with the program. Following this notice may exist - a copyright and/or license notice that predates the release of Scribus 1.3.2 - for which a new license (GPL+exception) is in place. - */ -/*************************************************************************** -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -***************************************************************************/ - -#include "canvasmode_imageimport.h" - -#include <QApplication> -#include <QBuffer> -#include <QCursor> -#include <QEvent> -#include <QMouseEvent> -#include <QPainterPath> -#include <QPixmap> -#include <QPoint> -#include <QRect> -#include <QToolTip> -#include <QDebug> - -#include "canvas.h" -#include "canvasmode.h" -#include "prefsmanager.h" -#include "ui/propertiespalette.h" -#include "ui/propertiespalette_image.h" -#include "scribus.h" -#include "scribusdoc.h" -#include "scribusview.h" -#include "selection.h" -#include "util_icon.h" - -CanvasMode_ImageImport::CanvasMode_ImageImport(ScribusView *view) : CanvasMode(view), m_ScMW(view->m_ScMW) -{ - Mx=0; - My=0; -} - -void CanvasMode_ImageImport::setImageList(QStringList l) -{ - imageList = l; - if(l.size()==1) - { - while(!(m_doc->m_Selection->itemAt(0)->isImageFrame())) - m_doc->m_Selection->removeFirst(); - if(!m_doc->m_Selection->isEmpty()) - { - setImage(m_doc->m_Selection->itemAt(0)); - m_view->requestMode(submodePaintingDone); - } - else - newToolTip(l.first()); - } - else - newToolTip(l.first()); -} - -void CanvasMode_ImageImport::newToolTip(QString name) -{ - QPainter p; - QImage pm = QImage(80, 80, QImage::Format_ARGB32_Premultiplied); - QBrush b(QColor(205,205,205), loadIcon("testfill.png")); - p.begin(&pm); - p.fillRect(QRectF(0, 0, 80, 80), b); - QImage thumb; - if(thumb.load(name)) - { - thumb = thumb.scaled(80,80,Qt::KeepAspectRatio); - p.drawImage((80 - thumb.width()) / 2, (80 - thumb.height()) / 2, thumb); - QBuffer buffer; - buffer.open(QIODevice::WriteOnly); - pm.save(&buffer, "PNG"); - QByteArray ba = buffer.buffer().toBase64(); - buffer.close(); - tipText = "<p align=\"center\"><img src=\"data:image/png;base64," + QString(ba) + "\"></p>"; - } - else - tipText = "<p align=\"center\">" + name.right(name.lastIndexOf("/")) + "</p>"; - QToolTip::showText(QPoint(Mx,My), tipText, qApp->activeWindow()); - p.end(); -} - -void CanvasMode_ImageImport::drawControls(QPainter* p) -{ - commonDrawControls(p, false); -} - -void CanvasMode_ImageImport::enterEvent(QEvent *) -{ - if (!m_canvas->m_viewMode.m_MouseButtonPressed) - setModeCursor(); -} - -void CanvasMode_ImageImport::keyPressEvent(QKeyEvent *e) -{ - int kk = e->key(); - if (m_keyRepeat) - return; - m_keyRepeat = true; - e->accept(); - switch (kk) - { - case Qt::Key_Tab: - imageList.prepend(imageList.takeLast()); - break; - case Qt::Key_Backtab: - imageList.append(imageList.takeFirst()); - break; - case Qt::Key_Backspace: - imageList.removeFirst(); - break; - case Qt::Key_Escape: - imageList.clear(); - break; - } - updateList(); - m_keyRepeat = false; -} - - -void CanvasMode_ImageImport::leaveEvent(QEvent *e) -{ -} - -void CanvasMode_ImageImport::activate(bool fromGesture) -{ - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); - m_keyRepeat = false; - m_doc->DragP = false; - m_doc->leaveDrag = false; - m_canvas->m_viewMode.operItemMoving = false; - m_canvas->m_viewMode.operItemResizing = false; - m_view->MidButt = false; - setModeCursor(); - if (fromGesture) - m_view->update(); -} - -void CanvasMode_ImageImport::deactivate(bool forGesture) -{ - m_view->redrawMarker->hide(); -} - -void CanvasMode_ImageImport::mouseDoubleClickEvent(QMouseEvent *m) -{ - m->accept(); - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); -} - -void CanvasMode_ImageImport::mouseMoveEvent(QMouseEvent *m) -{ - Mx = m->globalPos().x(); - My = m->globalPos().y(); - QToolTip::showText(m->globalPos(), tipText, qApp->activeWindow()); - QToolTip::showText(m->globalPos(), tipText + "<b></b>", qApp->activeWindow()); - m->accept(); - PageItem *item; - if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) - { - PageItem_ImageFrame *currItem; - if((currItem = item->asImageFrame()) != NULL) - m_view->setCursor(QCursor(loadIcon("DrawImageFrame.xpm"))); - else - m_view->setCursor(QCursor(Qt::ArrowCursor)); - } - else - m_view->setCursor(QCursor(loadIcon("DrawImageFrame.xpm"))); - if (commonMouseMove(m)) - return; -} - -void CanvasMode_ImageImport::mousePressEvent(QMouseEvent *m) -{ - m_canvas->PaintSizeRect(QRect()); - m_canvas->m_viewMode.m_MouseButtonPressed = true; - m_canvas->m_viewMode.operItemMoving = false; - m_view->HaveSelRect = false; - m_doc->DragP = false; - m_doc->leaveDrag = false; - m->accept(); - m_view->registerMousePress(m->globalPos()); - PageItem *item; - if(imageList.size()>0) - { - if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) - { - PageItem_ImageFrame *currItem; - if((currItem = item->asImageFrame()) != NULL) - setImage(currItem); - } - else - view()->ImageAfterDraw = true; - } - if (m->button() == Qt::MidButton) - { - m_view->MidButt = true; - if (m->modifiers() & Qt::ControlModifier) - m_view->DrawNew(); - return; - } -} - -void CanvasMode_ImageImport::mouseReleaseEvent(QMouseEvent *m) -{ - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); - m->accept(); - m_view->updateContents(); - m_canvas->setRenderModeUseBuffer(false); - m_doc->DragP = false; - m_doc->leaveDrag = false; - m_canvas->m_viewMode.operItemMoving = false; - m_canvas->m_viewMode.operItemResizing = false; - m_view->MidButt = false; - updateList(); -} - -void CanvasMode_ImageImport::setImage(PageItem *currItem) -{ - QString fileName = imageList.takeFirst(); - currItem->EmProfile = ""; - currItem->pixm.imgInfo.isRequest = false; - currItem->UseEmbedded = true; - currItem->IProfile = m_doc->cmsSettings().DefaultImageRGBProfile; - currItem->IRender = m_doc->cmsSettings().DefaultIntentImages; - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - m_doc->loadPict(fileName, currItem, false, true); - m_ScMW->propertiesPalette->imagePal->displayScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset()); - m_ScMW->repaint(); - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - m_view->DrawNew(); - currItem->emitAllToGUI(); -} - -void CanvasMode_ImageImport::updateList() -{ - if(imageList.isEmpty()) - { - m_view->requestMode(submodePaintingDone); - QToolTip::hideText(); - } - else - newToolTip(imageList.first()); -} diff --git a/Scribus/scribus/canvasmode_imageimport.h b/Scribus/scribus/canvasmode_imageimport.h deleted file mode 100644 index 673dfba..0000000 --- a/Scribus/scribus/canvasmode_imageimport.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - For general Scribus (>=1.3.2) copyright and licensing information please refer - to the COPYING file provided with the program. Following this notice may exist - a copyright and/or license notice that predates the release of Scribus 1.3.2 - for which a new license (GPL+exception) is in place. - */ -/*************************************************************************** -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -***************************************************************************/ - - -#ifndef CANVASMODE_IMAGEIMPORT_H -#define CANVASMODE_IMAGEIMPORT_H - -#include <QEvent> -#include <QMouseEvent> -#include <QPainter> -#include <QPixmap> -#include <QStringList> - -#include "canvasmode.h" - -class PageItem; -class ScribusView; -class ScribusMainWindow; - -class CanvasMode_ImageImport : public CanvasMode -{ -public: - explicit CanvasMode_ImageImport(ScribusView* view); - virtual ~CanvasMode_ImageImport() {} - - virtual void enterEvent(QEvent *); - virtual void leaveEvent(QEvent *); - - virtual void activate(bool); - virtual void deactivate(bool); - virtual void keyPressEvent(QKeyEvent *e); - virtual bool handleKeyEvents() { return true; } - virtual void mouseDoubleClickEvent(QMouseEvent *m); - virtual void mouseReleaseEvent(QMouseEvent *m); - virtual void mouseMoveEvent(QMouseEvent *m); - virtual void mousePressEvent(QMouseEvent *m); - virtual void drawControls(QPainter* p); - - void setImageList(QStringList l); - void setImage(PageItem* item); - void updateList(); - -private: - bool m_keyRepeat; - QString tipText; - QStringList imageList; - ScribusMainWindow *m_ScMW; - double Mx, My; - void newToolTip(QString name); -}; - -#endif // CANVASMODE_IMAGEIMPORT_H diff --git a/Scribus/scribus/canvasmode_importdata.cpp b/Scribus/scribus/canvasmode_importdata.cpp new file mode 100644 index 0000000..7d304dd --- /dev/null +++ b/Scribus/scribus/canvasmode_importdata.cpp @@ -0,0 +1,337 @@ +/* + For general Scribus (>=1.3.2) copyright and licensing information please refer + to the COPYING file provided with the program. Following this notice may exist + a copyright and/or license notice that predates the release of Scribus 1.3.2 + for which a new license (GPL+exception) is in place. + */ +/*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + +#include "canvasmode_importdata.h" + +#include <QApplication> +#include <QBuffer> +#include <QCursor> +#include <QDrag> +#include <QEvent> +#include <QMessageBox> +#include <QMouseEvent> +#include <QPainterPath> +#include <QPixmap> +#include <QPoint> +#include <QRect> +#include <QToolTip> +#include <QUrl> +#include <QDebug> + +#include "canvas.h" +#include "canvasmode.h" +#include "ui/bookmarkpalette.h" +#include "fileloader.h" +#include "plugins/formatidlist.h" +#include "hyphenator.h" +#include "loadsaveplugin.h" +#include "pageitem_textframe.h" +#include "prefsmanager.h" +#include "ui/propertiespalette.h" +#include "ui/propertiespalette_image.h" +#include "scribus.h" +#include "scribusdoc.h" +#include "scribusview.h" +#include "selection.h" +#include "ui/stylemanager.h" +#include "util_formats.h" +#include "util_icon.h" + +CanvasMode_ImportData::CanvasMode_ImportData(ScribusView *view) : CanvasMode(view), m_ScMW(view->m_ScMW) +{ + pw = new FDialogPreview(m_ScMW,Qt::ToolTip); + trans = NULL; +} + +void CanvasMode_ImportData::setInformation(ImportSetup is) +{ + impsetup = is; + if(!m_doc->m_Selection->isEmpty() && is.filename.size()==1) + { + if(m_doc->m_Selection->itemAt(0)->isTextFrame()) + { + setText(m_doc->m_Selection->itemAt(0)->asTextFrame()); + m_view->requestMode(submodePaintingDone); + } + else if(m_doc->m_Selection->itemAt(0)->isImageFrame()) + { + setImage(m_doc->m_Selection->itemAt(0)->asImageFrame()); + m_view->requestMode(submodePaintingDone); + } + else + pw->GenPreview(is.filename.first()); + } + else + pw->GenPreview(is.filename.first()); +} + +void CanvasMode_ImportData::drawControls(QPainter* p) +{ + commonDrawControls(p, false); +} + +void CanvasMode_ImportData::enterEvent(QEvent *) +{ + if (!m_canvas->m_viewMode.m_MouseButtonPressed) + setModeCursor(); +} + +void CanvasMode_ImportData::keyPressEvent(QKeyEvent *e) +{ + int kk = e->key(); + if (m_keyRepeat) + return; + m_keyRepeat = true; + e->accept(); + switch (kk) + { + case Qt::Key_Tab: + impsetup.filename.prepend(impsetup.filename.takeLast()); + break; + case Qt::Key_Backtab: + impsetup.filename.append(impsetup.filename.takeFirst()); + break; + case Qt::Key_Backspace: + impsetup.filename.removeFirst(); + break; + case Qt::Key_Escape: + impsetup.filename.clear(); + break; + } + updateList(); + m_keyRepeat = false; +} + + +void CanvasMode_ImportData::leaveEvent(QEvent *e) +{ + if (!m_canvas->m_viewMode.m_MouseButtonPressed) + qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); +} + +void CanvasMode_ImportData::activate(bool fromGesture) +{ + pw->setVisible(true); + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); + m_keyRepeat = false; + m_doc->DragP = false; + m_doc->leaveDrag = false; + m_canvas->m_viewMode.operItemMoving = false; + m_canvas->m_viewMode.operItemResizing = false; + m_view->MidButt = false; + setModeCursor(); + if (fromGesture) + m_view->update(); +} + +void CanvasMode_ImportData::deactivate(bool forGesture) +{ + pw->hide(); + m_view->redrawMarker->hide(); +} + +void CanvasMode_ImportData::mouseDoubleClickEvent(QMouseEvent *m) +{ + m->accept(); + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); +} + +void CanvasMode_ImportData::mouseMoveEvent(QMouseEvent *m) +{ + pw->move(m->globalPos() + QPoint(10,10)); + m->accept(); + if (commonMouseMove(m)) + return; +} + +void CanvasMode_ImportData::mousePressEvent(QMouseEvent *m) +{ + m_canvas->PaintSizeRect(QRect()); + m_canvas->m_viewMode.m_MouseButtonPressed = true; + m_canvas->m_viewMode.operItemMoving = false; + m_view->HaveSelRect = false; + m_doc->DragP = false; + m_doc->leaveDrag = false; + m->accept(); + m_view->registerMousePress(m->globalPos()); + PageItem *item; + if(impsetup.filename.size()>0) + { + if(UndoManager::undoEnabled()) + { + trans = new UndoTransaction(undoManager->beginTransaction(Um::NoObjectFrame, Um::IImageFrame, Um::ImportFile,"",Um::ICreate)); + SimpleState *ss = new SimpleState(Um::ImportFile,"",Um::ICreate); + ss->set("FILE_LOADER","file_loader"); + ss->set("name",impsetup.filename.first()); + undoManager->action(m_ScMW,ss); + } + if(FormatsManager::instance()->isVectorFile(impsetup.filename.at(0))) + { + QFileInfo fi(impsetup.filename.at(0)); + QString suffix = fi.suffix().toLower(); + if ((suffix == "sce") || (suffix == "shape")) + { + QList<QUrl> urls; + QMimeData* md = new QMimeData(); + urls.append( QUrl::fromLocalFile(impsetup.filename.takeFirst()) ); + md->setUrls(urls); + QDrag* dr = new QDrag(m_ScMW); + dr->setMimeData(md); + dr->setPixmap(loadIcon("DragPix.xpm")); + dr->exec(); + } + else + { + FileLoader *fileLoader = new FileLoader(impsetup.filename.at(0)); + int testResult = fileLoader->testFile(); + delete fileLoader; + if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER)) + { + const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult); + if( fmt ) + { + m_doc->dontResize = true; + fmt->loadFile(impsetup.filename.takeFirst(), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive); + m_doc->dontResize = false; + } + } + } + } + else if(getImageType(impsetup.filename.at(0)) == QString("")) + { + if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) + { + if((item->asTextFrame()) != NULL) + setText(item->asTextFrame()); + else + view()->TextAfterDraw = true; + } + else + view()->TextAfterDraw = true; + } + else if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) + { + if((item->asImageFrame()) != NULL) + setImage(item->asImageFrame()); + else + view()->ImageAfterDraw = true; + } + else + view()->ImageAfterDraw = true; + } + if (m->button() == Qt::MidButton) + { + m_view->MidButt = true; + if (m->modifiers() & Qt::ControlModifier) + m_view->DrawNew(); + return; + } +} + +void CanvasMode_ImportData::mouseReleaseEvent(QMouseEvent *m) +{ + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); + m->accept(); + m_view->updateContents(); + m_canvas->setRenderModeUseBuffer(false); + m_doc->DragP = false; + m_doc->leaveDrag = false; + m_canvas->m_viewMode.operItemMoving = false; + m_canvas->m_viewMode.operItemResizing = false; + m_view->MidButt = false; + updateList(); +} + +void CanvasMode_ImportData::setImage(PageItem *currItem) +{ + QString fileName = impsetup.filename.takeFirst(); + currItem->EmProfile = ""; + currItem->pixm.imgInfo.isRequest = false; + currItem->UseEmbedded = true; + currItem->IProfile = m_doc->cmsSettings().DefaultImageRGBProfile; + currItem->IRender = m_doc->cmsSettings().DefaultIntentImages; + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + m_doc->loadPict(fileName, currItem, false, true); + // if preference is image simze value + if(!(1 & m_doc->prefsData().itemToolPrefs.imageDefaultSize)) + { + currItem->setWidthHeight(currItem->pixm.width(),currItem->pixm.height()); + currItem->updateClip(); + } + m_ScMW->propertiesPalette->imagePal->displayScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset()); + m_ScMW->repaint(); + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + m_view->DrawNew(); + currItem->emitAllToGUI(); +} + +void CanvasMode_ImportData::updateList() +{ + if(trans) + { + trans->commit(); + delete trans; + trans = NULL; + } + if(impsetup.filename.isEmpty()) + { + pw->hide(); + m_view->requestMode(submodePaintingDone); + } + else + pw->GenPreview(impsetup.filename.first()); +} + + +void CanvasMode_ImportData::setText(PageItem_TextFrame *currItem) +{ + QString fileName = impsetup.filename.takeFirst(); + gtGetText* gt = new gtGetText(m_doc); + if (currItem->itemText.length() != 0) + { + int t = QMessageBox::warning(m_doc->scMW(), CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + if (t == QMessageBox::No) + return; + } + gt->launchImporter(-1, fileName, impsetup.textOnly, impsetup.encoding, false,currItem); + if (m_doc->docHyphenator->AutoCheck) + m_doc->docHyphenator->slotHyphenate(currItem); + for (int a = 0; a < m_doc->Items->count(); ++a) + { + if (m_doc->Items->at(a)->isBookmark) + m_doc->scMW()->bookmarkPalette->BView->ChangeText(m_doc->Items->at(a)); + } + m_view->DrawNew(); + m_doc->changed(); + m_doc->scMW()->styleMgr()->setDoc(m_doc); + delete gt; +} + +void CanvasMode_ImportData::insertImage(int i,QString fileName) +{ + impsetup.filename.insert(i, fileName); + if(i==0) + { + pw->GenPreview(fileName); + } +} + +void CanvasMode_ImportData::deleteImage(QString fileName) +{ + impsetup.filename.removeAt(impsetup.filename.indexOf(fileName)); +} diff --git a/Scribus/scribus/canvasmode_importdata.h b/Scribus/scribus/canvasmode_importdata.h new file mode 100644 index 0000000..3c790fb --- /dev/null +++ b/Scribus/scribus/canvasmode_importdata.h @@ -0,0 +1,69 @@ +/* + For general Scribus (>=1.3.2) copyright and licensing information please refer + to the COPYING file provided with the program. Following this notice may exist + a copyright and/or license notice that predates the release of Scribus 1.3.2 + for which a new license (GPL+exception) is in place. + */ +/*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + + +#ifndef CANVASMODE_IMPORTDATA_H +#define CANVASMODE_IMPORTDATA_H + +#include <QEvent> +#include <QMouseEvent> +#include <QPainter> +#include <QPixmap> +#include <QStringList> + +#include "canvasmode.h" +#include "ui/customfdialog.h" +#include "gtgettext.h" +#include "undomanager.h" + +class PageItem; +class ScribusView; +class ScribusMainWindow; + +class CanvasMode_ImportData : public CanvasMode +{ +public: + explicit CanvasMode_ImportData(ScribusView* view); + virtual ~CanvasMode_ImportData() {} + + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); + + virtual void activate(bool); + virtual void deactivate(bool); + virtual void keyPressEvent(QKeyEvent *e); + virtual bool handleKeyEvents() { return true; } + virtual void mouseDoubleClickEvent(QMouseEvent *m); + virtual void mouseReleaseEvent(QMouseEvent *m); + virtual void mouseMoveEvent(QMouseEvent *m); + virtual void mousePressEvent(QMouseEvent *m); + virtual void drawControls(QPainter* p); + + void setInformation(ImportSetup is); + void insertImage(int i,QString fileName); + void deleteImage(QString fileName); + void setImage(PageItem* item); + void setText(PageItem_TextFrame* item); + void updateList(); + +private: + UndoTransaction *trans; + FDialogPreview *pw; + bool m_keyRepeat; + ImportSetup impsetup; + ScribusMainWindow *m_ScMW; +}; + +#endif // CANVASMODE_IMPORTDATA_H diff --git a/Scribus/scribus/canvasmode_objimport.cpp b/Scribus/scribus/canvasmode_objimport.cpp index 3b1e1ea..f70325b 100644 --- a/Scribus/scribus/canvasmode_objimport.cpp +++ b/Scribus/scribus/canvasmode_objimport.cpp @@ -180,8 +180,8 @@ void CanvasMode_ObjImport::mousePressEvent(QMouseEvent *m) delete undoTransaction; undoTransaction = NULL; } - // Return to normal mode - m_view->requestMode(modeNormal); + // Return to Import data mode + m_view->requestMode(modeImportData); } } diff --git a/Scribus/scribus/gtgettext.cpp b/Scribus/scribus/gtgettext.cpp index 7355a84..4afde4b 100644 --- a/Scribus/scribus/gtgettext.cpp +++ b/Scribus/scribus/gtgettext.cpp @@ -35,14 +35,13 @@ for which a new license (GPL+exception) is in place. //Added by qt3to4: #include <QPixmap> #include "util_icon.h" +#include "util_formats.h" // Constructor gtGetText::gtGetText(ScribusDoc* doc) { // Attach to the active document m_Doc=doc; - // Load the plugins array. - loadImporterPlugins(); } // gtGetText::gtGetText(ScribusDoc* doc) // Look at the results of the file selection dialog and figure out if you need to use an importer. @@ -61,6 +60,7 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO { // Attempt to determine the importer based on the file's extension. // Create a Qstring with what could be an extension. + QMap<QString, ImporterData*> importerMap = FormatsManager::instance()->getMap(); QString fend = filename.right(filename.length() - filename.lastIndexOf(".") - 1); QString fendL(fend.toLower()); // Look for that extension in the importer QMap. @@ -79,19 +79,14 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO dias = new gtDialogs(); // Pop up the dialog asking the user to select the type from our list (ilist) of // importable file types. If one is not selected, set callImporter to false. - callImporter = dias->runImporterDialog(ilist); + callImporter = dias->runImporterDialog(FormatsManager::instance()->getIlist(),filename); // If we're gonna call an importer, we need to copy it's struct to ida. if (callImporter) - ida = importers[dias->getImporter()]; + ida = (FormatsManager::instance()->getImporters())[dias->getImporter()]; // Destroy the diag delete dias; - } // else - if (importerMap.find(fend) != importerMap.end()) + } } - else // If we know which importer to use - { - // Copy the importer's struct to ida. - ida = importers[importer]; - } // else - if (importer == -1) // Create a target text frame for the imported text and assign it to the parameter "target" PageItem* targetFrame=target; @@ -108,116 +103,9 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO } //void gtGetText::launchImporter(int importer, const QString& filename, bool textOnly, // const QString& encoding, bool append, PageItem* target) -// Find the available plugins based on the environment, validate they load, and -// create quick lookup mappings. -void gtGetText::loadImporterPlugins() -{ - // Get the path to the plugins - QString gtdir = ScPaths::instance().pluginDir(); - // Append the gettext path to the plugin - gtdir += "gettext"; - // Set the search parameteer for the platform specific extension for the plugins ( DLL, so, etc. ) - QString libPattern = QString("*.%1*").arg(PluginManager::platformDllExtension()); - // Search for matches. - QDir d(gtdir, libPattern, QDir::Name, (QDir::Filter) PluginManager::platformDllSearchFlags()); - - // Initialize a structure for the importers found - struct ImporterData ida; - ida.fileFormatName = ""; - - // Check and see if the directory existed and if the count of files matching is greater than 0. - if ((d.exists()) && (d.count() != 0)) - { - // loop through the entries. - for (uint dc = 0; dc < d.count(); ++dc) - { - // Verify the Plugin will load. If it does, collect the info on the plugin ( Name, extension, format, etc ) - if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) - { - // no plugin's "format name" marks "don't load plug" - if (ida.fileFormatName.isNull()) - continue; - // Store the path to the plugin. - ida.soFilePath = d[dc]; - // If the plugin path does not begin with /, prepend a /. - if (ida.soFilePath.left(1) != "/") - ida.soFilePath = "/" + ida.soFilePath; - // Add the plugin data to the end of the importer's vector. - importers.push_back(ida); - } // if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) - } // for (uint dc = 0; dc < d.count(); ++dc) - } // if ((d.exists()) && (d.count() != 0)) - // Create the Importer Extension to Plugin data qmap. - createMap(); -} // void gtGetText::loadImporterPlugins() - -// Creates the dialog for the user to import a file based on the supported file formats. -ImportSetup gtGetText::run() -{ - // Initialize a filters list. - QString filters = ""; - // Create a string for the "All supported files filter". Start with the label then loop through - // the importers vector and add all of the file extensions supported. - QString allSupported = QObject::tr("All Supported Formats") + " ("; - // Loop through the importers vector. - for (uint i = 0; i < importers.size(); ++i) - { - // If there are any file extnsions declared by the importer - if (importers[i].fileEndings.count() != 0) - { - // Add the importer name to the filters list - filters += importers[i].fileFormatName + " ("; - // Loop though the extensions supported by the importer - for (int j = 0; j < importers[i].fileEndings.count(); ++j) - { - // Add the extension to both the filter and allSupported strings - filters += "*." + importers[i].fileEndings[j] + " "; - allSupported += "*." + importers[i].fileEndings[j] + " "; - } // for (int j = 0; j < importers[i].fileEndings.count(); ++j) - // Trim the Qstring - filters = filters.trimmed(); - // Append "entry of entry" information to the end of the filter. - filters += ");;"; - } // if (importers[i].fileEndings.count() != 0) - } // for (uint i = 0; i < importers.size(); ++i) - // Trim the allSupported QString and append "end of entry" data to the end of it. - allSupported = allSupported.trimmed(); - allSupported += ");;"; - // Prepend allSupported to the filters Qstring. - filters = allSupported + filters; - // Add an "all files" entry to the end of the filters QString - filters += QObject::tr("All Files (*)"); - // Populate ilist with the file importer names. - for (uint i = 0; i < importers.size(); ++i) - ilist.append(importers[i].fileFormatName); - // Create a new dialog. - dias = new gtDialogs(); - // Create a new ImportSetup struct - ImportSetup impsetup; - // INitialize runDialog to false - impsetup.runDialog=false; - // If we get a true back from the File selection Dialog ( which we send our filters and extensions lists ) - if (dias->runFileDialog(filters, ilist)) - { - // Set the runDialog to true - impsetup.runDialog=true; - // Copy the other values for the struct from the dialog results - impsetup.encoding=dias->getEncoding(); - impsetup.filename=dias->getFileName(); - impsetup.importer=dias->getImporter(); - impsetup.textOnly=dias->importTextOnly(); -// launchImporter(dias->getImporter(), dias->getFileName(), -// dias->importTextOnly(), dias->getEncoding(), append); - } // if (dias->runFileDialog(filters, ilist)) - // Destroy the dialog. - delete dias; - // Return the ImportSetup struct. - return impsetup; -} // ImportSetup gtGetText::run() - // Loads, validates, and executes the Importer code. void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, - const QString& encoding, bool textOnly, bool append, PageItem* importItem) + const QString& encoding, bool textOnly, bool append, PageItem* importItem) { // Pointer for the loaded plugin. void* gtplugin; @@ -246,7 +134,7 @@ void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, importItem->itemText.clear(); // Execute the importer's "GetText2" method. (*fp_GetText2)(filePath, encoding, textOnly, importItem); - } // if (!fp_GetText2) + } // if (!fp_GetText2) else { // Attempt to map the old GetText method to to the pointer via the PluginManager. Store the result in fp_GetText. @@ -273,73 +161,6 @@ void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, } // void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, // const QString& encoding, bool textOnly, bool append, PageItem* importItem) -// Loads the "DLL", validates the importer is good, populates the passed parameters with -// the plugin information. -bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) -{ - // Pointer to the plugin, once loaded - void* gtplugin; - // typedef of Qstring to map the importer name (FileFormatName) method results to. - typedef QString (*sdem0)(); - // typedef of QStringList to map the file extensions supported method results to. - typedef QStringList (*sdem1)(); - // The actual importer name object - sdem0 fp_FileFormatName; - // The actual extensions supported object - sdem1 fp_FileExtensions; - // Initialise the plugin file path ( with filename ) - QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(name); - // Attempt to load the plugin. - gtplugin = PluginManager::loadDLL(pluginFilePath); - // if gtplugin is NULL we were unable to load the plugin. Return an error and exit the method. - if (!gtplugin) - { - qWarning("Failed to load plugin %s", pluginFilePath.toLatin1().constData()); - return false; - } - // Attempt to resolve the plugin symbol to the importer name (FileFormatName) - fp_FileFormatName = (sdem0) PluginManager::resolveSym( gtplugin, "FileFormatName"); - // if fp_FileFormatName is NULL, we could not find the FileFormatName symbol. The plugin is incomplete. - // Report an error, unload the plugin, and exit the method. - if (!fp_FileFormatName) - { - qWarning("Failed to get FileFormatName() from %s", pluginFilePath.toLatin1().constData()); - PluginManager::unloadDLL(gtplugin); - return false; - } - // Attempt to resolve the plugin symbol to the list of supported file extensions. - fp_FileExtensions = (sdem1) PluginManager::resolveSym( gtplugin, "FileExtensions"); - // if fp_FileExtensions is NULL, we could not find the FileExtensions symbol. The plugin is incomplete. - // Report an error, unload the plugin, and exit the method. - if (!fp_FileExtensions) - { - qWarning("Failed to get FileExtensions() from %s", pluginFilePath.toLatin1().constData()); - PluginManager::unloadDLL(gtplugin); - return false; - } - // Set the format name based on the resolved method. - *ffName = (*fp_FileFormatName)(); - // Set the extensions list based on the resolved method. - *fEndings = (*fp_FileExtensions)(); - // Unload the plugin - PluginManager::unloadDLL(gtplugin); - // Successfully return! - return true; -} // bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) - -// Create the importer Qmap. -void gtGetText::createMap() -{ - // Loop through the importers Vector - for (uint i = 0; i < importers.size(); ++i) - { - // Loop through each file extension the importer uses/importers and create an individual - // Qmap entry for it. - for (int j = 0; j < importers[i].fileEndings.count(); ++j) - importerMap.insert(importers[i].fileEndings[j], &importers[i]); - } // for (uint i = 0; i < importers.size(); ++i) -} // void gtGetText::createMap() - // Destructor gtGetText::~gtGetText() { diff --git a/Scribus/scribus/gtgettext.h b/Scribus/scribus/gtgettext.h index ff30238..a247b24 100644 --- a/Scribus/scribus/gtgettext.h +++ b/Scribus/scribus/gtgettext.h @@ -39,51 +39,26 @@ for which a new license (GPL+exception) is in place. #include "scconfig.h" #include "scribusapi.h" #include "scfonts.h" +#include "util_formats.h" class PageItem; class ScribusDoc; class gtDialogs; -// A struct for holding the Importer specific information. -struct ImporterData { - QString soFilePath; // Path to the Importer - QString fileFormatName; // Name of the Importer - QStringList fileEndings; // Array of filenames supported by the importer -}; - -// A Struct for holding the results of the File selection Dialog -struct ImportSetup { - bool runDialog; // Did the dialog run correctly? - int importer; // Which importer was selected? - QString filename; // What filename is to be loaded? - bool textOnly; // Do we import as text only? - QString encoding; // File encoding -}; - /* - GetText handles the open file dialog and importer plugins loading and launching. + GetText handles importer plugins loading and launching. */ class SCRIBUS_API gtGetText { private: - std::vector<ImporterData> importers; // Vector of the loaded importers - QMap<QString, ImporterData*> importerMap; // QMap of the supported extensions to their relevant importers entry for easy access - void loadImporterPlugins(); // Find the available plugins based on the environment, validate they load, and - // create quick lookup mappings. void CallDLL(const ImporterData& idata, const QString& filePath, - const QString& encoding, bool textOnly, bool append, PageItem* importItem); + const QString& encoding, bool textOnly, bool append, PageItem* importItem); // Loads, validates, and executes the Importer code. - bool DLLName(QString name, QString *ffName, QStringList *fileEndings); - // Loads the "DLL", validates the importer is good, populates the passed parameters with - // the plugin information. - void createMap(); // Create the importer Qmap. gtDialogs* dias; // File Selection Dialog pointer. - QStringList ilist; // List of supported importers, used with dialogs ScribusDoc* m_Doc; // Which document are we working with. public: gtGetText(ScribusDoc* doc); // Constructor ~gtGetText(); // Destructor - ImportSetup run(); // Creates the dialog for the user to import a file based on the supported file formats. void launchImporter(int importer, const QString& filename, bool textOnly, const QString& encoding, bool append, PageItem* target=0); // Look at the results of the file selection dialog and figure out if you need to use an importer. // Prompt the user if the importer to use isn't obvious. diff --git a/Scribus/scribus/pageitem.cpp b/Scribus/scribus/pageitem.cpp index c74ed26..1d21c05 100644 --- a/Scribus/scribus/pageitem.cpp +++ b/Scribus/scribus/pageitem.cpp @@ -4996,6 +4996,14 @@ void PageItem::restore(UndoState *state, bool isUndo) restoreUniteItem(ss, isUndo); else if (ss->contains("SPLITITEM")) restoreSplitItem(ss, isUndo); + else if (ss->contains("CREATE_MESH_GRAD")) + restoreCreateMeshGrad(ss, isUndo); + else if (ss->contains("MOVE_MESH_GRAD")) + restoreMoveMeshGrad(ss, isUndo); + else if (ss->contains("RESET_MESH_GRAD")) + restoreResetMeshGrad(ss, isUndo); + else if (ss->contains("REMOVE_MESH_PATCH")) + restoreRemoveMeshPatch(ss, isUndo); else if (ss->contains("MIRROR_PATH_H")) { bool editContour = m_Doc->nodeEdit.isContourLine; @@ -5565,6 +5573,7 @@ void PageItem::restoreTransform(SimpleState *ss, bool isUndo) } } + void PageItem::restoreSnapToPatchGrid(SimpleState *state, bool isUndo) { if (isUndo) @@ -5574,7 +5583,6 @@ void PageItem::restoreSnapToPatchGrid(SimpleState *state, bool isUndo) update(); } - void PageItem::restoreMaskType(SimpleState *state, bool isUndo) { if (isUndo) @@ -9082,7 +9090,7 @@ bool PageItem::loadImage(const QString& filename, const bool reload, const int g } } } - + Pfile = fi.absoluteFilePath(); if (reload && pixm.imgInfo.PDSpathData.contains(clPath)) { @@ -9423,7 +9431,7 @@ void PageItem::AdjustPictScale() { if (itemType() != PageItem::ImageFrame) return; - if (ScaleType) + if (ScaleType || !(doc()->prefsData().itemToolPrefs.imageDefaultSize &1)) return; if (OrigW == 0 || OrigH == 0) return; diff --git a/Scribus/scribus/pageitem_imageframe.cpp b/Scribus/scribus/pageitem_imageframe.cpp index 9f57ef6..8499a21 100644 --- a/Scribus/scribus/pageitem_imageframe.cpp +++ b/Scribus/scribus/pageitem_imageframe.cpp @@ -424,7 +424,6 @@ bool PageItem_ImageFrame::createInfoGroup(QFrame *infoGroup, QGridLayout *infoGr void PageItem_ImageFrame::applicableActions(QStringList & actionList) { - actionList << "fileImportImage"; actionList << "itemConvertToTextFrame"; actionList << "itemImageIsVisible"; actionList << "itemPreviewFull"; diff --git a/Scribus/scribus/pageitem_textframe.cpp b/Scribus/scribus/pageitem_textframe.cpp index a5490d1..be812b3 100644 --- a/Scribus/scribus/pageitem_textframe.cpp +++ b/Scribus/scribus/pageitem_textframe.cpp @@ -5214,14 +5214,13 @@ void PageItem_TextFrame::togleEditModeActions() void PageItem_TextFrame::applicableActions(QStringList & actionList) { + actionList << "fileImport"; actionList << "insertMarkVariableText"; if (!m_Doc->masterPageMode()) actionList << "insertMarkAnchor"; //notes frames are not simply text frames if (isNoteFrame()) return; - actionList << "fileImportText"; - actionList << "fileImportAppendText"; actionList << "toolsEditWithStoryEditor"; actionList << "insertSampleText"; actionList << "itemPDFIsAnnotation"; diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp index 407e6a8..f8192b5 100644 --- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp +++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp @@ -4585,6 +4585,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at break; } + UndoManager::instance()->setUndoEnabled(false); currItem->FrameType = attrs.valueAsInt("FRTYPE", 0); int startArrowIndex = attrs.valueAsInt("startArrowIndex", 0); if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles().size()))) @@ -5213,6 +5214,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at //currItem->setRedrawBounding(); //currItem->OwnPage = view->OnPage(currItem); + UndoManager::instance()->setUndoEnabled(true); return currItem; } diff --git a/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api b/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api index a2f6556..cfecd46 100644 --- a/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api +++ b/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api @@ -804,14 +804,6 @@ */ /** -* Scripter.dialogs.mainWindow.slotGetContent2() -*/ - -/** -* Scripter.dialogs.mainWindow.slotFileAppend() -*/ - -/** * Scripter.dialogs.mainWindow.removeRecent(fn) * fn is a QString */ @@ -840,10 +832,6 @@ */ /** -* Scripter.dialogs.mainWindow.importVectorFile() -*/ - -/** * Scripter.dialogs.mainWindow.rebuildLayersList() */ diff --git a/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html b/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html index ced0f38..abf7511 100644 --- a/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html +++ b/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html @@ -5194,10 +5194,6 @@ <tr><td colspan="2"><hr></td></tr> <tr> - <td><strong>ScripterNG.dialogs.mainWindow.importVectorFile()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> -<tr> <td colspan="2"> <em></em> </td> @@ -7418,11 +7414,6 @@ </td> </tr> <tr><td colspan="2"><hr></td></tr> - -<tr> - <td><strong>ScripterNG.dialogs.mainWindow.slotFileAppend()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> <tr> <td colspan="2"> <em></em> @@ -7607,11 +7598,6 @@ </td> </tr> <tr><td colspan="2"><hr></td></tr> - -<tr> - <td><strong>ScripterNG.dialogs.mainWindow.slotGetContent2()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> <tr> <td colspan="2"> <em></em> diff --git a/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py b/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py index f2bf0a2..3d91a8e 100644 --- a/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py +++ b/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py @@ -61,7 +61,6 @@ except ImportError: print "Unable to import the 'scribus' module. This script will only run within" print "the Python interpreter embedded in Scribus. Try Script->Execute Script." sys.exit(1) - pil_found = 1 try: diff --git a/Scribus/scribus/prefsmanager.cpp b/Scribus/scribus/prefsmanager.cpp index be10da4..2f068f5 100644 --- a/Scribus/scribus/prefsmanager.cpp +++ b/Scribus/scribus/prefsmanager.cpp @@ -289,6 +289,10 @@ void PrefsManager::initDefaults() appPrefs.itemToolPrefs.imageAspectRatio = true; appPrefs.itemToolPrefs.imageLowResType = 1; appPrefs.itemToolPrefs.imageUseEmbeddedPath = false; + appPrefs.itemToolPrefs.imageDefaultSize = 3; + appPrefs.itemToolPrefs.imageDefaultWidth = 100; + appPrefs.itemToolPrefs.imageDefaultHeight = 100; + appPrefs.itemToolPrefs.imageDefaultBasePoint = 0; // appPrefs.PSize = 40; appPrefs.printerPrefs.ClipMargin = false; appPrefs.printerPrefs.GCRMode = false; @@ -1503,6 +1507,10 @@ bool PrefsManager::WritePref(QString ho) dcItemTools.setAttribute("ImageStrokeColorShade",appPrefs.itemToolPrefs.imageStrokeColorShade); dcItemTools.setAttribute("ImageScaleX",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleX)); dcItemTools.setAttribute("ImageScaleY",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleY)); + dcItemTools.setAttribute("ImageDefaultSize",appPrefs.itemToolPrefs.imageDefaultSize); + dcItemTools.setAttribute("ImageDefaultWidth",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageDefaultWidth)); + dcItemTools.setAttribute("ImageDefaultHeight",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageDefaultHeight)); + dcItemTools.setAttribute("ImageDefaultBasePoint",appPrefs.itemToolPrefs.imageDefaultBasePoint); dcItemTools.setAttribute("PolygonCorners", appPrefs.itemToolPrefs.polyCorners); dcItemTools.setAttribute("PolygonFactor", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyFactor)); dcItemTools.setAttribute("PolygonRotation", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyRotation)); @@ -2114,6 +2122,10 @@ bool PrefsManager::ReadPref(QString ho) appPrefs.itemToolPrefs.imageStrokeColorShade = dc.attribute("ImageStrokeColorShade", "100").toInt(); appPrefs.itemToolPrefs.imageScaleX = ScCLocale::toDoubleC(dc.attribute("ImageScaleX"), 1.0); appPrefs.itemToolPrefs.imageScaleY = ScCLocale::toDoubleC(dc.attribute("ImageScaleY"), 1.0); + appPrefs.itemToolPrefs.imageDefaultSize = dc.attribute("ImageDefaultSize").toInt(); + appPrefs.itemToolPrefs.imageDefaultBasePoint = dc.attribute("ImageDefaultBasePoint").toInt(); + appPrefs.itemToolPrefs.imageDefaultWidth = ScCLocale::toDoubleC(dc.attribute("ImageDefaultWidth"), 100.0); + appPrefs.itemToolPrefs.imageDefaultHeight = ScCLocale::toDoubleC(dc.attribute("ImageDefaultHeight"), 100.0); appPrefs.itemToolPrefs.imageScaleType = static_cast<bool>(dc.attribute("PSCALE", "0").toInt()); appPrefs.itemToolPrefs.imageAspectRatio = static_cast<bool>(dc.attribute("PASPECT", "1").toInt()); appPrefs.itemToolPrefs.imageUseEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt()); diff --git a/Scribus/scribus/prefsstructs.h b/Scribus/scribus/prefsstructs.h index cc58c93..2175614 100644 --- a/Scribus/scribus/prefsstructs.h +++ b/Scribus/scribus/prefsstructs.h @@ -237,6 +237,10 @@ struct ItemToolPrefs bool imageAspectRatio; //! Use stored aspect ratio for the image int imageLowResType; //! Preview type for an image frame bool imageUseEmbeddedPath; //! Use embedded path, eg from an EPS etc. + int imageDefaultSize; //! Default behaviour for oneclick event + double imageDefaultHeight; //! Default height value for oneclick event + double imageDefaultWidth; //! Defaut width value for oneclick event + double imageDefaultBasePoint; //! Defaut basepoint for oneclick event /* Calligraphic Pen Tool */ QString calligrapicPenFillColor; //! Default calligrapicPen fill color QString calligrapicPenLineColor; //! Default calligrapicPen line color diff --git a/Scribus/scribus/scpage.cpp b/Scribus/scribus/scpage.cpp index dc04495..e0e1f2e 100644 --- a/Scribus/scribus/scpage.cpp +++ b/Scribus/scribus/scpage.cpp @@ -311,6 +311,8 @@ void ScPage::restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo) return; int stateCode = state->transactionCode; PageItem *ite = state->getItem(); + bool old_lock =ite->locked(); + ite->setLocked(false); bool oldMPMode=m_Doc->masterPageMode(); if ((stateCode == 0) || (stateCode == 1)) { @@ -344,6 +346,7 @@ void ScPage::restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo) } m_Doc->setMasterPageMode(oldMPMode); m_Doc->m_Selection->delaySignalsOff(); + ite->setLocked(old_lock); } void ScPage::restorePageItemDeletion(ScItemState< QList<PageItem*> > *state, bool isUndo) diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp index 24ff0f4..a5faa43 100644 --- a/Scribus/scribus/scribus.cpp +++ b/Scribus/scribus/scribus.cpp @@ -86,7 +86,7 @@ for which a new license (GPL+exception) is in place. #include "actionmanager.h" #include "canvasmode.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "commonstrings.h" #include "desaxe/digester.h" #include "desaxe/saxXML.h" @@ -738,12 +738,7 @@ void ScribusMainWindow::initMenuBar() scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File", false); scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File", false); scrMenuMgr->addMenuSeparator("File"); - scrMenuMgr->createMenu("FileImport", tr("&Import"), "File"); - scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport", false); -// scrMenuMgr->addMenuItem(scrActions["fileImportText2"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportVector"], "FileImport", true); + scrMenuMgr->addMenuItem(scrActions["fileImport"], "File", true); scrMenuMgr->createMenu("FileExport", tr("&Export"), "File"); scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport", false); @@ -1476,7 +1471,7 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k) case modeEditWeldPoint: case modeEyeDropper: case modeImportObject: - case modeImportImage: + case modeImportData: case modePanning: view->requestMode(modeNormal); break; @@ -2660,7 +2655,6 @@ void ScribusMainWindow::HaveNewDoc() connect(view, SIGNAL(CutItem()), this, SLOT(slotEditCut()), Qt::UniqueConnection); connect(view, SIGNAL(LoadPic()), this, SLOT(slotGetContent()), Qt::UniqueConnection); connect(view, SIGNAL(StatusPic()), this, SLOT(StatusPic()), Qt::UniqueConnection); - connect(view, SIGNAL(AppendText()), this, SLOT(slotFileAppend()), Qt::UniqueConnection); connect(view, SIGNAL(AnnotProps()), this, SLOT(ModifyAnnot()), Qt::UniqueConnection); connect(view, SIGNAL(LoadElem(QString, double ,double, bool, bool, ScribusDoc *, ScribusView*)), this, SLOT(slotElemRead(QString, double, double, bool, bool, ScribusDoc *, ScribusView*)), Qt::UniqueConnection); connect(view, SIGNAL(AddBM(PageItem *)), this, SLOT(AddBookMark(PageItem *)), Qt::UniqueConnection); @@ -2807,10 +2801,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) switch (SelectedType) { case -1: // None - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["itemDuplicate"]->setEnabled(false); scrActions["itemMulDuplicate"]->setEnabled(false); @@ -2867,10 +2857,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) propertiesPalette->setGradientEditMode(false); break; case PageItem::ImageFrame: //Image Frame - scrActions["fileImportAppendText"]->setEnabled(false); - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); scrMenuMgr->setMenuEnabled("EditContents", true); @@ -2920,10 +2906,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) break; case PageItem::TextFrame: //Text Frame - scrActions["fileImportText"]->setEnabled(true); - scrActions["fileImportText2"]->setEnabled(true); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(true); scrActions["fileExportText"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3039,10 +3021,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) } break; case PageItem::PathText: //Path Text - scrActions["fileImportText"]->setEnabled(true); - scrActions["fileImportText2"]->setEnabled(true); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(true); scrActions["fileExportText"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3104,10 +3082,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) } break; default: - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3636,78 +3610,6 @@ void ScribusMainWindow::doPasteRecent(QString data) } } -void ScribusMainWindow::importVectorFile() -{ - QString fileName = ""; - QStringList formats; - QString allFormats = tr("All Supported Formats")+" ("; - int fmtCode = FORMATID_FIRSTUSER; - const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); - while (fmt != 0) - { - if (fmt->load) - { - formats.append(fmt->filter); - int an = fmt->filter.indexOf("("); - int en = fmt->filter.indexOf(")"); - while (an != -1) - { - allFormats += fmt->filter.mid(an+1, en-an-1)+" "; - an = fmt->filter.indexOf("(", en); - en = fmt->filter.indexOf(")", an); - } - } - fmtCode++; - fmt = LoadSavePlugin::getFormatById(fmtCode); - } - allFormats += "*.sce *.SCE);;"; - formats.append("Scribus Objects (*.sce *.SCE)"); - qSort(formats); - allFormats += formats.join(";;"); - PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); - QString wdir = dirs->get("pastefile", "."); - CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdExistingFiles); - if (dia.exec() == QDialog::Accepted) - fileName = dia.selectedFile(); - else - return; - if (!fileName.isEmpty()) - { - PrefsManager::instance()->prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/"))); - QFileInfo fi(fileName); - QString suffix = fi.suffix().toLower(); - if ((suffix == "sce") || (suffix == "shape")) - { - QList<QUrl> urls; - QMimeData* md = new QMimeData(); - urls.append( QUrl::fromLocalFile(fileName) ); - md->setUrls(urls); - QDrag* dr = new QDrag(this); - dr->setMimeData(md); - const QPixmap& dragCursor = loadIcon("DragPix.xpm"); - dr->setPixmap(dragCursor); - dr->exec(); - } - else - { - FileLoader *fileLoader = new FileLoader(fileName); - int testResult = fileLoader->testFile(); - delete fileLoader; - if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER)) - { - const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult); - if( fmt ) - { - doc->dontResize = true; - fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive); - doc->dontResize = false; - } - } - } - requestUpdate(reqColorsUpdate | reqSymbolsUpdate | reqLineStylesUpdate | reqTextStylesUpdate); - } -} - void ScribusMainWindow::rebuildLayersList() { if (HaveDoc) @@ -3799,8 +3701,6 @@ bool ScribusMainWindow::slotPageImport() bool ret = false; MergeDoc *dia = new MergeDoc(this, false, doc->DocPages.count(), doc->currentPage()->pageNr() + 1); UndoTransaction* activeTransaction = NULL; - if(UndoManager::undoEnabled()) - activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, 0, Um::ILock)); if (dia->exec()) { @@ -4378,87 +4278,71 @@ bool ScribusMainWindow::postLoadDoc() // do with file->open for a LONG time. It's used for get text / get picture. void ScribusMainWindow::slotGetContent() { - if (doc->m_Selection->count() != 0) + int flags = fdExistingFilesI; + QString docDir = "."; + ImportSetup impsetup; + QString allFormats = ""; + QString formatD = ""; + PageItem *currItem = doc->m_Selection->itemAt(0); + if(!currItem) { - PageItem *currItem = doc->m_Selection->itemAt(0); - if (currItem->itemType() == PageItem::ImageFrame) - { - QString formatD(FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME)); - - QString docDir = "."; - QString prefsDocDir=prefsManager->documentDir(); - if (!prefsDocDir.isEmpty()) - docDir = prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir); - else - docDir = prefsManager->prefsFile->getContext("dirs")->get("images", "."); - - QStringList fileNames; - fileNames.clear(); - CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI); - if (dia->exec() == QDialog::Accepted) - fileNames = dia->fileDialog->selectedFiles(); - delete dia; - //QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles); - if (!fileNames.isEmpty()) - { - prefsManager->prefsFile->getContext("dirs")->set("images", fileNames[0].left(fileNames[0].lastIndexOf("/"))); - view->requestMode(modeImportImage); - dynamic_cast<CanvasMode_ImageImport*>(view->canvasMode())->setImageList(fileNames); - } - } - else if (currItem->asTextFrame()) - { - gtGetText* gt = new gtGetText(doc); - ImportSetup impsetup=gt->run(); - if (impsetup.runDialog) - { - if (currItem->itemText.length() != 0) - { - int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (t == QMessageBox::No) - return; - } - gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false); - } - delete gt; - if (doc->docHyphenator->AutoCheck) - doc->docHyphenator->slotHyphenate(currItem); - for (int a = 0; a < doc->Items->count(); ++a) - { - if (doc->Items->at(a)->isBookmark) - bookmarkPalette->BView->ChangeText(doc->Items->at(a)); - } - if (!impsetup.textOnly) - doc->flag_NumUpdateRequest = true; - view->DrawNew(); - slotDocCh(); - styleManager->setDoc(doc); - marksManager->setDoc(doc); - nsEditor->setDoc(doc); - } + formatD = FormatsManager::instance()->fileDialogVectorFormatList(); + PrefsContext* dirs = prefsManager->prefsFile->getContext("dirs"); + docDir = dirs->get("pastefile", "."); + allFormats += " " + formatD.mid(formatD.indexOf("(")+1,formatD.indexOf(")")-(formatD.indexOf("(")+1)); } -} - -void ScribusMainWindow::slotGetContent2() // kk2006 -{ - if (doc->m_Selection->count() == 0) - return; // nothing to do, no selection - - PageItem *currItem = doc->m_Selection->itemAt(0); + if (!currItem || currItem->itemType() == PageItem::ImageFrame) + { + flags |= fdShowPreview; + QString formatI = FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME); + allFormats += " " + formatI.mid(formatI.indexOf("(")+1,formatI.indexOf(")")-(formatI.indexOf("(")+1)); + if(formatD.length()!=0) + formatD = formatD.left(formatD.lastIndexOf(";") +1); + formatD +=formatI; + QString prefsDocDir=prefsManager->documentDir(); + if (!prefsDocDir.isEmpty()) + docDir = prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir); + else + docDir = prefsManager->prefsFile->getContext("dirs")->get("images", "."); + } + if (!currItem || currItem->asTextFrame()) + { + flags |= fdShowCodecs; + QString formatT = FormatsManager::instance()->fileDialogTextFormatList(); + allFormats += " " + formatT.mid(formatT.indexOf("(")+1,formatT.indexOf(")")-(formatT.indexOf("(")+1)); + if(formatD.length()!=0) + formatD = formatD.left(formatD.lastIndexOf(";") +1); + formatD += formatT; + } + formatD = tr("All Supported Formats") + "(" + allFormats + ");;" + formatD; + CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, flags ); + if (dia->exec() == QDialog::Accepted) + impsetup.filename = dia->fileDialog->selectedFiles(); - if (!currItem->asTextFrame()) - return; // not a text frame + if(flags & fdShowCodecs) + { + impsetup.encoding=dia->TxCodeM->currentText(); + impsetup.textOnly=dia->TextOnly->isChecked(); + } + else + { + QString localEn = QTextCodec::codecForLocale()->name(); + if (localEn == "ISO-10646-UCS-2") + localEn = "UTF-16"; + impsetup.encoding = localEn; + impsetup.textOnly = false; + } - ScGTPluginManager::instance()->run(); - if (doc->docHyphenator->AutoCheck) - doc->docHyphenator->slotHyphenate(currItem); - for (int a = 0; a < doc->Items->count(); ++a) + if (!impsetup.filename.isEmpty()) { - if (doc->Items->at(a)->isBookmark) - bookmarkPalette->BView->ChangeText(doc->Items->at(a)); + if (currItem && currItem->itemType() == PageItem::ImageFrame) + prefsManager->prefsFile->getContext("dirs")->set("images", impsetup.filename.first().left(impsetup.filename.first().lastIndexOf("/"))); + if(!currItem) + prefsManager->prefsFile->getContext("dirs")->set("pastefile", impsetup.filename.first().left(impsetup.filename.first().lastIndexOf("/"))); + view->requestMode(modeImportData); + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->setInformation(impsetup); } - view->DrawNew(); - slotDocCh(); + delete dia; } void ScribusMainWindow::slotGetClipboardImage() @@ -4571,25 +4455,6 @@ void ScribusMainWindow::toogleInlineState() } } -void ScribusMainWindow::slotFileAppend() -{ - if (doc->m_Selection->count() != 0) - { - gtGetText* gt = new gtGetText(doc); - ImportSetup impsetup=gt->run(); - if (impsetup.runDialog) - { - gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, true); - } - delete gt; - //CB Hyphenating now emits doc changed, plus we change lang as appropriate - if (doc->docHyphenator->AutoCheck) - doc->itemSelection_DoHyphenate(); - view->DrawNew(); - //slotDocCh(); - } -} - void ScribusMainWindow::slotFileRevert() { if ((doc->hasName) && (doc->isModified()) && (!doc->masterPageMode()) && (!doc->isConverted)) @@ -4829,10 +4694,7 @@ bool ScribusMainWindow::DoFileClose() scrActions["fileExportAsPDF"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["fileExportAsEPS"]->setEnabled(false); - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); + scrActions["fileImport"]->setEnabled(false); // scrMenuMgr->setMenuEnabled("Page", false); scrActions["pageInsert"]->setEnabled(false); scrActions["pageImport"]->setEnabled(false); @@ -9254,7 +9116,21 @@ void ScribusMainWindow::restore(UndoState* state, bool isUndo) restoreAddPage(ss, isUndo); else if (ss->contains("DELETE_PAGE")) restoreDeletePage(ss, isUndo); + else if (ss->contains("FILE_LOADER")) + restoreFileLoader(ss, isUndo); + } +} + +void ScribusMainWindow::restoreFileLoader(SimpleState *state, bool isUndo) +{ + if(isUndo) + { + if(doc->appMode != modeImportData) + view->requestMode(modeImportData); + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->insertImage(0,state->get("name")); } + else + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->deleteImage(state->get("name")); } void ScribusMainWindow::restoreDeletePage(SimpleState *state, bool isUndo) diff --git a/Scribus/scribus/scribus.h b/Scribus/scribus/scribus.h index 9872c53..7e2b0bb 100644 --- a/Scribus/scribus/scribus.h +++ b/Scribus/scribus/scribus.h @@ -183,6 +183,7 @@ public: void restoreUngrouping(SimpleState *state, bool isUndo); void restoreAddPage(SimpleState *state, bool isUndo); void restoreDeletePage(SimpleState *state, bool isUndo); + void restoreFileLoader(SimpleState *state, bool isUndo); void setPreviewToolbar(); struct CopyContentsBuffer contentsBuffer; bool internalCopy; @@ -296,14 +297,8 @@ public slots: bool loadPage(QString fileName, int Nr, bool Mpa, const QString& renamedPageName=QString::null); 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 - */ - void slotFileAppend(); void removeRecent(QString fn, bool fromFileWatcher = false); void removeRecentFromWatcher(QString fn); @@ -312,7 +307,6 @@ public slots: void rebuildRecentPasteMenu(); void pasteRecent(QString fn); void pasteFromScrapbook(QString fn); - void importVectorFile(); void rebuildLayersList(); bool slotDocOpen(); bool loadDoc(QString); diff --git a/Scribus/scribus/scribusdoc.cpp b/Scribus/scribus/scribusdoc.cpp index ee2f298..f365cc8 100644 --- a/Scribus/scribus/scribusdoc.cpp +++ b/Scribus/scribus/scribusdoc.cpp @@ -5582,8 +5582,7 @@ int ScribusDoc::itemAddUserFrame(InsertAFrameData &iafData) if (!iafData.source.isEmpty() && prevItem == NULL && QFile::exists(iafData.source)) { gtGetText* gt = new gtGetText(this); - if (iafData.impsetup.runDialog) - gt->launchImporter(iafData.impsetup.importer, iafData.impsetup.filename, iafData.impsetup.textOnly, iafData.impsetup.encoding, true, currItem); + gt->launchImporter(-1, iafData.impsetup.filename.at(0), iafData.impsetup.textOnly, iafData.impsetup.encoding, true, currItem); delete gt; } prevItem=currItem; diff --git a/Scribus/scribus/scribusstructs.h b/Scribus/scribus/scribusstructs.h index 2323e98..16fe139 100644 --- a/Scribus/scribus/scribusstructs.h +++ b/Scribus/scribus/scribusstructs.h @@ -289,7 +289,7 @@ enum AppMode modeDrawLine, modeRotation, modeLinkFrames, - modeImportImage, + modeImportData, modeUnlinkFrames, modeDrawRegularPolygon, modeDrawBezierLine, diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp index 3d1304f..f639b6d 100644 --- a/Scribus/scribus/scribusview.cpp +++ b/Scribus/scribus/scribusview.cpp @@ -77,7 +77,7 @@ for which a new license (GPL+exception) is in place. #include "canvasgesture.h" #include "canvasmode.h" #include "canvasmode_objimport.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "actionmanager.h" #include "commonstrings.h" #include "filewatcher.h" @@ -164,6 +164,7 @@ ScribusView::ScribusView(QWidget* win, ScribusMainWindow* mw, ScribusDoc *doc) : _isGlobalMode(true), linkAfterDraw(false), ImageAfterDraw(false), + TextAfterDraw(false), m_vhRulerHW(17) { setObjectName("s"); @@ -4356,16 +4357,26 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event) } if (ImageAfterDraw) { - //user creates new frame using linking tool PageItem * frame = Doc->m_Selection->itemAt(0); - requestMode(modeImportImage); + requestMode(modeImportData); if (frame) { - dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->setImage(frame); - dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->updateList(); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->setImage(frame); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->updateList(); } ImageAfterDraw = false; } + else if (TextAfterDraw) + { + PageItem * frame = Doc->m_Selection->itemAt(0); + requestMode(modeImportData); + if (frame) + { + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->setText(frame->asTextFrame()); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->updateList(); + } + TextAfterDraw = false; + } return true; } else if (obj == widget() && event->type() == QEvent::MouseButtonPress) @@ -4385,10 +4396,12 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event) } else firstFrame = NULL; - if(Doc->appMode == modeImportImage && ImageAfterDraw) + if(Doc->appMode == modeImportData && (ImageAfterDraw || TextAfterDraw)) { - //switch to drawing new text frame - requestMode(modeDrawImage); + if(TextAfterDraw) + requestMode(modeDrawText); + else + requestMode(modeDrawImage); m_canvasMode->mousePressEvent(m); } m_canvas->m_viewMode.m_MouseButtonPressed = true; diff --git a/Scribus/scribus/scribusview.h b/Scribus/scribus/scribusview.h index 1cb9ad3..f21a0ca 100644 --- a/Scribus/scribus/scribusview.h +++ b/Scribus/scribus/scribusview.h @@ -107,12 +107,13 @@ public: friend class CanvasMode_EditArc; friend class CanvasMode_EditSpiral; friend class CanvasMode_FrameLinks; - friend class CanvasMode_ImageImport; + friend class CanvasMode_ImportData; friend class CanvasMode_Magnifier; friend class CanvasMode_NodeEdit; friend class CanvasMode_Normal; friend class CanvasMode_ObjImport; friend class CanvasMode_Rotate; + friend class CreateMode; void requestMode(int appMode); void startGesture(CanvasGesture*); @@ -325,6 +326,7 @@ private: // Private attributes bool _isGlobalMode; bool linkAfterDraw; bool ImageAfterDraw; + bool TextAfterDraw; double oldItemX; double oldItemY; diff --git a/Scribus/scribus/ui/contextmenu.cpp b/Scribus/scribus/ui/contextmenu.cpp index c1c5a53..28a92bf 100644 --- a/Scribus/scribus/ui/contextmenu.cpp +++ b/Scribus/scribus/ui/contextmenu.cpp @@ -195,13 +195,15 @@ void ContextMenu::createMenuItems_Selection() addSeparator(); addAction(m_AP->scrActions["itemUpdateMarks"]); } - if (m_actionList.contains("fileImportText")) + if (m_actionList.contains("fileImport")) { addSeparator(); - addAction(m_AP->scrActions["fileImportText"]); - addAction(m_AP->scrActions["fileImportAppendText"]); - addAction(m_AP->scrActions["toolsEditWithStoryEditor"]); - addAction(m_AP->scrActions["insertSampleText"]); + addAction(m_AP->scrActions["fileImport"]); + if (currItem->isTextFrame()) + { + addAction(m_AP->scrActions["toolsEditWithStoryEditor"]); + addAction(m_AP->scrActions["insertSampleText"]); + } } else //enable this for, eg, text on a path if (m_actionList.contains("toolsEditWithStoryEditor")) @@ -210,8 +212,6 @@ void ContextMenu::createMenuItems_Selection() addAction(m_AP->scrActions["toolsEditWithStoryEditor"]); } addSeparator(); - if (m_actionList.contains("fileImportImage")) - addAction(m_AP->scrActions["fileImportImage"]); if (selectedItemCount==1 && currItem->asImageFrame()) { if (QApplication::clipboard()->mimeData()->hasImage()) diff --git a/Scribus/scribus/ui/customfdialog.cpp b/Scribus/scribus/ui/customfdialog.cpp index 666db23..6c6e763 100644 --- a/Scribus/scribus/ui/customfdialog.cpp +++ b/Scribus/scribus/ui/customfdialog.cpp @@ -24,6 +24,7 @@ for which a new license (GPL+exception) is in place. #include <QCheckBox> #include <QComboBox> +#include <QCoreApplication> #include <QDir> #include <QFileInfo> #include <QFrame> @@ -35,6 +36,7 @@ for which a new license (GPL+exception) is in place. #include <QPixmap> #include <QPushButton> #include <QTextCodec> +#include <Qt> #include <QVBoxLayout> #include "customfdialog.h" @@ -111,7 +113,7 @@ QIcon ImIconProvider::icon(const QFileInfo &fi) const return QIcon(); } -FDialogPreview::FDialogPreview(QWidget *pa) : QLabel(pa) +FDialogPreview::FDialogPreview(QWidget *pa, Qt::WindowFlags f) : QLabel(pa,f) { setAlignment(Qt::AlignLeft | Qt::AlignTop); setFixedSize( QSize( 200, 200 ) ); @@ -298,7 +300,7 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt vboxLayout = new QVBoxLayout(this); vboxLayout->setSpacing(5); vboxLayout->setMargin(10); - hboxLayout = new QHBoxLayout; + hboxLayout = new QHBoxLayout; hboxLayout->setSpacing(5); hboxLayout->setMargin(0); fileDialog = new ScFileWidget(this); @@ -318,7 +320,7 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt vboxLayout1->addWidget(pw); hboxLayout->addLayout(vboxLayout1); vboxLayout->addLayout(hboxLayout); - QHBoxLayout *hboxLayout1 = new QHBoxLayout; + QHBoxLayout *hboxLayout1 = new QHBoxLayout; hboxLayout1->setSpacing(5); hboxLayout1->setContentsMargins(9, 0, 0, 0); showPreview = new QCheckBox(this); @@ -440,6 +442,12 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt } TxCodeM->setMinimumSize(QSize(200, 0)); Layout1C->addWidget(TxCodeM); + Layout1C->addStretch(); + TextOnly = new QCheckBox(); + TextOnly->setText( tr("Import &Text only")); + TextOnly->setToolTip( tr("Import the text without style formating")); + TextOnly->setChecked(false); + Layout1C->addWidget(TextOnly); QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); Layout1C->addItem( spacer2 ); vboxLayout->addWidget(LayoutC); @@ -511,6 +519,11 @@ QString CustomFDialog::selectedFile() return QString(); } +QStringList CustomFDialog::selectedFiles() +{ + return fileDialog->selectedFiles(); +} + void CustomFDialog::addWidgets(QWidget *widgets) { vboxLayout->addWidget(widgets); diff --git a/Scribus/scribus/ui/customfdialog.h b/Scribus/scribus/ui/customfdialog.h index 52d154f..987d58a 100644 --- a/Scribus/scribus/ui/customfdialog.h +++ b/Scribus/scribus/ui/customfdialog.h @@ -62,7 +62,7 @@ class SCRIBUS_API FDialogPreview : public QLabel { Q_OBJECT public: - FDialogPreview(QWidget *pa); + FDialogPreview(QWidget *pa, Qt::WindowFlags f = 0); ~FDialogPreview() {}; void updtPix(); void GenPreview(QString name); @@ -122,10 +122,12 @@ public: ScFileWidget *fileDialog; FDialogPreview *pw; QCheckBox *showPreview; + QCheckBox *TextOnly; QPushButton* OKButton; QPushButton* CancelB; void setSelection(QString ); QString selectedFile(); + QStringList selectedFiles(); void addWidgets(QWidget *widgets); private slots: //! \brief Go to the document home dir. diff --git a/Scribus/scribus/ui/delpages.cpp b/Scribus/scribus/ui/delpages.cpp index 83dc4ae..904e41d 100644 --- a/Scribus/scribus/ui/delpages.cpp +++ b/Scribus/scribus/ui/delpages.cpp @@ -27,7 +27,6 @@ DelPages::DelPages( QWidget* parent, int currentPage, int maxPage ) : QDialog( p fromToLayout->addWidget( fromLabel ); fromPageData = new ScrSpinBox(this); fromPageData->setDecimals(0); - fromPageData->setSuffix(""); fromPageData->setMinimum(1); fromPageData->setMaximum(maxPage); fromPageData->setSuffix(""); @@ -42,7 +41,6 @@ DelPages::DelPages( QWidget* parent, int currentPage, int maxPage ) : QDialog( p toPageData->setMaximum(maxPage); toPageData->setSuffix(""); toPageData->setValue( currentPage ); - toPageData->setSuffix(""); fromToLayout->addWidget( toPageData ); dialogLayout->addLayout( fromToLayout ); diff --git a/Scribus/scribus/ui/gtdialogs.cpp b/Scribus/scribus/ui/gtdialogs.cpp index af88379..79dd452 100644 --- a/Scribus/scribus/ui/gtdialogs.cpp +++ b/Scribus/scribus/ui/gtdialogs.cpp @@ -38,7 +38,6 @@ for which a new license (GPL+exception) is in place. #include <QPushButton> #include "commonstrings.h" #include "util_icon.h" -#include "ui/gtfiledialog.h" extern QString DocDir; @@ -114,44 +113,19 @@ gtImporterDialog::~gtImporterDialog() gtDialogs::gtDialogs() { fdia = NULL; - fileName = ""; - encoding = ""; importer = -1; prefs = PrefsManager::instance()->prefsFile->getContext("gtDialogs"); - pwd = QDir::currentPath(); } -bool gtDialogs::runFileDialog(const QString& filters, const QStringList& importers) -{ - bool accepted = false; - PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); - QString dir = dirs->get("get_text", "."); - fdia = new gtFileDialog(filters, importers, dir); - - if (fdia->exec() == QDialog::Accepted) - { - fileName = fdia->selectedFile(); - if (!fileName.isEmpty()) - accepted = true; - encoding = fdia->encodingCombo->currentText(); -// if (encoding == "UTF-16") -// encoding = "ISO-10646-UCS-2"; - importer = fdia->importerCombo->currentIndex() - 1; - dirs->set("get_text", fileName.left(fileName.lastIndexOf("/"))); - } - QDir::setCurrent(pwd); - return accepted; -} - -bool gtDialogs::runImporterDialog(const QStringList& importers) +bool gtDialogs::runImporterDialog(const QStringList& importers, QString filename) { int curSel = prefs->getInt("curSel", 0); QString extension = ""; - QString shortName = fileName.right(fileName.length() - fileName.lastIndexOf("/") - 1); + QString shortName = filename.right(filename.length() - filename.lastIndexOf("/") - 1); if (shortName.indexOf(".") == -1) extension = ".no_extension"; else - extension = fileName.right(fileName.length() - fileName.lastIndexOf(".")); + extension = filename.right(filename.length() - filename.lastIndexOf(".")); int extensionSel = prefs->getInt(extension, -1); QString imp = prefs->get("remember"+extension, QString("false")); QString res = ""; @@ -190,12 +164,12 @@ bool gtDialogs::runImporterDialog(const QStringList& importers) { importer = i; prefs->set("curSel", static_cast<int>(i)); - if (fileName.indexOf(".") != -1) + if (filename.indexOf(".") != -1) { if (shortName.indexOf(".") == -1) fileExtension = ".no_extension"; else - fileExtension = fileName.right(fileName.length() - fileName.lastIndexOf(".")); + fileExtension = filename.right(filename.length() - filename.lastIndexOf(".")); if (!fileExtension.isEmpty()) { prefs->set(fileExtension, static_cast<int>(i)); @@ -210,29 +184,11 @@ bool gtDialogs::runImporterDialog(const QStringList& importers) return ok; } -const QString& gtDialogs::getFileName() -{ - return fileName; -} - -const QString& gtDialogs::getEncoding() -{ - return encoding; -} - int gtDialogs::getImporter() { return importer; } -bool gtDialogs::importTextOnly() -{ - bool ret = false; - if (fdia) - ret = fdia->textOnlyCheckBox->isChecked(); - return ret; -} - gtDialogs::~gtDialogs() { delete fdia; diff --git a/Scribus/scribus/ui/gtdialogs.h b/Scribus/scribus/ui/gtdialogs.h index 0b1616d..c38a5a1 100644 --- a/Scribus/scribus/ui/gtdialogs.h +++ b/Scribus/scribus/ui/gtdialogs.h @@ -28,6 +28,7 @@ for which a new license (GPL+exception) is in place. #define GTDIALOGS_H #include <QDialog> +#include <QCheckBox> #include "scribusapi.h" @@ -55,20 +56,13 @@ class SCRIBUS_API gtDialogs { private: gtFileDialog* fdia; - QString fileName; - QString encoding; int importer; PrefsContext* prefs; - QString pwd; public: gtDialogs(); ~gtDialogs(); - const QString& getFileName(); - const QString& getEncoding(); int getImporter(); - bool importTextOnly(); - bool runFileDialog(const QString& filters, const QStringList& importers); - bool runImporterDialog(const QStringList& importers); + bool runImporterDialog(const QStringList& importers, QString filename); }; #endif // GTDIALOGS_H diff --git a/Scribus/scribus/ui/gtfiledialog.h b/Scribus/scribus/ui/gtfiledialog.h deleted file mode 100644 index 8b1e5a8..0000000 --- a/Scribus/scribus/ui/gtfiledialog.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef GTFILEDIALOG_H -#define GTFILEDIALOG_H - -#include <QDialog> -#include "ui_gtfiledialog.h" -#include "scribusapi.h" - - -/*! \brief Enhanced file dialog for get-text plugins -This class is separated from gtdialogs.h file due the huge -(almost) circle dependencies with fonts subdir/library -\author Petr Vanek <petr@scribus.info> -\author Riku Leino -*/ -class SCRIBUS_API gtFileDialog : public QDialog, public Ui::gtFileDialog -{ - Q_OBJECT -public: - gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir); - ~gtFileDialog(); - - QString selectedFile(); - -public slots: - virtual void accept(); - -protected: - void loadSettings(void); - void saveSettings(void); -}; - -#endif diff --git a/Scribus/scribus/ui/gtfiledialog.ui b/Scribus/scribus/ui/gtfiledialog.ui deleted file mode 100644 index b0a6726..0000000 --- a/Scribus/scribus/ui/gtfiledialog.ui +++ /dev/null @@ -1,112 +0,0 @@ -<ui version="4.0" > - <class>gtFileDialog</class> - <widget class="QDialog" name="gtFileDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>373</width> - <height>317</height> - </rect> - </property> - <property name="windowTitle" > - <string>Open</string> - </property> - <layout class="QGridLayout" > - <item row="0" column="0" colspan="3" > - <widget class="ScFileWidget" native="1" name="fileWidget" /> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>&Importer:</string> - </property> - <property name="buddy" > - <cstring>importerCombo</cstring> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="ScComboBox" name="importerCombo" /> - </item> - <item row="1" column="2" > - <widget class="QCheckBox" name="textOnlyCheckBox" > - <property name="text" > - <string>Import &Text Only</string> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>&Encoding:</string> - </property> - <property name="buddy" > - <cstring>encodingCombo</cstring> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="ScComboBox" name="encodingCombo" /> - </item> - <item row="3" column="0" colspan="3" > - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>ScFileWidget</class> - <extends>QWidget</extends> - <header>ui/scfilewidget.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>ScComboBox</class> - <extends>QComboBox</extends> - <header>ui/sccombobox.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>gtFileDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel" > - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>gtFileDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel" > - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/Scribus/scribus/ui/insertaframe.cpp b/Scribus/scribus/ui/insertaframe.cpp index c336a26..d8912aa 100644 --- a/Scribus/scribus/ui/insertaframe.cpp +++ b/Scribus/scribus/ui/insertaframe.cpp @@ -232,19 +232,19 @@ void InsertAFrame::locateImageFile() QString fileName(""); CustomFDialog dia(this, docDir, tr("Open"), formatD, fdShowPreview | fdExistingFiles); if (dia.exec() == QDialog::Accepted) - fileName = dia.selectedFile(); + fileName = dia.selectedFile().at(0); sourceImageLineEdit->setText(QDir::toNativeSeparators(fileName)); } void InsertAFrame::locateDocFile() { - m_ImportSetup.runDialog=false; - gtGetText* gt = new gtGetText(m_Doc); - m_ImportSetup=gt->run(); - if (m_ImportSetup.runDialog) - sourceDocLineEdit->setText(QDir::toNativeSeparators(m_ImportSetup.filename)); - delete gt; + QString formatD(FormatsManager::instance()->fileDialogTextFormatList()); + + CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), ".", tr("Open"), formatD, fdShowCodecs | fdExistingFiles); + if (dia->exec() == QDialog::Accepted) + sourceDocLineEdit->setText(QDir::toNativeSeparators(dia->selectedFile())); + delete dia; } void InsertAFrame::slotCreatePageNumberRange( ) diff --git a/Scribus/scribus/ui/oneclick.cpp b/Scribus/scribus/ui/oneclick.cpp index ddeb72c..5df24b2 100644 --- a/Scribus/scribus/ui/oneclick.cpp +++ b/Scribus/scribus/ui/oneclick.cpp @@ -23,7 +23,7 @@ for which a new license (GPL+exception) is in place. #include "units.h" #include "commonstrings.h" -OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, bool remember, int origin, int mode ) : QDialog( parent ) +OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, int origin, int mode ) : QDialog( parent ) { double m_unitRatio = unitGetRatioFromIndex(unitIndex); QString m_suffix = unitGetSuffixFromIndex(unitIndex); @@ -98,11 +98,6 @@ OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, } editLayout->addWidget( SizeGroup, 0, 1 ); - checkRemember = new QCheckBox(this); - checkRemember->setText( tr("Remember Values")); - checkRemember->setChecked(remember); - editLayout->addWidget( checkRemember, 1, 0, 1, 2 ); - queryLayout->addLayout( editLayout ); okCancelLayout = new QHBoxLayout; okCancelLayout->setSpacing( 5 ); diff --git a/Scribus/scribus/ui/oneclick.h b/Scribus/scribus/ui/oneclick.h index 325642a..e143f7f 100644 --- a/Scribus/scribus/ui/oneclick.h +++ b/Scribus/scribus/ui/oneclick.h @@ -27,12 +27,11 @@ class SCRIBUS_API OneClick : public QDialog Q_OBJECT public: - OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, bool remember, int origin, int mode ); + OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, int origin, int mode ); ~OneClick() {}; ScrSpinBox *spinWidth; ScrSpinBox *spinHeight; LinkButton* linkSize; - QCheckBox* checkRemember; QGroupBox* RotationGroupContainer; BasePointWidget* RotationGroup; diff --git a/Scribus/scribus/ui/prefs_itemtools.cpp b/Scribus/scribus/ui/prefs_itemtools.cpp index eda3540..b1e001b 100644 --- a/Scribus/scribus/ui/prefs_itemtools.cpp +++ b/Scribus/scribus/ui/prefs_itemtools.cpp @@ -154,6 +154,12 @@ void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData) onscreenResolutionLowRadioButton->setChecked(true); break; } + basepoint->setCheckedId(prefsData->itemToolPrefs.imageDefaultBasePoint); + imageSize->setChecked(!(prefsData->itemToolPrefs.imageDefaultSize & 1)); + defaultSize->setChecked(prefsData->itemToolPrefs.imageDefaultSize & 1); + askOneClick->setChecked(prefsData->itemToolPrefs.imageDefaultSize & 2); + defaultWidth->setValue(prefsData->itemToolPrefs.imageDefaultWidth); + defaultHeight->setValue(prefsData->itemToolPrefs.imageDefaultHeight); //Shape Tool shapeFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeLineColor); @@ -274,7 +280,10 @@ void Prefs_ItemTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const if (onscreenResolutionLowRadioButton->isChecked()) haRes = 2; prefsData->itemToolPrefs.imageLowResType = haRes; - + prefsData->itemToolPrefs.imageDefaultBasePoint = basepoint->checkedId(); + prefsData->itemToolPrefs.imageDefaultSize = defaultSize->isChecked() + askOneClick->isChecked()*2 ; + prefsData->itemToolPrefs.imageDefaultHeight = defaultHeight->value() / unitRatio; + prefsData->itemToolPrefs.imageDefaultWidth = defaultWidth->value() / unitRatio; //Shape tool prefsData->itemToolPrefs.shapeLineColor = shapeFrameLineColorComboBox->currentText(); diff --git a/Scribus/scribus/ui/prefs_itemtoolsbase.ui b/Scribus/scribus/ui/prefs_itemtoolsbase.ui index f6cef40..bf013c3 100644 --- a/Scribus/scribus/ui/prefs_itemtoolsbase.ui +++ b/Scribus/scribus/ui/prefs_itemtoolsbase.ui @@ -78,9 +78,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>0</y> - <width>643</width> - <height>646</height> + <y>-44</y> + <width>622</width> + <height>677</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> @@ -651,8 +651,8 @@ <rect> <x>0</x> <y>0</y> - <width>643</width> - <height>646</height> + <width>637</width> + <height>633</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_7"> @@ -806,7 +806,7 @@ <string>Free Scaling</string> </property> <attribute name="buttonGroup"> - <string>scalingButtonGroup</string> + <string notr="true">scalingButtonGroup</string> </attribute> </widget> </item> @@ -884,7 +884,7 @@ <string>Scale Image to Frame Size</string> </property> <attribute name="buttonGroup"> - <string>scalingButtonGroup</string> + <string notr="true">scalingButtonGroup</string> </attribute> </widget> </item> @@ -937,7 +937,7 @@ <string>Full Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> @@ -947,7 +947,7 @@ <string>Normal Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> @@ -957,11 +957,184 @@ <string>Low Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> <item> + <spacer name="verticalSpacer_13"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_53"> + <property name="text"> + <string>Default frame size</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="imageSize"> + <property name="text"> + <string>Use image size</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_13"> + <property name="sizeConstraint"> + <enum>QLayout::SetMaximumSize</enum> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QRadioButton" name="defaultSize"> + <property name="text"> + <string>Use default size</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_19"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QFormLayout" name="formLayout_15"> + <item row="0" column="0"> + <widget class="QLabel" name="width"> + <property name="text"> + <string>width</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDoubleSpinBox" name="defaultWidth"> + <property name="minimum"> + <double>1.000000000000000</double> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="height"> + <property name="text"> + <string>height</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="defaultHeight"> + <property name="minimum"> + <double>1.000000000000000</double> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_20"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>74</height> + </size> + </property> + <property name="title"> + <string>Baseline</string> + </property> + <widget class="BasePointWidget" name="basepoint" native="true"> + <property name="geometry"> + <rect> + <x>12</x> + <y>15</y> + <width>58</width> + <height>55</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>55</width> + <height>55</height> + </size> + </property> + </widget> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_21"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Maximum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="askOneClick"> + <property name="text"> + <string>Ask before apply</string> + </property> + </widget> + </item> + </layout> + </item> + <item> <spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -969,7 +1142,7 @@ <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>145</height> + <height>40</height> </size> </property> </spacer> @@ -1580,6 +1753,12 @@ <header>ui/spiralwidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>BasePointWidget</class> + <extends>QWidget</extends> + <header location="global">ui/basepointwidget.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>tabWidget</tabstop> diff --git a/Scribus/scribus/ui/prefs_operatortoolsbase.ui b/Scribus/scribus/ui/prefs_operatortoolsbase.ui index 9a5c63b..c932504 100644 --- a/Scribus/scribus/ui/prefs_operatortoolsbase.ui +++ b/Scribus/scribus/ui/prefs_operatortoolsbase.ui @@ -89,10 +89,10 @@ <string> %</string> </property> <property name="minimum"> - <number>1</number> + <double>1.000000000000000</double> </property> <property name="maximum"> - <number>3200</number> + <double>3200.000000000000000</double> </property> </widget> </item> @@ -115,7 +115,7 @@ <string> %</string> </property> <property name="minimum"> - <number>100</number> + <number>0</number> </property> <property name="maximum"> <number>500</number> @@ -266,8 +266,8 @@ <customwidgets> <customwidget> <class>ScrSpinBox</class> - <extends>QSpinBox</extends> - <header location="global">ui/scrspinbox.h</header> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> </customwidget> </customwidgets> <resources/> diff --git a/Scribus/scribus/undomanager.cpp b/Scribus/scribus/undomanager.cpp index 460ad84..101c05d 100644 --- a/Scribus/scribus/undomanager.cpp +++ b/Scribus/scribus/undomanager.cpp @@ -1051,6 +1051,7 @@ void UndoManager::languageChange() UndoManager::PathOperation = tr("Path Operation"); UndoManager::ChangePageAttrs = tr("Change Page Attributes"); UndoManager::Transform = tr("Transform"); + UndoManager::ImportFile = tr("Import file"); UndoManager::WeldItems = tr("Weld Items"); } @@ -1323,6 +1324,7 @@ QString UndoManager::ClearImage = ""; QString UndoManager::PathOperation = ""; QString UndoManager::ChangePageAttrs = ""; QString UndoManager::Transform = ""; +QString UndoManager::ImportFile = ""; QString UndoManager::WeldItems = ""; /*** Icons for UndoObjects *******************************************/ diff --git a/Scribus/scribus/undomanager.h b/Scribus/scribus/undomanager.h index 5d7a17f..9ca06c5 100644 --- a/Scribus/scribus/undomanager.h +++ b/Scribus/scribus/undomanager.h @@ -631,6 +631,7 @@ public: static QString MultipleDuplicate; static QString Duplicate; static QString Transform; + static QString ImportFile; static QString ApplyTextStyle; static QString RemoveTextStyle; static QString Columns; diff --git a/Scribus/scribus/util_formats.cpp b/Scribus/scribus/util_formats.cpp index e052355..37643bf 100644 --- a/Scribus/scribus/util_formats.cpp +++ b/Scribus/scribus/util_formats.cpp @@ -5,11 +5,16 @@ a copyright and/or license notice that predates the release of Scribus 1.3.2 for which a new license (GPL+exception) is in place. */ +#include <QDir> #include <QImageReader> #include <QMapIterator> #include <QObject> #include "commonstrings.h" +#include "plugins/formatidlist.h" +#include "loadsaveplugin.h" +#include "pluginmanager.h" +#include "scpaths.h" #include "util_formats.h" FormatsManager* FormatsManager::_instance = 0; @@ -93,6 +98,7 @@ FormatsManager::FormatsManager() m_qtSupportedImageFormats=QImageReader::supportedImageFormats(); m_supportedImageFormats=m_qtSupportedImageFormats; updateSupportedImageFormats(m_supportedImageFormats); + loadImporterPlugins(); } FormatsManager::~FormatsManager() @@ -214,7 +220,7 @@ QString FormatsManager::extensionListForFormat(int type, int listType) void FormatsManager::fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly) { - QString fmtList = QObject::tr("All Supported Formats")+" ("; + QString fmtList = QObject::tr("All Supported Image Formats")+" ("; QString fmtText; QMapIterator<int, QStringList> it(m_fmts); bool first=true; @@ -352,3 +358,214 @@ QString getImageType(QString filename) } return ret; } + +// Find the available plugins based on the environment, validate they load, and +// create quick lookup mappings. +void FormatsManager::loadImporterPlugins() +{ + // Get the path to the plugins + QString gtdir = ScPaths::instance().pluginDir(); + // Append the gettext path to the plugin + gtdir += "gettext"; + // Set the search parameteer for the platform specific extension for the plugins ( DLL, so, etc. ) + QString libPattern = QString("*.%1*").arg(PluginManager::platformDllExtension()); + // Search for matches. + QDir d(gtdir, libPattern, QDir::Name, (QDir::Filter) PluginManager::platformDllSearchFlags()); + + // Initialize a structure for the importers found + struct ImporterData ida; + ida.fileFormatName = ""; + + // Check and see if the directory existed and if the count of files matching is greater than 0. + if ((d.exists()) && (d.count() != 0)) + { + // loop through the entries. + for (uint dc = 0; dc < d.count(); ++dc) + { + // Verify the Plugin will load. If it does, collect the info on the plugin ( Name, extension, format, etc ) + if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) + { + // no plugin's "format name" marks "don't load plug" + if (ida.fileFormatName.isNull()) + continue; + // Store the path to the plugin. + ida.soFilePath = d[dc]; + // If the plugin path does not begin with /, prepend a /. + if (ida.soFilePath.left(1) != "/") + ida.soFilePath = "/" + ida.soFilePath; + // Add the plugin data to the end of the importer's vector. + importers.push_back(ida); + } // if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) + } // for (uint dc = 0; dc < d.count(); ++dc) + } // if ((d.exists()) && (d.count() != 0)) + // Create the Importer Extension to Plugin data qmap. + createMap(); + // Populate ilist with the file importer names. + for (uint i = 0; i < importers.size(); ++i) + ilist.append(importers[i].fileFormatName); +} // void gtGetText::loadImporterPlugins() + +// Create the importer Qmap. +void FormatsManager::createMap() +{ + // Loop through the importers Vector + for (uint i = 0; i < importers.size(); ++i) + { + // Loop through each file extension the importer uses/importers and create an individual + // Qmap entry for it. + for (int j = 0; j < importers[i].fileEndings.count(); ++j) + importerMap.insert(importers[i].fileEndings[j], &importers[i]); + } // for (uint i = 0; i < importers.size(); ++i) +} // void gtGetText::createMap() + +QString FormatsManager::fileDialogTextFormatList() +{ + // Initialize a filters list. + QString filters = ""; + // Create a string for the "All supported files filter". Start with the label then loop through + // the importers vector and add all of the file extensions supported. + QString allSupported = QObject::tr("All Supported Text Formats") + " ("; + // Loop through the importers vector. + for (uint i = 0; i < importers.size(); ++i) + { + // If there are any file extnsions declared by the importer + if (importers[i].fileEndings.count() != 0) + { + // Add the importer name to the filters list + filters += importers[i].fileFormatName + " ("; + // Loop though the extensions supported by the importer + for (int j = 0; j < importers[i].fileEndings.count(); ++j) + { + // Add the extension to both the filter and allSupported strings + filters += "*." + importers[i].fileEndings[j] + " "; + allSupported += "*." + importers[i].fileEndings[j] + " "; + } // for (int j = 0; j < importers[i].fileEndings.count(); ++j) + // Trim the Qstring + filters = filters.trimmed(); + // Append "entry of entry" information to the end of the filter. + filters += ");;"; + } // if (importers[i].fileEndings.count() != 0) + } // for (uint i = 0; i < importers.size(); ++i) + // Trim the allSupported QString and append "end of entry" data to the end of it. + allSupported = allSupported.trimmed(); + allSupported += ");;"; + // Prepend allSupported to the filters Qstring. + filters = allSupported + filters; + // Add an "all files" entry to the end of the filters QString + filters += QObject::tr("All Files (*)"); + return filters; +} + +// Loads the "DLL", validates the importer is good, populates the passed parameters with +// the plugin information. +bool FormatsManager::DLLName(QString name, QString *ffName, QStringList *fEndings) +{ + // Pointer to the plugin, once loaded + void* gtplugin; + // typedef of Qstring to map the importer name (FileFormatName) method results to. + typedef QString (*sdem0)(); + // typedef of QStringList to map the file extensions supported method results to. + typedef QStringList (*sdem1)(); + // The actual importer name object + sdem0 fp_FileFormatName; + // The actual extensions supported object + sdem1 fp_FileExtensions; + // Initialise the plugin file path ( with filename ) + QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(name); + // Attempt to load the plugin. + gtplugin = PluginManager::loadDLL(pluginFilePath); + // if gtplugin is NULL we were unable to load the plugin. Return an error and exit the method. + if (!gtplugin) + { + qWarning("Failed to load plugin %s", pluginFilePath.toAscii().constData()); + return false; + } + // Attempt to resolve the plugin symbol to the importer name (FileFormatName) + fp_FileFormatName = (sdem0) PluginManager::resolveSym( gtplugin, "FileFormatName"); + // if fp_FileFormatName is NULL, we could not find the FileFormatName symbol. The plugin is incomplete. + // Report an error, unload the plugin, and exit the method. + if (!fp_FileFormatName) + { + qWarning("Failed to get FileFormatName() from %s", pluginFilePath.toAscii().constData()); + PluginManager::unloadDLL(gtplugin); + return false; + } + // Attempt to resolve the plugin symbol to the list of supported file extensions. + fp_FileExtensions = (sdem1) PluginManager::resolveSym( gtplugin, "FileExtensions"); + // if fp_FileExtensions is NULL, we could not find the FileExtensions symbol. The plugin is incomplete. + // Report an error, unload the plugin, and exit the method. + if (!fp_FileExtensions) + { + qWarning("Failed to get FileExtensions() from %s", pluginFilePath.toAscii().constData()); + PluginManager::unloadDLL(gtplugin); + return false; + } + // Set the format name based on the resolved method. + *ffName = (*fp_FileFormatName)(); + // Set the extensions list based on the resolved method. + *fEndings = (*fp_FileExtensions)(); + // Unload the plugin + PluginManager::unloadDLL(gtplugin); + // Successfully return! + return true; +} // bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) + + +QString FormatsManager::fileDialogVectorFormatList() +{ + QStringList formats; + QString allFormats = QObject::tr("All Supported Vector Formats")+" ("; + int fmtCode = FORMATID_FIRSTUSER; + const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); + while (fmt != 0) + { + if (fmt->load) + { + formats.append(fmt->filter); + int an = fmt->filter.indexOf("("); + int en = fmt->filter.indexOf(")"); + while (an != -1) + { + allFormats += fmt->filter.mid(an+1, en-an-1)+" "; + an = fmt->filter.indexOf("(", en); + en = fmt->filter.indexOf(")", an); + } + } + fmtCode++; + fmt = LoadSavePlugin::getFormatById(fmtCode); + } + allFormats += "*.sce *.SCE);;"; + formats.append("Scribus Objects (*.sce *.SCE)"); + qSort(formats); + allFormats += formats.join(";;"); + return allFormats; +} + +bool FormatsManager::isVectorFile(QString fileName) +{ + QStringList formats; + QFileInfo fi(fileName); + int fmtCode = FORMATID_FIRSTUSER; + const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); + while (fmt != 0) + { + if (fmt->load) + { + formats.append(fmt->filter); + int an = fmt->filter.indexOf("("); + int en = fmt->filter.indexOf(")"); + while (an != -1) + { + if(fmt->filter.mid(an+1, en-an-1).toLower().contains(fi.suffix().toLower())) + return true; + an = fmt->filter.indexOf("(", en); + en = fmt->filter.indexOf(")", an); + } + } + fmtCode++; + fmt = LoadSavePlugin::getFormatById(fmtCode); + } + if(QString("*.sce *.SCE").toLower().contains(fi.suffix().toLower())) + return true; + return false; +} diff --git a/Scribus/scribus/util_formats.h b/Scribus/scribus/util_formats.h index bb717a9..95ef0c0 100644 --- a/Scribus/scribus/util_formats.h +++ b/Scribus/scribus/util_formats.h @@ -31,6 +31,21 @@ bool SCRIBUS_API extensionIndicatesPattern(const QString &ext); bool SCRIBUS_API extensionIndicatesTIFF(const QString &ext); QString SCRIBUS_API getImageType(QString filename); + +// A struct for holding the Importer specific information. +struct ImporterData { + QString soFilePath; // Path to the Importer + QString fileFormatName; // Name of the Importer + QStringList fileEndings; // Array of filenames supported by the importer +}; + +// A Struct for holding the results of the File selection Dialog +struct ImportSetup { + QStringList filename; // What filename is to be loaded? + bool textOnly; // Do we import as text only? + QString encoding; // File encoding +}; + class SCRIBUS_API FormatsManager { public: @@ -126,7 +141,15 @@ class SCRIBUS_API FormatsManager //! Returns in the form of "All Supported Formats (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI);;EPS (*.eps *.EPS);;EPSI (*.epsf *.EPSF);;EPSI (*.epsi *.EPSI);;All Files (*)" QString fileDialogFormatList(int type); - + QString fileDialogTextFormatList(); + QString fileDialogVectorFormatList(); + + bool isVectorFile(QString); + + QMap<QString, ImporterData*> getMap(){return importerMap;} + QList<ImporterData> getImporters(){return importers;} + QStringList getIlist(){return ilist;} + protected: QMap<int, QString> m_fmtNames; QMap<int, QStringList> m_fmtMimeTypes; @@ -146,6 +169,20 @@ class SCRIBUS_API FormatsManager * instance(). */ static FormatsManager* _instance; + +//we need some informations about importer and dll to know which text format can be use + + QMap<QString, ImporterData*> importerMap; // QMap of the supported extensions to their relevant importers entry for easy access + QStringList ilist; // List of supported importers, used with dialogs + QList<ImporterData> importers; // Vector of the loaded importers + + void loadImporterPlugins(); // Find the available plugins based on the environment, validate they load, and + // create quick lookup mappings. + void createMap(); // Create the importer Qmap. + + bool DLLName(QString name, QString *ffName, QStringList *fileEndings); + // Loads the "DLL", validates the importer is good, populates the passed parameters with + // the plugin information. }; #endif |
|
More tests have revealed some non-crashing issue in the preference management. See #11637 Plz wait for new patch. |
|
Chelen, let us know when the issues are resolved and we can review again. |
|
Maybe we could also make it easier for former InDesign users by adding a "Place" command? |
|
new patch is available. I only fix what we can call issue (bad unitRatio) but I prefer seeing it in the trunk before doing more work on it. Also, I may do really smallest patch later (so easier to review for you bradney). |
|
unitloaderpatch.diff (135,287 bytes)
diff --git a/Scribus/Scribus.pro b/Scribus/Scribus.pro index a17cc45..ee124db 100644 --- a/Scribus/Scribus.pro +++ b/Scribus/Scribus.pro @@ -595,7 +595,6 @@ HEADERS += scribus/actionmanager.h \ scribus/ui/gradientpreview.h \ scribus/ui/gradientvectordialog.h \ scribus/ui/gtdialogs.h \ - scribus/ui/gtfiledialog.h \ scribus/ui/guidemanager.h \ scribus/ui/helpbrowser.h \ scribus/ui/helpnavigation.h \ @@ -1128,7 +1127,8 @@ HEADERS += scribus/actionmanager.h \ scribus/styles/cellstyle.attrdefs.cxx \ scribus/main_nix.cpp \ scribus/main_win32.cpp \ - scribus/styles/linestyle.attrdefs.cxx + scribus/styles/linestyle.attrdefs.cxx \ + scribus/canvasmode_importdata.h FORMS += scribus/ui/aboutplugins.ui \ scribus/ui/aligndistribute.ui \ scribus/ui/arcvectorbase.ui \ @@ -1142,7 +1142,6 @@ FORMS += scribus/ui/aboutplugins.ui \ scribus/ui/gradientaddedit.ui \ scribus/ui/gradienteditor.ui \ scribus/ui/gradientvectorbase.ui \ - scribus/ui/gtfiledialog.ui \ scribus/ui/guidemanager.ui \ scribus/ui/helpbrowser.ui \ scribus/ui/helpbrowsernavigation.ui \ @@ -1606,7 +1605,6 @@ SOURCES += scribus/actionmanager.cpp \ scribus/ui/gradientpreview.cpp \ scribus/ui/gradientvectordialog.cpp \ scribus/ui/gtdialogs.cpp \ - scribus/ui/gtfiledialog.cpp \ scribus/ui/guidemanager.cpp \ scribus/ui/helpbrowser.cpp \ scribus/ui/helpnavigation.cpp \ @@ -2177,7 +2175,8 @@ SOURCES += scribus/actionmanager.cpp \ scribus/plugins/tools/2geomtools/meshdistortion/meshdistortion.cpp \ scribus/plugins/tools/2geomtools/meshdistortion/meshdistortiondialog.cpp \ scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp \ - scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp + scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp \ + scribus/canvasmode_importdata.cpp RESOURCES += scribus/plugins/scripter/python/sceditor/dockwidget_icons.qrc TRANSLATIONS += resources/translations/po/scribus.af.ts \ resources/translations/po/scribus.ar.ts \ diff --git a/Scribus/scribus/CMakeLists.txt b/Scribus/scribus/CMakeLists.txt index 80cea9d..7d4e840 100644 --- a/Scribus/scribus/CMakeLists.txt +++ b/Scribus/scribus/CMakeLists.txt @@ -78,7 +78,6 @@ SET(SCRIBUS_UI_SRC ui/gradientaddedit.ui ui/gradienteditor.ui ui/gradientvectorbase.ui - ui/gtfiledialog.ui ui/guidemanager.ui ui/insertaframe.ui ui/inserttablecolumnsdialog.ui @@ -312,7 +311,6 @@ SET(SCRIBUS_MOC_CLASSES ui/gradientvectordialog.h ui/gradientpreview.h ui/gtdialogs.h - ui/gtfiledialog.h ui/guidemanager.h ui/helpbrowser.h ui/hruler.h @@ -515,7 +513,7 @@ SET(SCRIBUS_SOURCES canvasmode_drawfreehand.cpp canvasmode_eyedropper.cpp canvasmode_framelinks.cpp - canvasmode_imageimport.cpp + canvasmode_importdata.cpp canvasmode_edit.cpp canvasmode_editarc.cpp canvasmode_editgradient.cpp @@ -758,7 +756,6 @@ SET(SCRIBUS_SOURCES ui/gradientvectordialog.cpp ui/gradientpreview.cpp ui/gtdialogs.cpp - ui/gtfiledialog.cpp ui/guidemanager.cpp ui/helpbrowser.cpp ui/hruler.cpp diff --git a/Scribus/scribus/actionmanager.cpp b/Scribus/scribus/actionmanager.cpp index 39a7274..f3a6ab4 100644 --- a/Scribus/scribus/actionmanager.cpp +++ b/Scribus/scribus/actionmanager.cpp @@ -118,15 +118,7 @@ void ActionManager::initFileMenuActions() name="fileCollect"; scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); //File Import Menu - name="fileImportText"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportText2"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportAppendText"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportImage"; - scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); - name="fileImportVector"; + name="fileImport"; scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow)); //File Export Menu @@ -171,11 +163,7 @@ void ActionManager::initFileMenuActions() connect( (*scrActions)["fileCollect"], SIGNAL(triggered()), mainWindow, SLOT(fileCollect()) ); connect( (*scrActions)["fileQuit"], SIGNAL(triggered()), mainWindow, SLOT(slotFileQuit()) ); //File Import Menu - connect( (*scrActions)["fileImportText"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); - connect( (*scrActions)["fileImportText2"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent2()) ); - connect( (*scrActions)["fileImportAppendText"], SIGNAL(triggered()), mainWindow, SLOT(slotFileAppend()) ); - connect( (*scrActions)["fileImportImage"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); - connect( (*scrActions)["fileImportVector"], SIGNAL(triggered()), mainWindow, SLOT(importVectorFile()) ); + connect( (*scrActions)["fileImport"], SIGNAL(triggered()), mainWindow, SLOT(slotGetContent()) ); //File Export Menu connect( (*scrActions)["fileExportText"], SIGNAL(triggered()), mainWindow, SLOT(SaveText()) ); connect( (*scrActions)["fileExportAsEPS"], SIGNAL(triggered()), mainWindow, SLOT(SaveAsEps()) ); @@ -1426,10 +1414,7 @@ void ActionManager::languageChange() (*scrActions)["fileSaveAs"]->setTexts( tr("Save &As...")); (*scrActions)["fileRevert"]->setTexts( tr("Re&vert to Saved")); (*scrActions)["fileCollect"]->setTexts( tr("Collect for O&utput...")); - (*scrActions)["fileImportText"]->setTexts( tr("Get Text...")); - (*scrActions)["fileImportAppendText"]->setTexts( tr("Append &Text...")); - (*scrActions)["fileImportImage"]->setTexts( tr("Get Image...")); - (*scrActions)["fileImportVector"]->setTexts( tr("Get Vector File...")); + (*scrActions)["fileImport"]->setTexts( tr("Get File...")); (*scrActions)["fileExportText"]->setTexts( tr("Save &Text...")); (*scrActions)["fileExportAsEPS"]->setTexts( tr("Save as &EPS...")); @@ -1818,8 +1803,7 @@ void ActionManager::createDefaultShortcuts() defKeys.insert("fileClose", QKeySequence::Close); defKeys.insert("fileSave", QKeySequence::Save); defKeys.insert("fileSaveAs", Qt::CTRL+Qt::SHIFT+Qt::Key_S); - defKeys.insert("fileImportText", Qt::CTRL+Qt::Key_I); - defKeys.insert("fileImportImage", Qt::CTRL+Qt::Key_I); + defKeys.insert("fileImport", Qt::CTRL+Qt::Key_I); defKeys.insert("filePrint", QKeySequence::Print); defKeys.insert("fileExportAsPDF", Qt::CTRL+Qt::SHIFT+Qt::Key_P); defKeys.insert("fileQuit", Qt::CTRL+Qt::Key_Q); @@ -1978,10 +1962,7 @@ void ActionManager::createDefaultMenus() << "fileSaveAs" << "fileRevert" << "fileCollect" - << "fileImportText" - << "fileImportAppendText" - << "fileImportImage" - << "fileImportVector" + << "fileImport" << "fileExportText" << "fileExportAsEPS" << "fileExportAsPDF" diff --git a/Scribus/scribus/canvas.h b/Scribus/scribus/canvas.h index e76447f..529d147 100644 --- a/Scribus/scribus/canvas.h +++ b/Scribus/scribus/canvas.h @@ -101,7 +101,7 @@ public: friend class CanvasMode_EditTable; friend class CanvasMode_EyeDropper; friend class CanvasMode_FrameLinks; - friend class CanvasMode_ImageImport; + friend class CanvasMode_ImportData; friend class CanvasMode_Magnifier; friend class CanvasMode_NodeEdit; friend class CanvasMode_ObjImport; diff --git a/Scribus/scribus/canvasgesture_resize.cpp b/Scribus/scribus/canvasgesture_resize.cpp index a8e0505..ef23eeb 100644 --- a/Scribus/scribus/canvasgesture_resize.cpp +++ b/Scribus/scribus/canvasgesture_resize.cpp @@ -268,7 +268,7 @@ void ResizeGesture::doResize(bool scaleContent) double imgScX = (newBounds.width() - m_extraWidth) / divX * currItem->imageXScale(); double imgScY = (newBounds.height() - m_extraHeight) / divY * currItem->imageYScale(); // The aspect ratio has been fixed, so make the modification in the direction of the larger movement. - if (currItem->keepAspectRatio() && currItem->fitImageToFrame()) + if (currItem->keepAspectRatio() && currItem->fitImageToFrame()) { if (qAbs((newBounds.width() - m_extraWidth) - currItem->width()) > qAbs((newBounds.height() - m_extraHeight) - currItem->height())) imgScY = imgScX; @@ -305,10 +305,10 @@ void ResizeGesture::doResize(bool scaleContent) } // We do not want to scale the text of a linked frame // as it would alter text in other frames of the string - else if((currItem->itemType() == PageItem::TextFrame) - && (currItem->nextInChain() == 0) - && (currItem->prevInChain() == 0) - && scaleContent) + else if((currItem->itemType() == PageItem::TextFrame) + && (currItem->nextInChain() == 0) + && (currItem->prevInChain() == 0) + && scaleContent) { double divX = (currItem->width() != 0) ? currItem->width() : 1.0; double divY = (currItem->height() != 0) ? currItem->height() : 1.0; @@ -352,8 +352,8 @@ void ResizeGesture::doResize(bool scaleContent) if (mm.m22() < 0) dy *= -1; currItem->moveBy(-dx, -dy, true); - currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth); - currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight); + currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth + currItem->lineWidth()); + currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight + currItem->lineWidth()); if (mm.m11() < 0) currItem->moveBy(-currItem->width(), 0); if (mm.m22() < 0) diff --git a/Scribus/scribus/canvasgesture_rulermove.cpp b/Scribus/scribus/canvasgesture_rulermove.cpp index ee61520..5c107ab 100644 --- a/Scribus/scribus/canvasgesture_rulermove.cpp +++ b/Scribus/scribus/canvasgesture_rulermove.cpp @@ -158,14 +158,20 @@ void RulerGesture::mouseSelectGuide(QMouseEvent *m) void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) { FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); - const int page = m_doc->OnPage(mousePointDoc.x(), mousePointDoc.y()); + double x = mousePointDoc.x(), y = mousePointDoc.y(); + double dx = -x, dy = -y; + m_doc->ApplyGuides(&x,&y,true); + dx += x; + dy += y; + const int page = m_doc->OnPage(x, y); QRect viewport(m_view->viewport()->mapToGlobal(QPoint(0,0)), QSize(m_view->visibleWidth(), m_view->visibleHeight())); - QPoint newMousePoint = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0))); + QPointF newMousePoint = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0))); + newMousePoint += QPointF(dx,dy)*m_canvas->scale(); switch (m_mode) { case ORIGIN: m_canvas->repaint(); - m_canvas->displayCorrectedXYHUD(m->globalPos(), mousePointDoc.x(), mousePointDoc.y()); + m_canvas->displayCorrectedXYHUD(m->globalPos(), x, y); break; case HORIZONTAL: if (!m_ScMW->doc->guidesPrefs().guidesShown) @@ -179,8 +185,8 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) qApp->changeOverrideCursor(QCursor(Qt::SplitVCursor)); if (mouseRelease) { - m_doc->Pages->at(page)->guides.addHorizontal(mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); - m_guide = mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(); + m_doc->Pages->at(page)->guides.addHorizontal(y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_guide = y - m_doc->Pages->at(page)->yOffset(); m_page = page; m_haveGuide = true; m_doc->changed(); @@ -189,11 +195,11 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) else if (mouseRelease) { if (page == m_page) - m_doc->Pages->at(page)->guides.moveHorizontal( m_guide, mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.moveHorizontal( m_guide, y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); else { m_doc->Pages->at(m_page)->guides.deleteHorizontal( m_guide, GuideManagerCore::Standard); - m_doc->Pages->at(page)->guides.addHorizontal(mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.addHorizontal(y - m_doc->Pages->at(page)->yOffset(), GuideManagerCore::Standard); m_page = page; } if (m_doc->currentPage() != m_doc->Pages->at(m_page)) @@ -206,7 +212,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) if (cursor && (cursor->shape() != Qt::SplitVCursor)) qApp->changeOverrideCursor(QCursor(Qt::SplitVCursor)); } - m_currentGuide = mousePointDoc.y() - m_doc->Pages->at(page)->yOffset(); + m_currentGuide = y - m_doc->Pages->at(page)->yOffset(); } else { @@ -221,7 +227,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) } } } - m_canvas->displayCorrectedSingleHUD(m->globalPos(), mousePointDoc.y(), false); + m_canvas->displayCorrectedSingleHUD(m->globalPos(),y, false); break; case VERTICAL: if (!m_ScMW->doc->guidesPrefs().guidesShown) @@ -235,8 +241,8 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) qApp->changeOverrideCursor(QCursor(Qt::SplitHCursor)); if (mouseRelease) { - m_doc->Pages->at(page)->guides.addVertical(mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); - m_guide = mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(); + m_doc->Pages->at(page)->guides.addVertical(x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_guide = x - m_doc->Pages->at(page)->xOffset(); m_page = page; m_haveGuide = true; m_doc->changed(); @@ -245,11 +251,11 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) else if (mouseRelease) { if (page == m_page) - m_doc->Pages->at(page)->guides.moveVertical( m_guide, mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.moveVertical( m_guide,x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); else { m_doc->Pages->at(m_page)->guides.deleteVertical( m_guide, GuideManagerCore::Standard); - m_doc->Pages->at(page)->guides.addVertical(mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); + m_doc->Pages->at(page)->guides.addVertical(x - m_doc->Pages->at(page)->xOffset(), GuideManagerCore::Standard); m_page = page; } if (m_doc->currentPage() != m_doc->Pages->at(m_page)) @@ -262,7 +268,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) if (cursor && (cursor->shape() != Qt::SplitHCursor)) qApp->changeOverrideCursor(QCursor(Qt::SplitHCursor)); } - m_currentGuide = mousePointDoc.x() - m_doc->Pages->at(page)->xOffset(); + m_currentGuide = x - m_doc->Pages->at(page)->xOffset(); } else { @@ -277,7 +283,7 @@ void RulerGesture::movePoint(QMouseEvent* m, bool mouseRelease) } } } - m_canvas->displayCorrectedSingleHUD(m->globalPos(), mousePointDoc.x(), true); + m_canvas->displayCorrectedSingleHUD(m->globalPos(), x, true); break; } m_xy = newMousePoint; diff --git a/Scribus/scribus/canvasgesture_rulermove.h b/Scribus/scribus/canvasgesture_rulermove.h index 42eaf17..c2cd312 100644 --- a/Scribus/scribus/canvasgesture_rulermove.h +++ b/Scribus/scribus/canvasgesture_rulermove.h @@ -88,7 +88,7 @@ private: double m_currentGuide; bool m_haveCursor; QCursor m_cursor; - QPoint m_xy; + QPointF m_xy; void movePoint(QMouseEvent *m, bool mouseRelease); signals: diff --git a/Scribus/scribus/canvasmode.cpp b/Scribus/scribus/canvasmode.cpp index b09f184..a501b1d 100644 --- a/Scribus/scribus/canvasmode.cpp +++ b/Scribus/scribus/canvasmode.cpp @@ -34,7 +34,7 @@ #include "canvasmode_editweldpoint.h" #include "canvasmode_eyedropper.h" #include "canvasmode_framelinks.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "canvasmode_magnifier.h" #include "canvasmode_measurements.h" #include "canvasmode_nodeedit.h" @@ -177,8 +177,8 @@ CanvasMode* CanvasMode::createForAppMode(ScribusView* view, int appMode) case modeUnlinkFrames: result = new CanvasMode_FrameLinks(view); break; - case modeImportImage: - result = new CanvasMode_ImageImport(view); + case modeImportData: + result = new CanvasMode_ImportData(view); break; case modeMagnifier: result = new CanvasMode_Magnifier(view); diff --git a/Scribus/scribus/canvasmode_create.cpp b/Scribus/scribus/canvasmode_create.cpp index 6a71ebf..ed3029f 100644 --- a/Scribus/scribus/canvasmode_create.cpp +++ b/Scribus/scribus/canvasmode_create.cpp @@ -596,15 +596,8 @@ PageItem* CreateMode::doCreateNewObject(void) skipOneClick = false; } if (!skipOneClick) - { if ((!m_view->moveTimerElapsed()) || ((fabs(wSize) < 2.0) && (fabs(hSize) < 2.0))) - { - if (!doOneClick(createObjectPos, canvasCurrCoord)) - { - return NULL; - } - } - } + !doOneClick(createObjectPos, canvasCurrCoord); wSize = canvasCurrCoord.x() - createObjectPos.x(); hSize = canvasCurrCoord.y() - createObjectPos.y(); @@ -850,102 +843,78 @@ PageItem* CreateMode::doCreateNewObject(void) bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint) { - bool doCreate = false; double xSize, ySize; int originPoint = 0; if (QApplication::keyboardModifiers() & Qt::ControlModifier) return true; - PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize"); - bool doRemember = sizes->getBool("Remember", true); + ItemToolPrefs sizes = m_doc->prefsData().itemToolPrefs; int lmode = (createObjectMode == modeDrawLine) ? 1 : 0; - if (lmode == 0) - { - xSize = sizes->getDouble("defWidth", 100.0); - ySize = sizes->getDouble("defHeight", 100.0); - originPoint = sizes->getInt("Origin", 0); - } - else - { - xSize = sizes->getDouble("defLength", 100.0); - ySize = sizes->getDouble("defAngle", 0.0); - originPoint = sizes->getInt("OriginL", 0); - } + xSize = sizes.imageDefaultWidth; + ySize = sizes.imageDefaultHeight; + originPoint = sizes.imageDefaultBasePoint; -// qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); - OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, lmode); - if (dia->exec()) + qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); + OneClick *dia = NULL; + if(sizes.imageDefaultSize > 1 && !(view()->ImageAfterDraw && sizes.imageDefaultSize == 2)) { - doRemember = dia->checkRemember->isChecked(); - if (lmode == 0) + dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, originPoint, lmode); + if (dia->exec()) { xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex()); originPoint = dia->RotationGroup->checkedId(); - if (doRemember) - { - sizes->set("defWidth", xSize); - sizes->set("defHeight", ySize); - sizes->set("Origin", originPoint); - } - endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize); - switch (originPoint) - { - case 0: - break; - case 1: - startPoint.setX(startPoint.x() - xSize); - endPoint.setX(endPoint.x() - xSize); - break; - case 2: - startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0); - endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0); - break; - case 3: - startPoint.setY(startPoint.y() - ySize); - endPoint.setY(endPoint.y() - ySize); - break; - case 4: - startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize); - endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize); - break; - } } - else + } + if (lmode == 0) + { + endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize); + switch (originPoint) { - FPoint oldStart = startPoint; - xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); - ySize = dia->spinHeight->value(); - originPoint = dia->RotationGroup->checkedId(); - if (doRemember) - { - sizes->set("defLength", xSize); - sizes->set("defAngle", ySize); - sizes->set("OriginL", originPoint); - } - double angle = -ySize * M_PI / 180.0; - switch (originPoint) - { - case 0: - endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle)); - break; - case 1: - startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle)); - endPoint = oldStart; - break; - case 2: - startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle)); - endPoint = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle)); - break; - } + case 0: + break; + case 1: + startPoint.setX(startPoint.x() - xSize); + endPoint.setX(endPoint.x() - xSize); + break; + case 2: + startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0); + endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0); + break; + case 3: + startPoint.setY(startPoint.y() - ySize); + endPoint.setY(endPoint.y() - ySize); + break; + case 4: + startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize); + endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize); + break; + } + } + else + { + FPoint oldStart = startPoint; + double angle = -ySize * M_PI / 180.0; + switch (originPoint) + { + case 0: + endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle)); + break; + case 1: + startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle)); + endPoint = oldStart; + break; + case 2: + startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle)); + endPoint = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle)); + break; } - sizes->set("Remember", doRemember); - doCreate = true; } - delete dia; - return doCreate; + if(dia) + delete dia; + return true; } FRect CreateMode::adjustedRect(FPoint &firstPoint, FPoint &secondPoint) diff --git a/Scribus/scribus/canvasmode_imageimport.cpp b/Scribus/scribus/canvasmode_imageimport.cpp deleted file mode 100644 index 5c88e07..0000000 --- a/Scribus/scribus/canvasmode_imageimport.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - For general Scribus (>=1.3.2) copyright and licensing information please refer - to the COPYING file provided with the program. Following this notice may exist - a copyright and/or license notice that predates the release of Scribus 1.3.2 - for which a new license (GPL+exception) is in place. - */ -/*************************************************************************** -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -***************************************************************************/ - -#include "canvasmode_imageimport.h" - -#include <QApplication> -#include <QBuffer> -#include <QCursor> -#include <QEvent> -#include <QMouseEvent> -#include <QPainterPath> -#include <QPixmap> -#include <QPoint> -#include <QRect> -#include <QToolTip> -#include <QDebug> - -#include "canvas.h" -#include "canvasmode.h" -#include "prefsmanager.h" -#include "ui/propertiespalette.h" -#include "ui/propertiespalette_image.h" -#include "scribus.h" -#include "scribusdoc.h" -#include "scribusview.h" -#include "selection.h" -#include "util_icon.h" - -CanvasMode_ImageImport::CanvasMode_ImageImport(ScribusView *view) : CanvasMode(view), m_ScMW(view->m_ScMW) -{ - Mx=0; - My=0; -} - -void CanvasMode_ImageImport::setImageList(QStringList l) -{ - imageList = l; - if(l.size()==1) - { - while(!(m_doc->m_Selection->itemAt(0)->isImageFrame())) - m_doc->m_Selection->removeFirst(); - if(!m_doc->m_Selection->isEmpty()) - { - setImage(m_doc->m_Selection->itemAt(0)); - m_view->requestMode(submodePaintingDone); - } - else - newToolTip(l.first()); - } - else - newToolTip(l.first()); -} - -void CanvasMode_ImageImport::newToolTip(QString name) -{ - QPainter p; - QImage pm = QImage(80, 80, QImage::Format_ARGB32_Premultiplied); - QBrush b(QColor(205,205,205), loadIcon("testfill.png")); - p.begin(&pm); - p.fillRect(QRectF(0, 0, 80, 80), b); - QImage thumb; - if(thumb.load(name)) - { - thumb = thumb.scaled(80,80,Qt::KeepAspectRatio); - p.drawImage((80 - thumb.width()) / 2, (80 - thumb.height()) / 2, thumb); - QBuffer buffer; - buffer.open(QIODevice::WriteOnly); - pm.save(&buffer, "PNG"); - QByteArray ba = buffer.buffer().toBase64(); - buffer.close(); - tipText = "<p align=\"center\"><img src=\"data:image/png;base64," + QString(ba) + "\"></p>"; - } - else - tipText = "<p align=\"center\">" + name.right(name.lastIndexOf("/")) + "</p>"; - QToolTip::showText(QPoint(Mx,My), tipText, qApp->activeWindow()); - p.end(); -} - -void CanvasMode_ImageImport::drawControls(QPainter* p) -{ - commonDrawControls(p, false); -} - -void CanvasMode_ImageImport::enterEvent(QEvent *) -{ - if (!m_canvas->m_viewMode.m_MouseButtonPressed) - setModeCursor(); -} - -void CanvasMode_ImageImport::keyPressEvent(QKeyEvent *e) -{ - int kk = e->key(); - if (m_keyRepeat) - return; - m_keyRepeat = true; - e->accept(); - switch (kk) - { - case Qt::Key_Tab: - imageList.prepend(imageList.takeLast()); - break; - case Qt::Key_Backtab: - imageList.append(imageList.takeFirst()); - break; - case Qt::Key_Backspace: - imageList.removeFirst(); - break; - case Qt::Key_Escape: - imageList.clear(); - break; - } - updateList(); - m_keyRepeat = false; -} - - -void CanvasMode_ImageImport::leaveEvent(QEvent *e) -{ -} - -void CanvasMode_ImageImport::activate(bool fromGesture) -{ - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); - m_keyRepeat = false; - m_doc->DragP = false; - m_doc->leaveDrag = false; - m_canvas->m_viewMode.operItemMoving = false; - m_canvas->m_viewMode.operItemResizing = false; - m_view->MidButt = false; - setModeCursor(); - if (fromGesture) - m_view->update(); -} - -void CanvasMode_ImageImport::deactivate(bool forGesture) -{ - m_view->setRedrawMarkerShown(false); -} - -void CanvasMode_ImageImport::mouseDoubleClickEvent(QMouseEvent *m) -{ - m->accept(); - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); -} - -void CanvasMode_ImageImport::mouseMoveEvent(QMouseEvent *m) -{ - Mx = m->globalPos().x(); - My = m->globalPos().y(); - QToolTip::showText(m->globalPos(), tipText, qApp->activeWindow()); - QToolTip::showText(m->globalPos(), tipText + "<b></b>", qApp->activeWindow()); - m->accept(); - PageItem *item; - if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) - { - PageItem_ImageFrame *currItem; - if((currItem = item->asImageFrame()) != NULL) - m_view->setCursor(QCursor(loadIcon("DrawImageFrame.xpm"))); - else - m_view->setCursor(QCursor(Qt::ArrowCursor)); - } - else - m_view->setCursor(QCursor(loadIcon("DrawImageFrame.xpm"))); - if (commonMouseMove(m)) - return; -} - -void CanvasMode_ImageImport::mousePressEvent(QMouseEvent *m) -{ - m_canvas->PaintSizeRect(QRect()); - m_canvas->m_viewMode.m_MouseButtonPressed = true; - m_canvas->m_viewMode.operItemMoving = false; - m_view->HaveSelRect = false; - m_doc->DragP = false; - m_doc->leaveDrag = false; - m->accept(); - m_view->registerMousePress(m->globalPos()); - PageItem *item; - if(imageList.size()>0) - { - if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) - { - PageItem_ImageFrame *currItem; - if((currItem = item->asImageFrame()) != NULL) - setImage(currItem); - } - else - view()->ImageAfterDraw = true; - } - if (m->button() == Qt::MidButton) - { - m_view->MidButt = true; - if (m->modifiers() & Qt::ControlModifier) - m_view->DrawNew(); - return; - } -} - -void CanvasMode_ImageImport::mouseReleaseEvent(QMouseEvent *m) -{ - m_canvas->m_viewMode.m_MouseButtonPressed = false; - m_canvas->resetRenderMode(); - m->accept(); - m_view->updateContents(); - m_canvas->setRenderModeUseBuffer(false); - m_doc->DragP = false; - m_doc->leaveDrag = false; - m_canvas->m_viewMode.operItemMoving = false; - m_canvas->m_viewMode.operItemResizing = false; - m_view->MidButt = false; - updateList(); -} - -void CanvasMode_ImageImport::setImage(PageItem *currItem) -{ - QString fileName = imageList.takeFirst(); - currItem->EmProfile = ""; - currItem->pixm.imgInfo.isRequest = false; - currItem->UseEmbedded = true; - currItem->IProfile = m_doc->cmsSettings().DefaultImageRGBProfile; - currItem->IRender = m_doc->cmsSettings().DefaultIntentImages; - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - m_doc->loadPict(fileName, currItem, false, true); - m_ScMW->propertiesPalette->imagePal->displayScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset()); - m_ScMW->repaint(); - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - m_view->DrawNew(); - currItem->emitAllToGUI(); -} - -void CanvasMode_ImageImport::updateList() -{ - if(imageList.isEmpty()) - { - m_view->requestMode(submodePaintingDone); - QToolTip::hideText(); - } - else - newToolTip(imageList.first()); -} diff --git a/Scribus/scribus/canvasmode_imageimport.h b/Scribus/scribus/canvasmode_imageimport.h deleted file mode 100644 index 673dfba..0000000 --- a/Scribus/scribus/canvasmode_imageimport.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - For general Scribus (>=1.3.2) copyright and licensing information please refer - to the COPYING file provided with the program. Following this notice may exist - a copyright and/or license notice that predates the release of Scribus 1.3.2 - for which a new license (GPL+exception) is in place. - */ -/*************************************************************************** -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -***************************************************************************/ - - -#ifndef CANVASMODE_IMAGEIMPORT_H -#define CANVASMODE_IMAGEIMPORT_H - -#include <QEvent> -#include <QMouseEvent> -#include <QPainter> -#include <QPixmap> -#include <QStringList> - -#include "canvasmode.h" - -class PageItem; -class ScribusView; -class ScribusMainWindow; - -class CanvasMode_ImageImport : public CanvasMode -{ -public: - explicit CanvasMode_ImageImport(ScribusView* view); - virtual ~CanvasMode_ImageImport() {} - - virtual void enterEvent(QEvent *); - virtual void leaveEvent(QEvent *); - - virtual void activate(bool); - virtual void deactivate(bool); - virtual void keyPressEvent(QKeyEvent *e); - virtual bool handleKeyEvents() { return true; } - virtual void mouseDoubleClickEvent(QMouseEvent *m); - virtual void mouseReleaseEvent(QMouseEvent *m); - virtual void mouseMoveEvent(QMouseEvent *m); - virtual void mousePressEvent(QMouseEvent *m); - virtual void drawControls(QPainter* p); - - void setImageList(QStringList l); - void setImage(PageItem* item); - void updateList(); - -private: - bool m_keyRepeat; - QString tipText; - QStringList imageList; - ScribusMainWindow *m_ScMW; - double Mx, My; - void newToolTip(QString name); -}; - -#endif // CANVASMODE_IMAGEIMPORT_H diff --git a/Scribus/scribus/canvasmode_importdata.cpp b/Scribus/scribus/canvasmode_importdata.cpp new file mode 100644 index 0000000..7d304dd --- /dev/null +++ b/Scribus/scribus/canvasmode_importdata.cpp @@ -0,0 +1,337 @@ +/* + For general Scribus (>=1.3.2) copyright and licensing information please refer + to the COPYING file provided with the program. Following this notice may exist + a copyright and/or license notice that predates the release of Scribus 1.3.2 + for which a new license (GPL+exception) is in place. + */ +/*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + +#include "canvasmode_importdata.h" + +#include <QApplication> +#include <QBuffer> +#include <QCursor> +#include <QDrag> +#include <QEvent> +#include <QMessageBox> +#include <QMouseEvent> +#include <QPainterPath> +#include <QPixmap> +#include <QPoint> +#include <QRect> +#include <QToolTip> +#include <QUrl> +#include <QDebug> + +#include "canvas.h" +#include "canvasmode.h" +#include "ui/bookmarkpalette.h" +#include "fileloader.h" +#include "plugins/formatidlist.h" +#include "hyphenator.h" +#include "loadsaveplugin.h" +#include "pageitem_textframe.h" +#include "prefsmanager.h" +#include "ui/propertiespalette.h" +#include "ui/propertiespalette_image.h" +#include "scribus.h" +#include "scribusdoc.h" +#include "scribusview.h" +#include "selection.h" +#include "ui/stylemanager.h" +#include "util_formats.h" +#include "util_icon.h" + +CanvasMode_ImportData::CanvasMode_ImportData(ScribusView *view) : CanvasMode(view), m_ScMW(view->m_ScMW) +{ + pw = new FDialogPreview(m_ScMW,Qt::ToolTip); + trans = NULL; +} + +void CanvasMode_ImportData::setInformation(ImportSetup is) +{ + impsetup = is; + if(!m_doc->m_Selection->isEmpty() && is.filename.size()==1) + { + if(m_doc->m_Selection->itemAt(0)->isTextFrame()) + { + setText(m_doc->m_Selection->itemAt(0)->asTextFrame()); + m_view->requestMode(submodePaintingDone); + } + else if(m_doc->m_Selection->itemAt(0)->isImageFrame()) + { + setImage(m_doc->m_Selection->itemAt(0)->asImageFrame()); + m_view->requestMode(submodePaintingDone); + } + else + pw->GenPreview(is.filename.first()); + } + else + pw->GenPreview(is.filename.first()); +} + +void CanvasMode_ImportData::drawControls(QPainter* p) +{ + commonDrawControls(p, false); +} + +void CanvasMode_ImportData::enterEvent(QEvent *) +{ + if (!m_canvas->m_viewMode.m_MouseButtonPressed) + setModeCursor(); +} + +void CanvasMode_ImportData::keyPressEvent(QKeyEvent *e) +{ + int kk = e->key(); + if (m_keyRepeat) + return; + m_keyRepeat = true; + e->accept(); + switch (kk) + { + case Qt::Key_Tab: + impsetup.filename.prepend(impsetup.filename.takeLast()); + break; + case Qt::Key_Backtab: + impsetup.filename.append(impsetup.filename.takeFirst()); + break; + case Qt::Key_Backspace: + impsetup.filename.removeFirst(); + break; + case Qt::Key_Escape: + impsetup.filename.clear(); + break; + } + updateList(); + m_keyRepeat = false; +} + + +void CanvasMode_ImportData::leaveEvent(QEvent *e) +{ + if (!m_canvas->m_viewMode.m_MouseButtonPressed) + qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); +} + +void CanvasMode_ImportData::activate(bool fromGesture) +{ + pw->setVisible(true); + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); + m_keyRepeat = false; + m_doc->DragP = false; + m_doc->leaveDrag = false; + m_canvas->m_viewMode.operItemMoving = false; + m_canvas->m_viewMode.operItemResizing = false; + m_view->MidButt = false; + setModeCursor(); + if (fromGesture) + m_view->update(); +} + +void CanvasMode_ImportData::deactivate(bool forGesture) +{ + pw->hide(); + m_view->redrawMarker->hide(); +} + +void CanvasMode_ImportData::mouseDoubleClickEvent(QMouseEvent *m) +{ + m->accept(); + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); +} + +void CanvasMode_ImportData::mouseMoveEvent(QMouseEvent *m) +{ + pw->move(m->globalPos() + QPoint(10,10)); + m->accept(); + if (commonMouseMove(m)) + return; +} + +void CanvasMode_ImportData::mousePressEvent(QMouseEvent *m) +{ + m_canvas->PaintSizeRect(QRect()); + m_canvas->m_viewMode.m_MouseButtonPressed = true; + m_canvas->m_viewMode.operItemMoving = false; + m_view->HaveSelRect = false; + m_doc->DragP = false; + m_doc->leaveDrag = false; + m->accept(); + m_view->registerMousePress(m->globalPos()); + PageItem *item; + if(impsetup.filename.size()>0) + { + if(UndoManager::undoEnabled()) + { + trans = new UndoTransaction(undoManager->beginTransaction(Um::NoObjectFrame, Um::IImageFrame, Um::ImportFile,"",Um::ICreate)); + SimpleState *ss = new SimpleState(Um::ImportFile,"",Um::ICreate); + ss->set("FILE_LOADER","file_loader"); + ss->set("name",impsetup.filename.first()); + undoManager->action(m_ScMW,ss); + } + if(FormatsManager::instance()->isVectorFile(impsetup.filename.at(0))) + { + QFileInfo fi(impsetup.filename.at(0)); + QString suffix = fi.suffix().toLower(); + if ((suffix == "sce") || (suffix == "shape")) + { + QList<QUrl> urls; + QMimeData* md = new QMimeData(); + urls.append( QUrl::fromLocalFile(impsetup.filename.takeFirst()) ); + md->setUrls(urls); + QDrag* dr = new QDrag(m_ScMW); + dr->setMimeData(md); + dr->setPixmap(loadIcon("DragPix.xpm")); + dr->exec(); + } + else + { + FileLoader *fileLoader = new FileLoader(impsetup.filename.at(0)); + int testResult = fileLoader->testFile(); + delete fileLoader; + if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER)) + { + const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult); + if( fmt ) + { + m_doc->dontResize = true; + fmt->loadFile(impsetup.filename.takeFirst(), LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive); + m_doc->dontResize = false; + } + } + } + } + else if(getImageType(impsetup.filename.at(0)) == QString("")) + { + if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) + { + if((item->asTextFrame()) != NULL) + setText(item->asTextFrame()); + else + view()->TextAfterDraw = true; + } + else + view()->TextAfterDraw = true; + } + else if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL) + { + if((item->asImageFrame()) != NULL) + setImage(item->asImageFrame()); + else + view()->ImageAfterDraw = true; + } + else + view()->ImageAfterDraw = true; + } + if (m->button() == Qt::MidButton) + { + m_view->MidButt = true; + if (m->modifiers() & Qt::ControlModifier) + m_view->DrawNew(); + return; + } +} + +void CanvasMode_ImportData::mouseReleaseEvent(QMouseEvent *m) +{ + m_canvas->m_viewMode.m_MouseButtonPressed = false; + m_canvas->resetRenderMode(); + m->accept(); + m_view->updateContents(); + m_canvas->setRenderModeUseBuffer(false); + m_doc->DragP = false; + m_doc->leaveDrag = false; + m_canvas->m_viewMode.operItemMoving = false; + m_canvas->m_viewMode.operItemResizing = false; + m_view->MidButt = false; + updateList(); +} + +void CanvasMode_ImportData::setImage(PageItem *currItem) +{ + QString fileName = impsetup.filename.takeFirst(); + currItem->EmProfile = ""; + currItem->pixm.imgInfo.isRequest = false; + currItem->UseEmbedded = true; + currItem->IProfile = m_doc->cmsSettings().DefaultImageRGBProfile; + currItem->IRender = m_doc->cmsSettings().DefaultIntentImages; + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + m_doc->loadPict(fileName, currItem, false, true); + // if preference is image simze value + if(!(1 & m_doc->prefsData().itemToolPrefs.imageDefaultSize)) + { + currItem->setWidthHeight(currItem->pixm.width(),currItem->pixm.height()); + currItem->updateClip(); + } + m_ScMW->propertiesPalette->imagePal->displayScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset()); + m_ScMW->repaint(); + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + m_view->DrawNew(); + currItem->emitAllToGUI(); +} + +void CanvasMode_ImportData::updateList() +{ + if(trans) + { + trans->commit(); + delete trans; + trans = NULL; + } + if(impsetup.filename.isEmpty()) + { + pw->hide(); + m_view->requestMode(submodePaintingDone); + } + else + pw->GenPreview(impsetup.filename.first()); +} + + +void CanvasMode_ImportData::setText(PageItem_TextFrame *currItem) +{ + QString fileName = impsetup.filename.takeFirst(); + gtGetText* gt = new gtGetText(m_doc); + if (currItem->itemText.length() != 0) + { + int t = QMessageBox::warning(m_doc->scMW(), CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + if (t == QMessageBox::No) + return; + } + gt->launchImporter(-1, fileName, impsetup.textOnly, impsetup.encoding, false,currItem); + if (m_doc->docHyphenator->AutoCheck) + m_doc->docHyphenator->slotHyphenate(currItem); + for (int a = 0; a < m_doc->Items->count(); ++a) + { + if (m_doc->Items->at(a)->isBookmark) + m_doc->scMW()->bookmarkPalette->BView->ChangeText(m_doc->Items->at(a)); + } + m_view->DrawNew(); + m_doc->changed(); + m_doc->scMW()->styleMgr()->setDoc(m_doc); + delete gt; +} + +void CanvasMode_ImportData::insertImage(int i,QString fileName) +{ + impsetup.filename.insert(i, fileName); + if(i==0) + { + pw->GenPreview(fileName); + } +} + +void CanvasMode_ImportData::deleteImage(QString fileName) +{ + impsetup.filename.removeAt(impsetup.filename.indexOf(fileName)); +} diff --git a/Scribus/scribus/canvasmode_importdata.h b/Scribus/scribus/canvasmode_importdata.h new file mode 100644 index 0000000..3c790fb --- /dev/null +++ b/Scribus/scribus/canvasmode_importdata.h @@ -0,0 +1,69 @@ +/* + For general Scribus (>=1.3.2) copyright and licensing information please refer + to the COPYING file provided with the program. Following this notice may exist + a copyright and/or license notice that predates the release of Scribus 1.3.2 + for which a new license (GPL+exception) is in place. + */ +/*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + + +#ifndef CANVASMODE_IMPORTDATA_H +#define CANVASMODE_IMPORTDATA_H + +#include <QEvent> +#include <QMouseEvent> +#include <QPainter> +#include <QPixmap> +#include <QStringList> + +#include "canvasmode.h" +#include "ui/customfdialog.h" +#include "gtgettext.h" +#include "undomanager.h" + +class PageItem; +class ScribusView; +class ScribusMainWindow; + +class CanvasMode_ImportData : public CanvasMode +{ +public: + explicit CanvasMode_ImportData(ScribusView* view); + virtual ~CanvasMode_ImportData() {} + + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); + + virtual void activate(bool); + virtual void deactivate(bool); + virtual void keyPressEvent(QKeyEvent *e); + virtual bool handleKeyEvents() { return true; } + virtual void mouseDoubleClickEvent(QMouseEvent *m); + virtual void mouseReleaseEvent(QMouseEvent *m); + virtual void mouseMoveEvent(QMouseEvent *m); + virtual void mousePressEvent(QMouseEvent *m); + virtual void drawControls(QPainter* p); + + void setInformation(ImportSetup is); + void insertImage(int i,QString fileName); + void deleteImage(QString fileName); + void setImage(PageItem* item); + void setText(PageItem_TextFrame* item); + void updateList(); + +private: + UndoTransaction *trans; + FDialogPreview *pw; + bool m_keyRepeat; + ImportSetup impsetup; + ScribusMainWindow *m_ScMW; +}; + +#endif // CANVASMODE_IMPORTDATA_H diff --git a/Scribus/scribus/canvasmode_objimport.cpp b/Scribus/scribus/canvasmode_objimport.cpp index 210c8b4..9d6eba2 100644 --- a/Scribus/scribus/canvasmode_objimport.cpp +++ b/Scribus/scribus/canvasmode_objimport.cpp @@ -195,8 +195,8 @@ void CanvasMode_ObjImport::mouseReleaseEvent(QMouseEvent *m) delete undoTransaction; undoTransaction = NULL; } - // Return to normal mode - m_view->requestMode(modeNormal); + // Return to Import data mode + m_view->requestMode(modeImportData); } // m_view->stopDragTimer(); diff --git a/Scribus/scribus/gtgettext.cpp b/Scribus/scribus/gtgettext.cpp index 7355a84..4afde4b 100644 --- a/Scribus/scribus/gtgettext.cpp +++ b/Scribus/scribus/gtgettext.cpp @@ -35,14 +35,13 @@ for which a new license (GPL+exception) is in place. //Added by qt3to4: #include <QPixmap> #include "util_icon.h" +#include "util_formats.h" // Constructor gtGetText::gtGetText(ScribusDoc* doc) { // Attach to the active document m_Doc=doc; - // Load the plugins array. - loadImporterPlugins(); } // gtGetText::gtGetText(ScribusDoc* doc) // Look at the results of the file selection dialog and figure out if you need to use an importer. @@ -61,6 +60,7 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO { // Attempt to determine the importer based on the file's extension. // Create a Qstring with what could be an extension. + QMap<QString, ImporterData*> importerMap = FormatsManager::instance()->getMap(); QString fend = filename.right(filename.length() - filename.lastIndexOf(".") - 1); QString fendL(fend.toLower()); // Look for that extension in the importer QMap. @@ -79,19 +79,14 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO dias = new gtDialogs(); // Pop up the dialog asking the user to select the type from our list (ilist) of // importable file types. If one is not selected, set callImporter to false. - callImporter = dias->runImporterDialog(ilist); + callImporter = dias->runImporterDialog(FormatsManager::instance()->getIlist(),filename); // If we're gonna call an importer, we need to copy it's struct to ida. if (callImporter) - ida = importers[dias->getImporter()]; + ida = (FormatsManager::instance()->getImporters())[dias->getImporter()]; // Destroy the diag delete dias; - } // else - if (importerMap.find(fend) != importerMap.end()) + } } - else // If we know which importer to use - { - // Copy the importer's struct to ida. - ida = importers[importer]; - } // else - if (importer == -1) // Create a target text frame for the imported text and assign it to the parameter "target" PageItem* targetFrame=target; @@ -108,116 +103,9 @@ void gtGetText::launchImporter(int importer, const QString& filename, bool textO } //void gtGetText::launchImporter(int importer, const QString& filename, bool textOnly, // const QString& encoding, bool append, PageItem* target) -// Find the available plugins based on the environment, validate they load, and -// create quick lookup mappings. -void gtGetText::loadImporterPlugins() -{ - // Get the path to the plugins - QString gtdir = ScPaths::instance().pluginDir(); - // Append the gettext path to the plugin - gtdir += "gettext"; - // Set the search parameteer for the platform specific extension for the plugins ( DLL, so, etc. ) - QString libPattern = QString("*.%1*").arg(PluginManager::platformDllExtension()); - // Search for matches. - QDir d(gtdir, libPattern, QDir::Name, (QDir::Filter) PluginManager::platformDllSearchFlags()); - - // Initialize a structure for the importers found - struct ImporterData ida; - ida.fileFormatName = ""; - - // Check and see if the directory existed and if the count of files matching is greater than 0. - if ((d.exists()) && (d.count() != 0)) - { - // loop through the entries. - for (uint dc = 0; dc < d.count(); ++dc) - { - // Verify the Plugin will load. If it does, collect the info on the plugin ( Name, extension, format, etc ) - if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) - { - // no plugin's "format name" marks "don't load plug" - if (ida.fileFormatName.isNull()) - continue; - // Store the path to the plugin. - ida.soFilePath = d[dc]; - // If the plugin path does not begin with /, prepend a /. - if (ida.soFilePath.left(1) != "/") - ida.soFilePath = "/" + ida.soFilePath; - // Add the plugin data to the end of the importer's vector. - importers.push_back(ida); - } // if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) - } // for (uint dc = 0; dc < d.count(); ++dc) - } // if ((d.exists()) && (d.count() != 0)) - // Create the Importer Extension to Plugin data qmap. - createMap(); -} // void gtGetText::loadImporterPlugins() - -// Creates the dialog for the user to import a file based on the supported file formats. -ImportSetup gtGetText::run() -{ - // Initialize a filters list. - QString filters = ""; - // Create a string for the "All supported files filter". Start with the label then loop through - // the importers vector and add all of the file extensions supported. - QString allSupported = QObject::tr("All Supported Formats") + " ("; - // Loop through the importers vector. - for (uint i = 0; i < importers.size(); ++i) - { - // If there are any file extnsions declared by the importer - if (importers[i].fileEndings.count() != 0) - { - // Add the importer name to the filters list - filters += importers[i].fileFormatName + " ("; - // Loop though the extensions supported by the importer - for (int j = 0; j < importers[i].fileEndings.count(); ++j) - { - // Add the extension to both the filter and allSupported strings - filters += "*." + importers[i].fileEndings[j] + " "; - allSupported += "*." + importers[i].fileEndings[j] + " "; - } // for (int j = 0; j < importers[i].fileEndings.count(); ++j) - // Trim the Qstring - filters = filters.trimmed(); - // Append "entry of entry" information to the end of the filter. - filters += ");;"; - } // if (importers[i].fileEndings.count() != 0) - } // for (uint i = 0; i < importers.size(); ++i) - // Trim the allSupported QString and append "end of entry" data to the end of it. - allSupported = allSupported.trimmed(); - allSupported += ");;"; - // Prepend allSupported to the filters Qstring. - filters = allSupported + filters; - // Add an "all files" entry to the end of the filters QString - filters += QObject::tr("All Files (*)"); - // Populate ilist with the file importer names. - for (uint i = 0; i < importers.size(); ++i) - ilist.append(importers[i].fileFormatName); - // Create a new dialog. - dias = new gtDialogs(); - // Create a new ImportSetup struct - ImportSetup impsetup; - // INitialize runDialog to false - impsetup.runDialog=false; - // If we get a true back from the File selection Dialog ( which we send our filters and extensions lists ) - if (dias->runFileDialog(filters, ilist)) - { - // Set the runDialog to true - impsetup.runDialog=true; - // Copy the other values for the struct from the dialog results - impsetup.encoding=dias->getEncoding(); - impsetup.filename=dias->getFileName(); - impsetup.importer=dias->getImporter(); - impsetup.textOnly=dias->importTextOnly(); -// launchImporter(dias->getImporter(), dias->getFileName(), -// dias->importTextOnly(), dias->getEncoding(), append); - } // if (dias->runFileDialog(filters, ilist)) - // Destroy the dialog. - delete dias; - // Return the ImportSetup struct. - return impsetup; -} // ImportSetup gtGetText::run() - // Loads, validates, and executes the Importer code. void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, - const QString& encoding, bool textOnly, bool append, PageItem* importItem) + const QString& encoding, bool textOnly, bool append, PageItem* importItem) { // Pointer for the loaded plugin. void* gtplugin; @@ -246,7 +134,7 @@ void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, importItem->itemText.clear(); // Execute the importer's "GetText2" method. (*fp_GetText2)(filePath, encoding, textOnly, importItem); - } // if (!fp_GetText2) + } // if (!fp_GetText2) else { // Attempt to map the old GetText method to to the pointer via the PluginManager. Store the result in fp_GetText. @@ -273,73 +161,6 @@ void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, } // void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath, // const QString& encoding, bool textOnly, bool append, PageItem* importItem) -// Loads the "DLL", validates the importer is good, populates the passed parameters with -// the plugin information. -bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) -{ - // Pointer to the plugin, once loaded - void* gtplugin; - // typedef of Qstring to map the importer name (FileFormatName) method results to. - typedef QString (*sdem0)(); - // typedef of QStringList to map the file extensions supported method results to. - typedef QStringList (*sdem1)(); - // The actual importer name object - sdem0 fp_FileFormatName; - // The actual extensions supported object - sdem1 fp_FileExtensions; - // Initialise the plugin file path ( with filename ) - QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(name); - // Attempt to load the plugin. - gtplugin = PluginManager::loadDLL(pluginFilePath); - // if gtplugin is NULL we were unable to load the plugin. Return an error and exit the method. - if (!gtplugin) - { - qWarning("Failed to load plugin %s", pluginFilePath.toLatin1().constData()); - return false; - } - // Attempt to resolve the plugin symbol to the importer name (FileFormatName) - fp_FileFormatName = (sdem0) PluginManager::resolveSym( gtplugin, "FileFormatName"); - // if fp_FileFormatName is NULL, we could not find the FileFormatName symbol. The plugin is incomplete. - // Report an error, unload the plugin, and exit the method. - if (!fp_FileFormatName) - { - qWarning("Failed to get FileFormatName() from %s", pluginFilePath.toLatin1().constData()); - PluginManager::unloadDLL(gtplugin); - return false; - } - // Attempt to resolve the plugin symbol to the list of supported file extensions. - fp_FileExtensions = (sdem1) PluginManager::resolveSym( gtplugin, "FileExtensions"); - // if fp_FileExtensions is NULL, we could not find the FileExtensions symbol. The plugin is incomplete. - // Report an error, unload the plugin, and exit the method. - if (!fp_FileExtensions) - { - qWarning("Failed to get FileExtensions() from %s", pluginFilePath.toLatin1().constData()); - PluginManager::unloadDLL(gtplugin); - return false; - } - // Set the format name based on the resolved method. - *ffName = (*fp_FileFormatName)(); - // Set the extensions list based on the resolved method. - *fEndings = (*fp_FileExtensions)(); - // Unload the plugin - PluginManager::unloadDLL(gtplugin); - // Successfully return! - return true; -} // bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) - -// Create the importer Qmap. -void gtGetText::createMap() -{ - // Loop through the importers Vector - for (uint i = 0; i < importers.size(); ++i) - { - // Loop through each file extension the importer uses/importers and create an individual - // Qmap entry for it. - for (int j = 0; j < importers[i].fileEndings.count(); ++j) - importerMap.insert(importers[i].fileEndings[j], &importers[i]); - } // for (uint i = 0; i < importers.size(); ++i) -} // void gtGetText::createMap() - // Destructor gtGetText::~gtGetText() { diff --git a/Scribus/scribus/gtgettext.h b/Scribus/scribus/gtgettext.h index ff30238..a247b24 100644 --- a/Scribus/scribus/gtgettext.h +++ b/Scribus/scribus/gtgettext.h @@ -39,51 +39,26 @@ for which a new license (GPL+exception) is in place. #include "scconfig.h" #include "scribusapi.h" #include "scfonts.h" +#include "util_formats.h" class PageItem; class ScribusDoc; class gtDialogs; -// A struct for holding the Importer specific information. -struct ImporterData { - QString soFilePath; // Path to the Importer - QString fileFormatName; // Name of the Importer - QStringList fileEndings; // Array of filenames supported by the importer -}; - -// A Struct for holding the results of the File selection Dialog -struct ImportSetup { - bool runDialog; // Did the dialog run correctly? - int importer; // Which importer was selected? - QString filename; // What filename is to be loaded? - bool textOnly; // Do we import as text only? - QString encoding; // File encoding -}; - /* - GetText handles the open file dialog and importer plugins loading and launching. + GetText handles importer plugins loading and launching. */ class SCRIBUS_API gtGetText { private: - std::vector<ImporterData> importers; // Vector of the loaded importers - QMap<QString, ImporterData*> importerMap; // QMap of the supported extensions to their relevant importers entry for easy access - void loadImporterPlugins(); // Find the available plugins based on the environment, validate they load, and - // create quick lookup mappings. void CallDLL(const ImporterData& idata, const QString& filePath, - const QString& encoding, bool textOnly, bool append, PageItem* importItem); + const QString& encoding, bool textOnly, bool append, PageItem* importItem); // Loads, validates, and executes the Importer code. - bool DLLName(QString name, QString *ffName, QStringList *fileEndings); - // Loads the "DLL", validates the importer is good, populates the passed parameters with - // the plugin information. - void createMap(); // Create the importer Qmap. gtDialogs* dias; // File Selection Dialog pointer. - QStringList ilist; // List of supported importers, used with dialogs ScribusDoc* m_Doc; // Which document are we working with. public: gtGetText(ScribusDoc* doc); // Constructor ~gtGetText(); // Destructor - ImportSetup run(); // Creates the dialog for the user to import a file based on the supported file formats. void launchImporter(int importer, const QString& filename, bool textOnly, const QString& encoding, bool append, PageItem* target=0); // Look at the results of the file selection dialog and figure out if you need to use an importer. // Prompt the user if the importer to use isn't obvious. diff --git a/Scribus/scribus/pageitem.cpp b/Scribus/scribus/pageitem.cpp index 291ef45..9efbc8e 100644 --- a/Scribus/scribus/pageitem.cpp +++ b/Scribus/scribus/pageitem.cpp @@ -4945,6 +4945,14 @@ void PageItem::restore(UndoState *state, bool isUndo) restoreUniteItem(ss, isUndo); else if (ss->contains("SPLITITEM")) restoreSplitItem(ss, isUndo); + else if (ss->contains("CREATE_MESH_GRAD")) + restoreCreateMeshGrad(ss, isUndo); + else if (ss->contains("MOVE_MESH_GRAD")) + restoreMoveMeshGrad(ss, isUndo); + else if (ss->contains("RESET_MESH_GRAD")) + restoreResetMeshGrad(ss, isUndo); + else if (ss->contains("REMOVE_MESH_PATCH")) + restoreRemoveMeshPatch(ss, isUndo); else if (ss->contains("MIRROR_PATH_H")) { bool editContour = m_Doc->nodeEdit.isContourLine; @@ -5514,6 +5522,7 @@ void PageItem::restoreTransform(SimpleState *ss, bool isUndo) } } + void PageItem::restoreSnapToPatchGrid(SimpleState *state, bool isUndo) { if (isUndo) @@ -5523,7 +5532,6 @@ void PageItem::restoreSnapToPatchGrid(SimpleState *state, bool isUndo) update(); } - void PageItem::restoreMaskType(SimpleState *state, bool isUndo) { if (isUndo) @@ -9035,7 +9043,7 @@ bool PageItem::loadImage(const QString& filename, const bool reload, const int g } } } - + Pfile = fi.absoluteFilePath(); if (reload && pixm.imgInfo.PDSpathData.contains(clPath)) { @@ -9376,7 +9384,7 @@ void PageItem::AdjustPictScale() { if (itemType() != PageItem::ImageFrame) return; - if (ScaleType) + if (ScaleType || !(doc()->prefsData().itemToolPrefs.imageDefaultSize &1)) return; if (OrigW == 0 || OrigH == 0) return; diff --git a/Scribus/scribus/pageitem_imageframe.cpp b/Scribus/scribus/pageitem_imageframe.cpp index 9f57ef6..8499a21 100644 --- a/Scribus/scribus/pageitem_imageframe.cpp +++ b/Scribus/scribus/pageitem_imageframe.cpp @@ -424,7 +424,6 @@ bool PageItem_ImageFrame::createInfoGroup(QFrame *infoGroup, QGridLayout *infoGr void PageItem_ImageFrame::applicableActions(QStringList & actionList) { - actionList << "fileImportImage"; actionList << "itemConvertToTextFrame"; actionList << "itemImageIsVisible"; actionList << "itemPreviewFull"; diff --git a/Scribus/scribus/pageitem_textframe.cpp b/Scribus/scribus/pageitem_textframe.cpp index 4a4c258..476f7fd 100644 --- a/Scribus/scribus/pageitem_textframe.cpp +++ b/Scribus/scribus/pageitem_textframe.cpp @@ -5219,14 +5219,13 @@ void PageItem_TextFrame::togleEditModeActions() void PageItem_TextFrame::applicableActions(QStringList & actionList) { + actionList << "fileImport"; actionList << "insertMarkVariableText"; if (!m_Doc->masterPageMode()) actionList << "insertMarkAnchor"; //notes frames are not simply text frames if (isNoteFrame()) return; - actionList << "fileImportText"; - actionList << "fileImportAppendText"; actionList << "toolsEditWithStoryEditor"; actionList << "insertSampleText"; actionList << "itemPDFIsAnnotation"; diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp index 94ddb52..46547b8 100644 --- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp +++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp @@ -4609,6 +4609,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at break; } + UndoManager::instance()->setUndoEnabled(false); currItem->FrameType = attrs.valueAsInt("FRTYPE", 0); int startArrowIndex = attrs.valueAsInt("startArrowIndex", 0); if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles().size()))) @@ -5237,6 +5238,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at //currItem->setRedrawBounding(); //currItem->OwnPage = view->OnPage(currItem); + UndoManager::instance()->setUndoEnabled(true); return currItem; } diff --git a/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api b/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api index a2f6556..cfecd46 100644 --- a/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api +++ b/Scribus/scribus/plugins/scripter/api_Scripter.dialogs.mainWindow.api @@ -804,14 +804,6 @@ */ /** -* Scripter.dialogs.mainWindow.slotGetContent2() -*/ - -/** -* Scripter.dialogs.mainWindow.slotFileAppend() -*/ - -/** * Scripter.dialogs.mainWindow.removeRecent(fn) * fn is a QString */ @@ -840,10 +832,6 @@ */ /** -* Scripter.dialogs.mainWindow.importVectorFile() -*/ - -/** * Scripter.dialogs.mainWindow.rebuildLayersList() */ diff --git a/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html b/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html index ced0f38..abf7511 100644 --- a/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html +++ b/Scribus/scribus/plugins/scripter/doc/reference_dialogs.html @@ -5194,10 +5194,6 @@ <tr><td colspan="2"><hr></td></tr> <tr> - <td><strong>ScripterNG.dialogs.mainWindow.importVectorFile()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> -<tr> <td colspan="2"> <em></em> </td> @@ -7418,11 +7414,6 @@ </td> </tr> <tr><td colspan="2"><hr></td></tr> - -<tr> - <td><strong>ScripterNG.dialogs.mainWindow.slotFileAppend()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> <tr> <td colspan="2"> <em></em> @@ -7607,11 +7598,6 @@ </td> </tr> <tr><td colspan="2"><hr></td></tr> - -<tr> - <td><strong>ScripterNG.dialogs.mainWindow.slotGetContent2()</strong></td> - <td><strong>PROCEDURE</strong></td> -</tr> <tr> <td colspan="2"> <em></em> diff --git a/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py b/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py index f2bf0a2..3d91a8e 100644 --- a/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py +++ b/Scribus/scribus/plugins/scriptplugin/scripts/InfoBox.py @@ -61,7 +61,6 @@ except ImportError: print "Unable to import the 'scribus' module. This script will only run within" print "the Python interpreter embedded in Scribus. Try Script->Execute Script." sys.exit(1) - pil_found = 1 try: diff --git a/Scribus/scribus/prefsmanager.cpp b/Scribus/scribus/prefsmanager.cpp index 1abf735..4935ed2 100644 --- a/Scribus/scribus/prefsmanager.cpp +++ b/Scribus/scribus/prefsmanager.cpp @@ -289,6 +289,10 @@ void PrefsManager::initDefaults() appPrefs.itemToolPrefs.imageAspectRatio = true; appPrefs.itemToolPrefs.imageLowResType = 1; appPrefs.itemToolPrefs.imageUseEmbeddedPath = false; + appPrefs.itemToolPrefs.imageDefaultSize = 3; + appPrefs.itemToolPrefs.imageDefaultWidth = 100; + appPrefs.itemToolPrefs.imageDefaultHeight = 100; + appPrefs.itemToolPrefs.imageDefaultBasePoint = 0; // appPrefs.PSize = 40; appPrefs.printerPrefs.ClipMargin = false; appPrefs.printerPrefs.GCRMode = false; @@ -1502,6 +1506,10 @@ bool PrefsManager::WritePref(QString ho) dcItemTools.setAttribute("ImageStrokeColorShade",appPrefs.itemToolPrefs.imageStrokeColorShade); dcItemTools.setAttribute("ImageScaleX",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleX)); dcItemTools.setAttribute("ImageScaleY",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleY)); + dcItemTools.setAttribute("ImageDefaultSize",appPrefs.itemToolPrefs.imageDefaultSize); + dcItemTools.setAttribute("ImageDefaultWidth",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageDefaultWidth)); + dcItemTools.setAttribute("ImageDefaultHeight",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageDefaultHeight)); + dcItemTools.setAttribute("ImageDefaultBasePoint",appPrefs.itemToolPrefs.imageDefaultBasePoint); dcItemTools.setAttribute("PolygonCorners", appPrefs.itemToolPrefs.polyCorners); dcItemTools.setAttribute("PolygonFactor", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyFactor)); dcItemTools.setAttribute("PolygonRotation", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyRotation)); @@ -2115,6 +2123,10 @@ bool PrefsManager::ReadPref(QString ho) appPrefs.itemToolPrefs.imageStrokeColorShade = dc.attribute("ImageStrokeColorShade", "100").toInt(); appPrefs.itemToolPrefs.imageScaleX = ScCLocale::toDoubleC(dc.attribute("ImageScaleX"), 1.0); appPrefs.itemToolPrefs.imageScaleY = ScCLocale::toDoubleC(dc.attribute("ImageScaleY"), 1.0); + appPrefs.itemToolPrefs.imageDefaultSize = dc.attribute("ImageDefaultSize").toInt(); + appPrefs.itemToolPrefs.imageDefaultBasePoint = dc.attribute("ImageDefaultBasePoint").toInt(); + appPrefs.itemToolPrefs.imageDefaultWidth = ScCLocale::toDoubleC(dc.attribute("ImageDefaultWidth"), 100.0); + appPrefs.itemToolPrefs.imageDefaultHeight = ScCLocale::toDoubleC(dc.attribute("ImageDefaultHeight"), 100.0); appPrefs.itemToolPrefs.imageScaleType = static_cast<bool>(dc.attribute("PSCALE", "0").toInt()); appPrefs.itemToolPrefs.imageAspectRatio = static_cast<bool>(dc.attribute("PASPECT", "1").toInt()); appPrefs.itemToolPrefs.imageUseEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt()); diff --git a/Scribus/scribus/prefsstructs.h b/Scribus/scribus/prefsstructs.h index 68f643e..a267f2b 100644 --- a/Scribus/scribus/prefsstructs.h +++ b/Scribus/scribus/prefsstructs.h @@ -244,6 +244,10 @@ struct ItemToolPrefs bool imageAspectRatio; //! Use stored aspect ratio for the image int imageLowResType; //! Preview type for an image frame bool imageUseEmbeddedPath; //! Use embedded path, eg from an EPS etc. + int imageDefaultSize; //! Default behaviour for oneclick event + double imageDefaultHeight; //! Default height value for oneclick event + double imageDefaultWidth; //! Defaut width value for oneclick event + double imageDefaultBasePoint; //! Defaut basepoint for oneclick event /* Calligraphic Pen Tool */ QString calligrapicPenFillColor; //! Default calligrapicPen fill color QString calligrapicPenLineColor; //! Default calligrapicPen line color diff --git a/Scribus/scribus/scpage.cpp b/Scribus/scribus/scpage.cpp index 84d2da7..27995ec 100644 --- a/Scribus/scribus/scpage.cpp +++ b/Scribus/scribus/scpage.cpp @@ -317,6 +317,8 @@ void ScPage::restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo) return; int stateCode = state->transactionCode; PageItem *ite = state->getItem(); + bool old_lock =ite->locked(); + ite->setLocked(false); bool oldMPMode=m_Doc->masterPageMode(); if ((stateCode == 0) || (stateCode == 1)) { @@ -350,6 +352,7 @@ void ScPage::restorePageItemCreation(ScItemState<PageItem*> *state, bool isUndo) } m_Doc->setMasterPageMode(oldMPMode); m_Doc->m_Selection->delaySignalsOff(); + ite->setLocked(old_lock); } void ScPage::restorePageItemDeletion(ScItemState< QList<PageItem*> > *state, bool isUndo) diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp index 42b855d..94275fb 100644 --- a/Scribus/scribus/scribus.cpp +++ b/Scribus/scribus/scribus.cpp @@ -87,7 +87,7 @@ for which a new license (GPL+exception) is in place. #include "actionmanager.h" #include "canvasmode.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "commonstrings.h" #include "desaxe/digester.h" #include "desaxe/saxXML.h" @@ -734,12 +734,7 @@ void ScribusMainWindow::initMenuBar() scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File", false); scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File", false); scrMenuMgr->addMenuSeparator("File"); - scrMenuMgr->createMenu("FileImport", tr("&Import"), "File"); - scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport", false); -// scrMenuMgr->addMenuItem(scrActions["fileImportText2"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport", false); - scrMenuMgr->addMenuItem(scrActions["fileImportVector"], "FileImport", true); + scrMenuMgr->addMenuItem(scrActions["fileImport"], "File", true); scrMenuMgr->createMenu("FileExport", tr("&Export"), "File"); scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport", false); @@ -1468,7 +1463,7 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k) case modeEditWeldPoint: case modeEyeDropper: case modeImportObject: - case modeImportImage: + case modeImportData: case modePanning: view->requestMode(modeNormal); break; @@ -2652,7 +2647,6 @@ void ScribusMainWindow::HaveNewDoc() connect(view, SIGNAL(CutItem()), this, SLOT(slotEditCut()), Qt::UniqueConnection); connect(view, SIGNAL(LoadPic()), this, SLOT(slotGetContent()), Qt::UniqueConnection); connect(view, SIGNAL(StatusPic()), this, SLOT(StatusPic()), Qt::UniqueConnection); - connect(view, SIGNAL(AppendText()), this, SLOT(slotFileAppend()), Qt::UniqueConnection); connect(view, SIGNAL(AnnotProps()), this, SLOT(ModifyAnnot()), Qt::UniqueConnection); connect(view, SIGNAL(LoadElem(QString, double ,double, bool, bool, ScribusDoc *, ScribusView*)), this, SLOT(slotElemRead(QString, double, double, bool, bool, ScribusDoc *, ScribusView*)), Qt::UniqueConnection); connect(view, SIGNAL(AddBM(PageItem *)), this, SLOT(AddBookMark(PageItem *)), Qt::UniqueConnection); @@ -2799,10 +2793,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) switch (SelectedType) { case -1: // None - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["itemDuplicate"]->setEnabled(false); scrActions["itemMulDuplicate"]->setEnabled(false); @@ -2859,10 +2849,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) propertiesPalette->setGradientEditMode(false); break; case PageItem::ImageFrame: //Image Frame - scrActions["fileImportAppendText"]->setEnabled(false); - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); scrMenuMgr->setMenuEnabled("EditContents", true); @@ -2912,10 +2898,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) break; case PageItem::TextFrame: //Text Frame - scrActions["fileImportText"]->setEnabled(true); - scrActions["fileImportText2"]->setEnabled(true); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(true); scrActions["fileExportText"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3031,10 +3013,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) } break; case PageItem::PathText: //Path Text - scrActions["fileImportText"]->setEnabled(true); - scrActions["fileImportText2"]->setEnabled(true); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(true); scrActions["fileExportText"]->setEnabled(true); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3096,10 +3074,6 @@ void ScribusMainWindow::HaveNewSel(int SelectedType) } break; default: - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["editCut"]->setEnabled(true); scrActions["editCopy"]->setEnabled(true); @@ -3630,78 +3604,6 @@ void ScribusMainWindow::doPasteRecent(QString data) } } -void ScribusMainWindow::importVectorFile() -{ - QString fileName = ""; - QStringList formats; - QString allFormats = tr("All Supported Formats")+" ("; - int fmtCode = FORMATID_FIRSTUSER; - const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); - while (fmt != 0) - { - if (fmt->load) - { - formats.append(fmt->filter); - int an = fmt->filter.indexOf("("); - int en = fmt->filter.indexOf(")"); - while (an != -1) - { - allFormats += fmt->filter.mid(an+1, en-an-1)+" "; - an = fmt->filter.indexOf("(", en); - en = fmt->filter.indexOf(")", an); - } - } - fmtCode++; - fmt = LoadSavePlugin::getFormatById(fmtCode); - } - allFormats += "*.sce *.SCE);;"; - formats.append("Scribus Objects (*.sce *.SCE)"); - qSort(formats); - allFormats += formats.join(";;"); - PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); - QString wdir = dirs->get("pastefile", "."); - CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdExistingFiles); - if (dia.exec() == QDialog::Accepted) - fileName = dia.selectedFile(); - else - return; - if (!fileName.isEmpty()) - { - PrefsManager::instance()->prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/"))); - QFileInfo fi(fileName); - QString suffix = fi.suffix().toLower(); - if ((suffix == "sce") || (suffix == "shape")) - { - QList<QUrl> urls; - QMimeData* md = new QMimeData(); - urls.append( QUrl::fromLocalFile(fileName) ); - md->setUrls(urls); - QDrag* dr = new QDrag(this); - dr->setMimeData(md); - const QPixmap& dragCursor = loadIcon("DragPix.xpm"); - dr->setPixmap(dragCursor); - dr->exec(); - } - else - { - FileLoader *fileLoader = new FileLoader(fileName); - int testResult = fileLoader->testFile(); - delete fileLoader; - if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER)) - { - const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult); - if( fmt ) - { - doc->dontResize = true; - fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive); - doc->dontResize = false; - } - } - } - requestUpdate(reqColorsUpdate | reqSymbolsUpdate | reqLineStylesUpdate | reqTextStylesUpdate); - } -} - void ScribusMainWindow::rebuildLayersList() { if (HaveDoc) @@ -3793,8 +3695,6 @@ bool ScribusMainWindow::slotPageImport() bool ret = false; MergeDoc *dia = new MergeDoc(this, false, doc->DocPages.count(), doc->currentPage()->pageNr() + 1); UndoTransaction* activeTransaction = NULL; - if(UndoManager::undoEnabled()) - activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, 0, Um::ILock)); if (dia->exec()) { @@ -4378,87 +4278,71 @@ bool ScribusMainWindow::postLoadDoc() // do with file->open for a LONG time. It's used for get text / get picture. void ScribusMainWindow::slotGetContent() { - if (doc->m_Selection->count() != 0) + int flags = fdExistingFilesI; + QString docDir = "."; + ImportSetup impsetup; + QString allFormats = ""; + QString formatD = ""; + PageItem *currItem = doc->m_Selection->itemAt(0); + if(!currItem) { - PageItem *currItem = doc->m_Selection->itemAt(0); - if (currItem->itemType() == PageItem::ImageFrame) - { - QString formatD(FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME)); - - QString docDir = "."; - QString prefsDocDir=prefsManager->documentDir(); - if (!prefsDocDir.isEmpty()) - docDir = prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir); - else - docDir = prefsManager->prefsFile->getContext("dirs")->get("images", "."); - - QStringList fileNames; - fileNames.clear(); - CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI); - if (dia->exec() == QDialog::Accepted) - fileNames = dia->fileDialog->selectedFiles(); - delete dia; - //QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles); - if (!fileNames.isEmpty()) - { - prefsManager->prefsFile->getContext("dirs")->set("images", fileNames[0].left(fileNames[0].lastIndexOf("/"))); - view->requestMode(modeImportImage); - dynamic_cast<CanvasMode_ImageImport*>(view->canvasMode())->setImageList(fileNames); - } - } - else if (currItem->asTextFrame()) - { - gtGetText* gt = new gtGetText(doc); - ImportSetup impsetup=gt->run(); - if (impsetup.runDialog) - { - if (currItem->itemText.length() != 0) - { - int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (t == QMessageBox::No) - return; - } - gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false); - } - delete gt; - if (doc->docHyphenator->AutoCheck) - doc->docHyphenator->slotHyphenate(currItem); - for (int a = 0; a < doc->Items->count(); ++a) - { - if (doc->Items->at(a)->isBookmark) - bookmarkPalette->BView->ChangeText(doc->Items->at(a)); - } - if (!impsetup.textOnly) - doc->flag_NumUpdateRequest = true; - view->DrawNew(); - slotDocCh(); - styleManager->setDoc(doc); - marksManager->setDoc(doc); - nsEditor->setDoc(doc); - } + formatD = FormatsManager::instance()->fileDialogVectorFormatList(); + PrefsContext* dirs = prefsManager->prefsFile->getContext("dirs"); + docDir = dirs->get("pastefile", "."); + allFormats += " " + formatD.mid(formatD.indexOf("(")+1,formatD.indexOf(")")-(formatD.indexOf("(")+1)); } -} - -void ScribusMainWindow::slotGetContent2() // kk2006 -{ - if (doc->m_Selection->count() == 0) - return; // nothing to do, no selection - - PageItem *currItem = doc->m_Selection->itemAt(0); + if (!currItem || currItem->itemType() == PageItem::ImageFrame) + { + flags |= fdShowPreview; + QString formatI = FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME); + allFormats += " " + formatI.mid(formatI.indexOf("(")+1,formatI.indexOf(")")-(formatI.indexOf("(")+1)); + if(formatD.length()!=0) + formatD = formatD.left(formatD.lastIndexOf(";") +1); + formatD +=formatI; + QString prefsDocDir=prefsManager->documentDir(); + if (!prefsDocDir.isEmpty()) + docDir = prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir); + else + docDir = prefsManager->prefsFile->getContext("dirs")->get("images", "."); + } + if (!currItem || currItem->asTextFrame()) + { + flags |= fdShowCodecs; + QString formatT = FormatsManager::instance()->fileDialogTextFormatList(); + allFormats += " " + formatT.mid(formatT.indexOf("(")+1,formatT.indexOf(")")-(formatT.indexOf("(")+1)); + if(formatD.length()!=0) + formatD = formatD.left(formatD.lastIndexOf(";") +1); + formatD += formatT; + } + formatD = tr("All Supported Formats") + "(" + allFormats + ");;" + formatD; + CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, flags ); + if (dia->exec() == QDialog::Accepted) + impsetup.filename = dia->fileDialog->selectedFiles(); - if (!currItem->asTextFrame()) - return; // not a text frame + if(flags & fdShowCodecs) + { + impsetup.encoding=dia->TxCodeM->currentText(); + impsetup.textOnly=dia->TextOnly->isChecked(); + } + else + { + QString localEn = QTextCodec::codecForLocale()->name(); + if (localEn == "ISO-10646-UCS-2") + localEn = "UTF-16"; + impsetup.encoding = localEn; + impsetup.textOnly = false; + } - ScGTPluginManager::instance()->run(); - if (doc->docHyphenator->AutoCheck) - doc->docHyphenator->slotHyphenate(currItem); - for (int a = 0; a < doc->Items->count(); ++a) + if (!impsetup.filename.isEmpty()) { - if (doc->Items->at(a)->isBookmark) - bookmarkPalette->BView->ChangeText(doc->Items->at(a)); + if (currItem && currItem->itemType() == PageItem::ImageFrame) + prefsManager->prefsFile->getContext("dirs")->set("images", impsetup.filename.first().left(impsetup.filename.first().lastIndexOf("/"))); + if(!currItem) + prefsManager->prefsFile->getContext("dirs")->set("pastefile", impsetup.filename.first().left(impsetup.filename.first().lastIndexOf("/"))); + view->requestMode(modeImportData); + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->setInformation(impsetup); } - view->DrawNew(); - slotDocCh(); + delete dia; } void ScribusMainWindow::slotGetClipboardImage() @@ -4571,25 +4455,6 @@ void ScribusMainWindow::toogleInlineState() } } -void ScribusMainWindow::slotFileAppend() -{ - if (doc->m_Selection->count() != 0) - { - gtGetText* gt = new gtGetText(doc); - ImportSetup impsetup=gt->run(); - if (impsetup.runDialog) - { - gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, true); - } - delete gt; - //CB Hyphenating now emits doc changed, plus we change lang as appropriate - if (doc->docHyphenator->AutoCheck) - doc->itemSelection_DoHyphenate(); - view->DrawNew(); - //slotDocCh(); - } -} - void ScribusMainWindow::slotFileRevert() { if ((doc->hasName) && (doc->isModified()) && (!doc->masterPageMode()) && (!doc->isConverted)) @@ -4829,10 +4694,7 @@ bool ScribusMainWindow::DoFileClose() scrActions["fileExportAsPDF"]->setEnabled(false); scrActions["fileExportText"]->setEnabled(false); scrActions["fileExportAsEPS"]->setEnabled(false); - scrActions["fileImportText"]->setEnabled(false); - scrActions["fileImportText2"]->setEnabled(false); - scrActions["fileImportImage"]->setEnabled(false); - scrActions["fileImportAppendText"]->setEnabled(false); + scrActions["fileImport"]->setEnabled(false); // scrMenuMgr->setMenuEnabled("Page", false); scrActions["pageInsert"]->setEnabled(false); scrActions["pageImport"]->setEnabled(false); @@ -9258,7 +9120,21 @@ void ScribusMainWindow::restore(UndoState* state, bool isUndo) restoreAddPage(ss, isUndo); else if (ss->contains("DELETE_PAGE")) restoreDeletePage(ss, isUndo); + else if (ss->contains("FILE_LOADER")) + restoreFileLoader(ss, isUndo); + } +} + +void ScribusMainWindow::restoreFileLoader(SimpleState *state, bool isUndo) +{ + if(isUndo) + { + if(doc->appMode != modeImportData) + view->requestMode(modeImportData); + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->insertImage(0,state->get("name")); } + else + dynamic_cast<CanvasMode_ImportData*>(view->canvasMode())->deleteImage(state->get("name")); } void ScribusMainWindow::restoreDeletePage(SimpleState *state, bool isUndo) diff --git a/Scribus/scribus/scribus.h b/Scribus/scribus/scribus.h index a3709a5..8bd3189 100644 --- a/Scribus/scribus/scribus.h +++ b/Scribus/scribus/scribus.h @@ -184,6 +184,7 @@ public: void restoreUngrouping(SimpleState *state, bool isUndo); void restoreAddPage(SimpleState *state, bool isUndo); void restoreDeletePage(SimpleState *state, bool isUndo); + void restoreFileLoader(SimpleState *state, bool isUndo); void setPreviewToolbar(); struct CopyContentsBuffer contentsBuffer; bool internalCopy; @@ -297,14 +298,8 @@ public slots: bool loadPage(QString fileName, int Nr, bool Mpa, const QString& renamedPageName=QString::null); 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 - */ - void slotFileAppend(); void removeRecent(QString fn, bool fromFileWatcher = false); void removeRecentFromWatcher(QString fn); @@ -313,7 +308,6 @@ public slots: void rebuildRecentPasteMenu(); void pasteRecent(QString fn); void pasteFromScrapbook(QString fn); - void importVectorFile(); void rebuildLayersList(); bool slotDocOpen(); bool loadDoc(QString); diff --git a/Scribus/scribus/scribusdoc.cpp b/Scribus/scribus/scribusdoc.cpp index 958b6d6..1de8821 100644 --- a/Scribus/scribus/scribusdoc.cpp +++ b/Scribus/scribus/scribusdoc.cpp @@ -5586,8 +5586,7 @@ int ScribusDoc::itemAddUserFrame(InsertAFrameData &iafData) if (!iafData.source.isEmpty() && prevItem == NULL && QFile::exists(iafData.source)) { gtGetText* gt = new gtGetText(this); - if (iafData.impsetup.runDialog) - gt->launchImporter(iafData.impsetup.importer, iafData.impsetup.filename, iafData.impsetup.textOnly, iafData.impsetup.encoding, true, currItem); + gt->launchImporter(-1, iafData.impsetup.filename.at(0), iafData.impsetup.textOnly, iafData.impsetup.encoding, true, currItem); delete gt; } prevItem=currItem; diff --git a/Scribus/scribus/scribusstructs.h b/Scribus/scribus/scribusstructs.h index 0f9ab37..f8b6ce9 100644 --- a/Scribus/scribus/scribusstructs.h +++ b/Scribus/scribus/scribusstructs.h @@ -297,7 +297,7 @@ enum AppMode modeDrawLine, modeRotation, modeLinkFrames, - modeImportImage, + modeImportData, modeUnlinkFrames, modeDrawRegularPolygon, modeDrawBezierLine, diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp index 441cf2c..782c73b 100644 --- a/Scribus/scribus/scribusview.cpp +++ b/Scribus/scribus/scribusview.cpp @@ -72,7 +72,7 @@ for which a new license (GPL+exception) is in place. #include "canvasgesture.h" #include "canvasmode.h" #include "canvasmode_objimport.h" -#include "canvasmode_imageimport.h" +#include "canvasmode_importdata.h" #include "actionmanager.h" #include "commonstrings.h" #include "filewatcher.h" @@ -158,6 +158,7 @@ ScribusView::ScribusView(QWidget* win, ScribusMainWindow* mw, ScribusDoc *doc) : _isGlobalMode(true), linkAfterDraw(false), ImageAfterDraw(false), + TextAfterDraw(false), m_vhRulerHW(17) { setObjectName("s"); @@ -4347,16 +4348,26 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event) } if (ImageAfterDraw) { - //user creates new frame using linking tool PageItem * frame = Doc->m_Selection->itemAt(0); - requestMode(modeImportImage); + requestMode(modeImportData); if (frame) { - dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->setImage(frame); - dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->updateList(); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->setImage(frame); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->updateList(); } ImageAfterDraw = false; } + else if (TextAfterDraw) + { + PageItem * frame = Doc->m_Selection->itemAt(0); + requestMode(modeImportData); + if (frame) + { + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->setText(frame->asTextFrame()); + dynamic_cast<CanvasMode_ImportData*>(canvasMode())->updateList(); + } + TextAfterDraw = false; + } return true; } else if (obj == widget() && event->type() == QEvent::MouseButtonPress) @@ -4376,10 +4387,12 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event) } else firstFrame = NULL; - if(Doc->appMode == modeImportImage && ImageAfterDraw) + if(Doc->appMode == modeImportData && (ImageAfterDraw || TextAfterDraw)) { - //switch to drawing new text frame - requestMode(modeDrawImage); + if(TextAfterDraw) + requestMode(modeDrawText); + else + requestMode(modeDrawImage); m_canvasMode->mousePressEvent(m); } m_canvas->m_viewMode.m_MouseButtonPressed = true; diff --git a/Scribus/scribus/scribusview.h b/Scribus/scribus/scribusview.h index 2db2a38..58a907a 100644 --- a/Scribus/scribus/scribusview.h +++ b/Scribus/scribus/scribusview.h @@ -108,12 +108,13 @@ public: friend class CanvasMode_EditArc; friend class CanvasMode_EditSpiral; friend class CanvasMode_FrameLinks; - friend class CanvasMode_ImageImport; + friend class CanvasMode_ImportData; friend class CanvasMode_Magnifier; friend class CanvasMode_NodeEdit; friend class CanvasMode_Normal; friend class CanvasMode_ObjImport; friend class CanvasMode_Rotate; + friend class CreateMode; void requestMode(int appMode); void startGesture(CanvasGesture*); @@ -327,6 +328,7 @@ private: // Private attributes bool _isGlobalMode; bool linkAfterDraw; bool ImageAfterDraw; + bool TextAfterDraw; double oldItemX; double oldItemY; diff --git a/Scribus/scribus/ui/contextmenu.cpp b/Scribus/scribus/ui/contextmenu.cpp index 365ecae..e60444a 100644 --- a/Scribus/scribus/ui/contextmenu.cpp +++ b/Scribus/scribus/ui/contextmenu.cpp @@ -197,13 +197,15 @@ void ContextMenu::createMenuItems_Selection() addSeparator(); addAction(m_ScMW->scrActions["itemUpdateMarks"]); } - if (m_actionList.contains("fileImportText")) + if (m_actionList.contains("fileImport")) { addSeparator(); - addAction(m_ScMW->scrActions["fileImportText"]); - addAction(m_ScMW->scrActions["fileImportAppendText"]); - addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]); - addAction(m_ScMW->scrActions["insertSampleText"]); + addAction(m_ScMW->scrActions["fileImport"]); + if (currItem->isTextFrame()) + { + addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]); + addAction(m_ScMW->scrActions["insertSampleText"]); + } } else //enable this for, eg, text on a path if (m_actionList.contains("toolsEditWithStoryEditor")) @@ -212,8 +214,6 @@ void ContextMenu::createMenuItems_Selection() addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]); } addSeparator(); - if (m_actionList.contains("fileImportImage")) - addAction(m_ScMW->scrActions["fileImportImage"]); if (selectedItemCount==1 && currItem->asImageFrame()) { if (QApplication::clipboard()->mimeData()->hasImage()) diff --git a/Scribus/scribus/ui/customfdialog.cpp b/Scribus/scribus/ui/customfdialog.cpp index 25c5cd5..b143ec2 100644 --- a/Scribus/scribus/ui/customfdialog.cpp +++ b/Scribus/scribus/ui/customfdialog.cpp @@ -24,6 +24,7 @@ for which a new license (GPL+exception) is in place. #include <QCheckBox> #include <QComboBox> +#include <QCoreApplication> #include <QDir> #include <QFileInfo> #include <QFrame> @@ -35,6 +36,7 @@ for which a new license (GPL+exception) is in place. #include <QPixmap> #include <QPushButton> #include <QTextCodec> +#include <Qt> #include <QVBoxLayout> #include "customfdialog.h" @@ -111,7 +113,7 @@ QIcon ImIconProvider::icon(const QFileInfo &fi) const return QIcon(); } -FDialogPreview::FDialogPreview(QWidget *pa) : QLabel(pa) +FDialogPreview::FDialogPreview(QWidget *pa, Qt::WindowFlags f) : QLabel(pa,f) { setAlignment(Qt::AlignLeft | Qt::AlignTop); setFixedSize( QSize( 200, 200 ) ); @@ -298,7 +300,7 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt vboxLayout = new QVBoxLayout(this); vboxLayout->setSpacing(5); vboxLayout->setMargin(10); - hboxLayout = new QHBoxLayout; + hboxLayout = new QHBoxLayout; hboxLayout->setSpacing(5); hboxLayout->setMargin(0); fileDialog = new ScFileWidget(this); @@ -318,7 +320,7 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt vboxLayout1->addWidget(pw); hboxLayout->addLayout(vboxLayout1); vboxLayout->addLayout(hboxLayout); - QHBoxLayout *hboxLayout1 = new QHBoxLayout; + QHBoxLayout *hboxLayout1 = new QHBoxLayout; hboxLayout1->setSpacing(5); hboxLayout1->setContentsMargins(9, 0, 0, 0); showPreview = new QCheckBox(this); @@ -440,6 +442,12 @@ CustomFDialog::CustomFDialog(QWidget *parent, QString wDir, QString caption, QSt } TxCodeM->setMinimumSize(QSize(200, 0)); Layout1C->addWidget(TxCodeM); + Layout1C->addStretch(); + TextOnly = new QCheckBox(); + TextOnly->setText( tr("Import &Text only")); + TextOnly->setToolTip( tr("Import the text without style formating")); + TextOnly->setChecked(false); + Layout1C->addWidget(TextOnly); QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); Layout1C->addItem( spacer2 ); vboxLayout->addWidget(LayoutC); @@ -507,6 +515,11 @@ QString CustomFDialog::selectedFile() return QString(); } +QStringList CustomFDialog::selectedFiles() +{ + return fileDialog->selectedFiles(); +} + void CustomFDialog::addWidgets(QWidget *widgets) { vboxLayout->addWidget(widgets); diff --git a/Scribus/scribus/ui/customfdialog.h b/Scribus/scribus/ui/customfdialog.h index 52d154f..987d58a 100644 --- a/Scribus/scribus/ui/customfdialog.h +++ b/Scribus/scribus/ui/customfdialog.h @@ -62,7 +62,7 @@ class SCRIBUS_API FDialogPreview : public QLabel { Q_OBJECT public: - FDialogPreview(QWidget *pa); + FDialogPreview(QWidget *pa, Qt::WindowFlags f = 0); ~FDialogPreview() {}; void updtPix(); void GenPreview(QString name); @@ -122,10 +122,12 @@ public: ScFileWidget *fileDialog; FDialogPreview *pw; QCheckBox *showPreview; + QCheckBox *TextOnly; QPushButton* OKButton; QPushButton* CancelB; void setSelection(QString ); QString selectedFile(); + QStringList selectedFiles(); void addWidgets(QWidget *widgets); private slots: //! \brief Go to the document home dir. diff --git a/Scribus/scribus/ui/delpages.cpp b/Scribus/scribus/ui/delpages.cpp index 83dc4ae..904e41d 100644 --- a/Scribus/scribus/ui/delpages.cpp +++ b/Scribus/scribus/ui/delpages.cpp @@ -27,7 +27,6 @@ DelPages::DelPages( QWidget* parent, int currentPage, int maxPage ) : QDialog( p fromToLayout->addWidget( fromLabel ); fromPageData = new ScrSpinBox(this); fromPageData->setDecimals(0); - fromPageData->setSuffix(""); fromPageData->setMinimum(1); fromPageData->setMaximum(maxPage); fromPageData->setSuffix(""); @@ -42,7 +41,6 @@ DelPages::DelPages( QWidget* parent, int currentPage, int maxPage ) : QDialog( p toPageData->setMaximum(maxPage); toPageData->setSuffix(""); toPageData->setValue( currentPage ); - toPageData->setSuffix(""); fromToLayout->addWidget( toPageData ); dialogLayout->addLayout( fromToLayout ); diff --git a/Scribus/scribus/ui/gtdialogs.cpp b/Scribus/scribus/ui/gtdialogs.cpp index af88379..79dd452 100644 --- a/Scribus/scribus/ui/gtdialogs.cpp +++ b/Scribus/scribus/ui/gtdialogs.cpp @@ -38,7 +38,6 @@ for which a new license (GPL+exception) is in place. #include <QPushButton> #include "commonstrings.h" #include "util_icon.h" -#include "ui/gtfiledialog.h" extern QString DocDir; @@ -114,44 +113,19 @@ gtImporterDialog::~gtImporterDialog() gtDialogs::gtDialogs() { fdia = NULL; - fileName = ""; - encoding = ""; importer = -1; prefs = PrefsManager::instance()->prefsFile->getContext("gtDialogs"); - pwd = QDir::currentPath(); } -bool gtDialogs::runFileDialog(const QString& filters, const QStringList& importers) -{ - bool accepted = false; - PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); - QString dir = dirs->get("get_text", "."); - fdia = new gtFileDialog(filters, importers, dir); - - if (fdia->exec() == QDialog::Accepted) - { - fileName = fdia->selectedFile(); - if (!fileName.isEmpty()) - accepted = true; - encoding = fdia->encodingCombo->currentText(); -// if (encoding == "UTF-16") -// encoding = "ISO-10646-UCS-2"; - importer = fdia->importerCombo->currentIndex() - 1; - dirs->set("get_text", fileName.left(fileName.lastIndexOf("/"))); - } - QDir::setCurrent(pwd); - return accepted; -} - -bool gtDialogs::runImporterDialog(const QStringList& importers) +bool gtDialogs::runImporterDialog(const QStringList& importers, QString filename) { int curSel = prefs->getInt("curSel", 0); QString extension = ""; - QString shortName = fileName.right(fileName.length() - fileName.lastIndexOf("/") - 1); + QString shortName = filename.right(filename.length() - filename.lastIndexOf("/") - 1); if (shortName.indexOf(".") == -1) extension = ".no_extension"; else - extension = fileName.right(fileName.length() - fileName.lastIndexOf(".")); + extension = filename.right(filename.length() - filename.lastIndexOf(".")); int extensionSel = prefs->getInt(extension, -1); QString imp = prefs->get("remember"+extension, QString("false")); QString res = ""; @@ -190,12 +164,12 @@ bool gtDialogs::runImporterDialog(const QStringList& importers) { importer = i; prefs->set("curSel", static_cast<int>(i)); - if (fileName.indexOf(".") != -1) + if (filename.indexOf(".") != -1) { if (shortName.indexOf(".") == -1) fileExtension = ".no_extension"; else - fileExtension = fileName.right(fileName.length() - fileName.lastIndexOf(".")); + fileExtension = filename.right(filename.length() - filename.lastIndexOf(".")); if (!fileExtension.isEmpty()) { prefs->set(fileExtension, static_cast<int>(i)); @@ -210,29 +184,11 @@ bool gtDialogs::runImporterDialog(const QStringList& importers) return ok; } -const QString& gtDialogs::getFileName() -{ - return fileName; -} - -const QString& gtDialogs::getEncoding() -{ - return encoding; -} - int gtDialogs::getImporter() { return importer; } -bool gtDialogs::importTextOnly() -{ - bool ret = false; - if (fdia) - ret = fdia->textOnlyCheckBox->isChecked(); - return ret; -} - gtDialogs::~gtDialogs() { delete fdia; diff --git a/Scribus/scribus/ui/gtdialogs.h b/Scribus/scribus/ui/gtdialogs.h index 0b1616d..c38a5a1 100644 --- a/Scribus/scribus/ui/gtdialogs.h +++ b/Scribus/scribus/ui/gtdialogs.h @@ -28,6 +28,7 @@ for which a new license (GPL+exception) is in place. #define GTDIALOGS_H #include <QDialog> +#include <QCheckBox> #include "scribusapi.h" @@ -55,20 +56,13 @@ class SCRIBUS_API gtDialogs { private: gtFileDialog* fdia; - QString fileName; - QString encoding; int importer; PrefsContext* prefs; - QString pwd; public: gtDialogs(); ~gtDialogs(); - const QString& getFileName(); - const QString& getEncoding(); int getImporter(); - bool importTextOnly(); - bool runFileDialog(const QString& filters, const QStringList& importers); - bool runImporterDialog(const QStringList& importers); + bool runImporterDialog(const QStringList& importers, QString filename); }; #endif // GTDIALOGS_H diff --git a/Scribus/scribus/ui/gtfiledialog.h b/Scribus/scribus/ui/gtfiledialog.h deleted file mode 100644 index 8b1e5a8..0000000 --- a/Scribus/scribus/ui/gtfiledialog.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -For general Scribus (>=1.3.2) copyright and licensing information please refer -to the COPYING file provided with the program. Following this notice may exist -a copyright and/or license notice that predates the release of Scribus 1.3.2 -for which a new license (GPL+exception) is in place. -*/ -#ifndef GTFILEDIALOG_H -#define GTFILEDIALOG_H - -#include <QDialog> -#include "ui_gtfiledialog.h" -#include "scribusapi.h" - - -/*! \brief Enhanced file dialog for get-text plugins -This class is separated from gtdialogs.h file due the huge -(almost) circle dependencies with fonts subdir/library -\author Petr Vanek <petr@scribus.info> -\author Riku Leino -*/ -class SCRIBUS_API gtFileDialog : public QDialog, public Ui::gtFileDialog -{ - Q_OBJECT -public: - gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir); - ~gtFileDialog(); - - QString selectedFile(); - -public slots: - virtual void accept(); - -protected: - void loadSettings(void); - void saveSettings(void); -}; - -#endif diff --git a/Scribus/scribus/ui/gtfiledialog.ui b/Scribus/scribus/ui/gtfiledialog.ui deleted file mode 100644 index b0a6726..0000000 --- a/Scribus/scribus/ui/gtfiledialog.ui +++ /dev/null @@ -1,112 +0,0 @@ -<ui version="4.0" > - <class>gtFileDialog</class> - <widget class="QDialog" name="gtFileDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>373</width> - <height>317</height> - </rect> - </property> - <property name="windowTitle" > - <string>Open</string> - </property> - <layout class="QGridLayout" > - <item row="0" column="0" colspan="3" > - <widget class="ScFileWidget" native="1" name="fileWidget" /> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>&Importer:</string> - </property> - <property name="buddy" > - <cstring>importerCombo</cstring> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="ScComboBox" name="importerCombo" /> - </item> - <item row="1" column="2" > - <widget class="QCheckBox" name="textOnlyCheckBox" > - <property name="text" > - <string>Import &Text Only</string> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>&Encoding:</string> - </property> - <property name="buddy" > - <cstring>encodingCombo</cstring> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="ScComboBox" name="encodingCombo" /> - </item> - <item row="3" column="0" colspan="3" > - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>ScFileWidget</class> - <extends>QWidget</extends> - <header>ui/scfilewidget.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>ScComboBox</class> - <extends>QComboBox</extends> - <header>ui/sccombobox.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>gtFileDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel" > - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>gtFileDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel" > - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/Scribus/scribus/ui/insertaframe.cpp b/Scribus/scribus/ui/insertaframe.cpp index c336a26..d8912aa 100644 --- a/Scribus/scribus/ui/insertaframe.cpp +++ b/Scribus/scribus/ui/insertaframe.cpp @@ -232,19 +232,19 @@ void InsertAFrame::locateImageFile() QString fileName(""); CustomFDialog dia(this, docDir, tr("Open"), formatD, fdShowPreview | fdExistingFiles); if (dia.exec() == QDialog::Accepted) - fileName = dia.selectedFile(); + fileName = dia.selectedFile().at(0); sourceImageLineEdit->setText(QDir::toNativeSeparators(fileName)); } void InsertAFrame::locateDocFile() { - m_ImportSetup.runDialog=false; - gtGetText* gt = new gtGetText(m_Doc); - m_ImportSetup=gt->run(); - if (m_ImportSetup.runDialog) - sourceDocLineEdit->setText(QDir::toNativeSeparators(m_ImportSetup.filename)); - delete gt; + QString formatD(FormatsManager::instance()->fileDialogTextFormatList()); + + CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), ".", tr("Open"), formatD, fdShowCodecs | fdExistingFiles); + if (dia->exec() == QDialog::Accepted) + sourceDocLineEdit->setText(QDir::toNativeSeparators(dia->selectedFile())); + delete dia; } void InsertAFrame::slotCreatePageNumberRange( ) diff --git a/Scribus/scribus/ui/oneclick.cpp b/Scribus/scribus/ui/oneclick.cpp index ddeb72c..5df24b2 100644 --- a/Scribus/scribus/ui/oneclick.cpp +++ b/Scribus/scribus/ui/oneclick.cpp @@ -23,7 +23,7 @@ for which a new license (GPL+exception) is in place. #include "units.h" #include "commonstrings.h" -OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, bool remember, int origin, int mode ) : QDialog( parent ) +OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, int origin, int mode ) : QDialog( parent ) { double m_unitRatio = unitGetRatioFromIndex(unitIndex); QString m_suffix = unitGetSuffixFromIndex(unitIndex); @@ -98,11 +98,6 @@ OneClick::OneClick( QWidget* parent, QString titel, int unitIndex, double defW, } editLayout->addWidget( SizeGroup, 0, 1 ); - checkRemember = new QCheckBox(this); - checkRemember->setText( tr("Remember Values")); - checkRemember->setChecked(remember); - editLayout->addWidget( checkRemember, 1, 0, 1, 2 ); - queryLayout->addLayout( editLayout ); okCancelLayout = new QHBoxLayout; okCancelLayout->setSpacing( 5 ); diff --git a/Scribus/scribus/ui/oneclick.h b/Scribus/scribus/ui/oneclick.h index 325642a..e143f7f 100644 --- a/Scribus/scribus/ui/oneclick.h +++ b/Scribus/scribus/ui/oneclick.h @@ -27,12 +27,11 @@ class SCRIBUS_API OneClick : public QDialog Q_OBJECT public: - OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, bool remember, int origin, int mode ); + OneClick( QWidget* parent, QString titel, int unitIndex, double defW, double defH, int origin, int mode ); ~OneClick() {}; ScrSpinBox *spinWidth; ScrSpinBox *spinHeight; LinkButton* linkSize; - QCheckBox* checkRemember; QGroupBox* RotationGroupContainer; BasePointWidget* RotationGroup; diff --git a/Scribus/scribus/ui/prefs_itemtools.cpp b/Scribus/scribus/ui/prefs_itemtools.cpp index eda3540..654aa25 100644 --- a/Scribus/scribus/ui/prefs_itemtools.cpp +++ b/Scribus/scribus/ui/prefs_itemtools.cpp @@ -64,6 +64,12 @@ void Prefs_ItemTools::unitChange(int newIndex) { textColumnGapSpinBox->setNewUnit(newIndex); textTabWidthSpinBox->setNewUnit(newIndex); + topTextDistanceSpinBox->setNewUnit(newIndex); + bottomTextDistanceSpinBox->setNewUnit(newIndex); + leftTextDistanceSpinBox->setNewUnit(newIndex); + rightTextDistanceSpinBox->setNewUnit(newIndex); + defaultWidth->setNewUnit(newIndex); + defaultHeight->setNewUnit(newIndex); } void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData) @@ -154,6 +160,12 @@ void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData) onscreenResolutionLowRadioButton->setChecked(true); break; } + basepoint->setCheckedId(prefsData->itemToolPrefs.imageDefaultBasePoint); + imageSize->setChecked(!(prefsData->itemToolPrefs.imageDefaultSize & 1)); + defaultSize->setChecked(prefsData->itemToolPrefs.imageDefaultSize & 1); + askOneClick->setChecked(prefsData->itemToolPrefs.imageDefaultSize & 2); + defaultWidth->setValue(prefsData->itemToolPrefs.imageDefaultWidth * unitRatio); + defaultHeight->setValue(prefsData->itemToolPrefs.imageDefaultHeight * unitRatio); //Shape Tool shapeFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeLineColor); @@ -274,7 +286,10 @@ void Prefs_ItemTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const if (onscreenResolutionLowRadioButton->isChecked()) haRes = 2; prefsData->itemToolPrefs.imageLowResType = haRes; - + prefsData->itemToolPrefs.imageDefaultBasePoint = basepoint->checkedId(); + prefsData->itemToolPrefs.imageDefaultSize = defaultSize->isChecked() + askOneClick->isChecked()*2 ; + prefsData->itemToolPrefs.imageDefaultHeight = defaultHeight->value() / unitRatio; + prefsData->itemToolPrefs.imageDefaultWidth = defaultWidth->value() / unitRatio; //Shape tool prefsData->itemToolPrefs.shapeLineColor = shapeFrameLineColorComboBox->currentText(); diff --git a/Scribus/scribus/ui/prefs_itemtoolsbase.ui b/Scribus/scribus/ui/prefs_itemtoolsbase.ui index f6cef40..a2fe031 100644 --- a/Scribus/scribus/ui/prefs_itemtoolsbase.ui +++ b/Scribus/scribus/ui/prefs_itemtoolsbase.ui @@ -78,9 +78,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>0</y> - <width>643</width> - <height>646</height> + <y>-44</y> + <width>622</width> + <height>677</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> @@ -651,8 +651,8 @@ <rect> <x>0</x> <y>0</y> - <width>643</width> - <height>646</height> + <width>637</width> + <height>633</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_7"> @@ -806,7 +806,7 @@ <string>Free Scaling</string> </property> <attribute name="buttonGroup"> - <string>scalingButtonGroup</string> + <string notr="true">scalingButtonGroup</string> </attribute> </widget> </item> @@ -884,7 +884,7 @@ <string>Scale Image to Frame Size</string> </property> <attribute name="buttonGroup"> - <string>scalingButtonGroup</string> + <string notr="true">scalingButtonGroup</string> </attribute> </widget> </item> @@ -937,7 +937,7 @@ <string>Full Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> @@ -947,7 +947,7 @@ <string>Normal Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> @@ -957,11 +957,184 @@ <string>Low Resolution</string> </property> <attribute name="buttonGroup"> - <string>previewButtonGroup</string> + <string notr="true">previewButtonGroup</string> </attribute> </widget> </item> <item> + <spacer name="verticalSpacer_13"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_53"> + <property name="text"> + <string>Default frame size</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="imageSize"> + <property name="text"> + <string>Use image size</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_13"> + <property name="sizeConstraint"> + <enum>QLayout::SetMaximumSize</enum> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QRadioButton" name="defaultSize"> + <property name="text"> + <string>Use default size</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_19"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QFormLayout" name="formLayout_15"> + <item row="0" column="0"> + <widget class="QLabel" name="width"> + <property name="text"> + <string>width</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="ScrSpinBox" name="defaultWidth"> + <property name="minimum"> + <double>1.000000000000000</double> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="height"> + <property name="text"> + <string>height</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="ScrSpinBox" name="defaultHeight"> + <property name="minimum"> + <double>1.000000000000000</double> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_20"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>74</height> + </size> + </property> + <property name="title"> + <string>Baseline</string> + </property> + <widget class="BasePointWidget" name="basepoint" native="true"> + <property name="geometry"> + <rect> + <x>12</x> + <y>15</y> + <width>58</width> + <height>55</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>55</width> + <height>55</height> + </size> + </property> + </widget> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_21"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Maximum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="askOneClick"> + <property name="text"> + <string>Ask before apply</string> + </property> + </widget> + </item> + </layout> + </item> + <item> <spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -969,7 +1142,7 @@ <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>145</height> + <height>40</height> </size> </property> </spacer> @@ -1580,6 +1753,12 @@ <header>ui/spiralwidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>BasePointWidget</class> + <extends>QWidget</extends> + <header location="global">ui/basepointwidget.h</header> + <container>1</container> + </customwidget> </customwidgets> <tabstops> <tabstop>tabWidget</tabstop> diff --git a/Scribus/scribus/ui/prefs_operatortoolsbase.ui b/Scribus/scribus/ui/prefs_operatortoolsbase.ui index 9a5c63b..c932504 100644 --- a/Scribus/scribus/ui/prefs_operatortoolsbase.ui +++ b/Scribus/scribus/ui/prefs_operatortoolsbase.ui @@ -89,10 +89,10 @@ <string> %</string> </property> <property name="minimum"> - <number>1</number> + <double>1.000000000000000</double> </property> <property name="maximum"> - <number>3200</number> + <double>3200.000000000000000</double> </property> </widget> </item> @@ -115,7 +115,7 @@ <string> %</string> </property> <property name="minimum"> - <number>100</number> + <number>0</number> </property> <property name="maximum"> <number>500</number> @@ -266,8 +266,8 @@ <customwidgets> <customwidget> <class>ScrSpinBox</class> - <extends>QSpinBox</extends> - <header location="global">ui/scrspinbox.h</header> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> </customwidget> </customwidgets> <resources/> diff --git a/Scribus/scribus/undomanager.cpp b/Scribus/scribus/undomanager.cpp index 460ad84..101c05d 100644 --- a/Scribus/scribus/undomanager.cpp +++ b/Scribus/scribus/undomanager.cpp @@ -1051,6 +1051,7 @@ void UndoManager::languageChange() UndoManager::PathOperation = tr("Path Operation"); UndoManager::ChangePageAttrs = tr("Change Page Attributes"); UndoManager::Transform = tr("Transform"); + UndoManager::ImportFile = tr("Import file"); UndoManager::WeldItems = tr("Weld Items"); } @@ -1323,6 +1324,7 @@ QString UndoManager::ClearImage = ""; QString UndoManager::PathOperation = ""; QString UndoManager::ChangePageAttrs = ""; QString UndoManager::Transform = ""; +QString UndoManager::ImportFile = ""; QString UndoManager::WeldItems = ""; /*** Icons for UndoObjects *******************************************/ diff --git a/Scribus/scribus/undomanager.h b/Scribus/scribus/undomanager.h index 5d7a17f..9ca06c5 100644 --- a/Scribus/scribus/undomanager.h +++ b/Scribus/scribus/undomanager.h @@ -631,6 +631,7 @@ public: static QString MultipleDuplicate; static QString Duplicate; static QString Transform; + static QString ImportFile; static QString ApplyTextStyle; static QString RemoveTextStyle; static QString Columns; diff --git a/Scribus/scribus/util_formats.cpp b/Scribus/scribus/util_formats.cpp index d796753..e83ac6b 100644 --- a/Scribus/scribus/util_formats.cpp +++ b/Scribus/scribus/util_formats.cpp @@ -5,11 +5,16 @@ a copyright and/or license notice that predates the release of Scribus 1.3.2 for which a new license (GPL+exception) is in place. */ +#include <QDir> #include <QImageReader> #include <QMapIterator> #include <QObject> #include "commonstrings.h" +#include "plugins/formatidlist.h" +#include "loadsaveplugin.h" +#include "pluginmanager.h" +#include "scpaths.h" #include "util_formats.h" FormatsManager* FormatsManager::_instance = 0; @@ -93,6 +98,7 @@ FormatsManager::FormatsManager() m_qtSupportedImageFormats=QImageReader::supportedImageFormats(); m_supportedImageFormats=m_qtSupportedImageFormats; updateSupportedImageFormats(m_supportedImageFormats); + loadImporterPlugins(); } FormatsManager::~FormatsManager() @@ -214,7 +220,7 @@ QString FormatsManager::extensionListForFormat(int type, int listType) void FormatsManager::fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly) { - QString fmtList = QObject::tr("All Supported Formats")+" ("; + QString fmtList = QObject::tr("All Supported Image Formats")+" ("; QString fmtText; QMapIterator<int, QStringList> it(m_fmts); bool first=true; @@ -352,3 +358,214 @@ QString getImageType(QString filename) } return ret; } + +// Find the available plugins based on the environment, validate they load, and +// create quick lookup mappings. +void FormatsManager::loadImporterPlugins() +{ + // Get the path to the plugins + QString gtdir = ScPaths::instance().pluginDir(); + // Append the gettext path to the plugin + gtdir += "gettext"; + // Set the search parameteer for the platform specific extension for the plugins ( DLL, so, etc. ) + QString libPattern = QString("*.%1*").arg(PluginManager::platformDllExtension()); + // Search for matches. + QDir d(gtdir, libPattern, QDir::Name, (QDir::Filter) PluginManager::platformDllSearchFlags()); + + // Initialize a structure for the importers found + struct ImporterData ida; + ida.fileFormatName = ""; + + // Check and see if the directory existed and if the count of files matching is greater than 0. + if ((d.exists()) && (d.count() != 0)) + { + // loop through the entries. + for (uint dc = 0; dc < d.count(); ++dc) + { + // Verify the Plugin will load. If it does, collect the info on the plugin ( Name, extension, format, etc ) + if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) + { + // no plugin's "format name" marks "don't load plug" + if (ida.fileFormatName.isNull()) + continue; + // Store the path to the plugin. + ida.soFilePath = d[dc]; + // If the plugin path does not begin with /, prepend a /. + if (ida.soFilePath.left(1) != "/") + ida.soFilePath = "/" + ida.soFilePath; + // Add the plugin data to the end of the importer's vector. + importers.push_back(ida); + } // if (DLLName(d[dc], &ida.fileFormatName, &ida.fileEndings)) + } // for (uint dc = 0; dc < d.count(); ++dc) + } // if ((d.exists()) && (d.count() != 0)) + // Create the Importer Extension to Plugin data qmap. + createMap(); + // Populate ilist with the file importer names. + for (uint i = 0; i < importers.size(); ++i) + ilist.append(importers[i].fileFormatName); +} // void gtGetText::loadImporterPlugins() + +// Create the importer Qmap. +void FormatsManager::createMap() +{ + // Loop through the importers Vector + for (uint i = 0; i < importers.size(); ++i) + { + // Loop through each file extension the importer uses/importers and create an individual + // Qmap entry for it. + for (int j = 0; j < importers[i].fileEndings.count(); ++j) + importerMap.insert(importers[i].fileEndings[j], &importers[i]); + } // for (uint i = 0; i < importers.size(); ++i) +} // void gtGetText::createMap() + +QString FormatsManager::fileDialogTextFormatList() +{ + // Initialize a filters list. + QString filters = ""; + // Create a string for the "All supported files filter". Start with the label then loop through + // the importers vector and add all of the file extensions supported. + QString allSupported = QObject::tr("All Supported Text Formats") + " ("; + // Loop through the importers vector. + for (uint i = 0; i < importers.size(); ++i) + { + // If there are any file extnsions declared by the importer + if (importers[i].fileEndings.count() != 0) + { + // Add the importer name to the filters list + filters += importers[i].fileFormatName + " ("; + // Loop though the extensions supported by the importer + for (int j = 0; j < importers[i].fileEndings.count(); ++j) + { + // Add the extension to both the filter and allSupported strings + filters += "*." + importers[i].fileEndings[j] + " "; + allSupported += "*." + importers[i].fileEndings[j] + " "; + } // for (int j = 0; j < importers[i].fileEndings.count(); ++j) + // Trim the Qstring + filters = filters.trimmed(); + // Append "entry of entry" information to the end of the filter. + filters += ");;"; + } // if (importers[i].fileEndings.count() != 0) + } // for (uint i = 0; i < importers.size(); ++i) + // Trim the allSupported QString and append "end of entry" data to the end of it. + allSupported = allSupported.trimmed(); + allSupported += ");;"; + // Prepend allSupported to the filters Qstring. + filters = allSupported + filters; + // Add an "all files" entry to the end of the filters QString + filters += QObject::tr("All Files (*)"); + return filters; +} + +// Loads the "DLL", validates the importer is good, populates the passed parameters with +// the plugin information. +bool FormatsManager::DLLName(QString name, QString *ffName, QStringList *fEndings) +{ + // Pointer to the plugin, once loaded + void* gtplugin; + // typedef of Qstring to map the importer name (FileFormatName) method results to. + typedef QString (*sdem0)(); + // typedef of QStringList to map the file extensions supported method results to. + typedef QStringList (*sdem1)(); + // The actual importer name object + sdem0 fp_FileFormatName; + // The actual extensions supported object + sdem1 fp_FileExtensions; + // Initialise the plugin file path ( with filename ) + QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(name); + // Attempt to load the plugin. + gtplugin = PluginManager::loadDLL(pluginFilePath); + // if gtplugin is NULL we were unable to load the plugin. Return an error and exit the method. + if (!gtplugin) + { + qWarning("Failed to load plugin %s", pluginFilePath.toAscii().constData()); + return false; + } + // Attempt to resolve the plugin symbol to the importer name (FileFormatName) + fp_FileFormatName = (sdem0) PluginManager::resolveSym( gtplugin, "FileFormatName"); + // if fp_FileFormatName is NULL, we could not find the FileFormatName symbol. The plugin is incomplete. + // Report an error, unload the plugin, and exit the method. + if (!fp_FileFormatName) + { + qWarning("Failed to get FileFormatName() from %s", pluginFilePath.toAscii().constData()); + PluginManager::unloadDLL(gtplugin); + return false; + } + // Attempt to resolve the plugin symbol to the list of supported file extensions. + fp_FileExtensions = (sdem1) PluginManager::resolveSym( gtplugin, "FileExtensions"); + // if fp_FileExtensions is NULL, we could not find the FileExtensions symbol. The plugin is incomplete. + // Report an error, unload the plugin, and exit the method. + if (!fp_FileExtensions) + { + qWarning("Failed to get FileExtensions() from %s", pluginFilePath.toAscii().constData()); + PluginManager::unloadDLL(gtplugin); + return false; + } + // Set the format name based on the resolved method. + *ffName = (*fp_FileFormatName)(); + // Set the extensions list based on the resolved method. + *fEndings = (*fp_FileExtensions)(); + // Unload the plugin + PluginManager::unloadDLL(gtplugin); + // Successfully return! + return true; +} // bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings) + + +QString FormatsManager::fileDialogVectorFormatList() +{ + QStringList formats; + QString allFormats = QObject::tr("All Supported Vector Formats")+" ("; + int fmtCode = FORMATID_FIRSTUSER; + const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); + while (fmt != 0) + { + if (fmt->load) + { + formats.append(fmt->filter); + int an = fmt->filter.indexOf("("); + int en = fmt->filter.indexOf(")"); + while (an != -1) + { + allFormats += fmt->filter.mid(an+1, en-an-1)+" "; + an = fmt->filter.indexOf("(", en); + en = fmt->filter.indexOf(")", an); + } + } + fmtCode++; + fmt = LoadSavePlugin::getFormatById(fmtCode); + } + allFormats += "*.sce *.SCE);;"; + formats.append("Scribus Objects (*.sce *.SCE)"); + qSort(formats); + allFormats += formats.join(";;"); + return allFormats; +} + +bool FormatsManager::isVectorFile(QString fileName) +{ + QStringList formats; + QFileInfo fi(fileName); + int fmtCode = FORMATID_FIRSTUSER; + const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode); + while (fmt != 0) + { + if (fmt->load) + { + formats.append(fmt->filter); + int an = fmt->filter.indexOf("("); + int en = fmt->filter.indexOf(")"); + while (an != -1) + { + if(fmt->filter.mid(an+1, en-an-1).toLower().contains(fi.suffix().toLower())) + return true; + an = fmt->filter.indexOf("(", en); + en = fmt->filter.indexOf(")", an); + } + } + fmtCode++; + fmt = LoadSavePlugin::getFormatById(fmtCode); + } + if(QString("*.sce *.SCE").toLower().contains(fi.suffix().toLower())) + return true; + return false; +} diff --git a/Scribus/scribus/util_formats.h b/Scribus/scribus/util_formats.h index bb717a9..95ef0c0 100644 --- a/Scribus/scribus/util_formats.h +++ b/Scribus/scribus/util_formats.h @@ -31,6 +31,21 @@ bool SCRIBUS_API extensionIndicatesPattern(const QString &ext); bool SCRIBUS_API extensionIndicatesTIFF(const QString &ext); QString SCRIBUS_API getImageType(QString filename); + +// A struct for holding the Importer specific information. +struct ImporterData { + QString soFilePath; // Path to the Importer + QString fileFormatName; // Name of the Importer + QStringList fileEndings; // Array of filenames supported by the importer +}; + +// A Struct for holding the results of the File selection Dialog +struct ImportSetup { + QStringList filename; // What filename is to be loaded? + bool textOnly; // Do we import as text only? + QString encoding; // File encoding +}; + class SCRIBUS_API FormatsManager { public: @@ -126,7 +141,15 @@ class SCRIBUS_API FormatsManager //! Returns in the form of "All Supported Formats (*.eps *.EPS *.epsf *.EPSF *.epsi *.EPSI);;EPS (*.eps *.EPS);;EPSI (*.epsf *.EPSF);;EPSI (*.epsi *.EPSI);;All Files (*)" QString fileDialogFormatList(int type); - + QString fileDialogTextFormatList(); + QString fileDialogVectorFormatList(); + + bool isVectorFile(QString); + + QMap<QString, ImporterData*> getMap(){return importerMap;} + QList<ImporterData> getImporters(){return importers;} + QStringList getIlist(){return ilist;} + protected: QMap<int, QString> m_fmtNames; QMap<int, QStringList> m_fmtMimeTypes; @@ -146,6 +169,20 @@ class SCRIBUS_API FormatsManager * instance(). */ static FormatsManager* _instance; + +//we need some informations about importer and dll to know which text format can be use + + QMap<QString, ImporterData*> importerMap; // QMap of the supported extensions to their relevant importers entry for easy access + QStringList ilist; // List of supported importers, used with dialogs + QList<ImporterData> importers; // Vector of the loaded importers + + void loadImporterPlugins(); // Find the available plugins based on the environment, validate they load, and + // create quick lookup mappings. + void createMap(); // Create the importer Qmap. + + bool DLLName(QString name, QString *ffName, QStringList *fileEndings); + // Loads the "DLL", validates the importer is good, populates the passed parameters with + // the plugin information. }; #endif |
|
I did first tests of that patch. I encountered following issues : 1) Text import related dialog shown when importing images - File > Get File - Select several images (all png in my case) - After first image is imported, a setting dialog related to text import is shown to user 2) Image following mouse cursor quite loosely - File > Get File - Select several images (all png in my case) - Image previews are shown at some varying distance from text cursor, would be probably better if that distance was kept constant |
|
The "text import dialog" issue didnt occure when i first tested the unitloader branch so its probably a little bug that was introduced in latest fix. |
|
I see now that this "unified import" feature would be really usefull. Unfriendly is the requirement to use 2 completely different menu entries to import "normal" images and "svg" images : Image import is "Insert" menu, when svg import is in "File" > "vector import" submenu. This patch does a lot more, but basicaly unifying the image import and the svg import would be a great usability improvement. |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-06-24 13:29 | Chelen | New Issue | |
2013-06-24 13:29 | Chelen | Status | new => assigned |
2013-06-24 13:29 | Chelen | Assigned To | => Chelen |
2013-06-24 13:29 | Chelen | File Added: patch.diff | |
2013-06-27 14:19 | JLuc | Note Added: 0030382 | |
2013-06-28 07:22 | JLuc | Note Edited: 0030382 | |
2013-07-14 04:25 | cbradney | Note Added: 0030440 | |
2013-07-14 07:19 | christoph_s | Note Added: 0030441 | |
2013-10-08 11:41 | Chelen | Note Added: 0030685 | |
2013-10-08 11:41 | Chelen | File Added: unitloaderpatch.diff | |
2013-10-09 21:10 | jghali | Note Added: 0030699 | |
2014-01-30 07:15 | christoph_s | Relationship added | related to 0012015 |
2014-01-30 10:30 | JLuc | Note Added: 0031226 | |
2014-11-19 21:33 | JLuc | Note Added: 0034224 | |
2014-11-20 12:42 | Kunda | Patch | => Yes |
2014-11-20 12:42 | Kunda | Summary | Improve Import management => [PATCH] Improve Import management |
2016-01-23 16:30 | Kunda | Relationship added | related to 0010908 |
2016-01-23 16:44 | Kunda | Relationship added | related to 0010947 |
2018-04-30 13:00 | jghali | Target Version | 1.5.0svn => |
2018-04-30 14:37 | JLuc | Tag Attached: #rottenpatch |