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/gettext.h"
27 #include "support/lstrings.h"
31 using namespace lyx::support;
36 /////////////////////////////////////////////////////////////////
40 /////////////////////////////////////////////////////////////////
42 char const * info_types[] =
43 { "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
45 char const * info_types_gui[] =
46 { N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"),
47 N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""};
50 GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
54 typeCO->blockSignals(true);
55 for (int n = 0; info_types[n][0]; ++n)
56 typeCO->addItem(qt_(info_types_gui[n]));
57 typeCO->blockSignals(false);
59 connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
60 connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
64 void GuiInfo::paramsToDialog(Inset const * inset)
66 InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
67 QString const type = toqstr(ii->infoType());
68 QString const name = toqstr(ii->infoName());
69 typeCO->blockSignals(true);
70 nameLE->blockSignals(true);
71 int type_index = findToken(info_types, fromqstr(type));
72 typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
73 // Without this test, 'math-insert' (name) will replace 'math-insert '
74 // in nameLE and effectively disallow the input of spaces after a LFUN.
75 if (nameLE->text().trimmed() != name)
76 nameLE->setText(name);
77 typeCO->blockSignals(false);
78 nameLE->blockSignals(false);
82 docstring GuiInfo::dialogToParams() const
84 int type_index = typeCO->currentIndex();
87 type = info_types[type_index];
88 QString const name = nameLE->text();
89 return qstring_to_ucs4(type + ' ' + name);
93 } // namespace frontend
96 #include "moc_GuiInfo.cpp"