]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiInfo.cpp
GuiInfo: display and initialize the information dialog, can not apply yet
[features.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 #include "FuncRequest.h"
23
24 #include "insets/InsetInfo.h"
25
26 #include "support/debug.h"
27 #include "support/lstrings.h"
28
29
30 using namespace std;
31 using namespace lyx::support;
32
33 namespace lyx {
34 namespace frontend {
35
36 /////////////////////////////////////////////////////////////////
37 //
38 // GuiInfo
39 //
40 /////////////////////////////////////////////////////////////////
41
42 char const * info_types[] =
43 { "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "" };
44
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"), ""};
48
49
50
51 GuiInfo::GuiInfo(GuiView & lv)
52         : DialogView(lv, "info", qt_("Info"))
53 {
54         setupUi(this);
55
56         connect(okPB, SIGNAL(clicked()), this, SLOT(slotApply()));
57
58         connect(typeCO, SIGNAL(clicked()), this, SLOT(change_adaptor()));
59         connect(nameLE, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor()));
60
61         for (int n = 0; info_types[n][0]; ++n)
62                 typeCO->addItem(qt_(info_types_gui[n]));
63 }
64
65
66 void GuiInfo::on_cancelPB_clicked()
67 {
68         hide();
69 }
70
71
72 void GuiInfo::applyView()
73 {
74         InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
75         if (!ii)
76                 return;
77         
78         // FIXME: update the inset contents
79
80         updateLabels(bufferview()->buffer());
81         bufferview()->updateMetrics();
82         bufferview()->buffer().changed();
83
84         hide();
85 }
86
87
88 void GuiInfo::updateView()
89 {
90         InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
91         if (!ii) {
92                 typeCO->setCurrentIndex(0);
93                 nameLE->clear();
94                 // FIXME: A New button to create an InsetInfo at the cursor location
95                 // would be nice.
96                 enableView(false);
97                 return;
98         }
99
100         int type = findToken(info_types, ii->infoType());
101         typeCO->setCurrentIndex(type >= 0 ? type : 0);
102         nameLE->setText(toqstr(ii->infoName()));
103 }
104
105
106 void GuiInfo::enableView(bool enable)
107 {
108         //FIXME: enable controls that need enabling.
109 }
110
111
112 void GuiInfo::dispatchParams()
113 {
114 }
115
116
117 Dialog * createGuiInfo(GuiView & lv) { return new GuiInfo(lv); }
118
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #include "GuiInfo_moc.cpp"