kpresenter
KPrRectProperty.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KPrRectProperty.h"
00022
00023 #include "rectpropertyui.h"
00024 #include "KPrRectPreview.h"
00025
00026 #include <KoImageResource.h>
00027
00028 #include <qspinbox.h>
00029 #include <qtoolbutton.h>
00030 #include <qlayout.h>
00031
00032 KPrRectProperty::KPrRectProperty( QWidget *parent, const char *name, KPrRectValueCmd::RectValues &rectValue )
00033 : QWidget( parent, name )
00034 , m_rectValue( rectValue )
00035 {
00036 formerVerticalValue = 0;
00037 QVBoxLayout *layout = new QVBoxLayout( this );
00038 layout->addWidget( m_ui = new RectPropertyUI( this ) );
00039 KoImageResource kir;
00040 m_ui->combineButton->setPixmap(kir.chain());
00041
00042 connect( m_ui->xRndInput, SIGNAL( valueChanged( int ) ), this, SLOT( slotRndChanged() ) );
00043 connect( m_ui->yRndInput, SIGNAL( valueChanged( int ) ), this, SLOT( slotRndChanged() ) );
00044 connect( m_ui->combineButton, SIGNAL( toggled( bool ) ), this, SLOT( combineToggled( bool ) ) );
00045
00046 slotReset();
00047 }
00048
00049 KPrRectProperty::~KPrRectProperty()
00050 {
00051 }
00052
00053
00054 int KPrRectProperty::getRectPropertyChange() const
00055 {
00056 int flags = 0;
00057
00058 if ( getXRnd() != m_rectValue.xRnd )
00059 flags |= KPrRectValueCmd::XRnd;
00060
00061 if ( getYRnd() != m_rectValue.yRnd )
00062 flags |= KPrRectValueCmd::YRnd;
00063
00064 return flags;
00065 }
00066
00067
00068 KPrRectValueCmd::RectValues KPrRectProperty::getRectValues() const
00069 {
00070 KPrRectValueCmd::RectValues rectValue;
00071 rectValue.xRnd = getXRnd();
00072 rectValue.yRnd = getYRnd();
00073
00074 return rectValue;
00075 }
00076
00077
00078 void KPrRectProperty::setRectValues( const KPrRectValueCmd::RectValues &rectValues )
00079 {
00080 m_rectValue = rectValues;
00081 slotReset();
00082 }
00083
00084
00085 void KPrRectProperty::apply()
00086 {
00087 int flags = getRectPropertyChange();
00088
00089 if ( flags & KPrRectValueCmd::XRnd )
00090 m_rectValue.xRnd = getXRnd();
00091
00092 if ( flags & KPrRectValueCmd::YRnd )
00093 m_rectValue.yRnd = getYRnd();
00094 }
00095
00096
00097 int KPrRectProperty::getXRnd() const
00098 {
00099 return m_ui->xRndInput->value();
00100 }
00101
00102
00103 int KPrRectProperty::getYRnd() const
00104 {
00105 return m_ui->yRndInput->value();
00106 }
00107
00108
00109 void KPrRectProperty::slotRndChanged()
00110 {
00111 m_ui->rectPreview->setRnds( getXRnd(), getYRnd() );
00112 }
00113
00114 void KPrRectProperty::slotReset()
00115 {
00116 m_ui->xRndInput->setValue( m_rectValue.xRnd );
00117 m_ui->yRndInput->setValue( m_rectValue.yRnd );
00118 if(m_rectValue.xRnd == m_rectValue.yRnd)
00119 combineToggled(true);
00120
00121 m_ui->rectPreview->setRnds( getXRnd(), getYRnd() );
00122 }
00123
00124 void KPrRectProperty::combineToggled( bool on)
00125 {
00126 KoImageResource kir;
00127 if( on ) {
00128 formerVerticalValue = getYRnd();
00129 m_ui->yRndInput->setValue( getXRnd() );
00130 connect(m_ui->yRndInput, SIGNAL( valueChanged ( int ) ),
00131 m_ui->xRndInput, SLOT( setValue ( int ) ));
00132 connect(m_ui->xRndInput, SIGNAL( valueChanged ( int ) ),
00133 m_ui->yRndInput, SLOT( setValue ( int ) ));
00134 m_ui->combineButton->setPixmap(kir.chain());
00135 }
00136 else {
00137 disconnect(m_ui->yRndInput, SIGNAL( valueChanged ( int ) ),
00138 m_ui->xRndInput, SLOT( setValue ( int ) ));
00139 disconnect(m_ui->xRndInput, SIGNAL( valueChanged ( int ) ),
00140 m_ui->yRndInput, SLOT( setValue ( int ) ));
00141 if(formerVerticalValue != 0)
00142 m_ui->yRndInput->setValue( formerVerticalValue );
00143 m_ui->combineButton->setPixmap(kir.chainBroken());
00144 }
00145 }
00146
00147 #include "KPrRectProperty.moc"
|