[Digikam-devel] extragear/graphics/digikam/imageplugins/perspective

Gilles Caulier caulier.gilles at gmail.com
Wed Jul 4 12:13:36 BST 2007


SVN commit 683198 by cgilles:

digikam from trunk (KDE4) : complete KDE4 port of Perspective image plugin.
CCMAIL: digikam-devel at kde.org


 M  +12 -15    CMakeLists.txt  
 M  +51 -50    imageeffect_perspective.cpp  
 M  +1 -3      imageeffect_perspective.h  
 M  +3 -2      imageplugin_perspective.cpp  
 M  +1 -2      imageplugin_perspective.h  
 M  +0 -1      matrix.cpp  
 M  +17 -20    perspectivewidget.cpp  
 M  +8 -9      perspectivewidget.h  
 M  +1 -1      triangle.h  


--- trunk/extragear/graphics/digikam/imageplugins/perspective/CMakeLists.txt #683197:683198
@@ -1,22 +1,19 @@
 
-include_directories( ${CMAKE_SOURCE_DIR}/digikam/utilities/imageeditor/editor ${CMAKE_SOURCE_DIR}/digikam/utilities/imageeditor/canvas ${CMAKE_SOURCE_DIR}/digikam/libs/histogram ${CMAKE_SOURCE_DIR}/digikam/libs/levels ${CMAKE_SOURCE_DIR}/digikam/libs/curves ${CMAKE_SOURCE_DIR}/digikam/libs/whitebalance ${CMAKE_SOURCE_DIR}/digikam/libs/widgets/common ${CMAKE_SOURCE_DIR}/digikam/libs/widgets/iccprofiles ${CMAKE_SOURCE_DIR}/digikam/libs/widgets/imageplugins ${CMAKE_SOURCE_DIR}/digikam/libs/dialogs ${CMAKE_SOURCE_DIR}/digikam/libs/dimg ${CMAKE_SOURCE_DIR}/digikam/libs/dmetadata ${CMAKE_SOURCE_DIR}/digikam/libs/dimg/filters ${CMAKE_SOURCE_DIR}/digikam/digikam   )
+SET(digikamimageplugin_perspective_PART_SRCS imageplugin_perspective.cpp
+                                             imageeffect_perspective.cpp
+                                             perspectivewidget.cpp 
+                                             triangle.cpp 
+                                             matrix.cpp 
+   )
 
+KDE4_AUTOMOC(${digikamimageplugin_perspective_PART_SRCS})
 
-########### next target ###############
+KDE4_ADD_PLUGIN(digikamimageplugin_perspective ${digikamimageplugin_perspective_PART_SRCS})
 
-set(digikamimageplugin_perspective_PART_SRCS imageplugin_perspective.cpp imageeffect_perspective.cpp perspectivewidget.cpp triangle.cpp matrix.cpp )
+TARGET_LINK_LIBRARIES(digikamimageplugin_perspective digikam)
 
-kde4_automoc(${digikamimageplugin_perspective_PART_SRCS})
+INSTALL(TARGETS digikamimageplugin_perspective DESTINATION ${PLUGIN_INSTALL_DIR})
 
-kde4_add_plugin(digikamimageplugin_perspective ${digikamimageplugin_perspective_PART_SRCS})
+INSTALL(FILES digikamimageplugin_perspective_ui.rc DESTINATION ${DATA_INSTALL_DIR}/digikam)
+INSTALL(FILES digikamimageplugin_perspective.desktop DESTINATION ${SERVICES_INSTALL_DIR})
 
-target_link_libraries(digikamimageplugin_perspective  digikam )
-
-install(TARGETS digikamimageplugin_perspective DESTINATION ${PLUGIN_INSTALL_DIR} )
-
-
-########### install files ###############
-
-install( FILES  digikamimageplugin_perspective_ui.rc DESTINATION ${DATA_INSTALL_DIR}/digikam )
-install( FILES  digikamimageplugin_perspective.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
-
--- trunk/extragear/graphics/digikam/imageplugins/perspective/imageeffect_perspective.cpp #683197:683198
@@ -24,18 +24,15 @@
 
 // Qt includes. 
  
-#include <q3vgroupbox.h>
-#include <qlabel.h>
-#include <qspinbox.h>
-#include <qpushbutton.h>
+#include <QGroupBox>
+#include <QLabel>
+#include <QSpinBox>
+#include <QPushButton>
+#include <QFrame>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QVBoxLayout>
 
-#include <qlayout.h>
-#include <q3frame.h>
-#include <qcheckbox.h>
-//Added by qt3to4:
-#include <Q3GridLayout>
-#include <Q3VBoxLayout>
-
 // KDE includes.
 
 #include <kcolorbutton.h>
@@ -92,16 +89,17 @@
     
     // -------------------------------------------------------------
    
-    QWidget * plain = new QWidget(this);
-   setMainWidget(plain); 
-    QFrame *frame = new Q3Frame(plain);
-    frame->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken);
-    Q3VBoxLayout* l  = new Q3VBoxLayout(frame, 5, 0);
+    QFrame *frame = new QFrame(mainWidget());
+    frame->setFrameStyle(QFrame::Panel|QFrame::Sunken);
+    QVBoxLayout* l  = new QVBoxLayout(frame);
     m_previewWidget = new PerspectiveWidget(525, 350, frame);
+    m_previewWidget->setWhatsThis( i18n("<p>This is the perspective transformation operation preview. "
+                                        "You can use the mouse for dragging the corner to adjust the "
+                                        "perspective transformation area."));
+
+    l->setMargin(5);
+    l->setSpacing(0);
     l->addWidget(m_previewWidget);
-    m_previewWidget->setWhatsThis( i18n("<p>This is the perspective transformation operation preview. "
-                                           "You can use the mouse for dragging the corner to adjust the "
-                                           "perspective transformation area."));
     setPreviewAreaWidget(frame); 
     
     // -------------------------------------------------------------
@@ -109,8 +107,8 @@
     QString temp;
     Digikam::ImageIface iface(0, 0);
 
-    QWidget *gbox2          = new QWidget(plain);
-    Q3GridLayout *gridLayout = new Q3GridLayout( gbox2, 13, 2, spacingHint());
+    QWidget *gbox2          = new QWidget(mainWidget());
+    QGridLayout *gridLayout = new QGridLayout(gbox2);
 
     QLabel *label1  = new QLabel(i18n("New width:"), gbox2);
     m_newWidthLabel = new QLabel(temp.setNum( iface.originalWidth()) + i18n(" px"), gbox2);
@@ -120,11 +118,6 @@
     m_newHeightLabel = new QLabel(temp.setNum( iface.originalHeight()) + i18n(" px"), gbox2);
     m_newHeightLabel->setAlignment( Qt::AlignBottom | Qt::AlignRight );
     
-    gridLayout->addMultiCellWidget(label1, 0, 0, 0, 0);
-    gridLayout->addMultiCellWidget(m_newWidthLabel, 0, 0, 1, 2);
-    gridLayout->addMultiCellWidget(label2, 1, 1, 0, 0);
-    gridLayout->addMultiCellWidget(m_newHeightLabel, 1, 1, 1, 2);
-    
     // -------------------------------------------------------------
     
     KSeparator *line = new KSeparator (Qt::Horizontal, gbox2);
@@ -139,6 +132,33 @@
     QLabel *label6 = new QLabel(i18n("  Bottom right:"), gbox2);
     m_bottomRightAngleLabel = new QLabel(gbox2);
     
+    // -------------------------------------------------------------
+
+    KSeparator *line2         = new KSeparator (Qt::Horizontal, gbox2);
+    m_drawWhileMovingCheckBox = new QCheckBox(i18n("Draw preview while moving"), gbox2);
+    m_drawGridCheckBox        = new QCheckBox(i18n("Draw grid"), gbox2);
+
+    // -------------------------------------------------------------
+
+    QLabel *label7 = new QLabel(i18n("Guide color:"), gbox2);
+    m_guideColorBt = new KColorButton( QColor( Qt::red ), gbox2 );
+    m_guideColorBt->setWhatsThis( i18n("<p>Set here the color used to draw guides dashed-lines."));
+
+    QLabel *space  = new QLabel(gbox2);
+    space->setFixedHeight(spacingHint());
+
+    QLabel *label8 = new QLabel(i18n("Guide width:"), gbox2);
+    m_guideSize    = new QSpinBox(gbox2);
+    m_guideSize->setRange(1, 5);
+    m_guideSize->setSingleStep(1);
+    m_guideSize->setWhatsThis( i18n("<p>Set here the width in pixels used to draw guides dashed-lines."));
+
+    gridLayout->setMargin(spacingHint());
+    gridLayout->setSpacing(0);
+    gridLayout->addMultiCellWidget(label1, 0, 0, 0, 0);
+    gridLayout->addMultiCellWidget(m_newWidthLabel, 0, 0, 1, 2);
+    gridLayout->addMultiCellWidget(label2, 1, 1, 0, 0);
+    gridLayout->addMultiCellWidget(m_newHeightLabel, 1, 1, 1, 2);
     gridLayout->addMultiCellWidget(line, 2, 2, 0, 2);
     gridLayout->addMultiCellWidget(angleLabel, 3, 3, 0, 2);
     gridLayout->addMultiCellWidget(label3, 4, 4, 0, 0);
@@ -149,35 +169,17 @@
     gridLayout->addMultiCellWidget(m_bottomLeftAngleLabel, 6, 6, 1, 2);
     gridLayout->addMultiCellWidget(label6, 7, 7, 0, 0);
     gridLayout->addMultiCellWidget(m_bottomRightAngleLabel, 7, 7, 1, 2);
-
-    // -------------------------------------------------------------
-
-    KSeparator *line2 = new KSeparator (Qt::Horizontal, gbox2);
-
-    m_drawWhileMovingCheckBox = new QCheckBox(i18n("Draw preview while moving"), gbox2);
     gridLayout->addMultiCellWidget(line2, 8, 8, 0, 2);
     gridLayout->addMultiCellWidget(m_drawWhileMovingCheckBox, 9, 9, 0, 2);
-
-    m_drawGridCheckBox = new QCheckBox(i18n("Draw grid"), gbox2);
     gridLayout->addMultiCellWidget(m_drawGridCheckBox, 10, 10, 0, 2);
-
-    // -------------------------------------------------------------
-
-    QLabel *label7 = new QLabel(i18n("Guide color:"), gbox2);
-    m_guideColorBt = new KColorButton( QColor( Qt::red ), gbox2 );
-    m_guideColorBt->setWhatsThis( i18n("<p>Set here the color used to draw guides dashed-lines."));
     gridLayout->addMultiCellWidget(label7, 11, 11, 0, 0);
     gridLayout->addMultiCellWidget(m_guideColorBt, 11, 11, 2, 2);
+    gridLayout->addMultiCellWidget(space, 12, 12, 0, 2);
+    gridLayout->addMultiCellWidget(label8, 13, 13, 0, 0);
+    gridLayout->addMultiCellWidget(m_guideSize, 13, 13, 2, 2);
+    gridLayout->setColumnStretch(1, 10);
+    gridLayout->setRowStretch(14, 10);
 
-    QLabel *label8 = new QLabel(i18n("Guide width:"), gbox2);
-    m_guideSize    = new QSpinBox( 1, 5, 1, gbox2);
-    m_guideSize->setWhatsThis( i18n("<p>Set here the width in pixels used to draw guides dashed-lines."));
-    gridLayout->addMultiCellWidget(label8, 12, 12, 0, 0);
-    gridLayout->addMultiCellWidget(m_guideSize, 12, 12, 2, 2);
-
-    gridLayout->setColStretch(1, 10);
-    gridLayout->setRowStretch(13, 10);
-
     setUserAreaWidget(gbox2);
 
     // -------------------------------------------------------------
@@ -255,4 +257,3 @@
 }
 
 }  // NameSpace DigikamPerspectiveImagesPlugin
-
--- trunk/extragear/graphics/digikam/imageplugins/perspective/imageeffect_perspective.h #683197:683198
@@ -26,9 +26,7 @@
 
 // Qt includes.
 
-#include <qrect.h>
-//Added by qt3to4:
-#include <QLabel>
+#include <QRect>
 
 // Digikam includes.
 
--- trunk/extragear/graphics/digikam/imageplugins/perspective/imageplugin_perspective.cpp #683197:683198
@@ -45,7 +45,9 @@
 {
     m_perspectiveAction  = new KAction(KIcon("perspective"), i18n("Perspective Adjustment..."), this);
     actionCollection()->addAction("imageplugin_perspective", m_perspectiveAction );
-    connect(m_perspectiveAction, SIGNAL(triggered(bool) ), SLOT(slotPerspective()));
+
+    connect(m_perspectiveAction, SIGNAL(triggered(bool)), 
+            this, SLOT(slotPerspective()));
     
     setXMLFile("digikamimageplugin_perspective_ui.rc");      
                                     
@@ -66,4 +68,3 @@
     DigikamPerspectiveImagesPlugin::ImageEffect_Perspective dlg(parentWidget());
     dlg.exec();
 }
-
--- trunk/extragear/graphics/digikam/imageplugins/perspective/imageplugin_perspective.h #683197:683198
@@ -37,8 +37,7 @@
     
 public:
 
-    ImagePlugin_Perspective(QObject *parent,
-                         const QStringList &args);
+    ImagePlugin_Perspective(QObject *parent, const QStringList &args);
     ~ImagePlugin_Perspective();
 
     void setEnabledActions(bool enable);
--- trunk/extragear/graphics/digikam/imageplugins/perspective/matrix.cpp #683197:683198
@@ -26,7 +26,6 @@
  * 
  * ============================================================ */
 
-
 // C++ includes.
 
 #include <cstring>
--- trunk/extragear/graphics/digikam/imageplugins/perspective/perspectivewidget.cpp #683197:683198
@@ -25,7 +25,6 @@
  * 
  * ============================================================ */
 
-
 // C++ includes.
 
 #include <cstdio>
@@ -34,14 +33,12 @@
 
 // Qt includes.
 
-#include <qregion.h>
-#include <qpainter.h>
-#include <qpen.h>
-#include <qbrush.h>
-#include <qpixmap.h>
-#include <qimage.h>
-#include <q3pointarray.h>
-//Added by qt3to4:
+#include <QRegion>
+#include <QPainter>
+#include <QPen>
+#include <QBrush>
+#include <QPixmap>
+#include <QImage>
 #include <QResizeEvent>
 #include <QMouseEvent>
 #include <QPaintEvent>
@@ -66,8 +63,9 @@
 {
 
 PerspectiveWidget::PerspectiveWidget(int w, int h, QWidget *parent)
-                 : QWidget(parent, 0, Qt::WDestructiveClose)
+                 : QWidget(parent)
 {
+    setAttribute(Qt::WA_DeleteOnClose);
     setBackgroundMode(Qt::NoBackground);
     setMinimumSize(w, h);
     setMouseTracking(true);
@@ -185,7 +183,7 @@
 
     m_antiAlias = true;
     updatePixmap();
-    repaint(false);
+    repaint();
 }
 
 void PerspectiveWidget::applyPerspectiveAdjustment(void)
@@ -215,7 +213,7 @@
 {
     m_antiAlias = a; 
     updatePixmap();
-    repaint(false);
+    repaint();
 }
 
 void PerspectiveWidget::slotToggleDrawWhileMoving(bool draw)
@@ -227,21 +225,21 @@
 {
     m_drawGrid = grid;
     updatePixmap();
-    repaint(false);
+    repaint();
 }
 
 void PerspectiveWidget::slotChangeGuideColor(const QColor &color)
 {
     m_guideColor = color;
     updatePixmap();
-    repaint(false);
+    repaint();
 }
 
 void PerspectiveWidget::slotChangeGuideSize(int size)
 {
     m_guideSize = size;
     updatePixmap();
-    repaint(false);
+    repaint();
 }
 
 void PerspectiveWidget::updatePixmap(void)
@@ -587,7 +585,7 @@
                 int u = iu - u1;
                 int v = iv - v1;
 
-                //TODO: Check why antialiasing shows no effect
+                //TODO: Check why antialiasing doesn't work
                 /*if (m_antiAlias)
                 {
                     if (sixteenBit)
@@ -710,7 +708,7 @@
         if (!m_drawWhileMoving)
         {
             updatePixmap();
-            repaint(false);
+            repaint();
         }
     }
     else
@@ -718,7 +716,7 @@
         m_spot.setX(e->x()-m_rect.x());
         m_spot.setY(e->y()-m_rect.y());
         updatePixmap();
-        repaint(false);
+        repaint();
     }
 }
 
@@ -823,7 +821,7 @@
             }
 
             updatePixmap();
-            repaint(false);
+            repaint();
         }
     }
     else
@@ -841,4 +839,3 @@
 }
 
 }  // NameSpace DigikamPerspectiveImagesPlugin
-
--- trunk/extragear/graphics/digikam/imageplugins/perspective/perspectivewidget.h #683197:683198
@@ -27,12 +27,11 @@
 
 // Qt includes.
 
-#include <qwidget.h>
-#include <qpoint.h>
-#include <q3pointarray.h>
-#include <qcolor.h>
-#include <qrect.h>
-//Added by qt3to4:
+#include <QWidget>
+#include <QPoint>
+#include <Q3PointArray>
+#include <QColor>
+#include <QRect>
 #include <QPixmap>
 #include <QResizeEvent>
 #include <QMouseEvent>
@@ -92,8 +91,8 @@
 
 signals:
 
-    void signalPerspectiveChanged( QRect newSize, float topLeftAngle, float topRightAngle,
-                                   float bottomLeftAngle, float bottomRightAngle );   
+    void signalPerspectiveChanged(QRect newSize, float topLeftAngle, float topRightAngle,
+                                   float bottomLeftAngle, float bottomRightAngle);   
 
 protected:
 
@@ -163,7 +162,7 @@
     QColor               m_guideColor;
 
     // 60 points will be stored to compute a grid of 15x15 lines.
-    Q3PointArray          m_grid;
+    Q3PointArray         m_grid;
 
     QPixmap             *m_pixmap;
 
--- trunk/extragear/graphics/digikam/imageplugins/perspective/triangle.h #683197:683198
@@ -26,7 +26,7 @@
 
 // Qt includes.
 
-#include <qpoint.h>
+#include <QPoint>
 
 namespace DigikamPerspectiveImagesPlugin
 {



More information about the Digikam-devel mailing list