[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kolourpaint] /: Store last selected scale type in scale/resize dialog
From:       Martin Koller <kollix () aon ! at>
Date:       2011-08-30 20:49:22
Message-ID: 20110830204922.1F878A6078 () git ! kde ! org
[Download RAW message or body]

Git commit b3c18b7d719bb78fa34acfa00a98c3ff9046d10f by Martin Koller.
Committed on 30/08/2011 at 22:46.
Pushed by mkoller into branch 'master'.

Store last selected scale type in scale/resize dialog

BUG: 173142

Handle settings save/restore from the scale/resize dialog only
inside the dialog itself.
Code cleanup (the names of the config entries need not be QStrings
as KConfigGroup converts them then to UTF-8)

M  +0    -2    mainWindow/kpMainWindowPrivate.h
M  +29   -48   dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h
M  +47   -54   kpDefs.h
M  +3    -15   mainWindow/kpMainWindow_Image.cpp
M  +128  -93   dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp
M  +0    -2    mainWindow/kpMainWindow.cpp

http://commits.kde.org/kolourpaint/b3c18b7d719bb78fa34acfa00a98c3ff9046d10f

diff --git a/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp \
b/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp index \
                5bb3e42..19e29f3 100644
--- a/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp
+++ b/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp
@@ -1,6 +1,6 @@
-
 /*
    Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
+   Copyright (c) 2011 Martin Koller <kollix@aon.at>
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,6 @@
 
 #include <math.h>
 
-#include <qapplication.h>
 #include <qboxlayout.h>
 #include <qbuttongroup.h>
 #include <qcheckbox.h>
@@ -42,13 +41,8 @@
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qpixmap.h>
-#include <qpoint.h>
-#include <qpolygon.h>
-#include <qpushbutton.h>
-#include <qrect.h>
 #include <qsize.h>
 #include <qtoolbutton.h>
-#include <qmatrix.h>
 
 #include <kcombobox.h>
 #include <kconfig.h>
@@ -63,11 +57,16 @@
 #include <kpAbstractSelection.h>
 #include <kpDefs.h>
 #include <kpDocument.h>
-#include <kpPixmapFX.h>
 #include <kpTextSelection.h>
 #include <kpTool.h>
 #include <kpTransformDialogEnvironment.h>
 
+//---------------------------------------------------------------------
+
+#define kpSettingResizeScaleLastKeepAspect "Resize Scale - Last Keep \
Aspect" +#define kpSettingResizeScaleScaleType "Resize Scale - ScaleType"
+
+//---------------------------------------------------------------------
 
 #define SET_VALUE_WITHOUT_SIGNAL_EMISSION(knuminput_instance,value)    \
 {                                                                      \
@@ -83,44 +82,37 @@
     m_ignoreKeepAspectRatio--;        \
 }
 
-
-// private static
-kpTransformResizeScaleCommand::Type \
                kpTransformResizeScaleDialog::s_lastType =
-    kpTransformResizeScaleCommand::Resize;
-
-// private static
-double kpTransformResizeScaleDialog::s_lastPercentWidth = 100,
-       kpTransformResizeScaleDialog::s_lastPercentHeight = 100;
-
+//---------------------------------------------------------------------
 
 kpTransformResizeScaleDialog::kpTransformResizeScaleDialog (
         kpTransformDialogEnvironment *_env, QWidget *parent)
     : KDialog (parent),
       m_environ (_env),
-      m_ignoreKeepAspectRatio (0)
+      m_ignoreKeepAspectRatio (0),
+      m_lastType(kpTransformResizeScaleCommand::Resize)
 {
     setCaption( i18nc ("@title:window", "Resize / Scale") );
     setButtons( KDialog::Ok | KDialog::Cancel);
-    // Using the percentage from last time become too confusing so disable \
                for now
-    s_lastPercentWidth = 100, s_lastPercentHeight = 100;
-
 
     QWidget *baseWidget = new QWidget (this);
     setMainWidget (baseWidget);
 
-
-    createActOnBox (baseWidget);
-    createOperationGroupBox (baseWidget);
-    createDimensionsGroupBox (baseWidget);
-
+    KHBox *actOnBox = createActOnBox(baseWidget);
+    QGroupBox *operationGroupBox = createOperationGroupBox(baseWidget);
+    QGroupBox *dimensionsGroupBox = createDimensionsGroupBox(baseWidget);
 
     QVBoxLayout *baseLayout = new QVBoxLayout (baseWidget);
     baseLayout->setSpacing (spacingHint ());
-    baseLayout->setMargin (0/*margin*/);
-    baseLayout->addWidget (m_actOnBox);
-    baseLayout->addWidget (m_operationGroupBox);
-    baseLayout->addWidget (m_dimensionsGroupBox);
+    baseLayout->setMargin(0/*margin*/);
+    baseLayout->addWidget(actOnBox);
+    baseLayout->addWidget(operationGroupBox);
+    baseLayout->addWidget(dimensionsGroupBox);
 
+    KConfigGroup cfg(KGlobal::config(), kpSettingsGroupGeneral);
+    setKeepAspectRatio(cfg.readEntry(kpSettingResizeScaleLastKeepAspect, \
false)); +    m_lastType = static_cast<kpTransformResizeScaleCommand::Type>
+                   (cfg.readEntry(kpSettingResizeScaleScaleType,
+                                  \
static_cast<int>(kpTransformResizeScaleCommand::Resize)));  
     slotActOnChanged ();
 
@@ -129,44 +121,46 @@ \
kpTransformResizeScaleDialog::kpTransformResizeScaleDialog (  \
//enableButtonOk (!isNoOp ());  }
 
-kpTransformResizeScaleDialog::~kpTransformResizeScaleDialog ()
-{
-}
-
-
+//---------------------------------------------------------------------
 // private
+
 kpDocument *kpTransformResizeScaleDialog::document () const
 {
     return m_environ->document ();
 }
 
+//---------------------------------------------------------------------
 // private
+
 kpAbstractSelection *kpTransformResizeScaleDialog::selection () const
 {
     Q_ASSERT (document ());
     return document ()->selection ();
 }
 
+//---------------------------------------------------------------------
 // private
+
 kpTextSelection *kpTransformResizeScaleDialog::textSelection () const
 {
     Q_ASSERT (document ());
     return document ()->textSelection ();
 }
 
-
+//---------------------------------------------------------------------
 // private
-void kpTransformResizeScaleDialog::createActOnBox (QWidget *baseWidget)
+
+KHBox *kpTransformResizeScaleDialog::createActOnBox(QWidget *baseWidget)
 {
-    m_actOnBox = new KHBox (baseWidget);
-    m_actOnBox->setSpacing (spacingHint () * 2);
+    KHBox *actOnBox = new KHBox (baseWidget);
+    actOnBox->setSpacing (spacingHint () * 2);
 
 
-    m_actOnLabel = new QLabel (i18n ("Ac&t on:"), m_actOnBox);
-    m_actOnCombo = new KComboBox (m_actOnBox);
+    QLabel *actOnLabel = new QLabel (i18n ("Ac&t on:"), actOnBox);
+    m_actOnCombo = new KComboBox (actOnBox);
 
 
-    m_actOnLabel->setBuddy (m_actOnCombo);
+    actOnLabel->setBuddy (m_actOnCombo);
 
     m_actOnCombo->insertItem (Image, i18n ("Entire Image"));
     if (selection ())
@@ -181,18 +175,21 @@ void kpTransformResizeScaleDialog::createActOnBox \
(QWidget *baseWidget)  }
     else
     {
-        m_actOnLabel->setEnabled (false);
+        actOnLabel->setEnabled (false);
         m_actOnCombo->setEnabled (false);
     }
 
 
-    m_actOnBox->setStretchFactor (m_actOnCombo, 1);
+    actOnBox->setStretchFactor (m_actOnCombo, 1);
 
 
     connect (m_actOnCombo, SIGNAL (activated (int)),
              this, SLOT (slotActOnChanged ()));
+
+    return actOnBox;
 }
 
+//---------------------------------------------------------------------
 
 static void toolButtonSetLook (QToolButton *button,
                                const QString &iconName,
@@ -201,7 +198,7 @@ static void toolButtonSetLook (QToolButton *button,
     QPixmap icon = UserIcon (iconName);
     button->setIconSize (QSize (icon.width (), icon.height ()));
     button->setIcon (icon);
-    
+
     button->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
     button->setText (name);
     button->setFocusPolicy (Qt::StrongFocus);
@@ -211,10 +208,10 @@ static void toolButtonSetLook (QToolButton *button,
 //---------------------------------------------------------------------
 // private
 
-void kpTransformResizeScaleDialog::createOperationGroupBox (QWidget \
*baseWidget) +QGroupBox \
*kpTransformResizeScaleDialog::createOperationGroupBox (QWidget \
*baseWidget)  {
-    m_operationGroupBox = new QGroupBox (i18n ("Operation"), baseWidget);
-    m_operationGroupBox->setWhatsThis(
+    QGroupBox *operationGroupBox = new QGroupBox (i18n ("Operation"), \
baseWidget); +    operationGroupBox->setWhatsThis(
         i18n ("<qt>"
               "<ul>"
                   "<li><b>Resize</b>: The size of the picture will be"
@@ -233,17 +230,17 @@ void \
kpTransformResizeScaleDialog::createOperationGroupBox (QWidget *baseWidget) \
"</ul>"  "</qt>"));
 
-    m_resizeButton = new QToolButton (m_operationGroupBox);
+    m_resizeButton = new QToolButton (operationGroupBox);
     toolButtonSetLook (m_resizeButton,
                        QLatin1String ("resize"),
                        i18n ("&Resize"));
 
-    m_scaleButton = new QToolButton (m_operationGroupBox);
+    m_scaleButton = new QToolButton (operationGroupBox);
     toolButtonSetLook (m_scaleButton,
                        QLatin1String ("scale"),
                        i18n ("&Scale"));
 
-    m_smoothScaleButton = new QToolButton (m_operationGroupBox);
+    m_smoothScaleButton = new QToolButton (operationGroupBox);
     toolButtonSetLook (m_smoothScaleButton,
                        QLatin1String ("smooth_scale"),
                        i18n ("S&mooth Scale"));
@@ -254,7 +251,7 @@ void \
kpTransformResizeScaleDialog::createOperationGroupBox (QWidget *baseWidget) \
resizeScaleButtonGroup->addButton (m_smoothScaleButton);  
 
-    QGridLayout *operationLayout = new QGridLayout (m_operationGroupBox );
+    QGridLayout *operationLayout = new QGridLayout (operationGroupBox );
     operationLayout->setMargin (marginHint () * 2/*don't overlap groupbox \
title*/);  operationLayout->setSpacing (spacingHint ());
 
@@ -268,63 +265,65 @@ void \
kpTransformResizeScaleDialog::createOperationGroupBox (QWidget *baseWidget) \
this, SLOT (slotTypeChanged ()));  connect (m_smoothScaleButton, SIGNAL \
(toggled (bool)),  this, SLOT (slotTypeChanged ()));
+
+    return operationGroupBox;
 }
 
 //---------------------------------------------------------------------
 // private
 
-void kpTransformResizeScaleDialog::createDimensionsGroupBox (QWidget \
*baseWidget) +QGroupBox \
*kpTransformResizeScaleDialog::createDimensionsGroupBox(QWidget \
*baseWidget)  {
-    m_dimensionsGroupBox = new QGroupBox (i18n ("Dimensions"), \
baseWidget); +    QGroupBox *dimensionsGroupBox = new QGroupBox (i18n \
("Dimensions"), baseWidget);  
-    QLabel *widthLabel = new QLabel (i18n ("Width:"), \
m_dimensionsGroupBox); +    QLabel *widthLabel = new QLabel (i18n \
                ("Width:"), dimensionsGroupBox);
     widthLabel->setAlignment (widthLabel->alignment () | \
                Qt::AlignHCenter);
-    QLabel *heightLabel = new QLabel (i18n ("Height:"), \
m_dimensionsGroupBox); +    QLabel *heightLabel = new QLabel (i18n \
                ("Height:"), dimensionsGroupBox);
     heightLabel->setAlignment (heightLabel->alignment () | \
Qt::AlignHCenter);  
-    QLabel *originalLabel = new QLabel (i18n ("Original:"), \
m_dimensionsGroupBox); +    QLabel *originalLabel = new QLabel (i18n \
("Original:"), dimensionsGroupBox);  m_originalWidthInput = new \
KIntNumInput (  document ()->width ((bool) selection ()),
-        m_dimensionsGroupBox);
-    QLabel *xLabel0 = new QLabel (i18n ("x"), m_dimensionsGroupBox);
+        dimensionsGroupBox);
+    QLabel *xLabel0 = new QLabel (i18n ("x"), dimensionsGroupBox);
     m_originalHeightInput = new KIntNumInput (
         document ()->height ((bool) selection ()),
-        m_dimensionsGroupBox);
+        dimensionsGroupBox);
 
-    QLabel *newLabel = new QLabel (i18n ("&New:"), m_dimensionsGroupBox);
-    m_newWidthInput = new KIntNumInput (m_dimensionsGroupBox);
-    QLabel *xLabel1 = new QLabel (i18n ("x"), m_dimensionsGroupBox);
-    m_newHeightInput = new KIntNumInput (m_dimensionsGroupBox);
+    QLabel *newLabel = new QLabel (i18n ("&New:"), dimensionsGroupBox);
+    m_newWidthInput = new KIntNumInput (dimensionsGroupBox);
+    QLabel *xLabel1 = new QLabel (i18n ("x"), dimensionsGroupBox);
+    m_newHeightInput = new KIntNumInput (dimensionsGroupBox);
 
-    QLabel *percentLabel = new QLabel (i18n ("&Percent:"), \
m_dimensionsGroupBox); +    QLabel *percentLabel = new QLabel (i18n \
                ("&Percent:"), dimensionsGroupBox);
     m_percentWidthInput = new KDoubleNumInput (0.01/*lower*/, \
1000000/*upper*/,  100/*value*/,
-                                               m_dimensionsGroupBox,
+                                               dimensionsGroupBox,
                                                1/*step*/,
                                                2/*precision*/);
     m_percentWidthInput->setSuffix (i18n ("%"));
-    QLabel *xLabel2 = new QLabel (i18n ("x"), m_dimensionsGroupBox);
+    QLabel *xLabel2 = new QLabel (i18n ("x"), dimensionsGroupBox);
     m_percentHeightInput = new KDoubleNumInput (0.01/*lower*/, \
1000000/*upper*/,  100/*value*/,
-                                                m_dimensionsGroupBox,
+                                                dimensionsGroupBox,
                                                 1/*step*/,
                                                 2/*precision*/);
     m_percentHeightInput->setSuffix (i18n ("%"));
 
     m_keepAspectRatioCheckBox = new QCheckBox (i18n ("Keep &aspect \
                ratio"),
-                                               m_dimensionsGroupBox);
+                                               dimensionsGroupBox);
 
 
     m_originalWidthInput->setEnabled (false);
     m_originalHeightInput->setEnabled (false);
     originalLabel->setBuddy (m_originalWidthInput);
     newLabel->setBuddy (m_newWidthInput);
-    m_percentWidthInput->setValue (s_lastPercentWidth);
-    m_percentHeightInput->setValue (s_lastPercentHeight);
+    m_percentWidthInput->setValue (100);
+    m_percentHeightInput->setValue (100);
     percentLabel->setBuddy (m_percentWidthInput);
 
 
-    QGridLayout *dimensionsLayout = new QGridLayout \
(m_dimensionsGroupBox); +    QGridLayout *dimensionsLayout = new \
QGridLayout (dimensionsGroupBox);  dimensionsLayout->setMargin (marginHint \
() * 2);  dimensionsLayout->setSpacing (spacingHint ());
     dimensionsLayout->setColumnStretch (1/*column*/, 1);
@@ -361,7 +360,7 @@ void \
kpTransformResizeScaleDialog::createDimensionsGroupBox (QWidget *baseWidget \
  // COMPAT: KDoubleNumInput only fires valueChanged(double) once per
     //         edit.  It should either fire:
-    //        
+    //
     //             1. At the end of the edit (triggered by clicking or \
tabbing  //                away), like with KDE 3.
     //
@@ -377,10 +376,13 @@ void \
kpTransformResizeScaleDialog::createDimensionsGroupBox (QWidget *baseWidget \
  connect (m_keepAspectRatioCheckBox, SIGNAL (toggled (bool)),
              this, SLOT (setKeepAspectRatio (bool)));
-}
 
+    return dimensionsGroupBox;
+}
 
+//---------------------------------------------------------------------
 // private
+
 void kpTransformResizeScaleDialog::widthFitHeightToAspectRatio ()
 {
     if (m_keepAspectRatioCheckBox->isChecked () && \
!m_ignoreKeepAspectRatio) @@ -393,7 +395,9 @@ void \
kpTransformResizeScaleDialog::widthFitHeightToAspectRatio ()  }
 }
 
+//---------------------------------------------------------------------
 // private
+
 void kpTransformResizeScaleDialog::heightFitWidthToAspectRatio ()
 {
     if (m_keepAspectRatioCheckBox->isChecked () && \
!m_ignoreKeepAspectRatio) @@ -406,28 +410,34 @@ void \
kpTransformResizeScaleDialog::heightFitWidthToAspectRatio ()  }
 }
 
-
+//---------------------------------------------------------------------
 // private
+
 bool kpTransformResizeScaleDialog::resizeEnabled () const
 {
     return (!actOnSelection () ||
             (actOnSelection () && textSelection ()));
 }
 
+//---------------------------------------------------------------------
 // private
+
 bool kpTransformResizeScaleDialog::scaleEnabled () const
 {
     return (!(actOnSelection () && textSelection ()));
 }
 
+//---------------------------------------------------------------------
 // private
+
 bool kpTransformResizeScaleDialog::smoothScaleEnabled () const
 {
     return scaleEnabled ();
 }
 
-
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::slotActOnChanged ()
 {
 #if DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG && 1
@@ -447,7 +457,7 @@ void kpTransformResizeScaleDialog::slotActOnChanged ()
         }
         else
         {
-            if (s_lastType == kpTransformResizeScaleCommand::Scale)
+            if (m_lastType == kpTransformResizeScaleCommand::Scale)
                 m_scaleButton->setChecked (true);
             else
                 m_smoothScaleButton->setChecked (true);
@@ -455,9 +465,9 @@ void kpTransformResizeScaleDialog::slotActOnChanged ()
     }
     else
     {
-        if (s_lastType == kpTransformResizeScaleCommand::Resize)
+        if (m_lastType == kpTransformResizeScaleCommand::Resize)
             m_resizeButton->setChecked (true);
-        else if (s_lastType == kpTransformResizeScaleCommand::Scale)
+        else if (m_lastType == kpTransformResizeScaleCommand::Scale)
             m_scaleButton->setChecked (true);
         else
             m_smoothScaleButton->setChecked (true);
@@ -488,13 +498,16 @@ void kpTransformResizeScaleDialog::slotActOnChanged \
()  setKeepAspectRatio (m_keepAspectRatioCheckBox->isChecked ());
 }
 
-
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::slotTypeChanged ()
 {
-    s_lastType = type ();
+    m_lastType = type ();
 }
 
+//---------------------------------------------------------------------
+
 // public slot
 void kpTransformResizeScaleDialog::slotWidthChanged (int width)
 {
@@ -509,10 +522,11 @@ void kpTransformResizeScaleDialog::slotWidthChanged \
(int width)  widthFitHeightToAspectRatio ();
 
     //enableButtonOk (!isNoOp ());
-    s_lastPercentWidth = newPercentWidth;
 }
 
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::slotHeightChanged (int height)
 {
 #if DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG && 1
@@ -526,10 +540,11 @@ void kpTransformResizeScaleDialog::slotHeightChanged \
(int height)  heightFitWidthToAspectRatio ();
 
     //enableButtonOk (!isNoOp ());
-    s_lastPercentHeight = newPercentHeight;
 }
 
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::slotPercentWidthChanged (double \
percentWidth)  {
 #if DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG && 1
@@ -543,10 +558,11 @@ void \
kpTransformResizeScaleDialog::slotPercentWidthChanged (double percentWidth) \
widthFitHeightToAspectRatio ();  
     //enableButtonOk (!isNoOp ());
-    s_lastPercentWidth = percentWidth;
 }
 
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::slotPercentHeightChanged (double \
percentHeight)  {
 #if DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG && 1
@@ -560,16 +576,11 @@ void \
kpTransformResizeScaleDialog::slotPercentHeightChanged (double percentHeigh \
heightFitWidthToAspectRatio ();  
     //enableButtonOk (!isNoOp ());
-    s_lastPercentHeight = percentHeight;
-}
-
-// public
-bool kpTransformResizeScaleDialog::keepAspectRatio () const
-{
-    return m_keepAspectRatioCheckBox->isChecked ();
 }
 
+//---------------------------------------------------------------------
 // public slot
+
 void kpTransformResizeScaleDialog::setKeepAspectRatio (bool on)
 {
 #if DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG && 1
@@ -583,42 +594,55 @@ void kpTransformResizeScaleDialog::setKeepAspectRatio \
(bool on)  widthFitHeightToAspectRatio ();
 }
 
+//---------------------------------------------------------------------
+
 #undef IGNORE_KEEP_ASPECT_RATIO
 #undef SET_VALUE_WITHOUT_SIGNAL_EMISSION
 
 
+//---------------------------------------------------------------------
 // private
+
 int kpTransformResizeScaleDialog::originalWidth () const
 {
     return document ()->width (actOnSelection ());
 }
 
+//---------------------------------------------------------------------
 // private
+
 int kpTransformResizeScaleDialog::originalHeight () const
 {
     return document ()->height (actOnSelection ());
 }
 
-
+//---------------------------------------------------------------------
 // public
+
 int kpTransformResizeScaleDialog::imageWidth () const
 {
     return m_newWidthInput->value ();
 }
 
+//---------------------------------------------------------------------
 // public
+
 int kpTransformResizeScaleDialog::imageHeight () const
 {
     return m_newHeightInput->value ();
 }
 
+//---------------------------------------------------------------------
 // public
+
 bool kpTransformResizeScaleDialog::actOnSelection () const
 {
     return (m_actOnCombo->currentIndex () == Selection);
 }
 
+//---------------------------------------------------------------------
 // public
+
 kpTransformResizeScaleCommand::Type kpTransformResizeScaleDialog::type () \
const  {
     if (m_resizeButton->isChecked ())
@@ -629,15 +653,18 @@ kpTransformResizeScaleCommand::Type \
kpTransformResizeScaleDialog::type () const  return \
kpTransformResizeScaleCommand::SmoothScale;  }
 
+//---------------------------------------------------------------------
 // public
+
 bool kpTransformResizeScaleDialog::isNoOp () const
 {
     return (imageWidth () == originalWidth () &&
             imageHeight () == originalHeight ());
 }
 
-
+//---------------------------------------------------------------------
 // private slot virtual [base QDialog]
+
 void kpTransformResizeScaleDialog::accept ()
 {
     enum { eText, eSelection, eImage } actionTarget = eText;
@@ -776,7 +803,15 @@ void kpTransformResizeScaleDialog::accept ()
     {
         KDialog::accept ();
     }
+
+    // store settings
+    KConfigGroup cfg(KGlobal::config(), kpSettingsGroupGeneral);
+
+    cfg.writeEntry(kpSettingResizeScaleLastKeepAspect, \
m_keepAspectRatioCheckBox->isChecked()); +    \
cfg.writeEntry(kpSettingResizeScaleScaleType, \
static_cast<int>(m_lastType)); +    cfg.sync();
 }
 
+//---------------------------------------------------------------------
 
 #include <kpTransformResizeScaleDialog.moc>
diff --git a/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h \
b/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h index \
                4f0e2d5..baeb448 100644
--- a/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h
+++ b/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h
@@ -1,6 +1,6 @@
-
 /*
    Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
+   Copyright (c) 2011 Martin Koller <kollix@aon.at>
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,6 @@
 
 class QCheckBox;
 class QGroupBox;
-class QLabel;
 class QToolButton;
 
 class KComboBox;
@@ -55,38 +54,22 @@ class kpTransformResizeScaleDialog : public KDialog
 {
 Q_OBJECT
 
-public:
-    kpTransformResizeScaleDialog (kpTransformDialogEnvironment *_env,
-        QWidget *parent);
-    virtual ~kpTransformResizeScaleDialog ();
+  public:
+    kpTransformResizeScaleDialog(kpTransformDialogEnvironment *_env, \
QWidget *parent);  
     enum ActOn
     {
         Image, Selection
     };
 
-private:
-    static kpTransformResizeScaleCommand::Type s_lastType;
-    static double s_lastPercentWidth, s_lastPercentHeight;
-
-private:
-    kpDocument *document () const;
-    kpAbstractSelection *selection () const;
-    kpTextSelection *textSelection () const;
-
-    void createActOnBox (QWidget *baseWidget);
-    void createOperationGroupBox (QWidget *baseWidget);
-    void createDimensionsGroupBox (QWidget *baseWidget);
-
-    void widthFitHeightToAspectRatio ();
-    void heightFitWidthToAspectRatio ();
+    int imageWidth () const;
+    int imageHeight () const;
+    bool actOnSelection () const;
+    kpTransformResizeScaleCommand::Type type () const;
 
-private:
-    bool resizeEnabled () const;
-    bool scaleEnabled () const;
-    bool smoothScaleEnabled () const;
+    bool isNoOp () const;
 
-public slots:
+  public slots:
     void slotActOnChanged ();
     void slotTypeChanged ();
 
@@ -96,47 +79,45 @@ public slots:
     void slotPercentWidthChanged (double percentWidth);
     void slotPercentHeightChanged (double percentHeight);
 
-public:
-    // (refers only to the state of the checkbox - user of dialog does
-    //  not have to do extra calculations)
-    bool keepAspectRatio () const;
-public slots:
-    void setKeepAspectRatio (bool on);
+  private:
+    kpDocument *document () const;
+    kpAbstractSelection *selection () const;
+    kpTextSelection *textSelection () const;
 
-private:
-    int originalWidth () const;
-    int originalHeight () const;
+    KHBox *createActOnBox(QWidget *baseWidget);
+    QGroupBox *createOperationGroupBox(QWidget *baseWidget);
+    QGroupBox *createDimensionsGroupBox(QWidget *baseWidget);
 
-public:
-    int imageWidth () const;
-    int imageHeight () const;
-    bool actOnSelection () const;
-    kpTransformResizeScaleCommand::Type type () const;
+    void widthFitHeightToAspectRatio ();
+    void heightFitWidthToAspectRatio ();
 
-    bool isNoOp () const;
+    bool resizeEnabled () const;
+    bool scaleEnabled () const;
+    bool smoothScaleEnabled () const;
+    int originalWidth () const;
+    int originalHeight () const;
 
-private slots:
-    virtual void accept ();
+  private slots:
+    virtual void accept();
+    void setKeepAspectRatio(bool on);
 
-private:
+  private:
     kpTransformDialogEnvironment *m_environ;
 
-    KHBox *m_actOnBox;
-    QLabel *m_actOnLabel;
     KComboBox *m_actOnCombo;
 
-    QGroupBox *m_operationGroupBox;
     QToolButton *m_resizeButton,
                 *m_scaleButton,
                 *m_smoothScaleButton;
 
-    QGroupBox *m_dimensionsGroupBox;
     KIntNumInput *m_originalWidthInput, *m_originalHeightInput,
                  *m_newWidthInput, *m_newHeightInput;
     KDoubleNumInput *m_percentWidthInput, *m_percentHeightInput;
     QCheckBox *m_keepAspectRatioCheckBox;
 
     int m_ignoreKeepAspectRatio;
+
+    kpTransformResizeScaleCommand::Type m_lastType;
 };
 
 
diff --git a/kpDefs.h b/kpDefs.h
index c0293a6..ef15cba 100644
--- a/kpDefs.h
+++ b/kpDefs.h
@@ -65,78 +65,71 @@
 // Settings
 //
 
-// (I would use QLatin1String but that doesn't compile with
-//  KConfigBase::readEntry()'s use of QVariant due to the lack of
-//  QLatin1String::QLatin1String(void))
+#define kpSettingsGroupRecentFiles "Recent Files"
 
-#define kpSettingsGroupRecentFiles QString::fromLatin1 ("Recent Files")
+#define kpSettingsGroupGeneral "General Settings"
+#define kpSettingFirstTime "First Time"
+#define kpSettingShowGrid "Show Grid"
+#define kpSettingShowPath "Show Path"
+#define kpSettingColorSimilarity "Color Similarity"
+#define kpSettingDitherOnOpen "Dither on Open if Screen is 15/16bpp and \
Image Num Colors More Than" +#define kpSettingPrintImageCenteredOnPage \
"Print Image Centered On Page" +#define kpSettingOpenImagesInSameWindow \
"Open Images in the Same Window"  
-#define kpSettingsGroupGeneral QString::fromLatin1 ("General Settings")
-#define kpSettingFirstTime QString::fromLatin1 ("First Time")
-#define kpSettingShowGrid QString::fromLatin1 ("Show Grid")
-#define kpSettingShowPath QString::fromLatin1 ("Show Path")
-#define kpSettingColorSimilarity QString::fromLatin1 ("Color Similarity")
-#define kpSettingDitherOnOpen QString::fromLatin1 ("Dither on Open if \
                Screen is 15/16bpp and Image Num Colors More Than")
-#define kpSettingPrintImageCenteredOnPage QString::fromLatin1 ("Print \
                Image Centered On Page")
-#define kpSettingOpenImagesInSameWindow QString::fromLatin1 ("Open Images \
in the Same Window") +#define kpSettingsGroupFileSaveAs "File/Save As"
+#define kpSettingsGroupFileExport "File/Export"
+#define kpSettingsGroupEditCopyTo "Edit/Copy To"
 
-#define kpSettingsGroupFileSaveAs QString::fromLatin1 ("File/Save As")
-#define kpSettingsGroupFileExport QString::fromLatin1 ("File/Export")
-#define kpSettingsGroupEditCopyTo QString::fromLatin1 ("Edit/Copy To")
+#define kpSettingForcedMimeType "Forced MimeType"
+#define kpSettingForcedColorDepth "Forced Color Depth"
+#define kpSettingForcedDither "Forced Dither"
+#define kpSettingForcedQuality "Forced Quality"
 
-#define kpSettingForcedMimeType QString::fromLatin1 ("Forced MimeType")
-#define kpSettingForcedColorDepth QString::fromLatin1 ("Forced Color \
                Depth")
-#define kpSettingForcedDither QString::fromLatin1 ("Forced Dither")
-#define kpSettingForcedQuality QString::fromLatin1 ("Forced Quality")
+#define kpSettingLastDocSize "Last Document Size"
 
-#define kpSettingLastDocSize QString::fromLatin1 ("Last Document Size")
+#define kpSettingMoreEffectsLastEffect "More Effects - Last Effect"
 
-#define kpSettingMoreEffectsLastEffect QString::fromLatin1 ("More Effects \
- Last Effect") +#define kpSettingsGroupMimeTypeProperties "MimeType \
Properties Version 1.2-2" +#define kpSettingMimeTypeMaximumColorDepth \
"Maximum Color Depth" +#define kpSettingMimeTypeHasConfigurableColorDepth \
"Configurable Color Depth" +#define kpSettingMimeTypeHasConfigurableQuality \
"Configurable Quality Setting"  
-#define kpSettingResizeScaleLastKeepAspect QString::fromLatin1 ("Resize \
Scale - Last Keep Aspect")  
+#define kpSettingsGroupUndoRedo "Undo/Redo Settings"
+#define kpSettingUndoMinLimit "Min Limit"
+#define kpSettingUndoMaxLimit "Max Limit"
+#define kpSettingUndoMaxLimitSizeLimit "Max Limit Size Limit"
 
-#define kpSettingsGroupMimeTypeProperties QString::fromLatin1 ("MimeType \
                Properties Version 1.2-2")
-#define kpSettingMimeTypeMaximumColorDepth QString::fromLatin1 ("Maximum \
                Color Depth")
-#define kpSettingMimeTypeHasConfigurableColorDepth QString::fromLatin1 \
                ("Configurable Color Depth")
-#define kpSettingMimeTypeHasConfigurableQuality QString::fromLatin1 \
("Configurable Quality Setting")  
+#define kpSettingsGroupThumbnail "Thumbnail Settings"
+#define kpSettingThumbnailShown "Shown"
+#define kpSettingThumbnailGeometry "Geometry"
+#define kpSettingThumbnailZoomed "Zoomed"
+#define kpSettingThumbnailShowRectangle "ShowRectangle"
 
-#define kpSettingsGroupUndoRedo QString::fromLatin1 ("Undo/Redo Settings")
-#define kpSettingUndoMinLimit QString::fromLatin1 ("Min Limit")
-#define kpSettingUndoMaxLimit QString::fromLatin1 ("Max Limit")
-#define kpSettingUndoMaxLimitSizeLimit QString::fromLatin1 ("Max Limit \
Size Limit")  
+#define kpSettingsGroupPreviewSave "Save Preview Settings"
+#define kpSettingPreviewSaveGeometry "Geometry"
+#define kpSettingPreviewSaveUpdateDelay "Update Delay"
 
-#define kpSettingsGroupThumbnail QString::fromLatin1 ("Thumbnail \
                Settings")
-#define kpSettingThumbnailShown QString::fromLatin1 ("Shown")
-#define kpSettingThumbnailGeometry QString::fromLatin1 ("Geometry")
-#define kpSettingThumbnailZoomed QString::fromLatin1 ("Zoomed")
-#define kpSettingThumbnailShowRectangle QString::fromLatin1 \
("ShowRectangle")  
+#define kpSettingsGroupTools "Tool Settings"
+#define kpSettingLastTool "Last Used Tool"
+#define kpSettingToolBoxIconSize "Tool Box Icon Size"
 
-#define kpSettingsGroupPreviewSave QString::fromLatin1 ("Save Preview \
                Settings")
-#define kpSettingPreviewSaveGeometry QString::fromLatin1 ("Geometry")
-#define kpSettingPreviewSaveUpdateDelay QString::fromLatin1 ("Update \
Delay")  
+#define kpSettingsGroupText "Text Settings"
+#define kpSettingFontFamily "Font Family"
+#define kpSettingFontSize "Font Size"
+#define kpSettingBold "Bold"
+#define kpSettingItalic "Italic"
+#define kpSettingUnderline "Underline"
+#define kpSettingStrikeThru "Strike Thru"
 
-#define kpSettingsGroupTools QString::fromLatin1 ("Tool Settings")
-#define kpSettingLastTool QString::fromLatin1 ("Last Used Tool")
-#define kpSettingToolBoxIconSize QString::fromLatin1 ("Tool Box Icon \
Size")  
-
-#define kpSettingsGroupText QString::fromLatin1 ("Text Settings")
-#define kpSettingFontFamily QString::fromLatin1 ("Font Family")
-#define kpSettingFontSize QString::fromLatin1 ("Font Size")
-#define kpSettingBold QString::fromLatin1 ("Bold")
-#define kpSettingItalic QString::fromLatin1 ("Italic")
-#define kpSettingUnderline QString::fromLatin1 ("Underline")
-#define kpSettingStrikeThru QString::fromLatin1 ("Strike Thru")
-
-
-#define kpSettingsGroupFlattenEffect QString::fromLatin1 ("Flatten Effect \
                Settings")
-#define kpSettingFlattenEffectColor1 QString::fromLatin1 ("Color1")
-#define kpSettingFlattenEffectColor2 QString::fromLatin1 ("Color2")
+#define kpSettingsGroupFlattenEffect "Flatten Effect Settings"
+#define kpSettingFlattenEffectColor1 "Color1"
+#define kpSettingFlattenEffectColor2 "Color2"
 
 
 //
diff --git a/mainWindow/kpMainWindow.cpp b/mainWindow/kpMainWindow.cpp
index 2b5da97..79517ca 100644
--- a/mainWindow/kpMainWindow.cpp
+++ b/mainWindow/kpMainWindow.cpp
@@ -118,7 +118,6 @@ void kpMainWindow::readGeneralSettings ()
     d->configShowGrid = cfg.readEntry (kpSettingShowGrid, false);
     d->configShowPath = cfg.readEntry (kpSettingShowPath, false);
     d->moreEffectsDialogLastEffect = cfg.readEntry \
                (kpSettingMoreEffectsLastEffect, 0);
-    d->resizeScaleDialogLastKeepAspect = cfg.readEntry \
(kpSettingResizeScaleLastKeepAspect, false);  
     if (cfg.hasKey (kpSettingOpenImagesInSameWindow))
     {
@@ -147,7 +146,6 @@ void kpMainWindow::readGeneralSettings ()
                << " showGrid=" << d->configShowGrid
                << " showPath=" << d->configShowPath
                << " moreEffectsDialogLastEffect=" << \
                d->moreEffectsDialogLastEffect
-               << " resizeScaleDialogLastKeepAspect=" << \
                d->resizeScaleDialogLastKeepAspect
                << " openImagesInSameWindow=" << \
                d->configOpenImagesInSameWindow
                << " printImageCenteredOnPage=" << \
d->configPrintImageCenteredOnPage;  #endif
diff --git a/mainWindow/kpMainWindowPrivate.h \
b/mainWindow/kpMainWindowPrivate.h index 5010c1f..b68b26c 100644
--- a/mainWindow/kpMainWindowPrivate.h
+++ b/mainWindow/kpMainWindowPrivate.h
@@ -196,8 +196,6 @@ struct kpMainWindowPrivate
     QAction *actionDrawColorSimilarity;
 
     int moreEffectsDialogLastEffect;
-    bool resizeScaleDialogLastKeepAspect;
-
 
     //
     // Colors Menu
diff --git a/mainWindow/kpMainWindow_Image.cpp \
b/mainWindow/kpMainWindow_Image.cpp index 356e41d..dd60415 100644
--- a/mainWindow/kpMainWindow_Image.cpp
+++ b/mainWindow/kpMainWindow_Image.cpp
@@ -381,9 +381,7 @@ void kpMainWindow::slotResizeScale ()
 {
     toolEndShape ();
 
-
-    kpTransformResizeScaleDialog dialog (transformDialogEnvironment (), \
                this);
-    dialog.setKeepAspectRatio (d->resizeScaleDialogLastKeepAspect);
+    kpTransformResizeScaleDialog dialog(transformDialogEnvironment(), \
this);  
     if (dialog.exec () && !dialog.isNoOp ())
     {
@@ -410,20 +408,10 @@ void kpMainWindow::slotResizeScale ()
             saveDefaultDocSize (QSize (dialog.imageWidth (), \
dialog.imageHeight ()));  }
     }
-
-
-    if (d->resizeScaleDialogLastKeepAspect != dialog.keepAspectRatio ())
-    {
-        d->resizeScaleDialogLastKeepAspect = dialog.keepAspectRatio ();
-
-        KConfigGroup cfg (KGlobal::config (), kpSettingsGroupGeneral);
-
-        cfg.writeEntry (kpSettingResizeScaleLastKeepAspect,
-                         d->resizeScaleDialogLastKeepAspect);
-        cfg.sync ();
-    }
 }
 
+//---------------------------------------------------------------------
+
 // public slot
 void kpMainWindow::slotCrop ()
 {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic