~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to karbon/plugins/flattenpath/FlattenPathPlugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include <QtGui/QHBoxLayout>
49
49
 
50
50
 
51
 
typedef KGenericFactory<FlattenPathPlugin,QWidget> FlattenPathPluginFactory;
52
 
K_EXPORT_COMPONENT_FACTORY( karbon_flattenpathplugin, FlattenPathPluginFactory( "karbonflattenpathplugin" ) )
 
51
typedef KGenericFactory<FlattenPathPlugin, QWidget> FlattenPathPluginFactory;
 
52
K_EXPORT_COMPONENT_FACTORY(karbon_flattenpathplugin, FlattenPathPluginFactory("karbonflattenpathplugin"))
53
53
 
54
 
FlattenPathPlugin::FlattenPathPlugin( QWidget *parent, const QStringList & )
55
 
: Plugin( parent/*, name*/ )
 
54
FlattenPathPlugin::FlattenPathPlugin(QWidget *parent, const QStringList &)
 
55
        : Plugin(parent/*, name*/)
56
56
{
57
57
    KAction *actionFlattenPath  = new KAction(KIcon("14_flatten"), i18n("&Flatten Path..."), this);
58
 
    actionCollection()->addAction("path_flatten", actionFlattenPath );
 
58
    actionCollection()->addAction("path_flatten", actionFlattenPath);
59
59
    connect(actionFlattenPath, SIGNAL(triggered()), this, SLOT(slotFlattenPath()));
60
60
 
61
 
    m_flattenPathDlg = new FlattenDlg( parent );
62
 
    m_flattenPathDlg->setFlatness( 10.0 );
 
61
    m_flattenPathDlg = new FlattenDlg(parent);
 
62
    m_flattenPathDlg->setFlatness(10.0);
63
63
}
64
64
 
65
65
void FlattenPathPlugin::slotFlattenPath()
67
67
    KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController();
68
68
    KoSelection *selection = canvasController->canvas()->shapeManager()->selection();
69
69
    KoShape * shape = selection->firstSelectedShape();
70
 
    if( ! shape )
 
70
    if (! shape)
71
71
        return;
72
72
 
73
73
    // check if we have a path based shape
74
 
    KoPathShape * path = dynamic_cast<KoPathShape*>( shape );
75
 
    if( ! path )
 
74
    KoPathShape * path = dynamic_cast<KoPathShape*>(shape);
 
75
    if (! path)
76
76
        return;
77
77
 
78
78
    // check if it is no parametric shape
79
 
    KoParameterShape * ps = dynamic_cast<KoParameterShape*>( shape );
80
 
    if( ps && ps->isParametricShape() )
81
 
        return;
82
 
 
83
 
    if( QDialog::Rejected == m_flattenPathDlg->exec() )
84
 
        return;
85
 
 
86
 
    canvasController->canvas()->addCommand( 
87
 
        new KarbonPathFlattenCommand( path, m_flattenPathDlg->flatness() ) );
 
79
    KoParameterShape * ps = dynamic_cast<KoParameterShape*>(shape);
 
80
    if (ps && ps->isParametricShape())
 
81
        return;
 
82
 
 
83
    if (QDialog::Rejected == m_flattenPathDlg->exec())
 
84
        return;
 
85
 
 
86
    canvasController->canvas()->addCommand(
 
87
        new KarbonPathFlattenCommand(path, m_flattenPathDlg->flatness()));
88
88
}
89
89
 
90
 
FlattenDlg::FlattenDlg( QWidget* parent, const char* name )
91
 
    : KDialog( parent )
 
90
FlattenDlg::FlattenDlg(QWidget* parent, const char* name)
 
91
        : KDialog(parent)
92
92
{
93
93
    setObjectName(name);
94
94
    setModal(true);
95
 
    setCaption( i18n( "Flatten Path" ) );
96
 
    setButtons( Ok | Cancel );
 
95
    setCaption(i18n("Flatten Path"));
 
96
    setButtons(Ok | Cancel);
97
97
 
98
98
    // add input fields on the left:
99
 
    QGroupBox* group = new QGroupBox( i18n( "Properties" ), this );
 
99
    QGroupBox* group = new QGroupBox(i18n("Properties"), this);
100
100
 
101
101
    QHBoxLayout* layout = new QHBoxLayout;
102
102
 
103
 
    layout->addWidget(new QLabel( i18n( "Flatness:" )));
 
103
    layout->addWidget(new QLabel(i18n("Flatness:")));
104
104
    m_flatness = new KDoubleNumInput(group);
105
105
    layout->addWidget(m_flatness);
106
106
 
107
107
    group->setLayout(layout);
108
 
    group->setMinimumWidth( 300 );
 
108
    group->setMinimumWidth(300);
109
109
 
110
110
    // signals and slots:
111
 
    connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
112
 
    connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
 
111
    connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
 
112
    connect(this, SIGNAL(cancelClicked()), this, SLOT(reject()));
113
113
 
114
 
    setMainWidget( group );
 
114
    setMainWidget(group);
115
115
}
116
116
 
117
117
qreal FlattenDlg::flatness() const
119
119
    return m_flatness->value();
120
120
}
121
121
 
122
 
void FlattenDlg::setFlatness( qreal value )
 
122
void FlattenDlg::setFlatness(qreal value)
123
123
{
124
 
    m_flatness->setValue( value);
 
124
    m_flatness->setValue(value);
125
125
}
126
126
 
127
127
#include "FlattenPathPlugin.moc"