]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiInfo.cpp
BoxUi.ui: revert unintended commit [a6e42e50/lyxgit]
[lyx.git] / src / frontends / qt4 / GuiInfo.cpp
1 /**
2  * \file GuiInfo.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Abdelrazak Younes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiInfo.h"
14
15 #include "qt_helpers.h"
16
17 #include "Buffer.h"
18 #include "buffer_funcs.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
21 #include "Cursor.h"
22
23 #include "insets/InsetInfo.h"
24
25 #include "support/gettext.h"
26 #include "support/lstrings.h"
27
28
29 using namespace std;
30 using namespace lyx::support;
31
32 namespace lyx {
33 namespace frontend {
34
35 /////////////////////////////////////////////////////////////////
36 //
37 // GuiInfo
38 //
39 /////////////////////////////////////////////////////////////////
40
41 char const * info_types[] =
42 { "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
43
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"), ""};
47
48
49 GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
50 {
51         setupUi(this);
52
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);
57
58         connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
59         connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
60 }
61
62
63 void GuiInfo::paramsToDialog(Inset const * inset)
64 {
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);
78 }
79
80
81 docstring GuiInfo::dialogToParams() const
82 {
83         int type_index = typeCO->currentIndex();
84         QString type;
85         if (type_index != -1)
86                 type = info_types[type_index];
87         QString const name = nameLE->text();
88         return qstring_to_ucs4(type + ' ' + name);
89 }
90
91
92 } // namespace frontend
93 } // namespace lyx
94
95 #include "moc_GuiInfo.cpp"