From 3c142cdd479343927b595e1bad0951347025c4c2 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Fri, 6 Jun 2008 04:10:42 +0000 Subject: [PATCH] GuiInfo: display and initialize the information dialog, can not apply yet git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25152 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiInfo.cpp | 30 +++++++++++- src/frontends/qt4/GuiInfo.h | 2 +- src/frontends/qt4/ui/InfoUi.ui | 89 +++++++++++++++++++++++----------- src/insets/InsetInfo.cpp | 6 +++ src/insets/InsetInfo.h | 4 ++ 5 files changed, 101 insertions(+), 30 deletions(-) diff --git a/src/frontends/qt4/GuiInfo.cpp b/src/frontends/qt4/GuiInfo.cpp index c07250aaec..82be0ce268 100644 --- a/src/frontends/qt4/GuiInfo.cpp +++ b/src/frontends/qt4/GuiInfo.cpp @@ -24,9 +24,11 @@ #include "insets/InsetInfo.h" #include "support/debug.h" +#include "support/lstrings.h" using namespace std; +using namespace lyx::support; namespace lyx { namespace frontend { @@ -37,14 +39,31 @@ namespace frontend { // ///////////////////////////////////////////////////////////////// +char const * info_types[] = +{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "" }; + +char const * info_types_gui[] = +{ N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"), + N_("menu"), N_("icon"), N_("buffer"), ""}; + + + GuiInfo::GuiInfo(GuiView & lv) : DialogView(lv, "info", qt_("Info")) { setupUi(this); + + connect(okPB, SIGNAL(clicked()), this, SLOT(slotApply())); + + connect(typeCO, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(nameLE, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); + + for (int n = 0; info_types[n][0]; ++n) + typeCO->addItem(qt_(info_types_gui[n])); } -void GuiInfo::on_closePB_clicked() +void GuiInfo::on_cancelPB_clicked() { hide(); } @@ -61,6 +80,8 @@ void GuiInfo::applyView() updateLabels(bufferview()->buffer()); bufferview()->updateMetrics(); bufferview()->buffer().changed(); + + hide(); } @@ -68,12 +89,17 @@ void GuiInfo::updateView() { InsetInfo * ii = static_cast(inset(INFO_CODE)); if (!ii) { + typeCO->setCurrentIndex(0); + nameLE->clear(); // FIXME: A New button to create an InsetInfo at the cursor location // would be nice. enableView(false); return; } - //FIXME: update the controls. + + int type = findToken(info_types, ii->infoType()); + typeCO->setCurrentIndex(type >= 0 ? type : 0); + nameLE->setText(toqstr(ii->infoName())); } diff --git a/src/frontends/qt4/GuiInfo.h b/src/frontends/qt4/GuiInfo.h index 01fcffd40f..4d24609a7c 100644 --- a/src/frontends/qt4/GuiInfo.h +++ b/src/frontends/qt4/GuiInfo.h @@ -38,7 +38,7 @@ public: //@} private Q_SLOTS: - void on_closePB_clicked(); + void on_cancelPB_clicked(); }; } // namespace frontend diff --git a/src/frontends/qt4/ui/InfoUi.ui b/src/frontends/qt4/ui/InfoUi.ui index 8dc4650c28..9297bf6964 100644 --- a/src/frontends/qt4/ui/InfoUi.ui +++ b/src/frontends/qt4/ui/InfoUi.ui @@ -5,8 +5,8 @@ 0 0 - 161 - 121 + 320 + 131 @@ -15,32 +15,67 @@ true - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 84 - 20 - - - + + + + + + + Information Type: + + + + + + + + + + Information Name: + + + + + + + - - - - &Close - - - true - - + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 84 + 20 + + + + + + + + &OK + + + + + + + &Cancel + + + true + + + + diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 1853291ff6..7663f323b4 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -69,6 +69,12 @@ void InsetInfo::draw(PainterInfo & pi, int x, int y) const } +string InsetInfo::infoType() const +{ + return nameTranslator().find(type_); +} + + docstring InsetInfo::toolTip(BufferView const &, int, int) const { odocstringstream os; diff --git a/src/insets/InsetInfo.h b/src/insets/InsetInfo.h index f1e8ae65ab..7af746f33e 100644 --- a/src/insets/InsetInfo.h +++ b/src/insets/InsetInfo.h @@ -105,6 +105,10 @@ public: /// void write(std::ostream & os) const; /// + std::string infoType() const; + /// + std::string infoName() const { return name_; } + /// bool showInsetDialog(BufferView * bv) const; /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;