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"
29 #include <QPushButton>
37 GuiPrintNomencl::GuiPrintNomencl(GuiView & lv)
38 : GuiDialog(lv, "nomencl_print", qt_("Nomenclature settings")),
39 params_(insetCode("nomencl_print"))
43 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
44 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
45 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
47 connect(valueLE, SIGNAL(textChanged(QString)),
48 this, SLOT(change_adaptor()));
49 connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
50 this, SLOT(change_adaptor()));
52 valueLE->setValidator(unsignedLengthValidator(valueLE));
54 // Manage the ok, apply, restore and cancel/close buttons
55 bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
57 bc().setApply(applyPB);
58 bc().setCancel(closePB);
60 // disable for read-only documents
61 bc().addReadOnly(valueLE);
62 bc().addReadOnly(unitLC);
64 // initialize the length validator
65 bc().addCheckedLineEdit(valueLE, valueLA);
67 setWidthCO->addItem(qt_("Default"),
68 QVariant(toqstr("none")));
69 setWidthCO->addItem(qt_("Longest label width"),
70 QVariant(toqstr("auto")));
71 setWidthCO->addItem(qt_("Custom"),
72 QVariant(toqstr("custom")));
76 void GuiPrintNomencl::change_adaptor()
82 void GuiPrintNomencl::on_setWidthCO_activated(int i)
85 (setWidthCO->itemData(i).toString()
87 valueLE->setEnabled(custom);
88 unitLC->setEnabled(custom);
89 valueLA->setEnabled(custom);
94 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & /*icp*/)
96 setWidthCO->setCurrentIndex(
97 setWidthCO->findData(toqstr(params_["set_width"])));
99 lengthToWidgets(valueLE,
102 Length::defaultUnit());
104 bc().setValid(isValid());
108 void GuiPrintNomencl::updateContents()
110 bool const custom = (setWidthCO->itemData(
111 setWidthCO->currentIndex()).toString()
113 valueLE->setEnabled(custom);
114 unitLC->setEnabled(custom);
115 valueLA->setEnabled(custom);
119 void GuiPrintNomencl::applyView()
121 docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
122 setWidthCO->currentIndex()).toString());
123 params_["set_width"] = set_width;
125 if (set_width == from_ascii("custom"))
126 width = from_utf8(widgetsToLength(valueLE, unitLC));
127 params_["width"] = width;
131 bool GuiPrintNomencl::isValid() const
133 return setWidthCO->itemData(
134 setWidthCO->currentIndex()).toString() != "custom"
135 || !valueLE->text().isEmpty();
139 bool GuiPrintNomencl::initialiseParams(std::string const & data)
141 InsetCommand::string2params(data, params_);
142 paramsToDialog(params_);
147 void GuiPrintNomencl::dispatchParams()
149 std::string const lfun = InsetCommand::params2string(params_);
150 dispatch(FuncRequest(getLfun(), lfun));
155 Dialog * createGuiPrintNomencl(GuiView & lv)
157 return new GuiPrintNomencl(lv);
161 } // namespace frontend
165 #include "moc_GuiPrintNomencl.cpp"