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 "smscrspinbox.h"
8
9
SMScrSpinBox(QWidget * pa,int s)10 SMScrSpinBox::SMScrSpinBox(QWidget *pa, int s)
11 : ScrSpinBox(pa, s)
12 {
13
14 }
15
SMScrSpinBox(double minValue,double maxValue,QWidget * pa,int s)16 SMScrSpinBox::SMScrSpinBox(double minValue, double maxValue, QWidget *pa, int s)
17 : ScrSpinBox(minValue, maxValue, pa, s)
18 {
19
20 }
21
SMScrSpinBox(QWidget * parent,const char * name)22 SMScrSpinBox::SMScrSpinBox(QWidget *parent, const char * name)
23 : ScrSpinBox(parent, 0)
24 {
25
26 }
27
setValue(double val)28 void SMScrSpinBox::setValue(double val)
29 {
30 disconnect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
31 m_hasParent = false;
32 m_pValue = 0.0;
33 setFont(false);
34
35 ScrSpinBox::setValue(val);
36 }
37
setValue(double val,bool isParentVal)38 void SMScrSpinBox::setValue(double val, bool isParentVal)
39 {
40 disconnect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
41 m_hasParent = true;
42 m_pValue = val;
43 setFont(!isParentVal);
44
45 ScrSpinBox::setValue(val);
46 connect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
47 }
48
clear()49 void SMScrSpinBox::clear()
50 {
51 disconnect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
52 ScrSpinBox::clear();
53 connect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
54 }
55
setParentValue(double val)56 void SMScrSpinBox::setParentValue(double val)
57 {
58 m_hasParent = true;
59 m_pValue = val;
60 }
61
useParentValue()62 bool SMScrSpinBox::useParentValue()
63 {
64 bool ret = m_useParentValue;
65 m_useParentValue = false;
66 return ret;
67 }
68
interpretText()69 void SMScrSpinBox::interpretText()
70 {
71 if (m_hasParent && text().isEmpty())
72 {
73 m_useParentValue = true;
74 setValue(m_pValue, true);
75 }
76 ScrSpinBox::interpretText();
77 }
78
setFont(bool wantBold)79 void SMScrSpinBox::setFont(bool wantBold)
80 {
81 QFont f(font());
82 f.setBold(wantBold);
83 ScrSpinBox::setFont(f);
84 }
85
slotValueChanged()86 void SMScrSpinBox::slotValueChanged()
87 {
88 if (m_hasParent)
89 setFont(true);
90 }
91