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 <q3buttongroup.h>
25 #include <qcheckbox.h>
26 #include <qlineedit.h>
27 #include <qpushbutton.h>
35 typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
38 QParagraph::QParagraph(Dialog & parent)
39 : base_class(parent, _("Paragraph Settings"))
43 void QParagraph::build_dialog()
46 dialog_.reset(new QParagraphDialog(this));
48 // Manage the ok, apply, restore and cancel/close buttons
49 bcview().setOK(dialog_->okPB);
50 bcview().setApply(dialog_->applyPB);
51 bcview().setCancel(dialog_->closePB);
52 bcview().setRestore(dialog_->restorePB);
56 void QParagraph::apply()
58 ParagraphParameters & params = controller().params();
62 switch (dialog_->align->currentItem()) {
64 align = LYX_ALIGN_BLOCK;
67 align = LYX_ALIGN_LEFT;
70 align = LYX_ALIGN_RIGHT;
73 align = LYX_ALIGN_CENTER;
76 align = LYX_ALIGN_BLOCK;
81 Spacing::Space linespacing = Spacing::Default;
83 switch (dialog_->linespacing->currentItem()) {
85 linespacing = Spacing::Default;
88 linespacing = Spacing::Single;
91 linespacing = Spacing::Onehalf;
94 linespacing = Spacing::Double;
97 linespacing = Spacing::Other;
98 other = fromqstr(dialog_->linespacingValue->text());
102 Spacing const spacing(linespacing, other);
103 params.spacing(spacing);
106 params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
108 params.noindent(!dialog_->indentCB->isChecked());
112 void QParagraph::update_contents()
114 ParagraphParameters const & params = controller().params();
117 string const & labelwidth = params.labelWidthString();
118 // _() is correct here (this is stupid though !)
119 if (labelwidth != _("Senseless with this layout!")) {
120 dialog_->labelwidthGB->setEnabled(true);
121 dialog_->labelWidth->setText(toqstr(labelwidth));
123 dialog_->labelwidthGB->setEnabled(false);
124 dialog_->labelWidth->setText("");
129 switch (params.align()) {
133 case LYX_ALIGN_RIGHT:
136 case LYX_ALIGN_CENTER:
143 dialog_->align->setCurrentItem(i);
146 //LyXAlignment alignpos = controller().alignPossible();
148 dialog_->indentCB->setChecked(!params.noindent());
152 Spacing const & space = params.spacing();
153 switch (space.getSpace()) {
154 case Spacing::Single:
157 case Spacing::Onehalf:
160 case Spacing::Double:
170 dialog_->linespacing->setCurrentItem(linespacing);
171 if (space.getSpace() == Spacing::Other) {
172 dialog_->linespacingValue->setText(toqstr(space.getValueAsString()));
173 dialog_->linespacingValue->setEnabled(true);
175 dialog_->linespacingValue->setText("");
176 dialog_->linespacingValue->setEnabled(false);
180 } // namespace frontend