Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPDFImportWidget Class Reference

#include <kis_pdf_import_widget.h>

+ Inheritance diagram for KisPDFImportWidget:

Public Member Functions

 KisPDFImportWidget (Poppler::Document *pdfDoc, QWidget *parent)
 
QList< int > pages ()
 
 ~KisPDFImportWidget ()
 

Private Slots

void heightAspectRatio ()
 
void selectAllPages (bool v)
 
void selectFirstPage (bool v)
 
void selectSelectionOfPages (bool v)
 
void slotAspectChanged (bool keep)
 
void updateHRes ()
 
void updateHVer ()
 
void updateMaxCanvasSize ()
 
void updateResolution ()
 
void updateSelectionOfPages ()
 
void widthAspectRatio ()
 

Private Attributes

bool m_keepAspect
 
double m_maxHeightInch
 
double m_maxWidthInch
 
QList< int > m_pages
 
Poppler::Document * m_pdfDoc
 

Detailed Description

Definition at line 19 of file kis_pdf_import_widget.h.

Constructor & Destructor Documentation

◆ KisPDFImportWidget()

KisPDFImportWidget::KisPDFImportWidget ( Poppler::Document * pdfDoc,
QWidget * parent )

Definition at line 31 of file kis_pdf_import_widget.cpp.

32 : QWidget(parent)
33 , m_pdfDoc(pdfDoc)
34 , m_keepAspect(true)
35{
36 setupUi(this);
37 m_pages.push_back(0); // The first page is selected
39
40 for (int i = 1; i <= m_pdfDoc->numPages(); i++) {
41 listPages->addItem(QString::number(i));
42 }
43
44 connect(intWidth, SIGNAL(valueChanged(int)), this, SLOT(updateHRes()));
45 connect(intHeight, SIGNAL(valueChanged(int)), this, SLOT(updateHVer()));
46 connect(intResolution, SIGNAL(valueChanged(int)), this, SLOT(updateResolution()));
47 connect(intHeight, SIGNAL(valueChanged(int)), this, SLOT(heightAspectRatio()));
48 connect(intWidth, SIGNAL(valueChanged(int)), this, SLOT(widthAspectRatio()));
49 connect(boolAllPages, SIGNAL(toggled(bool)), this, SLOT(selectAllPages(bool)));
50 connect(boolFirstPage, SIGNAL(toggled(bool)), this, SLOT(selectFirstPage(bool)));
51 connect(boolSelectionPage, SIGNAL(toggled(bool)), this, SLOT(selectSelectionOfPages(bool)));
52 connect(listPages, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelectionOfPages()));
53 connect(pixelAspectRatioBtn, SIGNAL(keepAspectRatioChanged(bool)), this, SLOT(slotAspectChanged(bool)));
54
55}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotAspectChanged(bool keep)
Poppler::Document * m_pdfDoc

References connect(), heightAspectRatio(), m_pages, m_pdfDoc, selectAllPages(), selectFirstPage(), selectSelectionOfPages(), slotAspectChanged(), updateHRes(), updateHVer(), updateMaxCanvasSize(), updateResolution(), updateSelectionOfPages(), and widthAspectRatio().

◆ ~KisPDFImportWidget()

KisPDFImportWidget::~KisPDFImportWidget ( )

Definition at line 58 of file kis_pdf_import_widget.cpp.

59{
60}

Member Function Documentation

◆ heightAspectRatio

void KisPDFImportWidget::heightAspectRatio ( )
privateslot

Definition at line 154 of file kis_pdf_import_widget.cpp.

155{
156 intWidth->blockSignals(true);
157 if(m_keepAspect)
158 {
159 intWidth->setValue((int) ceil(((intHeight->value() * m_maxWidthInch * 1.) / m_maxHeightInch * 1.) + 0.5));
160 }
161 intWidth->blockSignals(false);
162}

References m_keepAspect, m_maxHeightInch, and m_maxWidthInch.

◆ pages()

QList< int > KisPDFImportWidget::pages ( )
inline

Definition at line 27 of file kis_pdf_import_widget.h.

27 {
28 return m_pages;
29 }

References m_pages.

◆ selectAllPages

void KisPDFImportWidget::selectAllPages ( bool v)
privateslot

Definition at line 62 of file kis_pdf_import_widget.cpp.

63{
64 if (v) {
65 if (listPages->selectedItems().count() != 0){
66 listPages->clearSelection();
67 boolAllPages->toggle();
68 }
69 m_pages.clear();
70 for (int i = 0; i < m_pdfDoc->numPages(); i++) {
71 m_pages.push_back(i);
72 }
74 }
75}
qreal v

References m_pages, m_pdfDoc, updateMaxCanvasSize(), and v.

◆ selectFirstPage

void KisPDFImportWidget::selectFirstPage ( bool v)
privateslot

Definition at line 76 of file kis_pdf_import_widget.cpp.

77{
78 if (v) {
79 if (listPages->selectedItems().count() != 0){
80 listPages->clearSelection();
81 boolFirstPage->toggle();
82 }
83 m_pages.clear();
84 m_pages.push_back(0); // The first page is selected
86 }
87}

References m_pages, updateMaxCanvasSize(), and v.

◆ selectSelectionOfPages

void KisPDFImportWidget::selectSelectionOfPages ( bool v)
privateslot

Definition at line 88 of file kis_pdf_import_widget.cpp.

89{
90 if (v) {
93 }
94
95}

References updateMaxCanvasSize(), updateSelectionOfPages(), and v.

◆ slotAspectChanged

void KisPDFImportWidget::slotAspectChanged ( bool keep)
privateslot

Definition at line 172 of file kis_pdf_import_widget.cpp.

173{
174 pixelAspectRatioBtn->blockSignals(true);
175 pixelAspectRatioBtn->setKeepAspectRatio(keep);
176 pixelAspectRatioBtn->blockSignals(false);
177
178 m_keepAspect = keep;
179
180 if (keep)
181 {
183 }
184}

References heightAspectRatio(), and m_keepAspect.

◆ updateHRes

void KisPDFImportWidget::updateHRes ( )
privateslot

Definition at line 142 of file kis_pdf_import_widget.cpp.

143{
144 intResolution->blockSignals(true);
145 intResolution->setValue((int)(intWidth->value() / m_maxWidthInch));
146 intResolution->blockSignals(false);
147}

References m_maxWidthInch.

◆ updateHVer

void KisPDFImportWidget::updateHVer ( )
privateslot

Definition at line 148 of file kis_pdf_import_widget.cpp.

149{
150 intResolution->blockSignals(true);
151 intResolution->setValue((int)(intHeight->value() / m_maxHeightInch));
152 intResolution->blockSignals(false);
153}

References m_maxHeightInch.

◆ updateMaxCanvasSize

void KisPDFImportWidget::updateMaxCanvasSize ( )
privateslot

Definition at line 108 of file kis_pdf_import_widget.cpp.

109{
111 for (QList<int>::const_iterator it = m_pages.constBegin(); it != m_pages.constEnd(); ++it) {
112#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
113 Poppler::Page *p = m_pdfDoc->page(*it);
114#else
115 std::unique_ptr<Poppler::Page> p = m_pdfDoc->page(*it);
116#endif
117 QSizeF size = p->pageSizeF();
118 if (size.width() > m_maxWidthInch) {
119 m_maxWidthInch = size.width();
120 }
121 if (size.height() > m_maxHeightInch) {
122 m_maxHeightInch = size.height();
123 }
124 }
125 m_maxWidthInch /= 72.;
126 m_maxHeightInch /= 72.;
129}
const Params2D p
#define dbgFile
Definition kis_debug.h:53
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References dbgFile, m_maxHeightInch, m_maxWidthInch, m_pages, m_pdfDoc, p, and updateResolution().

◆ updateResolution

void KisPDFImportWidget::updateResolution ( )
privateslot

Definition at line 131 of file kis_pdf_import_widget.cpp.

132{
133 int resolution = intResolution->value();
134 intWidth->blockSignals(true);
135 intWidth->setValue((int) ceil(m_maxWidthInch * resolution));
136 intWidth->blockSignals(false);
137 intHeight->blockSignals(true);
138 intHeight->setValue((int) ceil(m_maxHeightInch * resolution));
139 intHeight->blockSignals(false);
140}

References m_maxHeightInch, and m_maxWidthInch.

◆ updateSelectionOfPages

void KisPDFImportWidget::updateSelectionOfPages ( )
privateslot

Definition at line 97 of file kis_pdf_import_widget.cpp.

98{
99 if (! boolSelectionPage->isChecked()) boolSelectionPage->toggle();
100 m_pages.clear();
101 for (int i = 0; i < m_pdfDoc->numPages(); i++) {
102 if (listPages->item(i)->isSelected()) m_pages.push_back(i);
103 }
105}

References m_pages, m_pdfDoc, and updateMaxCanvasSize().

◆ widthAspectRatio

void KisPDFImportWidget::widthAspectRatio ( )
privateslot

Definition at line 163 of file kis_pdf_import_widget.cpp.

164{
165 intHeight->blockSignals(true);
166 if(m_keepAspect)
167 {
168 intHeight->setValue((int) ceil(((intWidth->value() * m_maxHeightInch * 1.) / m_maxWidthInch * 1.) + 0.5));
169 }
170 intHeight->blockSignals(false);
171}

References m_keepAspect, m_maxHeightInch, and m_maxWidthInch.

Member Data Documentation

◆ m_keepAspect

bool KisPDFImportWidget::m_keepAspect
private

Definition at line 46 of file kis_pdf_import_widget.h.

◆ m_maxHeightInch

double KisPDFImportWidget::m_maxHeightInch
private

Definition at line 45 of file kis_pdf_import_widget.h.

◆ m_maxWidthInch

double KisPDFImportWidget::m_maxWidthInch
private

Definition at line 45 of file kis_pdf_import_widget.h.

◆ m_pages

QList<int> KisPDFImportWidget::m_pages
private

Definition at line 44 of file kis_pdf_import_widget.h.

◆ m_pdfDoc

Poppler::Document* KisPDFImportWidget::m_pdfDoc
private

Definition at line 43 of file kis_pdf_import_widget.h.


The documentation for this class was generated from the following files: