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() == "custom");
60 valueLE->setEnabled(custom);
61 unitLC->setEnabled(custom);
62 valueLA->setEnabled(custom);
67 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
69 setWidthCO->setCurrentIndex(
70 setWidthCO->findData(toqstr(params["set_width"])));
72 lengthToWidgets(valueLE, unitLC,
73 params["width"], Length::defaultUnit());
76 (setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
77 valueLE->setEnabled(custom);
78 unitLC->setEnabled(custom);
79 valueLA->setEnabled(custom);
83 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
85 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
86 paramsToDialog(nomencl->params());
90 docstring GuiPrintNomencl::dialogToParams() const
92 InsetCommandParams params(insetCode());
93 docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
94 setWidthCO->currentIndex()).toString());
95 params["set_width"] = set_width;
97 if (set_width == from_ascii("custom"))
98 width = from_utf8(widgetsToLength(valueLE, unitLC));
99 params["width"] = width;
100 return from_ascii(InsetNomencl::params2string(params));
104 bool GuiPrintNomencl::checkWidgets(bool readonly) const
106 valueLE->setReadOnly(readonly);
107 setWidthCO->setEnabled(!readonly);
108 unitLC->setEnabled(!readonly);
109 if (!InsetParamsWidget::checkWidgets())
111 return setWidthCO->itemData(
112 setWidthCO->currentIndex()).toString() != "custom"
113 || !valueLE->text().isEmpty();
116 } // namespace frontend
120 #include "moc_GuiPrintNomencl.cpp"