1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
/* This file is part of the KDE project
* Copyright (C) 2007 Rob Buis <buis@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "SpiralShapeConfigWidget.h"
#include "SpiralShapeConfigCommand.h"
#include <klocale.h>
SpiralShapeConfigWidget::SpiralShapeConfigWidget()
{
widget.setupUi(this);
widget.spiralType->clear();
widget.spiralType->addItem(i18n("Curve"));
widget.spiralType->addItem(i18n("Line"));
widget.fade->setMinimum(0.0);
widget.fade->setMaximum(1.0);
widget.clockWise->clear();
widget.clockWise->addItem("ClockWise");
widget.clockWise->addItem("Anti-ClockWise");
connect(widget.spiralType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(propertyChanged()));
connect(widget.clockWise, SIGNAL(currentIndexChanged(int)), this, SIGNAL(propertyChanged()));
connect(widget.fade, SIGNAL(editingFinished()), this, SIGNAL(propertyChanged()));
}
void SpiralShapeConfigWidget::open(KoShape *shape)
{
m_spiral = dynamic_cast<SpiralShape*>(shape);
if (!m_spiral)
return;
widget.spiralType->blockSignals(true);
widget.clockWise->blockSignals(true);
widget.fade->blockSignals(true);
widget.spiralType->setCurrentIndex(m_spiral->type());
widget.clockWise->setCurrentIndex(m_spiral->clockWise() ? 0 : 1);
widget.fade->setValue(m_spiral->fade());
widget.spiralType->blockSignals(false);
widget.clockWise->blockSignals(false);
widget.fade->blockSignals(false);
}
void SpiralShapeConfigWidget::save()
{
if (!m_spiral)
return;
m_spiral->setType(static_cast<SpiralShape::SpiralType>(widget.spiralType->currentIndex()));
m_spiral->setClockWise(widget.clockWise->currentIndex() == 0);
m_spiral->setFade(widget.fade->value());
}
QUndoCommand * SpiralShapeConfigWidget::createCommand()
{
if (!m_spiral)
return 0;
SpiralShape::SpiralType type = static_cast<SpiralShape::SpiralType>(widget.spiralType->currentIndex());
return new SpiralShapeConfigCommand(m_spiral, type, (widget.clockWise->currentIndex() == 0), widget.fade->value());
}
#include <SpiralShapeConfigWidget.moc>
|