-
Notifications
You must be signed in to change notification settings - Fork 0
/
printpreview.cpp
executable file
·106 lines (89 loc) · 1.9 KB
/
printpreview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "printpreview.h"
#include "ui_printpreview.h"
#include <qvariant.h>
#include <qrect.h>
#include "pixmaplabel.h"
/*
* Constructs a PrintPreview as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
PrintPreview::PrintPreview(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
init();
}
/*
* Destroys the object and frees any allocated resources
*/
PrintPreview::~PrintPreview()
{
destroy();
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void PrintPreview::languageChange()
{
retranslateUi(this);
}
void PrintPreview::init()
{
}
void PrintPreview::destroy()
{
}
/** @fn updatePreview
@brief Updates the pixmap label.
*/
void PrintPreview::updatePreview()
{
QImage img = pix.toImage();
if ( checkInvert->isChecked() ) {
img.invertPixels();
}
if ( checkMirror->isChecked() ) {
img = img.mirrored( TRUE, FALSE );
}
if ( checkFlip->isChecked() ) {
img = img.mirrored( FALSE, TRUE );
}
QPixmap pm;
pm.convertFromImage( img );
pixmapLabel->setPixmapLabel( pm );
pixmapLabel->update();
}
void PrintPreview::flip( bool )
{
updatePreview();
}
void PrintPreview::invertColors( bool )
{
updatePreview();
}
void PrintPreview::mirror( bool )
{
updatePreview();
}
void PrintPreview::setPixmap( const QPixmap & pm )
{
pix = pm;
updatePreview();
}
void PrintPreview::setPaletteView( PaletteView * paletteView )
{
pixmapLabel->setPaletteView( paletteView );
}
void PrintPreview::setPaletteRect(int x,int y,int width,int height)
{
pixmapLabel->setPaletteRect( x, y, width, height );
}
QRect PrintPreview::getPaletteRect()
{
return pixmapLabel->getPaletteRect();
}