Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Office
Calligra
Commits
bbb92161
Commit
bbb92161
authored
Mar 02, 2014
by
Halla Rempt
Browse files
Maintained the Aspect ratio of height and width during pdf import
BUG:297254 REVIEW:116009 Patch by Swarn Kumar. Thanks!
parent
cef0f55e
Changes
3
Hide whitespace changes
Inline
Side-by-side
krita/plugins/formats/pdf/kis_pdf_import_widget.cpp
View file @
bbb92161
...
...
@@ -33,9 +33,15 @@
// For ceil()
#include
<math.h>
// For KoAspectButton
#include
<klocale.h>
KisPDFImportWidget
::
KisPDFImportWidget
(
Poppler
::
Document
*
pdfDoc
,
QWidget
*
parent
)
:
QWidget
(
parent
),
m_pdfDoc
(
pdfDoc
)
:
QWidget
(
parent
)
,
m_pdfDoc
(
pdfDoc
)
,
m_keepAspect
(
true
)
{
setupUi
(
this
);
m_pages
.
push_back
(
0
);
// The first page is selected
...
...
@@ -49,10 +55,13 @@ KisPDFImportWidget::KisPDFImportWidget(Poppler::Document* pdfDoc, QWidget * pare
connect
(
intHeight
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateHVer
()));
connect
(
intHorizontal
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateWidth
()));
connect
(
intVertical
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateHeight
()));
connect
(
intHeight
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
heightAspectRatio
()));
connect
(
intWidth
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
widthAspectRatio
()));
connect
(
boolAllPages
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
selectAllPages
(
bool
)));
connect
(
boolFirstPage
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
selectFirstPage
(
bool
)));
connect
(
boolSelectionPage
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
selectSelectionOfPages
(
bool
)));
connect
(
listPages
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
updateSelectionOfPages
()));
connect
(
pixelAspectRatioBtn
,
SIGNAL
(
keepAspectRatioChanged
(
bool
)),
this
,
SLOT
(
slotAspectChanged
(
bool
)));
}
...
...
@@ -151,5 +160,36 @@ void KisPDFImportWidget::updateHVer()
intVertical
->
setValue
((
int
)(
intHeight
->
value
()
/
m_maxHeightInch
));
intVertical
->
blockSignals
(
false
);
}
void
KisPDFImportWidget
::
heightAspectRatio
()
{
intWidth
->
blockSignals
(
true
);
if
(
m_keepAspect
)
{
intWidth
->
setValue
((
int
)
ceil
(((
intHeight
->
value
()
*
m_maxWidthInch
*
1.
)
/
m_maxHeightInch
*
1.
)
+
0.5
));
}
intWidth
->
blockSignals
(
false
);
}
void
KisPDFImportWidget
::
widthAspectRatio
()
{
intHeight
->
blockSignals
(
true
);
if
(
m_keepAspect
)
{
intHeight
->
setValue
((
int
)
ceil
(((
intWidth
->
value
()
*
m_maxHeightInch
*
1.
)
/
m_maxWidthInch
*
1.
)
+
0.5
));
}
intHeight
->
blockSignals
(
false
);
}
void
KisPDFImportWidget
::
slotAspectChanged
(
bool
keep
)
{
pixelAspectRatioBtn
->
blockSignals
(
true
);
pixelAspectRatioBtn
->
setKeepAspectRatio
(
keep
);
pixelAspectRatioBtn
->
blockSignals
(
false
);
m_keepAspect
=
keep
;
if
(
keep
)
{
heightAspectRatio
();
}
}
#include
"kis_pdf_import_widget.moc"
krita/plugins/formats/pdf/kis_pdf_import_widget.h
View file @
bbb92161
...
...
@@ -49,11 +49,15 @@ private slots:
void
updateHeight
();
void
updateHRes
();
void
updateHVer
();
void
heightAspectRatio
();
void
widthAspectRatio
();
void
slotAspectChanged
(
bool
keep
);
void
updateMaxCanvasSize
();
private:
Poppler
::
Document
*
m_pdfDoc
;
QList
<
int
>
m_pages
;
double
m_maxWidthInch
,
m_maxHeightInch
;
bool
m_keepAspect
;
};
#endif
krita/plugins/formats/pdf/pdfimportwidgetbase.ui
View file @
bbb92161
...
...
@@ -165,6 +165,13 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"KoAspectButton"
name=
"pixelAspectRatioBtn"
native=
"true"
>
<property
name=
"text"
stdset=
"0"
>
<string/>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QSpinBox"
name=
"intVertical"
>
<property
name=
"suffix"
>
...
...
@@ -330,6 +337,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>
KoAspectButton
</class>
<extends>
QWidget
</extends>
<header>
KoAspectButton.h
</header>
<container>
1
</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>
boolAllPages
</tabstop>
<tabstop>
boolFirstPage
</tabstop>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment