20#include "kis_pdf_import_widget.h"
23#include <poppler-qt.h>
26#include <tqradiobutton.h>
30#include <tdelistbox.h>
33KisPDFImportWidget::KisPDFImportWidget(Poppler::Document* pdfDoc, TQWidget * parent,
const char * name)
34 : PDFImportWidgetBase(parent, name), m_pdfDoc(pdfDoc)
37 updateMaxCanvasSize();
39 for(
int i = 1; i <= m_pdfDoc->getNumPages(); i++)
41 listPages->insertItem(TQString::number( i ) );
44 connect(intWidth, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( updateHRes() ) );
45 connect(intHeight, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( updateHVer() ) );
46 connect(intHorizontal, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( updateWidth() ) );
47 connect(intVertical, TQ_SIGNAL( valueChanged (
int ) ),
this, TQ_SLOT( updateHeight() ) );
48 connect(boolAllPages, TQ_SIGNAL( toggled (
bool ) ),
this, TQ_SLOT( selectAllPages(
bool ) ) );
49 connect(boolFirstPage, TQ_SIGNAL( toggled (
bool ) ),
this, TQ_SLOT( selectFirstPage(
bool ) ) );
50 connect(boolSelectionPage, TQ_SIGNAL( toggled (
bool ) ),
this, TQ_SLOT( selectSelectionOfPages(
bool ) ) );
51 connect(listPages, TQ_SIGNAL(selectionChanged () ),
this, TQ_SLOT(updateSelectionOfPages()));
55KisPDFImportWidget::~KisPDFImportWidget()
59void KisPDFImportWidget::selectAllPages(
bool v)
64 for(
int i = 0; i < m_pdfDoc->getNumPages(); i++)
68 updateMaxCanvasSize();
71void KisPDFImportWidget::selectFirstPage(
bool v)
79void KisPDFImportWidget::selectSelectionOfPages(
bool v)
83 updateSelectionOfPages();
84 updateMaxCanvasSize();
89void KisPDFImportWidget::updateSelectionOfPages()
91 if(! boolSelectionPage->isChecked ()) boolSelectionPage->toggle();
93 for(
int i = 0; i < m_pdfDoc->getNumPages(); i++)
95 if(listPages->isSelected(i)) m_pages.push_back(i);
100void KisPDFImportWidget::updateMaxCanvasSize() {
101 m_maxWidthInch = 0., m_maxHeightInch =0.;
102 for(TQValueList<int>::const_iterator it = m_pages.begin(); it != m_pages.end(); ++it)
104 Poppler::Page *p = m_pdfDoc->getPage(*it );
105 TQSize size = p->pageSize();
106 if(size.width() > m_maxWidthInch)
108 m_maxWidthInch = size.width();
110 if(size.height() > m_maxHeightInch)
112 m_maxHeightInch = size.height();
115 m_maxWidthInch /= 72.;
116 m_maxHeightInch /= 72.;
117 kdDebug() << m_maxWidthInch <<
" " << m_maxHeightInch << endl;
122void KisPDFImportWidget::updateWidth()
124 intWidth->blockSignals(
true);
125 intWidth->setValue( (
int) m_maxWidthInch * intHorizontal->value() + 1 );
126 intWidth->blockSignals(
false);
128void KisPDFImportWidget::updateHeight()
130 intHeight->blockSignals(
true);
131 intHeight->setValue( (
int) m_maxHeightInch * intVertical->value() + 1 );
132 intHeight->blockSignals(
false);
134void KisPDFImportWidget::updateHRes()
136 intHorizontal->blockSignals(
true);
137 intHorizontal->setValue( (
int) (intWidth->value() / m_maxWidthInch ) );
138 intHorizontal->blockSignals(
false);
140void KisPDFImportWidget::updateHVer()
142 intVertical->blockSignals(
true);
143 intVertical->setValue( (
int) (intHeight->value() / m_maxHeightInch ) );
144 intVertical->blockSignals(
false);
147#include "kis_pdf_import_widget.moc"