3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "QParagraph.h"
15 #include "QParagraphDialog.h"
17 #include "qt_helpers.h"
20 #include "ParagraphParameters.h"
24 #include "controllers/ControlParagraph.h"
25 #include "controllers/helper_funcs.h"
29 #include <QPushButton>
38 typedef QController<ControlParagraph, QView<QParagraphDialog> > paragraph_base_class;
41 QParagraph::QParagraph(Dialog & parent)
42 : paragraph_base_class(parent, _("Paragraph Settings"))
46 void QParagraph::build_dialog()
49 dialog_.reset(new QParagraphDialog(this));
51 // Manage the ok, apply, restore and cancel/close buttons
52 bcview().setOK(dialog_->okPB);
53 bcview().setApply(dialog_->applyPB);
54 bcview().setCancel(dialog_->closePB);
55 bcview().setRestore(dialog_->restorePB);
59 void QParagraph::apply()
61 ParagraphParameters & params = controller().params();
63 params.align(dialog_->getAlignmentFromDialog());
66 Spacing::Space linespacing = Spacing::Default;
68 switch (dialog_->linespacing->currentIndex()) {
70 linespacing = Spacing::Default;
73 linespacing = Spacing::Single;
76 linespacing = Spacing::Onehalf;
79 linespacing = Spacing::Double;
82 linespacing = Spacing::Other;
83 other = fromqstr(dialog_->linespacingValue->text());
87 Spacing const spacing(linespacing, other);
88 params.spacing(spacing);
91 params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text()));
93 params.noindent(!dialog_->indentCB->isChecked());
97 void QParagraph::update_contents()
99 ParagraphParameters const & params = controller().params();
102 docstring const & labelwidth = params.labelWidthString();
103 // FIXME We should not compare translated strings
104 if (labelwidth != _("Senseless with this layout!")) {
105 dialog_->labelwidthGB->setEnabled(true);
106 dialog_->labelWidth->setText(toqstr(labelwidth));
108 dialog_->labelwidthGB->setEnabled(false);
109 dialog_->labelWidth->setText("");
113 LyXAlignment newAlignment = params.align();
114 LyXAlignment defaultAlignment = controller().alignDefault();
115 bool alignmentIsDefault =
116 newAlignment == LYX_ALIGN_LAYOUT || newAlignment == defaultAlignment;
117 dialog_->alignDefaultCB->blockSignals(true);
118 dialog_->alignDefaultCB->setChecked(alignmentIsDefault);
119 dialog_->alignDefaultCB->blockSignals(false);
120 dialog_->checkAlignmentRadioButtons();
121 dialog_->alignmentToRadioButtons(newAlignment);
124 dialog_->indentCB->setChecked(!params.noindent());
128 Spacing const & space = params.spacing();
129 switch (space.getSpace()) {
130 case Spacing::Single:
133 case Spacing::Onehalf:
136 case Spacing::Double:
146 dialog_->linespacing->setCurrentIndex(linespacing);
147 if (space.getSpace() == Spacing::Other) {
148 dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
149 dialog_->linespacingValue->setEnabled(true);
151 dialog_->linespacingValue->setText("");
152 dialog_->linespacingValue->setEnabled(false);
156 } // namespace frontend