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
Michael Winkelmann
QmlSlidePrinter
Commits
c09ad029
Commit
c09ad029
authored
Nov 02, 2018
by
Michael Winkelmann
Browse files
Remove support for custom printable items
parent
2a82bd02
Changes
2
Hide whitespace changes
Inline
Side-by-side
qmlprinter.cpp
View file @
c09ad029
/*
* Copyright (c) 2014 Taneli Peltoniemi <taneli.peltoniemi@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "qmlprinter.h"
#include <QLoggingCategory>
#include <QAbstractTextDocumentLayout>
#include <QPainter>
#include <QPrinter>
...
...
@@ -15,6 +8,8 @@
#include <QQuickWindow>
#include <QtMath>
Q_LOGGING_CATEGORY
(
lc
,
"qt.qmlprinter"
)
QmlPrinter
::
QmlPrinter
()
{}
QmlPrinter
::~
QmlPrinter
()
{}
...
...
@@ -126,20 +121,6 @@ void QmlPrinter::paintItem(QQuickItem *item, QQuickWindow *window,
}
}
}
}
else
if
(
isCustomPrintItem
(
item
->
metaObject
()
->
className
()))
{
const
int
boundingMargin
=
5
;
QRectF
boundingRect
;
boundingRect
.
setTop
(
item
->
boundingRect
().
top
()
-
boundingMargin
);
boundingRect
.
setLeft
(
item
->
boundingRect
().
left
()
-
boundingMargin
);
boundingRect
.
setHeight
(
item
->
boundingRect
().
height
()
+
boundingMargin
*
2
);
boundingRect
.
setWidth
(
item
->
boundingRect
().
width
()
+
boundingMargin
*
2
);
const
QRect
rect
(
0
,
0
,
int
(
item
->
width
()),
int
(
item
->
height
()));
QImage
image
=
window
->
grabWindow
();
painter
->
drawImage
(
0
,
0
,
image
,
0
,
0
,
rect
.
width
(),
rect
.
height
());
painter
->
restore
();
drawChildren
=
false
;
}
else
if
(
item
->
flags
().
testFlag
(
QQuickItem
::
ItemHasContents
))
{
if
(
inherits
(
item
->
metaObject
(),
"QQuickRectangle"
))
{
...
...
@@ -305,20 +286,6 @@ bool QmlPrinter::inherits(const QMetaObject *metaObject, const QString &name) {
return
false
;
}
void
QmlPrinter
::
addPrintableItem
(
const
QString
&
item
)
{
printableItems
.
push_back
(
item
);
}
bool
QmlPrinter
::
isCustomPrintItem
(
const
QString
&
item
)
{
QListIterator
<
QString
>
it
(
printableItems
);
while
(
it
.
hasNext
())
{
QString
printableItem
=
it
.
next
();
if
(
item
.
contains
(
printableItem
))
return
true
;
}
return
false
;
}
QMatrix
QmlPrinter
::
transformMatrix
(
QQuickItem
*
item
)
{
QTransform
t
;
...
...
qmlprinter.h
View file @
c09ad029
/*
* Copyright (c) 2014 Taneli Peltoniemi <taneli.peltoniemi@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef QMLPRINTER_H
#define QMLPRINTER_H
...
...
@@ -38,7 +31,6 @@ private:
QPainter
*
painter
);
bool
inherits
(
const
QMetaObject
*
metaObject
,
const
QString
&
name
);
bool
isCustomPrintItem
(
const
QString
&
item
);
void
changePrinterOrientation
(
QPrinter
&
printer
,
const
int
&
width
,
const
int
&
height
);
...
...
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