summaryrefslogtreecommitdiffstats
path: root/scribus/multipleduplicate.cpp
blob: cd3fbabe1379b544f5a1001c57f14acb44be707c (plain)
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
82
83
84
85
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include "multipleduplicate.h"

#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QTabWidget>

#include "scrspinbox.h"
#include "units.h"
#include "usertaskstructs.h"

MultipleDuplicate::MultipleDuplicate( int unitIndex, QWidget* parent, Qt::WFlags fl )
	: QDialog(parent, fl),
	m_unitIndex(unitIndex)
{
	setupUi(this);
	//set tab order
	QWidget::setTabOrder(createGapRadioButton, horizShiftSpinBox);
	QWidget::setTabOrder(horizShiftSpinBox, vertShiftSpinBox);
	QWidget::setTabOrder(gridColsSpinBox, horizRCGapSpinBox);
	QWidget::setTabOrder(horizRCGapSpinBox, vertRCGapSpinBox);
	QWidget::setTabOrder(vertRCGapSpinBox, rotationSpinBox);
	
	//set up mspinboxes
	horizShiftSpinBox->setNewUnit(unitIndex);
	vertShiftSpinBox->setNewUnit(unitIndex);
	horizRCGapSpinBox->setNewUnit(unitIndex);
	vertRCGapSpinBox->setNewUnit(unitIndex);
	horizShiftSpinBox->setMinimum(-1000);
	vertShiftSpinBox->setMinimum(-1000);
	horizRCGapSpinBox->setMinimum(-1000);
	vertRCGapSpinBox->setMinimum(-1000);
	horizShiftSpinBox->setMaximum(1000);
	vertShiftSpinBox->setMaximum(1000);
	horizRCGapSpinBox->setMaximum(1000);
	vertRCGapSpinBox->setMaximum(1000);

	rotationSpinBox->setValues(-180.0, 180.0, 6, 0.0);
	rotationSpinBox->setDecimals(1);
	rotationSpinBox->setNewUnit(6);
	
	createGapRadioButton->setChecked(true);
	setCopiesGap();
	// signals and slots connections
	connect(createGapRadioButton, SIGNAL(clicked()), this, SLOT(setCopiesGap()));
	connect(shiftCreatedItemsRadioButton, SIGNAL(clicked()), this, SLOT(setCopiesShift()));
}

MultipleDuplicate::~MultipleDuplicate()
{
}

void MultipleDuplicate::setCopiesShift()
{
	horizShiftLabel->setText( tr("&Horizontal Shift:"));
	vertShiftLabel->setText( tr("&Vertical Shift:"));
}

void MultipleDuplicate::setCopiesGap()
{
	horizShiftLabel->setText( tr("&Horizontal Gap:"));
	vertShiftLabel->setText( tr("&Vertical Gap:"));
}

void MultipleDuplicate::getMultiplyData(ItemMultipleDuplicateData& mdData)
{
	mdData.type = tabWidget->currentIndex();
	mdData.copyCount = numberOfCopiesSpinBox->value();
	mdData.copyShiftOrGap = createGapRadioButton->isChecked() ? 1 : 0;
	mdData.copyShiftGapH = horizShiftSpinBox->value();
	mdData.copyShiftGapV = vertShiftSpinBox->value();
	mdData.copyRotation = rotationSpinBox->value();
	mdData.gridRows = gridRowsSpinBox->value();
	mdData.gridCols = gridColsSpinBox->value();
	mdData.gridGapH = horizRCGapSpinBox->value();
	mdData.gridGapV = vertRCGapSpinBox->value();
}