kpresenter
KPrMarginWidget.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "KPrMarginWidget.h"
00024
00025 #include <qgroupbox.h>
00026 #include <qcheckbox.h>
00027 #include <qlayout.h>
00028
00029 #include <klocale.h>
00030 #include <knuminput.h>
00031
00032 #include "marginui.h"
00033 #include <KoUnitWidgets.h>
00034
00035 KPrMarginWidget::KPrMarginWidget( QWidget *parent, const char *name, const KoUnit::Unit unit )
00036 : QWidget( parent, name )
00037 , m_unit( unit )
00038 , m_changed( false )
00039 , m_noSignal( false )
00040 {
00041 QVBoxLayout *layout = new QVBoxLayout( this );
00042
00043 m_ui = new MarginUI( this );
00044 layout->addWidget( m_ui );
00045
00046 QSpacerItem *spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
00047 layout->addItem( spacer );
00048
00049 m_ui->margins->setTitle( i18n( "Margins" ) );
00050
00051 double dStep = KoUnit::fromUserValue( 0.5, unit );
00052 double dMax = KoUnit::fromUserValue( 9999, unit );
00053 m_ui->leftInput->setUnit( unit );
00054 m_ui->leftInput->setMinMaxStep( 0, dMax, dStep );
00055
00056 m_ui->rightInput->setUnit( unit );
00057 m_ui->rightInput->setMinMaxStep( 0, dMax, dStep );
00058
00059 m_ui->topInput->setUnit( unit );
00060 m_ui->topInput->setMinMaxStep( 0, dMax, dStep );
00061
00062 m_ui->bottomInput->setUnit( unit );
00063 m_ui->bottomInput->setMinMaxStep( 0, dMax, dStep );
00064
00065 connect( m_ui->leftInput, SIGNAL( valueChanged( double ) ),
00066 this, SLOT( slotValueChanged( double ) ) );
00067 connect( m_ui->rightInput, SIGNAL( valueChanged( double ) ),
00068 this, SLOT( slotValueChanged( double ) ) );
00069 connect( m_ui->topInput, SIGNAL( valueChanged( double ) ),
00070 this, SLOT( slotValueChanged( double ) ) );
00071 connect( m_ui->bottomInput, SIGNAL( valueChanged( double ) ),
00072 this, SLOT( slotValueChanged( double ) ) );
00073 }
00074
00075
00076 KPrMarginWidget::~KPrMarginWidget()
00077 {
00078 }
00079
00080
00081 void KPrMarginWidget::setValues( double left, double right, double top, double bottom )
00082 {
00083 m_ui->leftInput->changeValue( left );
00084 m_ui->rightInput->changeValue( right );
00085 m_ui->topInput->changeValue( top );
00086 m_ui->bottomInput->changeValue( bottom );
00087 }
00088
00089
00090 double KPrMarginWidget::leftValue() const
00091 {
00092 return m_ui->leftInput->value();
00093 }
00094
00095
00096 double KPrMarginWidget::rightValue() const
00097 {
00098 return m_ui->rightInput->value();
00099 }
00100
00101
00102 double KPrMarginWidget::topValue() const
00103 {
00104 return m_ui->topInput->value();
00105 }
00106
00107
00108 double KPrMarginWidget::bottomValue() const
00109 {
00110 return m_ui->bottomInput->value();
00111 }
00112
00113
00114 void KPrMarginWidget::slotValueChanged( double val )
00115 {
00116 m_changed = true;
00117 if ( m_ui->synchronize->isChecked() && !m_noSignal )
00118 {
00119 m_noSignal = true;
00120 m_ui->leftInput->setValue( val );
00121 m_ui->bottomInput->setValue( val );
00122 m_ui->rightInput->setValue( val );
00123 m_ui->topInput->setValue( val );
00124 m_noSignal = false;
00125 }
00126 }
00127
00128
00129 #include "KPrMarginWidget.moc"
|