extragear/graphics/gwenview/gvcore

Angelo Naselli <[email protected]>
Newsgroups gmane.comp.kde.gwenview
Message-ID <[email protected]>
SVN commit 618214 by anaselli:

gwenview now prints a picture at a time, if more than one are selected only the last one is printed.

BUG: 111641
CCMAIL: gwenview-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

 M  +3 -3      document.cpp  
 M  +17 -10    printdialog.cpp  
 M  +6 -0      printdialog.h  
 M  +3 -3      printdialogpagebase.ui  


--- trunk/extragear/graphics/gwenview/gvcore/document.cpp #618213:618214
@@ -388,13 +388,13 @@
 	int scaling = printer->option( "app-gwenview-scale" ).toInt();
 
 	QSize size = image.size();
-	if (scaling==1 /* Fit to page */) {
+	if (scaling==GV_FITTOPAGE /* Fit to page */) {
 		bool enlargeToFit = printer->option( "app-gwenview-enlargeToFit" ) != f;
 		if ((image.width() > pdWidth || image.height() > pdHeight) || enlargeToFit) {
 			size.scale( pdWidth, pdHeight, QSize::ScaleMin );
 		}
 	} else {
-		if (scaling==2 /* Scale To */) {
+		if (scaling==GV_SCALE /* Scale To */) {
 			int unit = (printer->option("app-gwenview-scaleUnit").isEmpty() ?
 				GV_INCHES : printer->option("app-gwenview-scaleUnit").toInt());
 			double inches = 1;
@@ -410,7 +410,7 @@
 			size.setWidth( int(wImg * printer->resolution()) );
 			size.setHeight( int(hImg * printer->resolution()) );
 		} else {
-			/* No scaling */
+			/* GV_NOSCALE: no scaling */
 			size = image.size();
 		}
 
--- trunk/extragear/graphics/gwenview/gvcore/printdialog.cpp #618213:618214
@@ -37,6 +37,7 @@
 #include "document.h"
 #include "printdialogpagebase.h"
 #include "printdialog.moc"
+
 namespace Gwenview {
 
 
@@ -99,9 +100,9 @@
 	opts["app-gwenview-printFilename"] = mContent->mAddFileName->isChecked() ? STR_TRUE : STR_FALSE;
 	opts["app-gwenview-printComment"] = mContent->mAddComment->isChecked() ? STR_TRUE : STR_FALSE;
 	opts["app-gwenview-scale"] = QString::number(
-		mContent->mNoScale->isChecked() ? 0
-		: mContent->mFitToPage->isChecked() ? 1
-		: 2);
+		mContent->mNoScale->isChecked() ? GV_NOSCALE
+		: mContent->mFitToPage->isChecked() ? GV_FITTOPAGE
+		: GV_SCALE);
 	opts["app-gwenview-fitToPage"] = mContent->mFitToPage->isChecked() ? STR_TRUE : STR_FALSE;
 	opts["app-gwenview-enlargeToFit"] = mContent->mEnlargeToFit->isChecked() ? STR_TRUE : STR_FALSE;
 
@@ -125,13 +126,14 @@
 
 	mContent->mAddFileName->setChecked( opts["app-gwenview-printFilename"] == STR_TRUE );
 	mContent->mAddComment->setChecked( opts["app-gwenview-printComment"] == STR_TRUE );
-	
-	val = opts["app-gwenview-scale"].toInt( &ok );
-	if (ok) {
-		mContent->mScaleGroup->setButton( val );
-	} else {
-		mContent->mScaleGroup->setButton( 0 );
-	}
+	// Starts from id 1 because 0 is returned if not ok, and seems to have a weird
+	// problem with id 2 (last id) otherwise :(
+	ScaleId scaleButtonId = static_cast<ScaleId>( opts["app-gwenview-scale"].toInt( &ok ) );
+ 	if (ok) {
+		mContent->mScaleGroup->setButton( scaleButtonId );
+ 	} else {
+ 		mContent->mScaleGroup->setButton( GV_NOSCALE );
+ 	}
 	mContent->mEnlargeToFit->setChecked( opts["app-gwenview-enlargeToFit"] == STR_TRUE );
 
 	Unit unit = static_cast<Unit>( opts["app-gwenview-scaleUnit"].toInt( &ok ) );
@@ -250,12 +252,17 @@
 
 void PrintDialogPage::toggleRatio(bool enable) {
 	if (!enable) return;
+	// choosing a startup value of 15x10 cm (common photo dimention)
+	// mContent->mHeight->value() or mContent->mWidth->value()
+	// are usually empty at startup and hxw (0x0) isn't good IMO keeping ratio
 	double hValue, wValue;
 	if (mDocument->height() > mDocument->width()) {
 		hValue = mContent->mHeight->value();
+		if (!hValue) hValue = 150*unitToMM(mPreviousUnit);
 		wValue = (mDocument->width() * hValue)/ mDocument->height();
 	} else {
 		wValue = mContent->mWidth->value();
+		if (!wValue) wValue = 150*unitToMM(mPreviousUnit);
 		hValue = (mDocument->height() * wValue)/ mDocument->width();
 	}
 	
--- trunk/extragear/graphics/gwenview/gvcore/printdialog.h #618213:618214
@@ -40,6 +40,12 @@
 	GV_INCHES
 };
 
+enum ScaleId {
+	GV_NOSCALE=1,
+	GV_FITTOPAGE,
+	GV_SCALE
+};
+
 class LIBGWENVIEW_EXPORT PrintDialogPage : public KPrintDialogPage {
 	Q_OBJECT
 
--- trunk/extragear/graphics/gwenview/gvcore/printdialogpagebase.ui #618213:618214
@@ -151,7 +151,7 @@
                         <bool>true</bool>
                     </property>
                     <property name="buttonGroupId">
-                        <number>0</number>
+                        <number>1</number>
                     </property>
                 </widget>
                 <widget class="QRadioButton">
@@ -165,7 +165,7 @@
                         <bool>false</bool>
                     </property>
                     <property name="buttonGroupId">
-                        <number>1</number>
+                        <number>2</number>
                     </property>
                 </widget>
                 <widget class="QLayoutWidget">
@@ -231,7 +231,7 @@
                         <string>&amp;Scale to:</string>
                     </property>
                     <property name="buttonGroupId">
-                        <number>2</number>
+                        <number>3</number>
                     </property>
                 </widget>
                 <widget class="QLayoutWidget">

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.