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"
24 #include <qbuttongroup.h>
25 #include <qcheckbox.h>
26 #include <qcombobox.h>
27 #include <qlineedit.h>
28 #include <qpushbutton.h>
36 typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
39 QParagraph::QParagraph(Dialog & parent)
40 : base_class(parent, _("LyX: Paragraph Settings"))
44 void QParagraph::build_dialog()
47 dialog_.reset(new QParagraphDialog(this));
49 // Manage the ok, apply, restore and cancel/close buttons
50 bcview().setOK(dialog_->okPB);
51 bcview().setApply(dialog_->applyPB);
52 bcview().setCancel(dialog_->closePB);
53 bcview().setRestore(dialog_->restorePB);
57 void QParagraph::apply()
59 ParagraphParameters & params = controller().params();
63 switch (dialog_->align->currentItem()) {
65 align = LYX_ALIGN_BLOCK;
68 align = LYX_ALIGN_LEFT;
71 align = LYX_ALIGN_RIGHT;
74 align = LYX_ALIGN_CENTER;
77 align = LYX_ALIGN_BLOCK;
82 Spacing::Space linespacing = Spacing::Default;
84 switch (dialog_->linespacing->currentItem()) {
86 linespacing = Spacing::Default;
89 linespacing = Spacing::Single;
92 linespacing = Spacing::Onehalf;
95 linespacing = Spacing::Double;
98 linespacing = Spacing::Other;
99 other = fromqstr(dialog_->linespacingValue->text());
103 Spacing const spacing(linespacing, other);
104 params.spacing(spacing);
107 params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
109 params.noindent(!dialog_->indentCB->isChecked());
113 void QParagraph::update_contents()
115 ParagraphParameters const & params = controller().params();
118 string const & labelwidth = params.labelWidthString();
119 // _() is correct here (this is stupid though !)
120 if (labelwidth != _("Senseless with this layout!")) {
121 dialog_->labelwidthGB->setEnabled(true);
122 dialog_->labelWidth->setText(toqstr(labelwidth));
124 dialog_->labelwidthGB->setEnabled(false);
125 dialog_->labelWidth->setText("");
130 switch (params.align()) {
134 case LYX_ALIGN_RIGHT:
137 case LYX_ALIGN_CENTER:
144 dialog_->align->setCurrentItem(i);
147 //LyXAlignment alignpos = controller().alignPossible();
149 dialog_->indentCB->setChecked(!params.noindent());
153 Spacing const & space = params.spacing();
154 switch (space.getSpace()) {
155 case Spacing::Single:
158 case Spacing::Onehalf:
161 case Spacing::Double:
171 dialog_->linespacing->setCurrentItem(linespacing);
172 if (space.getSpace() == Spacing::Other) {
173 dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
174 dialog_->linespacingValue->setEnabled(true);
176 dialog_->linespacingValue->setText("");
177 dialog_->linespacingValue->setEnabled(false);
181 } // namespace frontend