#include "support/gettext.h"
#include "support/lstrings.h"
-#include <QLineEdit>
-#include <QPushButton>
-#include <QValidator>
-
using namespace std;
namespace lyx {
namespace frontend {
-GuiPrintNomencl::GuiPrintNomencl(GuiView & lv)
- : GuiDialog(lv, "nomencl_print", qt_("Nomenclature settings")),
- params_(insetCode("nomencl_print"))
+GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-
connect(valueLE, SIGNAL(textChanged(QString)),
- this, SLOT(change_adaptor()));
+ this, SIGNAL(changed()));
connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(change_adaptor()));
+ this, SIGNAL(changed()));
valueLE->setValidator(unsignedLengthValidator(valueLE));
- // Manage the ok, apply, restore and cancel/close buttons
- bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setApply(applyPB);
- bc().setCancel(closePB);
-
- // disable for read-only documents
- bc().addReadOnly(valueLE);
- bc().addReadOnly(unitLC);
-
// initialize the length validator
- bc().addCheckedLineEdit(valueLE, valueLA);
+ addCheckedWidget(valueLE, valueLA);
setWidthCO->addItem(qt_("Default"),
QVariant(toqstr("none")));
}
-void GuiPrintNomencl::change_adaptor()
-{
- changed();
-}
-
-
void GuiPrintNomencl::on_setWidthCO_activated(int i)
{
bool const custom =
}
-void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & /*icp*/)
+void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
{
setWidthCO->setCurrentIndex(
- setWidthCO->findData(toqstr(params_["set_width"])));
+ setWidthCO->findData(toqstr(params["set_width"])));
lengthToWidgets(valueLE,
unitLC,
- params_["width"],
+ params["width"],
Length::defaultUnit());
-
- bc().setValid(isValid());
}
-void GuiPrintNomencl::updateContents()
+void GuiPrintNomencl::paramsToDialog(Inset const * inset)
{
- bool const custom = (setWidthCO->itemData(
- setWidthCO->currentIndex()).toString()
- == "custom");
- valueLE->setEnabled(custom);
- unitLC->setEnabled(custom);
- valueLA->setEnabled(custom);
+ InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
+ paramsToDialog(nomencl->params());
}
-void GuiPrintNomencl::applyView()
+docstring GuiPrintNomencl::dialogToParams() const
{
+ InsetCommandParams params(insetCode());
docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
setWidthCO->currentIndex()).toString());
- params_["set_width"] = set_width;
+ params["set_width"] = set_width;
docstring width;
if (set_width == from_ascii("custom"))
width = from_utf8(widgetsToLength(valueLE, unitLC));
- params_["width"] = width;
+ params["width"] = width;
+ return from_ascii(InsetNomencl::params2string(params));
}
-bool GuiPrintNomencl::isValid() const
+bool GuiPrintNomencl::checkWidgets() const
{
+ if (!InsetParamsWidget::checkWidgets())
+ return false;
return setWidthCO->itemData(
setWidthCO->currentIndex()).toString() != "custom"
|| !valueLE->text().isEmpty();
}
-
-bool GuiPrintNomencl::initialiseParams(std::string const & data)
-{
- InsetCommand::string2params(data, params_);
- paramsToDialog(params_);
- return true;
-}
-
-
-void GuiPrintNomencl::dispatchParams()
-{
- std::string const lfun = InsetCommand::params2string(params_);
- dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-
-Dialog * createGuiPrintNomencl(GuiView & lv)
-{
- return new GuiPrintNomencl(lv);
-}
-
-
} // namespace frontend
} // namespace lyx
#ifndef GUIPRINTNOMENCL_H
#define GUIPRINTNOMENCL_H
-#include "GuiDialog.h"
+#include "InsetParamsWidget.h"
#include "ui_PrintNomenclUi.h"
-#include "insets/InsetCommandParams.h"
-
-
namespace lyx {
namespace frontend {
-class GuiPrintNomencl : public GuiDialog, public Ui::PrintNomenclUi
+class GuiPrintNomencl : public InsetParamsWidget, public Ui::PrintNomenclUi
{
Q_OBJECT
public:
- GuiPrintNomencl(GuiView & lv);
+ GuiPrintNomencl(QWidget * parent = 0);
private Q_SLOTS:
- void change_adaptor();
void on_setWidthCO_activated(int);
private:
- /// Apply changes
- void applyView();
- /// Update dialog before showing it
- void updateContents();
- ///
- bool initialiseParams(std::string const & data);
- ///
- void paramsToDialog(InsetCommandParams const & icp);
- ///
- void clearParams() { params_.clear(); }
- ///
- void dispatchParams();
- ///
- bool isBufferDependent() const { return true; }
- ///
- bool isValid() const;
-
- ///
- InsetCommandParams params_;
+ /// \name InsetParamsWidget inherited methods
+ //@{
+ InsetCode insetCode() const { return NOMENCL_PRINT_CODE; }
+ FuncCode creationCode() const { return LFUN_INSET_INSERT; }
+ void paramsToDialog(Inset const *);
+ void paramsToDialog(InsetCommandParams const &);
+ docstring dialogToParams() const;
+ bool checkWidgets() const;
+ //@}
};
} // namespace frontend
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrintNomenclUi</class>
- <widget class="QDialog" name="PrintNomenclUi">
+ <widget class="QWidget" name="PrintNomenclUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>280</width>
- <height>119</height>
+ <width>336</width>
+ <height>80</height>
</rect>
</property>
<property name="windowTitle">
- <string/>
- </property>
- <property name="sizeGripEnabled">
- <bool>true</bool>
+ <string>"Nomenclature settings"</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="1" column="3">
<widget class="LengthCombo" name="unitLC"/>
</item>
- <item row="2" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>74</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="1" colspan="3">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QPushButton" name="okPB">
- <property name="text">
- <string>&OK</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="applyPB">
- <property name="text">
- <string>&Apply</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closePB">
- <property name="text">
- <string>&Close</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<customwidgets>
</customwidgets>
<tabstops>
<tabstop>valueLE</tabstop>
- <tabstop>okPB</tabstop>
- <tabstop>applyPB</tabstop>
- <tabstop>closePB</tabstop>
</tabstops>
<includes>
<include location="local">qt_i18n.h</include>