#include "BufferParams.h"
#include "BufferView.h"
#include "Cursor.h"
-#include "FuncRequest.h"
#include "insets/InsetInfo.h"
#include "support/debug.h"
+#include "support/gettext.h"
+#include "support/lstrings.h"
using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace frontend {
//
/////////////////////////////////////////////////////////////////
-GuiInfo::GuiInfo(GuiView & lv)
- : DialogView(lv, "info", qt_("Info"))
-{
- setupUi(this);
-}
+char const * info_types[] =
+{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
-
-void GuiInfo::on_closePB_clicked()
-{
- hide();
-}
+char const * info_types_gui[] =
+{ N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"),
+ N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""};
-void GuiInfo::applyView()
+GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
{
- InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
- if (!ii)
- return;
-
- // FIXME: update the inset contents
-
- updateLabels(bufferview()->buffer());
- bufferview()->updateMetrics();
- bufferview()->buffer().changed();
-}
+ setupUi(this);
+ typeCO->blockSignals(true);
+ for (int n = 0; info_types[n][0]; ++n)
+ typeCO->addItem(qt_(info_types_gui[n]));
+ typeCO->blockSignals(false);
-void GuiInfo::updateView()
-{
- InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
- if (!ii) {
- // FIXME: A New button to create an InsetInfo at the cursor location
- // would be nice.
- enableView(false);
- return;
- }
- //FIXME: update the controls.
+ connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+ connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
}
-void GuiInfo::enableView(bool enable)
+void GuiInfo::paramsToDialog(Inset const * inset)
{
- //FIXME: enable controls that need enabling.
+ InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
+ QString const type = toqstr(ii->infoType());
+ QString const name = toqstr(ii->infoName());
+ typeCO->blockSignals(true);
+ nameLE->blockSignals(true);
+ int type_index = findToken(info_types, fromqstr(type));
+ typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
+ // Without this test, 'math-insert' (name) will replace 'math-insert '
+ // in nameLE and effectively disallow the input of spaces after a LFUN.
+ if (nameLE->text().trimmed() != name)
+ nameLE->setText(name);
+ typeCO->blockSignals(false);
+ nameLE->blockSignals(false);
}
-void GuiInfo::dispatchParams()
+docstring GuiInfo::dialogToParams() const
{
+ int type_index = typeCO->currentIndex();
+ QString type;
+ if (type_index != -1)
+ type = info_types[type_index];
+ QString const name = nameLE->text();
+ return qstring_to_ucs4(type + ' ' + name);
}
-Dialog * createGuiInfo(GuiView & lv) { return new GuiInfo(lv); }
-
-
} // namespace frontend
} // namespace lyx
-#include "GuiInfo_moc.cpp"
+#include "moc_GuiInfo.cpp"