From 820960a9ae75a82ddf1687c8666466008607cd3d Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 22 Jul 2005 09:29:43 +0000 Subject: [PATCH] Improving layout and look'n'feel in SpectrumView and NuclideBoardDialog. Small hack for the Makefile.am. svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=437537 --- kalzium/src/spectrum.cpp | 71 +++++++++++++++++++++++++--------------- kalzium/src/spectrum.h | 6 ++-- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp index cbc9782..c6168cf 100644 --- a/kalzium/src/spectrum.cpp +++ b/kalzium/src/spectrum.cpp @@ -23,9 +23,13 @@ #include #include -#include +#include +#include +#include #include +#include +#include #include #include #include @@ -132,37 +136,37 @@ QString Spectrum::BandsAsHtml() { QString html = "Chemical datai"; - html.append( "" ); + html += "
"; QValueList::const_iterator it = m_bandlist.begin(); const QValueList::const_iterator itEnd = m_bandlist.end(); for (;it!=itEnd;++it) { - html.append( "" ); - html.append( i18n( "" ).arg( ( *it ).wavelength ) ); - html.append( i18n( "" ).arg( ( *it ).intensity ) ); - html.append( i18n( "" ).arg( ( *it ).aki ) ); - html.append( i18n( "" ).arg( ( *it ).energy1 ) ); - html.append( i18n( "" ).arg( ( *it ).energy2 ) ); - html.append( i18n( "" ).arg( ( *it ).electronconfig1 ) ); - html.append( i18n( "" ).arg( ( *it ).electronconfig2 ) ); - html.append( i18n( "" ).arg( ( *it ).term1 ) ); - html.append( i18n( "" ).arg( ( *it ).term2 ) ); - html.append( i18n( "" ).arg( ( *it ).J1 ) ); - html.append( i18n( "" ).arg( ( *it ).J2 ) ); - html.append( "\n"); + html += QString( "" ) + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "\n"; } - html.append( "
Wavelength: %1 nmIntensity: %1Probability: %1 108s-1Energy 1: %1Energy 2: %1Electronconfiguration 1: %1Electronconfiguration 2: %1Term 1: %1Term 2: %1J 1: %1J 2: %1
" + i18n( "Wavelength: %1 nm" ).arg( ( *it ).wavelength ) + "" + i18n( "Intensity: %1" ).arg( ( *it ).intensity ) + "" + i18n( "Probability: %1 108s-1" ).arg( ( *it ).aki ) + "" + i18n( "Energy 1: %1" ).arg( ( *it ).energy1 ) + "" + i18n( "Energy 2: %1" ).arg( ( *it ).energy2 ) + "" + i18n( "Electron Configuration 1: %1" ).arg( ( *it ).electronconfig1 ) + "" + i18n( "Electron Configuration 2: %1" ).arg( ( *it ).electronconfig2 ) + "" + i18n( "Term 1: %1" ).arg( ( *it ).term1 ) + "" + i18n( "Term 2: %1" ).arg( ( *it ).term2 ) + "" + i18n( "J 1: %1" ).arg( ( *it ).J1 ) + "" + i18n( "J 2: %1" ).arg( ( *it ).J2 ) + "
" ); + html += ""; - html.append( "" ); + html += ""; return html; } SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name ) : QWidget( parent, name ) { - QVBoxLayout *spectrumLayout = new QVBoxLayout( this, 0, -1, "spectrumLayout" ); + QVBoxLayout *spectrumLayout = new QVBoxLayout( this, 0, KDialog::spacingHint(), "spectrumLayout" ); m_spectrum = spec->adjustToWavelength( 100.0, 1000.0 ); m_spectrum->adjustMinMax(); @@ -174,19 +178,26 @@ SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name ) spectrumLayout->addWidget( m_spectrumWidget ); - QHBoxLayout *hbox = new QHBoxLayout( this ); + QHBoxLayout *hbox = new QHBoxLayout( this, 0, KDialog::spacingHint() ); + QHBoxLayout *hbox1 = new QHBoxLayout( this, 0, KDialog::spacingHint() ); + QHBoxLayout *hbox2 = new QHBoxLayout( this, 0, KDialog::spacingHint() ); //X m_spinbox_left = new QSpinBox( m_spectrum->min(), m_spectrum->max()-1, 1, this ); //X m_spinbox_right = new QSpinBox( m_spectrum->min()+1, m_spectrum->max(), 1, this );i m_spinbox_left = new QSpinBox( 100, 1000, 1, this ); 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" ); - + m_button_save = new KPushButton( KGuiItem( i18n( "Export spectrum as..." ), "fileexport" ), this, "button_save" ); + QPopupMenu *pp = new QPopupMenu( m_button_save ); + m_button_save->setPopup( pp ); + KActionCollection *coll = new KActionCollection( this ); + KAction *actExpImage = new KAction( i18n( "PNG" ), 0, 0, + this, SLOT( slotExportAsImage() ), coll, "export_image" ); + actExpImage->plug( pp ); + 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" ); @@ -197,14 +208,20 @@ SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name ) m_spinbox_right->setValue( 1000 ); m_spectrumWidget->setBorders( 100, 1000 ); - hbox->addWidget( new QLabel( i18n( "Minimumvalue" ), this ) ); + hbox->addWidget( new QLabel( i18n( "Minimum Value:" ), this ) ); hbox->addWidget( m_spinbox_left ); - hbox->addWidget( new QLabel( i18n( "Maximumvalue" ), this ) ); + hbox->addWidget( new QLabel( i18n( "Maximum Value:" ), this ) ); hbox->addWidget( m_spinbox_right ); - hbox->addWidget( m_button_save ); - hbox->addWidget( m_spectrumbox ); + + hbox1->addWidget( new QLabel( i18n( "Type of Spectrum:" ), this ) ); + hbox1->addWidget( m_spectrumbox ); + + hbox2->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + hbox2->addWidget( m_button_save ); spectrumLayout->addLayout( hbox ); + spectrumLayout->addLayout( hbox1 ); + spectrumLayout->addLayout( hbox2 ); } void SpectrumView::slotBordersChanged( int left, int right ) @@ -213,7 +230,7 @@ void SpectrumView::slotBordersChanged( int left, int right ) m_spinbox_right->setValue( right ); } -void SpectrumView::slotSave() +void SpectrumView::slotExportAsImage() { QString fileName = KFileDialog::getSaveFileName( QString::null, "*.png", this, i18n( "Save Spectrum" ) ); if( !fileName.isEmpty() ) diff --git a/kalzium/src/spectrum.h b/kalzium/src/spectrum.h index 123bfca..c5b23a5 100644 --- a/kalzium/src/spectrum.h +++ b/kalzium/src/spectrum.h @@ -35,7 +35,7 @@ #include "element.h" class SpectrumWidget; -class QPushButton; +class KPushButton; /** * @author Carsten Niehaus @@ -200,11 +200,11 @@ class SpectrumView : public QWidget KComboBox *m_spectrumbox; - QPushButton *m_button_save; + KPushButton *m_button_save; public slots: void slotBordersChanged( int, int ); - void slotSave(); + void slotExportAsImage(); }; #endif // SPECTRUM_H -- 2.47.3