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 "support/tostr.h"
26 #include <qbuttongroup.h>
27 #include <qcheckbox.h>
28 #include <qcombobox.h>
29 #include <qlineedit.h>
30 #include <qpushbutton.h>
38 typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
41 QParagraph::QParagraph(Dialog & parent)
42 : base_class(parent, _("LyX: 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();
65 switch (dialog_->align->currentItem()) {
67 align = LYX_ALIGN_BLOCK;
70 align = LYX_ALIGN_LEFT;
73 align = LYX_ALIGN_RIGHT;
76 align = LYX_ALIGN_CENTER;
79 align = LYX_ALIGN_BLOCK;
84 Spacing::Space linespacing = Spacing::Default;
86 switch (dialog_->linespacing->currentItem()) {
88 linespacing = Spacing::Default;
91 linespacing = Spacing::Single;
94 linespacing = Spacing::Onehalf;
97 linespacing = Spacing::Double;
100 linespacing = Spacing::Other;
101 other = fromqstr(dialog_->linespacingValue->text());
105 Spacing const spacing(linespacing, other);
106 params.spacing(spacing);
109 params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
111 params.noindent(!dialog_->indentCB->isChecked());
115 void QParagraph::update_contents()
117 ParagraphParameters const & params = controller().params();
120 string const & labelwidth = params.labelWidthString();
121 // _() is correct here (this is stupid though !)
122 if (labelwidth != _("Senseless with this layout!")) {
123 dialog_->labelwidthGB->setEnabled(true);
124 dialog_->labelWidth->setText(toqstr(labelwidth));
126 dialog_->labelwidthGB->setEnabled(false);
127 dialog_->labelWidth->setText("");
132 switch (params.align()) {
136 case LYX_ALIGN_RIGHT:
139 case LYX_ALIGN_CENTER:
146 dialog_->align->setCurrentItem(i);
149 //LyXAlignment alignpos = controller().alignPossible();
151 dialog_->indentCB->setChecked(!params.noindent());
155 Spacing const & space = params.spacing();
156 switch (space.getSpace()) {
157 case Spacing::Single:
160 case Spacing::Onehalf:
163 case Spacing::Double:
173 dialog_->linespacing->setCurrentItem(linespacing);
174 if (space.getSpace() == Spacing::Other) {
175 string const sp = tostr(space.getValue());
176 dialog_->linespacingValue->setText(toqstr(sp));
177 dialog_->linespacingValue->setEnabled(true);
179 dialog_->linespacingValue->setText("");
180 dialog_->linespacingValue->setEnabled(false);
184 } // namespace frontend