3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "QParagraph.h"
14 #include "QParagraphDialog.h"
16 #include "qt_helpers.h"
18 #include "ParagraphParameters.h"
21 #include "controllers/ControlParagraph.h"
22 #include "controllers/helper_funcs.h"
26 #include <QPushButton>
34 typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
37 QParagraph::QParagraph(Dialog & parent)
38 : base_class(parent, _("Paragraph Settings"))
42 void QParagraph::build_dialog()
45 dialog_.reset(new QParagraphDialog(this));
47 // Manage the ok, apply, restore and cancel/close buttons
48 bcview().setOK(dialog_->okPB);
49 bcview().setApply(dialog_->applyPB);
50 bcview().setCancel(dialog_->closePB);
51 bcview().setRestore(dialog_->restorePB);
55 void QParagraph::apply()
57 ParagraphParameters & params = controller().params();
61 switch (dialog_->align->currentItem()) {
63 align = LYX_ALIGN_BLOCK;
66 align = LYX_ALIGN_LEFT;
69 align = LYX_ALIGN_RIGHT;
72 align = LYX_ALIGN_CENTER;
75 align = LYX_ALIGN_BLOCK;
80 Spacing::Space linespacing = Spacing::Default;
82 switch (dialog_->linespacing->currentItem()) {
84 linespacing = Spacing::Default;
87 linespacing = Spacing::Single;
90 linespacing = Spacing::Onehalf;
93 linespacing = Spacing::Double;
96 linespacing = Spacing::Other;
97 other = fromqstr(dialog_->linespacingValue->text());
101 Spacing const spacing(linespacing, other);
102 params.spacing(spacing);
105 params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
107 params.noindent(!dialog_->indentCB->isChecked());
111 void QParagraph::update_contents()
113 ParagraphParameters const & params = controller().params();
116 string const & labelwidth = params.labelWidthString();
117 // _() is correct here (this is stupid though !)
118 if (labelwidth != _("Senseless with this layout!")) {
119 dialog_->labelwidthGB->setEnabled(true);
120 dialog_->labelWidth->setText(toqstr(labelwidth));
122 dialog_->labelwidthGB->setEnabled(false);
123 dialog_->labelWidth->setText("");
128 switch (params.align()) {
132 case LYX_ALIGN_RIGHT:
135 case LYX_ALIGN_CENTER:
142 dialog_->align->setCurrentItem(i);
145 //LyXAlignment alignpos = controller().alignPossible();
147 dialog_->indentCB->setChecked(!params.noindent());
151 Spacing const & space = params.spacing();
152 switch (space.getSpace()) {
153 case Spacing::Single:
156 case Spacing::Onehalf:
159 case Spacing::Double:
169 dialog_->linespacing->setCurrentItem(linespacing);
170 if (space.getSpace() == Spacing::Other) {
171 dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
172 dialog_->linespacingValue->setEnabled(true);
174 dialog_->linespacingValue->setText("");
175 dialog_->linespacingValue->setEnabled(false);
179 } // namespace frontend