karbon

flattenpathplugin.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "flattenpathplugin.h"
00021 #include "klocale.h"
00022 #include <karbon_view.h>
00023 #include <karbon_part.h>
00024 #include <kgenericfactory.h>
00025 #include <kdebug.h>
00026 #include <qgroupbox.h>
00027 #include <qlabel.h>
00028 
00029 #include <knuminput.h>
00030 #include <commands/vflattencmd.h>
00031 
00032 
00033 typedef KGenericFactory<FlattenPathPlugin, KarbonView> FlattenPathPluginFactory;
00034 K_EXPORT_COMPONENT_FACTORY( karbon_flattenpathplugin, FlattenPathPluginFactory( "karbonflattenpathplugin" ) )
00035 
00036 FlattenPathPlugin::FlattenPathPlugin( KarbonView *parent, const char* name, const QStringList & )
00037 : Plugin( parent, name )
00038 {
00039     new KAction(
00040         i18n( "&Flatten Path..." ), "14_flatten", 0, this,
00041         SLOT( slotFlattenPath() ), actionCollection(), "path_flatten" );
00042 
00043     m_flattenPathDlg = new VFlattenDlg();
00044     m_flattenPathDlg->setFlatness( 0.2 );
00045 }
00046 
00047 void
00048 FlattenPathPlugin::slotFlattenPath()
00049 {
00050     KarbonPart *part = ((KarbonView *)parent())->part();
00051     if( part && m_flattenPathDlg->exec() )
00052         part->addCommand( new VFlattenCmd( &part->document(), m_flattenPathDlg->flatness() ), true );
00053 }
00054 
00055 VFlattenDlg::VFlattenDlg( QWidget* parent, const char* name )
00056     : KDialogBase( parent, name, true,  i18n( "Flatten Path" ), Ok | Cancel )
00057 {
00058     // add input fields on the left:
00059     QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
00060     new QLabel( i18n( "Flatness:" ), group );
00061     m_flatness = new KDoubleNumInput( group );
00062     group->setMinimumWidth( 300 );
00063 
00064     // signals and slots:
00065     connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
00066     connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
00067 
00068     setMainWidget( group );
00069     setFixedSize( baseSize() );
00070 }
00071 
00072 double
00073 VFlattenDlg::flatness() const
00074 {
00075     return m_flatness->value();
00076 }
00077 
00078 void
00079 VFlattenDlg::setFlatness( double value )
00080 {
00081     m_flatness->setValue( value);
00082 }
00083 
00084 #include "flattenpathplugin.moc"
00085 
KDE Home | KDE Accessibility Home | Description of Access Keys