2 * \file GuiPrintNomencl.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
9 * Full author contact details are available in file CREDITS.
14 #include "GuiPrintNomencl.h"
16 #include "LengthCombo.h"
17 #include "qt_helpers.h"
18 #include "Validator.h"
20 #include "FuncRequest.h"
22 #include "insets/InsetNomencl.h"
24 #include "support/gettext.h"
25 #include "support/lstrings.h"
32 GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
36 connect(valueLE, SIGNAL(textChanged(QString)),
37 this, SIGNAL(changed()));
38 connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
39 this, SIGNAL(changed()));
41 valueLE->setValidator(unsignedLengthValidator(valueLE));
43 // initialize the length validator
44 addCheckedWidget(valueLE, valueLA);
46 setWidthCO->addItem(qt_("Default"),
47 QVariant(toqstr("none")));
48 setWidthCO->addItem(qt_("Longest label width"),
49 QVariant(toqstr("auto")));
50 setWidthCO->addItem(qt_("Custom"),
51 QVariant(toqstr("custom")));
55 void GuiPrintNomencl::on_setWidthCO_activated(int i)
58 (setWidthCO->itemData(i).toString() == "custom");
59 valueLE->setEnabled(custom);
60 unitLC->setEnabled(custom);
61 valueLA->setEnabled(custom);
66 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
68 setWidthCO->setCurrentIndex(
69 setWidthCO->findData(toqstr(params["set_width"])));
71 lengthToWidgets(valueLE, unitLC,
72 params["width"], Length::defaultUnit());
75 (setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
76 valueLE->setEnabled(custom);
77 unitLC->setEnabled(custom);
78 valueLA->setEnabled(custom);
82 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
84 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
85 paramsToDialog(nomencl->params());
89 docstring GuiPrintNomencl::dialogToParams() const
91 InsetCommandParams params(insetCode());
92 docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
93 setWidthCO->currentIndex()).toString());
94 params["set_width"] = set_width;
96 if (set_width == from_ascii("custom"))
97 width = from_utf8(widgetsToLength(valueLE, unitLC));
98 params["width"] = width;
99 return from_ascii(InsetNomencl::params2string(params));
103 bool GuiPrintNomencl::checkWidgets() const
105 if (!InsetParamsWidget::checkWidgets())
107 return setWidthCO->itemData(
108 setWidthCO->currentIndex()).toString() != "custom"
109 || !valueLE->text().isEmpty();
112 } // namespace frontend
116 #include "moc_GuiPrintNomencl.cpp"