3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
16 #include "LengthCombo.h"
17 #include "qt_helpers.h"
18 #include "Validator.h"
20 #include "FuncRequest.h"
22 #include "insets/InsetLine.h"
24 #include "support/debug.h"
25 #include "support/gettext.h"
26 #include "support/lstrings.h"
29 #include <QPushButton>
37 GuiLine::GuiLine(QWidget * parent) : InsetParamsWidget(parent)
41 connect(OffsetLE, SIGNAL(textChanged(QString)),
42 this, SIGNAL(changed()));
43 connect(OffsetUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
44 this, SIGNAL(changed()));
45 connect(WidthLE, SIGNAL(textChanged(QString)),
46 this, SIGNAL(changed()));
47 connect(WidthUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
48 this, SIGNAL(changed()));
49 connect(HeightLE, SIGNAL(textChanged(QString)),
50 this, SIGNAL(changed()));
51 connect(HeightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
52 this, SIGNAL(changed()));
54 // initialize the length validator
55 addCheckedWidget(OffsetLE, OffsetValueL);
56 addCheckedWidget(WidthLE, WidthValueL);
57 addCheckedWidget(HeightLE, HeightValueL);
59 OffsetLE->setValidator(unsignedGlueLengthValidator(OffsetLE));
60 WidthLE->setValidator(unsignedGlueLengthValidator(WidthLE));
61 HeightLE->setValidator(unsignedGlueLengthValidator(HeightLE));
63 OffsetLE->setText("0.5");
64 OffsetUnitCO->setCurrentItem(Length::EX);
65 WidthLE->setText("100");
66 WidthUnitCO->setCurrentItem(Length::PCW);
67 HeightLE->setText("1");
68 HeightUnitCO->setCurrentItem(Length::PT);
69 setFocusProxy(WidthLE);
73 docstring GuiLine::dialogToParams() const
75 InsetCommandParams params(insetCode());
76 params["offset"] = from_utf8(widgetsToLength(OffsetLE, OffsetUnitCO));
77 params["width"] = from_utf8(widgetsToLength(WidthLE, WidthUnitCO));
78 params["height"] = from_utf8(widgetsToLength(HeightLE, HeightUnitCO));
79 params.setCmdName("rule");
80 return from_ascii(InsetLine::params2string(params));
84 void GuiLine::paramsToDialog(Inset const * inset)
86 InsetLine const * line = static_cast<InsetLine const *>(inset);
87 InsetCommandParams const & params = line->params();
88 lengthToWidgets(OffsetLE,
91 Length::defaultUnit());
92 lengthToWidgets(WidthLE,
95 Length::defaultUnit());
96 lengthToWidgets(HeightLE,
99 Length::defaultUnit());
103 bool GuiLine::checkWidgets() const
105 if (!InsetParamsWidget::checkWidgets())
107 // FIXME: this should be handled in unsignedGlueLengthValidator!
108 if (WidthLE->text().startsWith('-'))
110 // FIXME: this should be handled in unsignedGlueLengthValidator!
111 if (HeightLE->text().startsWith('-'))
116 } // namespace frontend
120 #include "moc_GuiLine.cpp"