Index: printdialogpagebase.ui =================================================================== --- printdialogpagebase.ui (revisione 618211) +++ printdialogpagebase.ui (copia locale) @@ -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>&Scale to:</string> </property> <property name="buttonGroupId"> - <number>2</number> + <number>3</number> </property> </widget> <widget class="QLayoutWidget"> Index: printdialog.cpp =================================================================== --- printdialog.cpp (revisione 618211) +++ printdialog.cpp (copia locale) @@ -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(); } Index: document.cpp =================================================================== --- document.cpp (revisione 618211) +++ document.cpp (copia locale) @@ -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(); } Index: printdialog.h =================================================================== --- printdialog.h (revisione 618211) +++ printdialog.h (copia locale) @@ -40,6 +40,12 @@ GV_INCHES }; +enum ScaleId { + GV_NOSCALE=1, + GV_FITTOPAGE, + GV_SCALE +}; + class LIBGWENVIEW_EXPORT PrintDialogPage : public KPrintDialogPage { Q_OBJECT