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/gettext.h"
25 #include "support/lstrings.h"
28 #include <QPushButton>
36 GuiLine::GuiLine(QWidget * parent) : InsetParamsWidget(parent)
40 connect(OffsetLE, SIGNAL(textChanged(QString)),
41 this, SIGNAL(changed()));
42 connect(OffsetUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
43 this, SIGNAL(changed()));
44 connect(WidthLE, SIGNAL(textChanged(QString)),
45 this, SIGNAL(changed()));
46 connect(WidthUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
47 this, SIGNAL(changed()));
48 connect(HeightLE, SIGNAL(textChanged(QString)),
49 this, SIGNAL(changed()));
50 connect(HeightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
51 this, SIGNAL(changed()));
53 // initialize the length validator
54 addCheckedWidget(OffsetLE, OffsetValueL);
55 addCheckedWidget(WidthLE, WidthValueL);
56 addCheckedWidget(HeightLE, HeightValueL);
58 OffsetLE->setValidator(unsignedGlueLengthValidator(OffsetLE));
59 WidthLE->setValidator(unsignedGlueLengthValidator(WidthLE));
60 HeightLE->setValidator(unsignedGlueLengthValidator(HeightLE));
62 OffsetLE->setText("0.5");
63 OffsetUnitCO->setCurrentItem(Length::EX);
64 WidthLE->setText("100");
65 WidthUnitCO->setCurrentItem(Length::PCW);
66 HeightLE->setText("1");
67 HeightUnitCO->setCurrentItem(Length::PT);
68 setFocusProxy(WidthLE);
72 docstring GuiLine::dialogToParams() const
74 InsetCommandParams params(insetCode());
75 params["offset"] = from_utf8(widgetsToLength(OffsetLE, OffsetUnitCO));
76 params["width"] = from_utf8(widgetsToLength(WidthLE, WidthUnitCO));
77 params["height"] = from_utf8(widgetsToLength(HeightLE, HeightUnitCO));
78 params.setCmdName("rule");
79 return from_ascii(InsetLine::params2string(params));
83 void GuiLine::paramsToDialog(Inset const * inset)
85 InsetLine const * line = static_cast<InsetLine const *>(inset);
86 InsetCommandParams const & params = line->params();
87 lengthToWidgets(OffsetLE,
90 Length::defaultUnit());
91 lengthToWidgets(WidthLE,
94 Length::defaultUnit());
95 lengthToWidgets(HeightLE,
98 Length::defaultUnit());
102 bool GuiLine::checkWidgets() const
104 if (!InsetParamsWidget::checkWidgets())
106 // FIXME: this should be handled in unsignedGlueLengthValidator!
107 if (WidthLE->text().startsWith('-'))
109 // FIXME: this should be handled in unsignedGlueLengthValidator!
110 if (HeightLE->text().startsWith('-'))
115 } // namespace frontend
119 #include "moc_GuiLine.cpp"