]> Git trees. - libqmvoc.git/commitdiff
Png export
authorMartin Pfeiffer <hubipete@gmx.net>
Thu, 21 Jul 2005 13:16:36 +0000 (13:16 +0000)
committerMartin Pfeiffer <hubipete@gmx.net>
Thu, 21 Jul 2005 13:16:36 +0000 (13:16 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=437290

kalzium/src/spectrum.cpp
kalzium/src/spectrum.h

index ea4fbccb90ada723312e861d3adedefe6a0d38b9..1facff71e33787b4551cacbb22e1cbc9439a7865 100644 (file)
  ***************************************************************************/
 #include "spectrum.h"
 #include "spectrumwidget.h"
+#include "exporter.h"
 
 #include <qlayout.h>
 #include <qlabel.h>
+#include <qpushbutton.h>
 
 #include <kglobal.h>
 #include <kstandarddirs.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
 #include <klocale.h>
 #include <kdebug.h>
 
@@ -177,10 +181,12 @@ SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name )
        m_spinbox_right = new QSpinBox( 100, 1000, 1, this );
 //X    m_spinbox_left->setValue(  ( double ) m_spectrum->min() );
 //X    m_spinbox_right->setValue( ( double ) m_spectrum->max() );
+       m_button_save = new QPushButton( i18n("Save spectrum as PNG"), this, "button_save" );
        
        connect( m_spinbox_right, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setRightBorder( int ) ) );
        connect( m_spinbox_left, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setLeftBorder( int ) ) );
        connect( m_spectrumWidget, SIGNAL( bordersChanged( int, int ) ), this, SLOT( slotBordersChanged( int, int ) ) );        
+       connect( m_button_save, SIGNAL( pressed() ), this, SLOT( slotSave() ) ); 
 
        m_spectrumbox = new KComboBox( this, "combobox" );
        m_spectrumbox->insertItem( "Emission Spectrum" );
@@ -195,6 +201,7 @@ SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name )
        hbox->addWidget( m_spinbox_left );
        hbox->addWidget( new QLabel( i18n( "Maximumvalue" ), this ) );
        hbox->addWidget( m_spinbox_right );
+       hbox->addWidget( m_button_save );
        hbox->addWidget( m_spectrumbox );
 
        spectrumLayout->addLayout( hbox );
@@ -206,4 +213,16 @@ void SpectrumView::slotBordersChanged( int left, int right )
        m_spinbox_right->setValue( right );
 }
 
+void SpectrumView::slotSave()
+{
+       QString fileName = KFileDialog::getSaveFileName( QString::null, "*.png", this, i18n( "Save Spectrum" ) ); 
+       if( !fileName.isEmpty() )
+       {
+               Exporter* exporter = new Exporter();
+               if ( !exporter->saveAsPNG( m_spectrumWidget, fileName ) )
+                       KMessageBox::error( this, i18n( "The spectrum could not be saved"), i18n( "PNG could not be saved") );
+               delete exporter;
+       }       
+}
+
 #include "spectrum.moc"
index 0731bdb81c36b43564e16b864753df3a3400dc33..5902bb8cd176486e2960029e4ac5bea4f21f949c 100644 (file)
@@ -35,6 +35,7 @@
 #include "element.h"
 
 class SpectrumWidget;
+class QPushButton;
 
 /**
  * @author Carsten Niehaus
@@ -190,8 +191,11 @@ class SpectrumView : public QWidget
 
                KComboBox *m_spectrumbox;
 
+               QPushButton *m_button_save;
+
        public slots:
                void slotBordersChanged( int, int );
+               void slotSave();
 };
 
 #endif // SPECTRUM_H