r17885 by fschmid - PDF-Import Options:
scribus-commit
scribus-commit at lists.scribus.net
Sun Nov 18 16:55:03 UTC 2012
Author: fschmid
Date: Sun Nov 18 16:55:03 2012
New Revision: 17885
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17885
Log:
PDF-Import Options:
- handle Preview correctly when resizing the Dialog
- only show the Dialog when the PDF has more than one page.
Modified:
trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
trunk/Scribus/scribus/ui/pageselector.cpp
trunk/Scribus/scribus/ui/pageselector.h
Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Sun Nov 18 16:55:03 2012
@@ -51,7 +51,7 @@
#include "undomanager.h"
#include "util.h"
#include "util_formats.h"
-#include "util_ghostscript.h"
+//#include "util_ghostscript.h"
#include "util_icon.h"
#include "util_math.h"
@@ -424,13 +424,14 @@
double vDPI = 72.0;
int firstPage = 1;
int lastPage = pdfDoc->getNumPages();
- if ((interactive) || (importerFlags & LoadSavePlugin::lfCreateDoc))
+ if (((interactive) || (importerFlags & LoadSavePlugin::lfCreateDoc)) && (lastPage > 1))
{
if (progressDialog)
progressDialog->hide();
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
PdfImportOptions *optImp = new PdfImportOptions(ScCore->primaryMainWindow());
- optImp->setUpOptions(firstPage, lastPage, interactive, this);
+ QFileInfo fi = QFileInfo(fn);
+ optImp->setUpOptions(fi.fileName(), firstPage, lastPage, interactive, this);
if (!optImp->exec())
{
if (progressDialog)
@@ -597,8 +598,16 @@
}
}
info.free();
- m_Doc->setPageHeight(pdfDoc->getPageMediaHeight(pageNs[0]));
- m_Doc->setPageWidth(pdfDoc->getPageMediaWidth(pageNs[0]));
+ if (crop)
+ {
+ m_Doc->setPageHeight(pdfDoc->getPageCropHeight(pageNs[0]));
+ m_Doc->setPageWidth(pdfDoc->getPageCropWidth(pageNs[0]));
+ }
+ else
+ {
+ m_Doc->setPageHeight(pdfDoc->getPageMediaHeight(pageNs[0]));
+ m_Doc->setPageWidth(pdfDoc->getPageMediaWidth(pageNs[0]));
+ }
m_Doc->setPageSize("Custom");
/* PDFRectangle *mediaBox = pdfDoc->getPage(1)->getMediaBox();
PDFRectangle *cropBox = pdfDoc->getPage(1)->getCropBox();
@@ -624,10 +633,20 @@
firstPg = false;
else
m_Doc->addPage(ap);
- m_Doc->currentPage()->setInitialHeight(pdfDoc->getPageMediaHeight(pp));
- m_Doc->currentPage()->setInitialWidth(pdfDoc->getPageMediaWidth(pp));
- m_Doc->currentPage()->setHeight(pdfDoc->getPageMediaHeight(pp));
- m_Doc->currentPage()->setWidth(pdfDoc->getPageMediaWidth(pp));
+ if (crop)
+ {
+ m_Doc->currentPage()->setInitialHeight(pdfDoc->getPageCropHeight(pp));
+ m_Doc->currentPage()->setInitialWidth(pdfDoc->getPageCropWidth(pp));
+ m_Doc->currentPage()->setHeight(pdfDoc->getPageCropHeight(pp));
+ m_Doc->currentPage()->setWidth(pdfDoc->getPageCropWidth(pp));
+ }
+ else
+ {
+ m_Doc->currentPage()->setInitialHeight(pdfDoc->getPageMediaHeight(pp));
+ m_Doc->currentPage()->setInitialWidth(pdfDoc->getPageMediaWidth(pp));
+ m_Doc->currentPage()->setHeight(pdfDoc->getPageMediaHeight(pp));
+ m_Doc->currentPage()->setWidth(pdfDoc->getPageMediaWidth(pp));
+ }
m_Doc->currentPage()->MPageNam = CommonStrings::trMasterPageNormal;
m_Doc->currentPage()->m_pageSize = "Custom";
m_Doc->reformPages(true);
Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp Sun Nov 18 16:55:03 2012
@@ -17,12 +17,27 @@
ui->pageSelectButton->setIcon(QIcon(loadIcon("ellipsis.png")));
m_plugin = NULL;
m_maxPage = 0;
+ m_resized = false;
ui->cropGroup->hide(); // for now as functionality is not implemented yet
}
PdfImportOptions::~PdfImportOptions()
{
delete ui;
+}
+
+void PdfImportOptions::resizeEvent(QResizeEvent *e)
+{
+ m_resized = true;
+ QDialog::resizeEvent(e);
+}
+
+void PdfImportOptions::paintEvent(QPaintEvent *e)
+{
+ if (m_resized)
+ updatePreview(ui->pgSelect->getCurrentPage());
+ m_resized = false;
+ QDialog::paintEvent(e);
}
QString PdfImportOptions::getPagesString()
@@ -34,9 +49,10 @@
return ui->pageRangeString->text();
}
-void PdfImportOptions::setUpOptions(int actPage, int numPages, bool interact, PdfPlug* plug)
+void PdfImportOptions::setUpOptions(QString fileName, int actPage, int numPages, bool interact, PdfPlug* plug)
{
m_plugin = plug;
+ ui->fileLabel->setText(fileName);
ui->spinBox->setMaximum(numPages);
ui->spinBox->setMinimum(actPage);
ui->spinBox->setValue(actPage);
@@ -58,8 +74,15 @@
m_maxPage = numPages;
updatePreview(actPage);
connect(ui->pgSelect, SIGNAL(GotoPage(int)), this, SLOT(updatePreview(int)));
+ connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFromSpinBox(int)));
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatePreview(int)));
connect(ui->pageSelectButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
+}
+
+
+void PdfImportOptions::updateFromSpinBox(int pg)
+{
+ ui->pgSelect->GotoPg(pg - 1);
}
void PdfImportOptions::updatePreview(int pg)
Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h Sun Nov 18 16:55:03 2012
@@ -21,10 +21,15 @@
public:
explicit PdfImportOptions(QWidget *parent = 0);
~PdfImportOptions();
- void setUpOptions(int actPage, int numPages, bool interact, PdfPlug* plug);
+ void setUpOptions(QString fileName, int actPage, int numPages, bool interact, PdfPlug* plug);
QString getPagesString();
+ void paintEvent(QPaintEvent *e);
+
+protected:
+ void resizeEvent(QResizeEvent *e);
public slots:
+ void updateFromSpinBox(int pg);
void updatePreview(int pg);
void createPageNumberRange();
@@ -32,6 +37,7 @@
Ui::PdfImportOptions *ui;
PdfPlug* m_plugin;
int m_maxPage;
+ bool m_resized;
};
#endif // PDFIMPORTOPTIONS_H
Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.ui Sun Nov 18 16:55:03 2012
@@ -7,18 +7,48 @@
<x>0</x>
<y>0</y>
<width>452</width>
- <height>424</height>
+ <height>449</height>
</rect>
</property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>PDF-Import</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Importing File:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="fileLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@@ -176,13 +206,52 @@
<height>340</height>
</size>
</property>
+ <property name="frameShape">
+ <enum>QFrame::Panel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
<property name="text">
<string/>
</property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
</widget>
</item>
<item>
- <widget class="PageSelector" name="pgSelect" native="true"/>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="PageSelector" name="pgSelect" native="true"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
</layout>
</item>
Modified: trunk/Scribus/scribus/ui/pageselector.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/ui/pageselector.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pageselector.cpp (original)
+++ trunk/Scribus/scribus/ui/pageselector.cpp Sun Nov 18 16:55:03 2012
@@ -164,13 +164,17 @@
QWidget::setFont(fo);
}
+int PageSelector::getCurrentPage()
+{
+ return APage;
+}
+
void PageSelector::GotoPgE(int a)
{
clearFocus();
GotoPg(a);
emit GotoPage(a+1);
}
-
void PageSelector::GotoPage()
{
@@ -183,7 +187,6 @@
GotoPg(p-1);
emit GotoPage(p);
}
-
void PageSelector::GotoPg(int a)
{
Modified: trunk/Scribus/scribus/ui/pageselector.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17885&path=/trunk/Scribus/scribus/ui/pageselector.h
==============================================================================
--- trunk/Scribus/scribus/ui/pageselector.h (original)
+++ trunk/Scribus/scribus/ui/pageselector.h Sun Nov 18 16:55:03 2012
@@ -35,6 +35,7 @@
bool hasFocus();
void focusPolicy(Qt::FocusPolicy policy);
void setFont ( const QFont & );
+ int getCurrentPage();
#if OPTION_USE_QTOOLBUTTON
QToolButton* Start;
More information about the scribus-commit
mailing list