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
This commit is contained in:
Bo Peng 2008-06-06 04:10:42 +00:00
parent f5101ebec8
commit 3c142cdd47
5 changed files with 101 additions and 30 deletions

View File

@ -24,9 +24,11 @@
#include "insets/InsetInfo.h" #include "insets/InsetInfo.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/lstrings.h"
using namespace std; using namespace std;
using namespace lyx::support;
namespace lyx { namespace lyx {
namespace frontend { 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) GuiInfo::GuiInfo(GuiView & lv)
: DialogView(lv, "info", qt_("Info")) : DialogView(lv, "info", qt_("Info"))
{ {
setupUi(this); 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(); hide();
} }
@ -61,6 +80,8 @@ void GuiInfo::applyView()
updateLabels(bufferview()->buffer()); updateLabels(bufferview()->buffer());
bufferview()->updateMetrics(); bufferview()->updateMetrics();
bufferview()->buffer().changed(); bufferview()->buffer().changed();
hide();
} }
@ -68,12 +89,17 @@ void GuiInfo::updateView()
{ {
InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE)); InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
if (!ii) { if (!ii) {
typeCO->setCurrentIndex(0);
nameLE->clear();
// FIXME: A New button to create an InsetInfo at the cursor location // FIXME: A New button to create an InsetInfo at the cursor location
// would be nice. // would be nice.
enableView(false); enableView(false);
return; return;
} }
//FIXME: update the controls.
int type = findToken(info_types, ii->infoType());
typeCO->setCurrentIndex(type >= 0 ? type : 0);
nameLE->setText(toqstr(ii->infoName()));
} }

View File

@ -38,7 +38,7 @@ public:
//@} //@}
private Q_SLOTS: private Q_SLOTS:
void on_closePB_clicked(); void on_cancelPB_clicked();
}; };
} // namespace frontend } // namespace frontend

View File

@ -5,8 +5,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>161</width> <width>320</width>
<height>121</height> <height>131</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -15,32 +15,67 @@
<property name="sizeGripEnabled" > <property name="sizeGripEnabled" >
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout" > <layout class="QVBoxLayout" >
<item row="0" column="0" > <item>
<spacer name="spacer" > <layout class="QGridLayout" >
<property name="orientation" > <item row="0" column="0" >
<enum>Qt::Horizontal</enum> <widget class="QLabel" name="typeLBL" >
</property> <property name="text" >
<property name="sizeType" > <string>Information Type:</string>
<enum>QSizePolicy::Expanding</enum> </property>
</property> </widget>
<property name="sizeHint" stdset="0" > </item>
<size> <item row="0" column="1" >
<width>84</width> <widget class="QComboBox" name="typeCO" />
<height>20</height> </item>
</size> <item row="1" column="0" >
</property> <widget class="QLabel" name="nameLBL" >
</spacer> <property name="text" >
<string>Information Name:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="nameLE" />
</item>
</layout>
</item> </item>
<item row="0" column="1" > <item>
<widget class="QPushButton" name="closePB" > <layout class="QHBoxLayout" >
<property name="text" > <item>
<string>&amp;Close</string> <spacer>
</property> <property name="orientation" >
<property name="default" > <enum>Qt::Horizontal</enum>
<bool>true</bool> </property>
</property> <property name="sizeType" >
</widget> <enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>84</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okPB" >
<property name="text" >
<string>&amp;OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelPB" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -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 docstring InsetInfo::toolTip(BufferView const &, int, int) const
{ {
odocstringstream os; odocstringstream os;

View File

@ -105,6 +105,10 @@ public:
/// ///
void write(std::ostream & os) const; void write(std::ostream & os) const;
/// ///
std::string infoType() const;
///
std::string infoName() const { return name_; }
///
bool showInsetDialog(BufferView * bv) const; bool showInsetDialog(BufferView * bv) const;
/// ///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;