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 "propertywidget_orphans.h"
9 
10 
11 #include "scribusdoc.h"
12 
PropertyWidget_Orphans(QWidget * parent)13 PropertyWidget_Orphans::PropertyWidget_Orphans(QWidget* parent) : QFrame(parent)
14 {
15 	setupUi(this);
16 
17 	layout()->setAlignment(Qt::AlignTop);
18 	keepLinesStart->setDecimals(0);
19 	keepLinesEnd->setDecimals(0);
20 
21 	languageChange();
22 }
23 
connectSignals()24 void PropertyWidget_Orphans::connectSignals()
25 {
26 	connect(keepLinesStart, SIGNAL(valueChanged(double)), this, SLOT(handleKeepLinesStart()));
27 	connect(keepLinesEnd, SIGNAL(valueChanged(double)), this, SLOT(handleKeepLinesEnd()));
28 	connect(keepTogether, SIGNAL(stateChanged(int)), this, SLOT(handleKeepTogether()));
29 	connect(keepWithNext, SIGNAL(stateChanged(int)), this, SLOT(handleKeepWithNext()));
30 }
31 
disconnectSignals()32 void PropertyWidget_Orphans::disconnectSignals()
33 {
34 	disconnect(keepLinesStart, SIGNAL(valueChanged(double)), this, SLOT(handleKeepLinesStart()));
35 	disconnect(keepLinesEnd, SIGNAL(valueChanged(double)), this, SLOT(handleKeepLinesEnd()));
36 	disconnect(keepTogether, SIGNAL(stateChanged(int)), this, SLOT(handleKeepTogether()));
37 	disconnect(keepWithNext, SIGNAL(stateChanged(int)), this, SLOT(handleKeepWithNext()));
38 }
39 
handleKeepLinesStart()40 void PropertyWidget_Orphans::handleKeepLinesStart()
41 {
42 	if (!m_doc) return;
43 	ParagraphStyle newStyle;
44 	newStyle.setKeepLinesStart (keepLinesStart->value());
45 	m_doc->itemSelection_ApplyParagraphStyle(newStyle);
46 }
47 
handleKeepLinesEnd()48 void PropertyWidget_Orphans::handleKeepLinesEnd()
49 {
50 	if (!m_doc) return;
51 	ParagraphStyle newStyle;
52 	newStyle.setKeepLinesEnd (keepLinesEnd->value());
53 	m_doc->itemSelection_ApplyParagraphStyle(newStyle);
54 }
55 
handleKeepTogether()56 void PropertyWidget_Orphans::handleKeepTogether()
57 {
58 	if (!m_doc) return;
59 	ParagraphStyle newStyle;
60 	newStyle.setKeepTogether (keepTogether->isChecked());
61 	m_doc->itemSelection_ApplyParagraphStyle(newStyle);
62 }
63 
handleKeepWithNext()64 void PropertyWidget_Orphans::handleKeepWithNext()
65 {
66 	if (!m_doc) return;
67 	ParagraphStyle newStyle;
68 	newStyle.setKeepWithNext (keepWithNext->isChecked());
69 	m_doc->itemSelection_ApplyParagraphStyle(newStyle);
70 }
71 
updateStyle(const ParagraphStyle & newCurrent)72 void PropertyWidget_Orphans::updateStyle(const ParagraphStyle& newCurrent)
73 {
74 	disconnectSignals ();
75 	keepLinesStart->setValue (newCurrent.keepLinesStart());
76 	keepLinesEnd->setValue (newCurrent.keepLinesEnd());
77 	keepTogether->setChecked (newCurrent.keepTogether());
78 	keepWithNext->setChecked (newCurrent.keepWithNext());
79 	connectSignals ();
80 }
81 
changeEvent(QEvent * e)82 void PropertyWidget_Orphans::changeEvent(QEvent *e)
83 {
84 	if (e->type() == QEvent::LanguageChange)
85 	{
86 		languageChange();
87 		return;
88 	}
89 	QWidget::changeEvent(e);
90 }
91 
languageChange()92 void PropertyWidget_Orphans::languageChange()
93 {
94 	retranslateUi(this);
95 }
96 
97