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