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", "vcs", "lyxinfo", "" };
45 char const * info_types_gui[] =
46 { N_("Unknown"), N_("Last Assigned Keyboard Shortcut"), N_("All Keyboard Shortcuts"),
47 N_("LyX Preferences Entry"), N_("LaTeX Package Availability"), N_("LaTeX Class Availability"),
48 N_("LyX Menu Location"), N_("LyX Toolbar Icon"), N_("Document Information"),
49 N_("Version Control Information"), N_("LyX Application Information"), ""};
51 char const * info_name_gui[] =
52 { N_("Not Applicable"), N_("LyX Function"), N_("LyX Function"), N_("Preferences Key"), N_("Package Name"),
53 N_("Class Name"), N_("LyX Function"), N_("LyX Function"), N_("Information"),
54 N_("Information"), N_("Information"), ""};
56 char const * info_tooltip[] =
57 { N_("Please select a valid type above"),
58 N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
59 "The output is the most recently assigned keyboard shortcut for this function"),
60 N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
61 "The output lists all possible keyboard shortcuts for this function"),
62 N_("Enter a LyX preferences key such as 'bind_file'. Please refer to src/LyXRC.h for available entries. "
63 "The output is the current setting of this preference."),
64 N_("Enter a LaTeX package name such as 'hyperref' (extension is optional). "
65 "The output will be 'Yes' (package available) or 'No' (package unavailable)."),
66 N_("Enter a LaTeX class name such as 'article' (extension is optional). "
67 "The output will be 'Yes' (class available) or 'No' (class unavailable)."),
68 N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
69 "The output is the path to the function in the menu (using the current localization)."),
70 N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
71 "The output is the toolbar icon for this function (using the active icon theme)."),
72 N_("Enter either 'name' (outputs the filename of the current document), 'path' (outputs the file path), or 'class' (outputs the text class)."),
73 N_("Enter either 'revision', 'tree-revision', 'author', 'time' or 'date'. If available, the respective version control information is output."),
74 N_("Currently supported information type: 'version' (outputs the current LyX version)."),
78 GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
82 typeCO->blockSignals(true);
83 for (int n = 0; info_types[n][0]; ++n)
84 typeCO->addItem(qt_(info_types_gui[n]), info_types[n]);
85 typeCO->blockSignals(false);
87 connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
88 connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
92 void GuiInfo::paramsToDialog(Inset const * inset)
94 InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
95 QString const type = toqstr(ii->infoType());
96 QString const name = toqstr(ii->infoName());
97 typeCO->blockSignals(true);
98 nameLE->blockSignals(true);
99 int const i = typeCO->findData(type);
100 typeCO->setCurrentIndex(i);
101 // Without this test, 'math-insert' (name) will replace 'math-insert '
102 // in nameLE and effectively disallow the input of spaces after a LFUN.
103 if (nameLE->text().trimmed() != name)
104 nameLE->setText(name);
105 typeCO->blockSignals(false);
106 nameLE->blockSignals(false);
110 docstring GuiInfo::dialogToParams() const
113 typeCO->itemData(typeCO->currentIndex()).toString();
114 QString const name = nameLE->text();
115 return qstring_to_ucs4(type + ' ' + name);
119 bool GuiInfo::checkWidgets(bool readonly) const
121 nameLE->setReadOnly(readonly);
122 typeCO->setEnabled(!readonly);
123 nameLA->setText(qt_(info_name_gui[typeCO->currentIndex()]) + toqstr(":"));
124 bool const type_enabled =
125 typeCO->itemData(typeCO->currentIndex()).toString() != "unknown";
126 nameLA->setEnabled(type_enabled);
127 nameLE->setEnabled(type_enabled);
128 nameLE->setToolTip(qt_(info_tooltip[typeCO->currentIndex()]));
130 if (!InsetParamsWidget::checkWidgets())
132 return !nameLE->text().isEmpty();
136 } // namespace frontend
139 #include "moc_GuiInfo.cpp"