20#include "KPrPieProperty.h"
29#include "piepropertyui.h"
30#include "KPrPiePreview.h"
33KPrPieProperty::KPrPieProperty( TQWidget *parent,
const char *name, KPrPieValueCmd::PieValues pieValues )
34: TQWidget( parent, name )
35, m_pieValues( pieValues )
37 TQVBoxLayout *layout =
new TQVBoxLayout(
this );
38 layout->addWidget( m_ui =
new PiePropertyUI(
this ) );
40 m_ui->typeCombo->insertItem( i18n(
"Pie" ) );
41 m_ui->typeCombo->insertItem( i18n(
"Arc" ) );
42 m_ui->typeCombo->insertItem( i18n(
"Chord" ) );
44 connect( m_ui->typeCombo, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( slotTypeChanged(
int ) ) );
46 connect( m_ui->angleInput, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( slotAngleChanged(
int ) ) );
47 connect( m_ui->lengthInput, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( slotLengthChanged(
int ) ) );
53KPrPieProperty::~KPrPieProperty()
58int KPrPieProperty::getPiePropertyChange()
const
62 KPrPieValueCmd::PieValues pieValues = getPieValues();
64 if ( pieValues.pieType != m_pieValues.pieType )
65 flags |= KPrPieValueCmd::Type;
67 if ( pieValues.pieAngle != m_pieValues.pieAngle )
68 flags |= KPrPieValueCmd::Angle;
70 if ( pieValues.pieLength != m_pieValues.pieLength )
71 flags |= KPrPieValueCmd::Length;
77KPrPieValueCmd::PieValues KPrPieProperty::getPieValues()
const
79 KPrPieValueCmd::PieValues pieValues;
80 pieValues.pieType =
static_cast<PieType
>( m_ui->typeCombo->currentItem() );
81 pieValues.pieAngle = m_ui->angleInput->value() * 16;
82 pieValues.pieLength = m_ui->lengthInput->value() * 16;
87void KPrPieProperty::setPieValues(
const KPrPieValueCmd::PieValues &pieValues )
89 m_pieValues = pieValues;
94void KPrPieProperty::apply()
96 int flags = getPiePropertyChange();
98 KPrPieValueCmd::PieValues pieValues = getPieValues();
100 if ( flags & KPrPieValueCmd::Type )
101 m_pieValues.pieType = pieValues.pieType;
103 if ( flags & KPrPieValueCmd::Angle )
104 m_pieValues.pieAngle = pieValues.pieAngle;
106 if ( flags & KPrPieValueCmd::Length )
107 m_pieValues.pieLength = pieValues.pieLength;
111void KPrPieProperty::slotReset()
113 m_ui->typeCombo->setCurrentItem( (
int ) m_pieValues.pieType );
114 m_ui->piePreview->setType( m_pieValues.pieType );
115 m_ui->angleInput->setValue( m_pieValues.pieAngle / 16 );
116 m_ui->piePreview->setAngle( m_pieValues.pieAngle );
117 m_ui->lengthInput->setValue( m_pieValues.pieLength / 16 );
118 m_ui->piePreview->setLength( m_pieValues.pieLength );
122void KPrPieProperty::slotTypeChanged(
int pos )
124 m_ui->piePreview->setType(
static_cast<PieType
>( pos ) );
128void KPrPieProperty::slotAngleChanged(
int num )
130 m_ui->piePreview->setAngle( num * 16 );
134void KPrPieProperty::slotLengthChanged(
int num )
136 m_ui->piePreview->setLength( num * 16 );
140#include "KPrPieProperty.moc"