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 "smstyleselect.h"
9
SMStyleSelect(QWidget * parent)10 SMStyleSelect::SMStyleSelect(QWidget *parent)
11 : StyleSelect(parent)
12 {
13 parentButton = new QToolButton(this);
14 parentButton->setMaximumSize(QSize(22, 22));
15 parentButton->setMinimumSize(QSize(22, 22));
16 parentButton->setText( tr("P", "P as in Parent"));
17 parentButton->setToolTip( tr("Use parent style's effects instead of overriding them"));
18 ssLayout->addWidget(parentButton);
19 resize(minimumSizeHint());
20 parentButton->hide();
21 }
22
setStyle(int i)23 void SMStyleSelect::setStyle(int i)
24 {
25 disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
26 disconnect(ShadowVal->Xoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
27 disconnect(ShadowVal->Yoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
28 disconnect(OutlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
29 disconnect(UnderlineVal->LPos, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
30 disconnect(UnderlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
31 disconnect(StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
32 disconnect(StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
33 disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
34 setFont(false);
35 m_hasParent = false;
36 m_pStyle = 0;
37 parentButton->hide();
38 StyleSelect::setStyle(i);
39 }
40
setStyle(int i,bool isParentValue)41 void SMStyleSelect::setStyle(int i, bool isParentValue)
42 {
43 disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
44 disconnect(ShadowVal->Xoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
45 disconnect(ShadowVal->Yoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
46 disconnect(OutlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
47 disconnect(UnderlineVal->LPos, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
48 disconnect(UnderlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
49 disconnect(StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
50 disconnect(StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
51 disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
52 m_hasParent = true;
53 m_pStyle = i;
54 setFont(!isParentValue);
55 if (isParentValue)
56 parentButton->hide();
57 else
58 parentButton->show();
59 parentButton->setChecked(true);
60 StyleSelect::setStyle(i);
61 connect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
62 connect(ShadowVal->Xoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
63 connect(ShadowVal->Yoffset, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
64 connect(OutlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
65 connect(UnderlineVal->LPos, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
66 connect(UnderlineVal->LWidth, SIGNAL(valueChanged(double)),this, SLOT(styleChanged()));
67 connect(StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
68 connect(StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(styleChanged()));
69 connect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
70 }
71
setParentItem(int i)72 void SMStyleSelect::setParentItem(int i)
73 {
74 m_hasParent = true;
75 m_pStyle = i;
76 }
77
useParentValue()78 bool SMStyleSelect::useParentValue()
79 {
80 bool ret = m_useParentStyle;
81 m_useParentStyle = false;
82 if (ret)
83 setStyle(m_pStyle, true);
84
85 return ret;
86 }
87
setFont(bool wantBold)88 void SMStyleSelect::setFont(bool wantBold)
89 {
90 QFont f(font());
91 f.setBold(wantBold);
92 parentButton->setFont(f);
93 ShadowVal->Xoffset->setFont(f);
94 ShadowVal->Yoffset->setFont(f);
95 OutlineVal->LWidth->setFont(f);
96 UnderlineVal->LPos->setFont(f);
97 UnderlineVal->LWidth->setFont(f);
98 StrikeVal->LPos->setFont(f);
99 StrikeVal->LWidth->setFont(f);
100 StyleSelect::setFont(f);
101 }
102
styleChanged()103 void SMStyleSelect::styleChanged()
104 {
105 if (m_hasParent)
106 {
107 setFont(true);
108 parentButton->show();
109 }
110 }
111
pbPressed()112 void SMStyleSelect::pbPressed()
113 {
114 m_useParentStyle = true;
115 emit State(getStyle());
116 }
117