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 #include <QSpinBox>
8 #include "ui/prefs_operatortools.h"
9 #include "prefsstructs.h"
10 #include "scrspinbox.h"
11 #include "units.h"
12 
13 #include "scribusdoc.h"
14 
Prefs_OperatorTools(QWidget * parent,ScribusDoc * doc)15 Prefs_OperatorTools::Prefs_OperatorTools(QWidget* parent, ScribusDoc* doc)
16 	: Prefs_Pane(parent)
17 {
18 	setupUi(this);
19 	languageChange();
20 
21 	m_caption = tr("Operator Tools");
22 	m_icon = "tools_16.png";
23 
24 	itemDuplicateXDispSpinBox->setMaximum(1000);
25 	itemDuplicateYDispSpinBox->setMaximum(1000);
26 	itemDuplicateXDispSpinBox->setMinimum(-1000);
27 	itemDuplicateYDispSpinBox->setMinimum(-1000);
28 
29 	rotationConstraintSpinBox->setNewUnit(6);
30 	rotationConstraintSpinBox->setMaximum(359.99);
31 	rotationConstraintSpinBox->setMinimum(0);
32 }
33 
34 Prefs_OperatorTools::~Prefs_OperatorTools() = default;
35 
languageChange()36 void Prefs_OperatorTools::languageChange()
37 {
38 	zoomMinimumSpinBox->setToolTip( tr( "Minimum magnification allowed" ) );
39 	zoomMaximumSpinBox->setToolTip( tr( "Maximum magnification allowed" ) );
40 	zoomSteppingSpinBox->setToolTip( tr( "Change in magnification for each zoom operation" ) );
41 	itemDuplicateXDispSpinBox->setToolTip( tr( "Horizontal displacement of page items") );
42 	itemDuplicateYDispSpinBox->setToolTip( tr( "Vertical displacement of page items" ) );
43 	rotationConstraintSpinBox->setToolTip( tr( "Constrain value for the rotation tool when the Control key is pressed" ) );
44 }
45 
unitChange(int unitIndex)46 void Prefs_OperatorTools::unitChange(int unitIndex)
47 {
48 	itemDuplicateXDispSpinBox->setNewUnit(unitIndex);
49 	itemDuplicateYDispSpinBox->setNewUnit(unitIndex);
50 }
51 
restoreDefaults(struct ApplicationPrefs * prefsData)52 void Prefs_OperatorTools::restoreDefaults(struct ApplicationPrefs *prefsData)
53 {
54 	zoomMinimumSpinBox->setValue(prefsData->opToolPrefs.magMin);
55 	zoomMaximumSpinBox->setValue(prefsData->opToolPrefs.magMax);
56 	zoomSteppingSpinBox->setValue(prefsData->opToolPrefs.magStep);
57 	int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
58 	unitChange(docUnitIndex);
59 	double unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex);
60 	itemDuplicateXDispSpinBox->setValue(prefsData->opToolPrefs.dispX * unitRatio);
61 	itemDuplicateYDispSpinBox->setValue(prefsData->opToolPrefs.dispY * unitRatio);
62 	rotationConstraintSpinBox->setValue(prefsData->opToolPrefs.constrain);
63 }
64 
saveGuiToPrefs(struct ApplicationPrefs * prefsData) const65 void Prefs_OperatorTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
66 {
67 	prefsData->opToolPrefs.magMin=zoomMinimumSpinBox->value();
68 	prefsData->opToolPrefs.magMax=zoomMaximumSpinBox->value();
69 	prefsData->opToolPrefs.magStep=zoomSteppingSpinBox->value();
70 	double unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex);
71 	prefsData->opToolPrefs.dispX=itemDuplicateXDispSpinBox->value() / unitRatio;
72 	prefsData->opToolPrefs.dispY=itemDuplicateYDispSpinBox->value() / unitRatio;
73 	prefsData->opToolPrefs.constrain=rotationConstraintSpinBox->value();
74 }
75 
76 
77