[Kde-imaging] extragear/graphics/kipi-plugins/printwizard
Angelo Naselli
anaselli at linux.it
Mon Nov 24 00:30:03 CET 2008
SVN commit 888181 by anaselli:
Added new option "don't crop" to skip cropping and scale instead.
Please test, it seems i cannot be sure it works since my printer does not care my settings :/
CCMAIL: kde-imaging at kde.org
M +13 -8 cropframe.cpp
M +2 -0 cropframe.h
M +23 -0 croppage.ui
M +56 -6 wizard.cpp
M +2 -0 wizard.h
--- trunk/extragear/graphics/kipi-plugins/printwizard/cropframe.cpp #888180:888181
@@ -46,6 +46,8 @@
: QWidget(parent)
{
m_mouseDown = false;
+ m_drawRec = true;
+ m_pixmap = NULL;
}
@@ -229,14 +231,17 @@
// draw the background pixmap
p.drawPixmap(m_pixmapX, m_pixmapY, *m_pixmap);
- // draw the rectangle
- p.setPen(QPen(m_color, 2));
- p.drawRect(m_cropRegion);
- // draw the crosshairs
- int midX = m_cropRegion.left() + m_cropRegion.width() / 2;
- int midY = m_cropRegion.top() + m_cropRegion.height() / 2;
- p.drawLine(midX - 10, midY, midX + 10, midY);
- p.drawLine(midX, midY - 10, midX, midY + 10);
+ if (m_drawRec)
+ {
+ // draw the rectangle
+ p.setPen(QPen(m_color, 2));
+ p.drawRect(m_cropRegion);
+ // draw the crosshairs
+ int midX = m_cropRegion.left() + m_cropRegion.width() / 2;
+ int midY = m_cropRegion.top() + m_cropRegion.height() / 2;
+ p.drawLine(midX - 10, midY, midX + 10, midY);
+ p.drawLine(midX, midY - 10, midX, midY + 10);
+ }
p.end();
QPainter newp(this);
--- trunk/extragear/graphics/kipi-plugins/printwizard/cropframe.h #888180:888181
@@ -47,6 +47,7 @@
void init(TPhoto *photo, int width, int height, bool autoRotate, bool paint = true);
void setColor(QColor);
QColor color();
+ void drawCropRectangle(bool draw=true) {m_drawRec=draw; };
private:
TPhoto *m_photo;
@@ -58,6 +59,7 @@
QColor m_color;
QRect m_cropRegion;
+ bool m_drawRec;
QRect _screenToPhotoRect(QRect r);
--- trunk/extragear/graphics/kipi-plugins/printwizard/croppage.ui #888180:888181
@@ -42,6 +42,29 @@
</spacer>
</item>
<item>
+ <widget class="QCheckBox" name="m_disableCrop" >
+ <property name="whatsThis" >
+ <string>Don't crop photos, just scale them</string>
+ </property>
+ <property name="text" >
+ <string>Don't crop</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QPushButton" name="BtnCropRotate" >
<property name="toolTip" >
<string>Rotate photo</string>
--- trunk/extragear/graphics/kipi-plugins/printwizard/wizard.cpp #888180:888181
@@ -71,14 +71,19 @@
setupUi(this);
layout()->setMargin(0);
mPage = dialog->addPage(this, title);
+ active = true;
}
KPageWidgetItem* page() const {
return mPage;
}
+ void disable(bool dis=true) {active = !dis;}
+ bool isActive() {return active;}
+
private:
KPageWidgetItem* mPage;
+ bool active;
};
@@ -215,6 +220,14 @@
connect (d->mPhotoPage->ListPhotoSizes, SIGNAL( currentRowChanged(int)),
this, SLOT(ListPhotoSizes_selected()));
+ // don't crop
+ connect (d->mCropPage->m_disableCrop, SIGNAL(stateChanged(int)),
+ this, SLOT(crop_selection(int)));
+
+ // remove a page
+ connect (this, SIGNAL(pageRemoved(KPageWidgetItem *)),
+ this, SLOT(PageRemoved(KPageWidgetItem *)));
+
// Default is A4
d->mInfoPage->CmbPaperSize->setCurrentIndex(A4);
initPhotoSizes(A4); // default to A4 for now.
@@ -228,8 +241,11 @@
readSettings();
if (d->mIntroPage->m_skipIntro->isChecked())
+ {
+ // sometimes it does not disable iteself in time
+ d->mIntroPage->disable();
removePage(d->mIntroPage->page());
-
+ }
}
Wizard::~Wizard() {
@@ -982,8 +998,14 @@
img = img.copy(QRect(x1, y1, w, h));
}
+ else if (d->mCropPage->m_disableCrop->isChecked())
+ {
+ img = img.scaled (photo->cropRegion.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
else
+ {
img = img.copy(photo->cropRegion);
+ }
int x1 = NINT((double)layout->left() * xRatio);
int y1 = NINT((double)layout->top() * yRatio);
@@ -1776,7 +1798,8 @@
group.writeEntry("PhotoSize", d->mPhotoPage->ListPhotoSizes->currentItem()->text());
//skip intro
- group.writeEntry("SkipIntro", d->mIntroPage->m_skipIntro->isChecked());
+ if (d->mIntroPage->isActive())
+ group.writeEntry("SkipIntro", d->mIntroPage->m_skipIntro->isChecked());
#ifdef NOT_YET
// kjobviewer
@@ -1986,7 +2009,34 @@
}
}
+void Wizard::PageRemoved(KPageWidgetItem *page)
+{
+ kDebug();
+ if (page == d->mIntroPage->page())
+ {
+ d->mIntroPage->disable();
+ }
+ else if (page == d->mInfoPage->page())
+ {
+ d->mInfoPage->disable();
+ }
+ else if (page == d->mPhotoPage->page())
+ {
+ d->mPhotoPage->disable();
+ }
+ else if (page == d->mCropPage->page())
+ {
+ d->mCropPage->disable();
+ }
+}
+
+void Wizard::crop_selection(int)
+{
+ d->mCropPage->cropFrame->drawCropRectangle(!d->mCropPage->m_disableCrop->isChecked());
+ update();
+}
+
// this is called when Cancel is clicked.
void Wizard::reject()
{
@@ -2001,10 +2051,7 @@
*/
void Wizard::accept()
{
- saveSettings();
- kDebug() << endl;
-
- // set the default crop regions if not already set
+ // set the default crop regions if not already set
TPhotoSize *s = d->m_photoSizes.at(d->mPhotoPage->ListPhotoSizes->currentRow());
QList<TPhoto*>::iterator it;
int i = 0;
@@ -2049,6 +2096,7 @@
dialog->setWindowTitle(i18n("Print Image"));
bool wantToPrint = dialog->exec();
+ kDebug() << "full page " << printer.fullPage() ;
if (!wantToPrint) {
return;
}
@@ -2091,6 +2139,8 @@
// if (d->m_gimpFiles.count() > 0)
// removeGimpFiles();
+ saveSettings();
+
KAssistantDialog::accept();
}
--- trunk/extragear/graphics/kipi-plugins/printwizard/wizard.h #888180:888181
@@ -79,6 +79,8 @@
virtual void ListPhotoSizes_selected();
virtual void reject();
+ virtual void crop_selection(int);
+ virtual void PageRemoved(KPageWidgetItem *page);
//private slots:
// void updateFinishButton();
More information about the Kde-imaging
mailing list