1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8 arcvectordialog.cpp - description
9 -------------------
10 begin : Mon Jan 17 2011
11 copyright : (C) 2011 by Franz Schmid
12 email : Franz.Schmid@altmuehlnet.de
13 ***************************************************************************/
14
15 /***************************************************************************
16 * *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
21 * *
22 ***************************************************************************/
23
24 #include "arcvectordialog.h"
25
ArcVectorDialog(QWidget * parent)26 ArcVectorDialog::ArcVectorDialog(QWidget* parent) : ScrPaletteBase(parent, "ArcVectorDialog", false, Qt::WindowFlags())
27 {
28 setupUi(this);
29 startAngle->setNewUnit(6);
30 startAngle->setValues(-360, 360, 1, 0);
31 sweepAngle->setNewUnit(6);
32 sweepAngle->setValues(-360, 360, 1, 0);
33 connect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
34 connect(sweepAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
35 connect(arcHeight, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
36 connect(arcWidth, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
37 connect(exitButton, SIGNAL(clicked()), this, SIGNAL(endEdit()));
38 languageChange();
39 resize(minimumSizeHint());
40 }
41
changeEvent(QEvent * e)42 void ArcVectorDialog::changeEvent(QEvent *e)
43 {
44 if (e->type() == QEvent::LanguageChange)
45 {
46 languageChange();
47 }
48 else
49 QWidget::changeEvent(e);
50 }
51
languageChange()52 void ArcVectorDialog::languageChange()
53 {
54 retranslateUi(this);
55 resize(minimumSizeHint());
56 }
57
setValues(double start,double sweep,double height,double width)58 void ArcVectorDialog::setValues(double start, double sweep, double height, double width)
59 {
60 disconnect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
61 disconnect(sweepAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
62 disconnect(arcHeight, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
63 disconnect(arcWidth, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
64 startAngle->setValue(start);
65 sweepAngle->setValue(sweep);
66 arcHeight->setValue(height * arcHeight->unitRatio());
67 arcWidth->setValue(width * arcWidth->unitRatio());
68 connect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
69 connect(sweepAngle, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
70 connect(arcHeight, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
71 connect(arcWidth, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
72 }
73
changeVectors()74 void ArcVectorDialog::changeVectors()
75 {
76 double newWidth = arcWidth->value() / arcWidth->unitRatio();
77 double newHeight = arcHeight->value() / arcHeight->unitRatio();
78 emit NewVectors(startAngle->value(), sweepAngle->value(), newHeight, newWidth);
79 }
80
unitChange(int unitIndex)81 void ArcVectorDialog::unitChange(int unitIndex)
82 {
83 disconnect(arcHeight, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
84 disconnect(arcWidth, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
85 arcHeight->setNewUnit(unitIndex);
86 arcWidth->setNewUnit(unitIndex);
87 connect(arcHeight, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
88 connect(arcWidth, SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
89 }
90