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*/)
62 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
64 setWidthCO->setCurrentIndex(
65 setWidthCO->findData(toqstr(params["set_width"])));
67 lengthToWidgets(valueLE, unitLC,
68 params["width"], Length::defaultUnit());
72 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
74 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
75 paramsToDialog(nomencl->params());
79 docstring GuiPrintNomencl::dialogToParams() const
81 InsetCommandParams params(insetCode());
82 docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
83 setWidthCO->currentIndex()).toString());
84 params["set_width"] = set_width;
86 if (set_width == from_ascii("custom"))
87 width = from_utf8(widgetsToLength(valueLE, unitLC));
88 params["width"] = width;
89 return from_ascii(InsetNomencl::params2string(params));
93 bool GuiPrintNomencl::checkWidgets(bool readonly) const
95 valueLE->setReadOnly(readonly);
97 setWidthCO->setEnabled(false);
98 unitLC->setEnabled(false);
99 valueLA->setEnabled(false);
102 (setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
103 valueLE->setEnabled(custom);
104 unitLC->setEnabled(custom);
105 valueLA->setEnabled(custom);
108 if (!InsetParamsWidget::checkWidgets())
110 return setWidthCO->itemData(
111 setWidthCO->currentIndex()).toString() != "custom"
112 || !valueLE->text().isEmpty();
115 } // namespace frontend
119 #include "moc_GuiPrintNomencl.cpp"