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"
22 #include "FuncRequest.h"
24 #include "insets/InsetInfo.h"
26 #include "support/debug.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", "" };
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"), ""};
50 GuiInfo::GuiInfo(GuiView & lv)
51 : InsetDialog(lv, INFO_CODE, LFUN_INFO_INSERT, "info", "Info")
55 typeCO->blockSignals(true);
56 for (int n = 0; info_types[n][0]; ++n)
57 typeCO->addItem(qt_(info_types_gui[n]));
58 typeCO->blockSignals(false);
60 connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(applyView()));
61 connect(nameLE, SIGNAL(textChanged(QString)), this, SLOT(applyView()));
65 void GuiInfo::paramsToDialog(Inset const * inset)
67 InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
68 QString const type = toqstr(ii->infoType());
69 QString const name = toqstr(ii->infoName());
70 typeCO->blockSignals(true);
71 nameLE->blockSignals(true);
72 int type_index = findToken(info_types, fromqstr(type));
73 typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
74 // Without this test, 'math-insert' (name) will replace 'math-insert '
75 // in nameLE and effectively disallow the input of spaces after a LFUN.
76 if (nameLE->text().trimmed() != name)
77 nameLE->setText(name);
78 typeCO->blockSignals(false);
79 nameLE->blockSignals(false);
83 docstring GuiInfo::dialogToParams() const
85 int type_index = typeCO->currentIndex();
88 type = info_types[type_index];
89 QString const name = nameLE->text();
90 return qstring_to_ucs4(type + ' ' + name);
94 void GuiInfo::enableView(bool enable)
96 typeCO->setEnabled(enable);
97 nameLE->setEnabled(enable);
98 newPB->setEnabled(!enable);
102 Dialog * createGuiInfo(GuiView & lv) { return new GuiInfo(lv); }
105 } // namespace frontend
108 #include "moc_GuiInfo.cpp"