3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Abdelrazak Younes
8 * Full author contact details are available in file CREDITS.
15 #include "qt_helpers.h"
18 #include "buffer_funcs.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
23 #include "insets/InsetInfo.h"
25 #include "support/debug.h"
26 #include "support/lstrings.h"
30 using namespace lyx::support;
35 /////////////////////////////////////////////////////////////////
39 /////////////////////////////////////////////////////////////////
41 char const * info_types[] =
42 { "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
44 char const * info_types_gui[] =
45 { N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"),
46 N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""};
49 GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
53 typeCO->blockSignals(true);
54 for (int n = 0; info_types[n][0]; ++n)
55 typeCO->addItem(qt_(info_types_gui[n]));
56 typeCO->blockSignals(false);
58 connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
59 connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
63 void GuiInfo::paramsToDialog(Inset const * inset)
65 InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
66 QString const type = toqstr(ii->infoType());
67 QString const name = toqstr(ii->infoName());
68 typeCO->blockSignals(true);
69 nameLE->blockSignals(true);
70 int type_index = findToken(info_types, fromqstr(type));
71 typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
72 // Without this test, 'math-insert' (name) will replace 'math-insert '
73 // in nameLE and effectively disallow the input of spaces after a LFUN.
74 if (nameLE->text().trimmed() != name)
75 nameLE->setText(name);
76 typeCO->blockSignals(false);
77 nameLE->blockSignals(false);
81 docstring GuiInfo::dialogToParams() const
83 int type_index = typeCO->currentIndex();
86 type = info_types[type_index];
87 QString const name = nameLE->text();
88 return qstring_to_ucs4(type + ' ' + name);
92 } // namespace frontend
95 #include "moc_GuiInfo.cpp"