21#include <tqcombobox.h>
24#include <tqtabwidget.h>
25#include <tqradiobutton.h>
26#include <tqvbuttongroup.h>
28#include <kiconloader.h>
30#include <kstandarddirs.h>
32#include "KoUnitWidgets.h"
34#include "karbon_part.h"
36#include "vselection.h"
37#include "vstrokecmd.h"
39#include "vstrokedlg.h"
42VStrokeDlg::VStrokeDlg(
KarbonPart* part, TQWidget* parent,
const char* name )
43 : KDialogBase ( parent, name, true, i18n(
"Stroke" ), Ok | Cancel ), m_part( part )
45 enableButtonSeparator(
true );
46 TQTabWidget *mainWidget =
new TQTabWidget(
this,
"strokemain" );
47 TQHBoxLayout *mainLayout =
new TQHBoxLayout (mainWidget, 3);
49 TQVBoxLayout *leftLayout =
new TQVBoxLayout( mainLayout, 4 );
51 TQLabel* widthLabel =
new TQLabel( i18n (
"stroke width",
"Width:" ), mainWidget );
52 leftLayout->addWidget ( widthLabel );
53 m_setLineWidth =
new KoUnitDoubleSpinBox( mainWidget, 0.0, 1000.0, 0.5, 1.0, KoUnit::U_PT, 1 );
54 leftLayout->addWidget ( m_setLineWidth );
57 TQLabel* styleLabel =
new TQLabel( i18n (
"Style:" ), mainWidget );
58 leftLayout->addWidget ( styleLabel );
59 m_styleCombo =
new TQComboBox( mainWidget );
60 m_styleCombo->setEnabled (
false );
61 leftLayout->addWidget ( m_styleCombo );
64 TQRadioButton* button;
65 m_typeOption =
new TQVButtonGroup ( mainWidget );
66 button =
new TQRadioButton ( i18n(
"None" ), m_typeOption );
67 m_typeOption->insert( button );
68 button =
new TQRadioButton ( i18n(
"Stroke" ), m_typeOption );
69 m_typeOption->insert( button );
70 button =
new TQRadioButton ( i18n(
"Gradient" ), m_typeOption );
71 m_typeOption->insert( button );
72 m_typeOption->setTitle( i18n(
"Type" ) );
73 mainLayout->addWidget( m_typeOption );
74 connect( m_typeOption, TQ_SIGNAL( clicked(
int ) ),
this, TQ_SLOT( slotTypeChanged(
int ) ) );
76 m_capOption =
new TQVButtonGroup ( mainWidget );
78 button =
new TQRadioButton ( m_capOption );
79 button->setPixmap( DesktopIcon(
"cap_butt" ) );
80 m_capOption->insert( button );
81 button =
new TQRadioButton ( m_capOption );
82 button->setPixmap( DesktopIcon(
"cap_round" ) );
83 m_capOption->insert( button );
84 button =
new TQRadioButton ( m_capOption );
85 button->setPixmap( DesktopIcon(
"cap_square" ) );
86 m_capOption->insert( button );
87 m_capOption->setTitle( i18n(
"Cap" ) );
88 mainLayout->addWidget( m_capOption );
89 connect( m_capOption, TQ_SIGNAL( clicked(
int ) ),
this, TQ_SLOT( slotCapChanged(
int ) ) );
91 m_joinOption =
new TQVButtonGroup ( mainWidget );
92 button =
new TQRadioButton ( m_joinOption );
93 button->setPixmap( DesktopIcon(
"join_miter" ) );
94 m_joinOption->insert( button );
95 button =
new TQRadioButton ( m_joinOption );
96 button->setPixmap( DesktopIcon(
"join_round" ) );
97 m_joinOption->insert( button );
98 button =
new TQRadioButton ( m_joinOption );
99 button->setPixmap( DesktopIcon(
"join_bevel" ) );
100 m_joinOption->insert( button );
101 m_joinOption->setTitle( i18n(
"Join" ) );
102 mainLayout->addWidget( m_joinOption );
103 connect( m_joinOption, TQ_SIGNAL( clicked(
int ) ),
this, TQ_SLOT( slotJoinChanged(
int ) ) );
106 if( sel && sel->
objects().count() > 0 )
108 m_stroke.setType ( sel->
objects().getFirst()->stroke()->type() );
109 m_stroke.setColor ( sel->
objects().getFirst()->stroke()->color() );
110 m_stroke.setLineWidth ( sel->
objects().getFirst()->stroke()->lineWidth() );
111 m_stroke.setLineCap ( sel->
objects().getFirst()->stroke()->lineCap() );
112 m_stroke.setLineJoin ( sel->
objects().getFirst()->stroke()->lineJoin() );
113 m_stroke.setMiterLimit ( sel->
objects().getFirst()->stroke()->miterLimit() );
117 mainLayout->activate();
121 m_colortab =
new VColorTab( sel->
objects().count() == 0 ? sel->
stroke()->color() :
122 sel->objects().getFirst()->stroke()->color(), this);
123 m_colortab->insertTab( mainWidget, i18n(
"Stroke"), 0 );
124 m_colortab->setCurrentPage( 0 );
126 setMainWidget( m_colortab );
129 connect (
this, TQ_SIGNAL( okClicked(
void ) ),
this, TQ_SLOT( slotOKClicked (
void ) ) );
132void VStrokeDlg::slotTypeChanged(
int ID )
140 m_stroke.setType ( VStroke::none );
144void VStrokeDlg::slotCapChanged(
int ID )
148 m_stroke.setLineCap ( VStroke::capRound );
break;
150 m_stroke.setLineCap ( VStroke::capSquare );
break;
152 m_stroke.setLineCap ( VStroke::capButt );
156void VStrokeDlg::slotJoinChanged(
int ID )
160 m_stroke.setLineJoin ( VStroke::joinRound );
break;
162 m_stroke.setLineJoin ( VStroke::joinBevel );
break;
164 m_stroke.setLineJoin ( VStroke::joinMiter );
168void VStrokeDlg::slotOKClicked()
170 m_stroke.setLineWidth ( m_setLineWidth->value() );
172 m_stroke.setColor( m_colortab->Color() );
174 if( m_part && m_part->document().selection()->objects().count() > 0 )
175 m_part->addCommand(
new VStrokeCmd( &m_part->document(), &m_stroke ),
true );
177 emit strokeChanged(
VStroke( m_stroke ) );
180void VStrokeDlg::slotUpdateDialog()
182 switch( m_stroke.type() )
185 m_typeOption->setButton( 1 );
break;
187 m_typeOption->setButton( 2 );
break;
189 m_typeOption->setButton( 0 );
192 switch( m_stroke.lineCap() )
194 case VStroke::capRound:
195 m_capOption->setButton( 1 );
break;
196 case VStroke::capSquare:
197 m_capOption->setButton( 2 );
break;
199 m_capOption->setButton( 0 );
202 switch( m_stroke.lineJoin() )
204 case VStroke::joinRound:
205 m_joinOption->setButton( 1 );
break;
206 case VStroke::joinBevel:
207 m_joinOption->setButton( 2 );
break;
209 m_joinOption->setButton( 0 );
212 m_setLineWidth->setValue( m_stroke.lineWidth() );
215#include "vstrokedlg.moc"
Keeps track of visual per document properties.
VSelection * selection() const
Returns a pointer to the selection.
virtual VStroke * stroke() const
Gets the object's actual stroke.
VSelection manages a set of selected vobjects.
const VObjectList & objects() const
Read only access to the selected objects.
Manages stroke properties.