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

Gilles Caulier caulier.gilles at gmail.com
Fri Jul 6 15:35:50 BST 2007


SVN commit 684355 by cgilles:

digiKam from trunk : BCG tool is now ported to KDE4
CCMAIL: digikam-devel at kde.org


 M  +1 -1      CMakeLists.txt  
 M  +71 -71    imageeffect_bcg.cpp  
 M  +9 -10     imageplugin_core.cpp  


--- trunk/extragear/graphics/digikam/imageplugins/coreplugin/CMakeLists.txt #684354:684355
@@ -42,7 +42,7 @@
 SET(digikamimageplugin_core_PART_SRCS 
     ${liblapack_SRCS} 
     ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageplugin_core.cpp 
-#    ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageeffect_bcg.cpp 
+    ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageeffect_bcg.cpp 
 #    ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageeffect_rgb.cpp 
 #    ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageeffect_blur.cpp 
 #    ${CMAKE_SOURCE_DIR}/digikam/imageplugins/coreplugin/imageeffect_autocorrection.cpp 
--- trunk/extragear/graphics/digikam/imageplugins/coreplugin/imageeffect_bcg.cpp #684354:684355
@@ -25,24 +25,16 @@
 
 // Qt includes.
  
-#include <qcolor.h>
-#include <q3groupbox.h>
-#include <q3hgroupbox.h>
-#include <q3vgroupbox.h>
-#include <Q3HButtonGroup> 
-#include <qlabel.h>
-
-#include <qlayout.h>
-#include <q3frame.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-
-#include <qtooltip.h>
-//Added by qt3to4:
-#include <Q3HBoxLayout>
-#include <Q3GridLayout>
+#include <QColor>
+#include <QGroupBox>
+#include <QButtonGroup> 
+#include <QLabel>
+#include <QFrame>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QHBoxLayout>
+#include <QGridLayout>
 #include <QPixmap>
 
 // KDE includes.
@@ -80,7 +72,7 @@
     m_destinationPreviewData = 0L;
     setHelp("bcgadjusttool.anchor", "digikam");
 
-    m_previewWidget = new Digikam::ImageWidget("bcgadjust Tool Dialog", plainPage(),
+    m_previewWidget = new Digikam::ImageWidget("bcgadjust Tool Dialog", mainWidget(),
                                                i18n("<p>Here you can see the image "
                                                "brightness-contrast-gamma adjustments preview. "
                                                "You can pick color on image "
@@ -89,55 +81,56 @@
 
     // -------------------------------------------------------------
                 
-    QWidget *gboxSettings     = new QWidget(plainPage());
-    Q3GridLayout* gridSettings = new Q3GridLayout( gboxSettings, 9, 4, spacingHint());
+    QWidget *gboxSettings     = new QWidget(mainWidget());
+    QGridLayout* gridSettings = new QGridLayout( gboxSettings );
 
     QLabel *label1 = new QLabel(i18n("Channel:"), gboxSettings);
     label1->setAlignment ( Qt::AlignRight | Qt::AlignVCenter );
-    m_channelCB = new QComboBox( false, gboxSettings );
-    m_channelCB->insertItem( i18n("Luminosity") );
-    m_channelCB->insertItem( i18n("Red") );
-    m_channelCB->insertItem( i18n("Green") );
-    m_channelCB->insertItem( i18n("Blue") );
+    m_channelCB = new QComboBox( gboxSettings );
+    m_channelCB->addItem( i18n("Luminosity") );
+    m_channelCB->addItem( i18n("Red") );
+    m_channelCB->addItem( i18n("Green") );
+    m_channelCB->addItem( i18n("Blue") );
     m_channelCB->setWhatsThis( i18n("<p>Select here the histogram channel to display:<p>"
-                                       "<b>Luminosity</b>: display the image's luminosity values.<p>"
-                                       "<b>Red</b>: display the red image-channel values.<p>"
-                                       "<b>Green</b>: display the green image-channel values.<p>"
-                                       "<b>Blue</b>: display the blue image-channel values.<p>"));
+                                    "<b>Luminosity</b>: display the image's luminosity values.<p>"
+                                    "<b>Red</b>: display the red image-channel values.<p>"
+                                    "<b>Green</b>: display the green image-channel values.<p>"
+                                    "<b>Blue</b>: display the blue image-channel values.<p>"));
 
-    m_scaleBG = new Q3HButtonGroup(gboxSettings);
-    m_scaleBG->setExclusive(true);
-    m_scaleBG->setFrameShape(QFrame::NoFrame);
-    m_scaleBG->setInsideMargin( 0 );
-    m_scaleBG->setWhatsThis( i18n("<p>Select here the histogram scale.<p>"
-                                     "If the image's maximal counts are small, you can use the linear scale.<p>"
-                                     "Logarithmic scale can be used when the maximal counts are big; "
-                                     "if it is used, all values (small and large) will be visible on the graph."));
+    QWidget *scaleBox = new QWidget(gboxSettings);
+    QHBoxLayout *hlay = new QHBoxLayout(scaleBox);
+    m_scaleBG         = new QButtonGroup(scaleBox);
+    scaleBox->setWhatsThis(i18n("<p>Select here the histogram scale.<p>"
+                                "If the image's maximal counts are small, you can use the linear scale.<p>"
+                                "Logarithmic scale can be used when the maximal counts are big; "
+                                "if it is used, all values (small and large) will be visible on the graph."));
     
-    QPushButton *linHistoButton = new QPushButton( m_scaleBG );
+    QPushButton *linHistoButton = new QPushButton( scaleBox );
     linHistoButton->setToolTip( i18n( "<p>Linear" ) );
-    m_scaleBG->insert(linHistoButton, Digikam::HistogramWidget::LinScaleHistogram);
-    KGlobal::dirs()->addResourceType("histogram-lin", KGlobal::dirs()->kde_default("data") + "digikam/data");
-    QString directory = KGlobal::dirs()->findResourceDir("histogram-lin", "histogram-lin.png");
-    linHistoButton->setPixmap( QPixmap( directory + "histogram-lin.png" ) );
-    linHistoButton->setToggleButton(true);
+    linHistoButton->setIcon(QPixmap(KStandardDirs::locate("data", "digikam/data/histogram-lin.png")));
+    linHistoButton->setCheckable(true);
+    m_scaleBG->addButton(linHistoButton, Digikam::HistogramWidget::LinScaleHistogram);
     
-    QPushButton *logHistoButton = new QPushButton( m_scaleBG );
+    QPushButton *logHistoButton = new QPushButton( scaleBox );
     logHistoButton->setToolTip( i18n( "<p>Logarithmic" ) );
-    m_scaleBG->insert(logHistoButton, Digikam::HistogramWidget::LogScaleHistogram);
-    KGlobal::dirs()->addResourceType("histogram-log", KGlobal::dirs()->kde_default("data") + "digikam/data");
-    directory = KGlobal::dirs()->findResourceDir("histogram-log", "histogram-log.png");
-    logHistoButton->setPixmap( QPixmap( directory + "histogram-log.png" ) );
-    logHistoButton->setToggleButton(true);       
+    logHistoButton->setIcon(QPixmap(KStandardDirs::locate("data", "digikam/data/histogram-log.png")));
+    logHistoButton->setCheckable(true);
+    m_scaleBG->addButton(logHistoButton, Digikam::HistogramWidget::LogScaleHistogram);
+    
+    hlay->setMargin(0);
+    hlay->setSpacing(0);
+    hlay->addWidget(linHistoButton);
+    hlay->addWidget(logHistoButton);
 
-    Q3HBoxLayout* l1 = new Q3HBoxLayout();
+    m_scaleBG->setExclusive(true);
+    logHistoButton->setChecked(true);
+
+    QHBoxLayout* l1 = new QHBoxLayout();
     l1->addWidget(label1);
     l1->addWidget(m_channelCB);
     l1->addStretch(10);
-    l1->addWidget(m_scaleBG);
+    l1->addWidget(scaleBox);
     
-    gridSettings->addMultiCellLayout(l1, 0, 0, 0, 4);
-
     // -------------------------------------------------------------
 
     KVBox *histoBox   = new KVBox(gboxSettings);
@@ -150,8 +143,6 @@
     m_hGradient = new Digikam::ColorGradientWidget( Digikam::ColorGradientWidget::Horizontal, 10, histoBox );
     m_hGradient->setColors( QColor( "black" ), QColor( "white" ) );
     
-    gridSettings->addMultiCellWidget(histoBox, 1, 2, 0, 4);
-
     // -------------------------------------------------------------
 
     QLabel *label2 = new QLabel(i18n("Brightness:"), gboxSettings);
@@ -159,16 +150,12 @@
     m_bInput->setRange(-100, 100, 1, true);
     m_bInput->setValue(0);
     m_bInput->setWhatsThis( i18n("<p>Set here the brightness adjustment of the image."));
-    gridSettings->addMultiCellWidget(label2, 3, 3, 0, 4);
-    gridSettings->addMultiCellWidget(m_bInput, 4, 4, 0, 4);
 
     QLabel *label3 = new QLabel(i18n("Contrast:"), gboxSettings);
     m_cInput       = new KIntNumInput(gboxSettings);
     m_cInput->setRange(-100, 100, 1, true);
     m_cInput->setValue(0);
     m_cInput->setWhatsThis( i18n("<p>Set here the contrast adjustment of the image."));
-    gridSettings->addMultiCellWidget(label3, 5, 5, 0, 4);
-    gridSettings->addMultiCellWidget(m_cInput, 6, 6, 0, 4);
 
     QLabel *label4 = new QLabel(i18n("Gamma:"), gboxSettings);
     m_gInput = new KDoubleNumInput(gboxSettings);
@@ -176,10 +163,21 @@
     m_gInput->setRange(0.1, 3.0, 0.01, true);
     m_gInput->setValue(1.0);
     m_gInput->setWhatsThis( i18n("<p>Set here the gamma adjustment of the image."));
+
+    // -------------------------------------------------------------
+
+    gridSettings->addMultiCellLayout(l1, 0, 0, 0, 4);
+    gridSettings->addMultiCellWidget(histoBox, 1, 2, 0, 4);
+    gridSettings->addMultiCellWidget(label2, 3, 3, 0, 4);
+    gridSettings->addMultiCellWidget(m_bInput, 4, 4, 0, 4);
+    gridSettings->addMultiCellWidget(label3, 5, 5, 0, 4);
+    gridSettings->addMultiCellWidget(m_cInput, 6, 6, 0, 4);
     gridSettings->addMultiCellWidget(label4, 7, 7, 0, 4);
     gridSettings->addMultiCellWidget(m_gInput, 8, 8, 0, 4);
+    gridSettings->setRowStretch(9, 10);    
+    gridSettings->setMargin(spacingHint());
+    gridSettings->setSpacing(spacingHint());
 
-    gridSettings->setRowStretch(9, 10);    
     setUserAreaWidget(gboxSettings);
     
     // -------------------------------------------------------------
@@ -187,7 +185,7 @@
     connect(m_channelCB, SIGNAL(activated(int)),
             this, SLOT(slotChannelChanged(int)));
 
-    connect(m_scaleBG, SIGNAL(released(int)),
+    connect(m_scaleBG, SIGNAL(buttonReleased(int)),
             this, SLOT(slotScaleChanged(int)));
 
     connect(m_previewWidget, SIGNAL(spotPositionChangedFromTarget( const Digikam::DColor &, const QPoint & )),
@@ -246,13 +244,13 @@
             break;
     }
 
-    m_histogramWidget->repaint(false);
+    m_histogramWidget->repaint();
 }
 
 void ImageEffect_BCG::slotScaleChanged(int scale)
 {
     m_histogramWidget->m_scaleType = scale;
-    m_histogramWidget->repaint(false);
+    m_histogramWidget->repaint();
 }
 
 void ImageEffect_BCG::slotColorSelectedFromTarget( const Digikam::DColor &color )
@@ -264,21 +262,24 @@
 {
     KSharedConfig::Ptr config = KGlobal::config();
     KConfigGroup group = config->group("bcgadjust Tool Dialog");
-    m_channelCB->setCurrentItem(group.readEntry("Histogram Channel", 0));    // Luminosity.
-    m_scaleBG->setButton(group.readEntry("Histogram Scale", Digikam::HistogramWidget::LogScaleHistogram));
+
+    m_channelCB->setCurrentIndex(group.readEntry("Histogram Channel", 0));    // Luminosity.
+    m_scaleBG->button(group.readEntry("Histogram Scale", 
+                      (int)Digikam::HistogramWidget::LogScaleHistogram))->setChecked(true);
+
     m_bInput->setValue(group.readEntry("BrightnessAjustment", 0));
     m_cInput->setValue(group.readEntry("ContrastAjustment", 0));
     m_gInput->setValue(group.readEntry("GammaAjustment", 1.0));
-    slotChannelChanged(m_channelCB->currentItem());
-    slotScaleChanged(m_scaleBG->selectedId());
+    slotChannelChanged(m_channelCB->currentIndex());
+    slotScaleChanged(m_scaleBG->checkedId());
 }
 
 void ImageEffect_BCG::writeUserSettings()
 {
     KSharedConfig::Ptr config = KGlobal::config();
     KConfigGroup group = config->group("bcgadjust Tool Dialog");
-    group.writeEntry("Histogram Channel", m_channelCB->currentItem());
-    group.writeEntry("Histogram Scale", m_scaleBG->selectedId());
+    group.writeEntry("Histogram Channel", m_channelCB->currentIndex());
+    group.writeEntry("Histogram Scale", m_scaleBG->checkedId());
     group.writeEntry("BrightnessAjustment", m_bInput->value());
     group.writeEntry("ContrastAjustment", m_cInput->value());
     group.writeEntry("GammaAjustment", m_gInput->value());
@@ -353,4 +354,3 @@
 }
 
 }  // NameSpace DigikamImagesPluginCore
-
--- trunk/extragear/graphics/digikam/imageplugins/coreplugin/imageplugin_core.cpp #684354:684355
@@ -73,11 +73,14 @@
                                  actionCollection(), "implugcore_redeye");
     m_redeyeAction->setWhatsThis( i18n( "This filter can be used to correct red eyes in a photo. "
                                         "Select a region including the eyes to use this option.") );
+*/
 
-    m_BCGAction = new KAction(i18n("Brightness/Contrast/Gamma..."), "contrast", 0,
-                      this, SLOT(slotBCG()),
-                      actionCollection(), "implugcore_bcg");
+    m_BCGAction  = new KAction(KIcon("contrast"), i18n("Brightness/Contrast/Gamma..."), this);
+    actionCollection()->addAction("implugcore_bcg", m_BCGAction );
+    connect(m_BCGAction, SIGNAL(triggered(bool) ), 
+            this, SLOT(slotBCG()));
 
+/*
     m_HSLAction = new KAction(i18n("Hue/Saturation/Lightness..."), "adjusthsl", 
                       Qt::CTRL+Qt::Key_U,      // NOTE: Photoshop 7 use CTRL+U.
                       this, SLOT(slotHSL()),
@@ -97,20 +100,16 @@
     m_invertAction  = new KAction(KIcon("invertimage"), i18n("Invert"), this);
     m_invertAction->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_I));      // NOTE: Photoshop 7 use CTRL+I.
     actionCollection()->addAction("implugcore_invert", m_invertAction );
-
     connect(m_invertAction, SIGNAL(triggered(bool) ), 
             this, SLOT(slotInvert()));
 
-
     m_convertTo8Bits  = new KAction(KIcon("depth16to8"), i18n("8 bits"), this);
     actionCollection()->addAction("implugcore_convertto8bits", m_convertTo8Bits );
-
     connect(m_convertTo8Bits, SIGNAL(triggered(bool) ), 
             this, SLOT(slotConvertTo8Bits()));
     
     m_convertTo16Bits  = new KAction(KIcon("depth8to16"), i18n("16 bits"), this);
     actionCollection()->addAction("implugcore_convertto16bits", m_convertTo16Bits );
-
     connect(m_convertTo16Bits, SIGNAL(triggered(bool) ), 
             this, SLOT(slotConvertTo16Bits()));
     
@@ -153,9 +152,9 @@
     m_convertTo8Bits->setEnabled(enable);
     m_convertTo16Bits->setEnabled(enable);
     m_invertAction->setEnabled(enable);
+    m_BCGAction->setEnabled(enable);
 
 /*    m_redeyeAction->setEnabled(enable);
-    m_BCGAction->setEnabled(enable);
     m_HSLAction->setEnabled(enable);
     m_RGBAction->setEnabled(enable);
     m_autoCorrectionAction->setEnabled(enable);
@@ -224,8 +223,8 @@
 
 void ImagePlugin_Core::slotBCG()
 {
-/*    DigikamImagesPluginCore::ImageEffect_BCG dlg(parentWidget());
-    dlg.exec();*/
+    DigikamImagesPluginCore::ImageEffect_BCG dlg(parentWidget());
+    dlg.exec();
 }
 
 void ImagePlugin_Core::slotBlur()



More information about the Digikam-devel mailing list