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/debug.h"
25 #include "support/gettext.h"
26 #include "support/lstrings.h"
33 GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
37 connect(valueLE, SIGNAL(textChanged(QString)),
38 this, SIGNAL(changed()));
39 connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
40 this, SIGNAL(changed()));
42 valueLE->setValidator(unsignedLengthValidator(valueLE));
44 // initialize the length validator
45 addCheckedWidget(valueLE, valueLA);
47 setWidthCO->addItem(qt_("Default"),
48 QVariant(toqstr("none")));
49 setWidthCO->addItem(qt_("Longest label width"),
50 QVariant(toqstr("auto")));
51 setWidthCO->addItem(qt_("Custom"),
52 QVariant(toqstr("custom")));
56 void GuiPrintNomencl::on_setWidthCO_activated(int i)
59 (setWidthCO->itemData(i).toString()
61 valueLE->setEnabled(custom);
62 unitLC->setEnabled(custom);
63 valueLA->setEnabled(custom);
68 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
70 setWidthCO->setCurrentIndex(
71 setWidthCO->findData(toqstr(params["set_width"])));
73 lengthToWidgets(valueLE,
76 Length::defaultUnit());
80 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
82 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
83 paramsToDialog(nomencl->params());
87 docstring GuiPrintNomencl::dialogToParams() const
89 InsetCommandParams params(insetCode());
90 docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
91 setWidthCO->currentIndex()).toString());
92 params["set_width"] = set_width;
94 if (set_width == from_ascii("custom"))
95 width = from_utf8(widgetsToLength(valueLE, unitLC));
96 params["width"] = width;
97 return from_ascii(InsetNomencl::params2string(params));
101 bool GuiPrintNomencl::checkWidgets() const
103 if (!InsetParamsWidget::checkWidgets())
105 return setWidthCO->itemData(
106 setWidthCO->currentIndex()).toString() != "custom"
107 || !valueLE->text().isEmpty();
110 } // namespace frontend
114 #include "moc_GuiPrintNomencl.cpp"