#include "GuiLabel.h"
-#include "FuncRequest.h"
#include "qt_helpers.h"
-#include "support/debug.h"
-#include "insets/InsetCommand.h"
+#include "insets/InsetLabel.h"
#include <QLabel>
#include <QPushButton>
//
/////////////////////////////////////////////////////////////////
-GuiLabel::GuiLabel(GuiView & lv)
- : GuiDialog(lv, "label", qt_("Label")),
- params_(insetCode("label"))
+GuiLabel::GuiLabel(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(keywordED, SIGNAL(textChanged(const QString &)),
- this, SLOT(change_adaptor()));
+ this, SIGNAL(changed()));
setFocusProxy(keywordED);
-
- bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setCancel(closePB);
- bc().addReadOnly(keywordED);
}
-void GuiLabel::change_adaptor()
+void GuiLabel::paramsToDialog(Inset const * inset)
{
- changed();
+ InsetLabel const * label = static_cast<InsetLabel const *>(inset);
+ InsetCommandParams const & params = label->params();
+ keywordED->setText(toqstr(params["name"]));
}
-void GuiLabel::reject()
+docstring GuiLabel::dialogToParams() const
{
- slotClose();
+ InsetCommandParams params(insetCode());
+ params["name"] = qstring_to_ucs4(keywordED->text());
+ return from_ascii(InsetLabel::params2string("label", params));
}
-void GuiLabel::updateContents()
-{
- docstring const contents = params_["name"];
- keywordED->setText(toqstr(contents));
- bc().setValid(!contents.empty());
-}
-
-
-void GuiLabel::applyView()
-{
- params_["name"] = qstring_to_ucs4(keywordED->text());
-}
-
-
-
-void GuiLabel::enableView(bool enable)
-{
- keywordED->setEnabled(enable);
-}
-
-
-bool GuiLabel::isValid()
+bool GuiLabel::checkWidgets() const
{
+ if (!InsetParamsWidget::checkWidgets())
+ return false;
return !keywordED->text().isEmpty();
}
-
-bool GuiLabel::initialiseParams(std::string const & data)
-{
- InsetCommand::string2params("label", data, params_);
- return true;
-}
-
-
-void GuiLabel::dispatchParams()
-{
- std::string const lfun = InsetCommand::params2string("label", params_);
- dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
-
-
} // namespace frontend
} // namespace lyx
#ifndef GUILABEL_H
#define GUILABEL_H
-#include "GuiDialog.h"
#include "ui_LabelUi.h"
-#include "insets/InsetCommandParams.h"
+#include "InsetParamsWidget.h"
namespace lyx {
namespace frontend {
-class GuiLabel : public GuiDialog, public Ui::LabelUi
+class GuiLabel : public InsetParamsWidget, public Ui::LabelUi
{
Q_OBJECT
public:
- GuiLabel(GuiView & lv);
-
-private Q_SLOTS:
- void change_adaptor();
- void reject();
-
-private:
- ///
- bool isValid();
- /// Apply changes
- void applyView();
- /// update
- void updateContents();
- ///
- bool initialiseParams(std::string const & data);
- /// clean-up on hide.
- void clearParams() { params_.clear(); }
- /// clean-up on hide.
- void dispatchParams();
- ///
- bool isBufferDependent() const { return true; }
- ///
- void enableView(bool enable);
- ///
- bool canApply() const { return true; }
+ GuiLabel(QWidget * parent = 0);
private:
- ///
- InsetCommandParams params_;
+ /// \name InsetParamsWidget inherited methods
+ //@{
+ InsetCode insetCode() const { return LABEL_CODE; }
+ FuncCode creationCode() const { return LFUN_INSET_INSERT; }
+ void paramsToDialog(Inset const *);
+ docstring dialogToParams() const;
+ bool checkWidgets() const;
+ //@}
};
} // namespace frontend
Dialog * createGuiGraphics(GuiView & lv);
Dialog * createGuiInclude(GuiView & lv);
Dialog * createGuiIndex(GuiView & lv);
-Dialog * createGuiLabel(GuiView & lv);
Dialog * createGuiListings(GuiView & lv);
Dialog * createGuiLog(GuiView & lv);
Dialog * createGuiMathMatrix(GuiView & lv);
Dialog * createGuiTexInfo(GuiView & lv);
Dialog * createGuiToc(GuiView & lv);
Dialog * createGuiThesaurus(GuiView & lv);
-Dialog * createGuiHyperlink(GuiView & lv);
Dialog * createGuiViewSource(GuiView & lv);
Dialog * createGuiWrap(GuiView & lv);
Dialog * createGuiProgressView(GuiView & lv);
return createGuiIndex(*this);
if (name == "index_print")
return createGuiPrintindex(*this);
- if (name == "label")
- return createGuiLabel(*this);
if (name == "listings")
return createGuiListings(*this);
if (name == "log")
#include "GuiERT.h"\r
#include "GuiHyperlink.h"\r
#include "GuiInfo.h"\r
+#include "GuiLabel.h"\r
#include "GuiLine.h"\r
#include "GuiHSpace.h"\r
#include "GuiTabular.h"\r
case INFO_CODE:\r
widget = new GuiInfo;\r
break;\r
+ case LABEL_CODE:\r
+ widget = new GuiLabel;\r
+ break;\r
case LINE_CODE:\r
widget = new GuiLine;\r
break;\r
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>LabelUi</class>
- <widget class="QDialog" name="LabelUi" >
- <property name="geometry" >
+ <widget class="QWidget" name="LabelUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
- <height>82</height>
+ <height>71</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string/>
</property>
- <property name="sizeGripEnabled" >
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>11</number>
- </property>
- <property name="spacing" >
+ <layout class="QVBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
+ <property name="margin">
+ <number>11</number>
+ </property>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
+ <layout class="QHBoxLayout">
+ <property name="spacing">
<number>6</number>
</property>
- <item>
- <widget class="QLabel" name="keywordLA" >
- <property name="toolTip" >
- <string/>
- </property>
- <property name="text" >
- <string>&Label:</string>
- </property>
- <property name="buddy" >
- <cstring>keywordED</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="keywordED" >
- <property name="toolTip" >
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
+ <property name="margin">
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
+ <widget class="QLabel" name="keywordLA">
+ <property name="toolTip">
+ <string/>
</property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <property name="text">
+ <string>&Label:</string>
</property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okPB" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="default" >
- <bool>true</bool>
+ <property name="buddy">
+ <cstring>keywordED</cstring>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="closePB" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>false</bool>
+ <widget class="QLineEdit" name="keywordED">
+ <property name="toolTip">
+ <string/>
</property>
</widget>
</item>
</layout>
</widget>
<includes>
- <include location="local" >qt_i18n.h</include>
+ <include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections/>