From 5d235f5251b4ba05f0492ac6aaf995ed94aa6a16 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 21 Feb 2010 09:28:33 +0000 Subject: [PATCH] Migrate GuiHSPace to InsetParamsDialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33525 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiHSpace.cpp | 301 ++++++++++-------------- src/frontends/qt4/GuiHSpace.h | 44 ++-- src/frontends/qt4/GuiView.cpp | 6 - src/frontends/qt4/InsetParamsDialog.cpp | 7 + src/frontends/qt4/InsetParamsWidget.h | 2 +- src/frontends/qt4/ui/HSpaceUi.ui | 152 +++++------- src/insets/Inset.cpp | 6 +- src/insets/InsetSpace.cpp | 14 -- src/insets/InsetSpace.h | 9 +- src/mathed/InsetMathNest.cpp | 5 +- src/mathed/InsetMathSpace.cpp | 17 +- src/mathed/InsetMathSpace.h | 5 +- 12 files changed, 211 insertions(+), 357 deletions(-) diff --git a/src/frontends/qt4/GuiHSpace.cpp b/src/frontends/qt4/GuiHSpace.cpp index 07b98aee23..4271ab5318 100644 --- a/src/frontends/qt4/GuiHSpace.cpp +++ b/src/frontends/qt4/GuiHSpace.cpp @@ -21,6 +21,8 @@ #include "insets/InsetSpace.h" +#include "mathed/InsetMathSpace.h" + #include "support/gettext.h" #include "support/lstrings.h" @@ -34,133 +36,89 @@ using namespace std; namespace lyx { namespace frontend { -GuiHSpace::GuiHSpace(GuiView & lv, bool math) - : GuiDialog(lv, math ? "mathspace" : "space", qt_("Horizontal Space Settings")) +GuiHSpace::GuiHSpace(bool math_mode, QWidget * parent) + : InsetParamsWidget(parent), math_mode_(math_mode) { - params_.math = math; setupUi(this); - connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); - connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); - connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); + spacingCO->clear(); + if (math_mode_) { + spacingCO->addItem(qt_("Thin space")); + spacingCO->addItem(qt_("Medium space")); + spacingCO->addItem(qt_("Thick space")); + spacingCO->addItem(qt_("Negative thin space")); + spacingCO->addItem(qt_("Negative medium space")); + spacingCO->addItem(qt_("Negative thick space")); + spacingCO->addItem(qt_("Half Quad (0.5 em)")); + spacingCO->addItem(qt_("Quad (1 em)")); + spacingCO->addItem(qt_("Double Quad (2 em)")); + spacingCO->addItem(qt_("Custom")); + } else { + spacingCO->addItem(qt_("Inter-word space")); + spacingCO->addItem(qt_("Thin space")); + spacingCO->addItem(qt_("Negative thin space")); + spacingCO->addItem(qt_("Half Quad (0.5 em)")); + spacingCO->addItem(qt_("Quad (1 em)")); + spacingCO->addItem(qt_("Double Quad (2 em)")); + spacingCO->addItem(qt_("Horizontal Fill")); + spacingCO->addItem(qt_("Custom")); + } connect(spacingCO, SIGNAL(highlighted(QString)), - this, SLOT(change_adaptor())); + this, SLOT(changedSlot())); connect(valueLE, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); + this, SLOT(changedSlot())); connect(spacingCO, SIGNAL(activated(int)), - this, SLOT(enableWidgets(int))); + this, SLOT(changedSlot())); connect(keepCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(changedSlot())); connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(change_adaptor())); + this, SLOT(changedSlot())); connect(fillPatternCO, SIGNAL(activated(int)), - this, SLOT(patternChanged())); + this, SLOT(changedSlot())); - if (params_.math) + if (math_mode_) valueLE->setValidator(unsignedLengthValidator(valueLE)); else valueLE->setValidator(unsignedGlueLengthValidator(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(spacingCO); - bc().addReadOnly(valueLE); - bc().addReadOnly(unitCO); - bc().addReadOnly(keepCB); - bc().addReadOnly(fillPatternCO); - // initialize the length validator - bc().addCheckedLineEdit(valueLE, valueL); + addCheckedWidget(valueLE, valueL); } -void GuiHSpace::change_adaptor() +void GuiHSpace::changedSlot() { + enableWidgets(); changed(); } -void GuiHSpace::setMath(bool custom) +void GuiHSpace::enableWidgets() { + int const selection = spacingCO->currentIndex(); + bool const custom = (selection == spacingCO->count() - 1); valueLE->setEnabled(custom); unitCO->setEnabled(custom); - fillPatternCO->setEnabled(false); - keepCB->setToolTip(qt_("Insert the spacing even after a line break")); - keepCB->setEnabled(false); -} - - -void GuiHSpace::enableWidgets(int selection) -{ - if (params_.math) { - setMath(selection == 9); - changed(); + if (math_mode_) { + fillPatternCO->setEnabled(false); + keepCB->setEnabled(false); return; } - valueLE->setEnabled(selection == 7); - unitCO->setEnabled(selection == 7); fillPatternCO->setEnabled(selection == 6); - int pattern = fillPatternCO->currentIndex(); + bool const no_pattern = fillPatternCO->currentIndex() == 0; bool const enable_keep = selection == 0 || selection == 3 || - (selection == 6 && pattern == 0) || selection == 7; + (selection == 6 && no_pattern) || custom; keepCB->setEnabled(enable_keep); - if (selection == 3) - keepCB->setToolTip(qt_("Insert the spacing even after a line break.\n" - "Note that a protected Half Quad will be turned into\n" - "a vertical space if used at the beginning of a paragraph!")); - else - keepCB->setToolTip(qt_("Insert the spacing even after a line break")); - changed(); -} - - -void GuiHSpace::patternChanged() -{ - enableWidgets(spacingCO->currentIndex()); - changed(); } -static void setWidgetsFromHSpace(InsetSpaceParams const & params, - QComboBox * spacing, - QLineEdit * value, - LengthCombo * unit, - QCheckBox * keep, - QComboBox * fillPattern) +void GuiHSpace::paramsToDialog(Inset const * inset) { - spacing->clear(); - if (params.math) { - spacing->addItem(qt_("Thin space")); - spacing->addItem(qt_("Medium space")); - spacing->addItem(qt_("Thick space")); - spacing->addItem(qt_("Negative thin space")); - spacing->addItem(qt_("Negative medium space")); - spacing->addItem(qt_("Negative thick space")); - spacing->addItem(qt_("Half Quad (0.5 em)")); - spacing->addItem(qt_("Quad (1 em)")); - spacing->addItem(qt_("Double Quad (2 em)")); - spacing->addItem(qt_("Custom")); - keep->setEnabled(false); - fillPattern->setEnabled(false); - } else { - spacing->addItem(qt_("Inter-word space")); - spacing->addItem(qt_("Thin space")); - spacing->addItem(qt_("Negative thin space")); - spacing->addItem(qt_("Half Quad (0.5 em)")); - spacing->addItem(qt_("Quad (1 em)")); - spacing->addItem(qt_("Double Quad (2 em)")); - spacing->addItem(qt_("Horizontal Fill")); - spacing->addItem(qt_("Custom")); - keep->setEnabled(true); - fillPattern->setEnabled(true); - } + InsetSpaceParams const params = math_mode_ + ? static_cast(inset)->params() + : static_cast(inset)->params(); int item = 0; int pattern = 0; @@ -243,45 +201,61 @@ static void setWidgetsFromHSpace(InsetSpaceParams const & params, protect = !params.math; break; } - spacing->setCurrentIndex(item); - fillPattern->setCurrentIndex(pattern); - keep->setChecked(protect); - + spacingCO->setCurrentIndex(item); + fillPatternCO->setCurrentIndex(pattern); + keepCB->setChecked(protect); + if (math_mode_) { + keepCB->setToolTip(qt_("Insert the spacing even after a line break")); + } else if (item == 3) { + keepCB->setToolTip(qt_("Insert the spacing even after a line break.\n" + "Note that a protected Half Quad will be turned into\n" + "a vertical space if used at the beginning of a paragraph!")); + } else { + keepCB->setToolTip(qt_("Insert the spacing even after a line break")); + } Length::UNIT const default_unit = Length::defaultUnit(); if (item == (params.math ? 9 : 7)) { string length = params.length.asString(); - lengthToWidgets(value, unit, length, default_unit); + lengthToWidgets(valueLE, unitCO, length, default_unit); } else - lengthToWidgets(value, unit, "", default_unit); + lengthToWidgets(valueLE, unitCO, "", default_unit); + + enableWidgets(); } -static InsetSpaceParams setHSpaceFromWidgets(int spacing, - QLineEdit * value, LengthCombo * unit, bool keep, int fill, bool math) +docstring GuiHSpace::dialogToMathParams() const { - InsetSpaceParams params(math); - if (math) { - switch (spacing) { - case 0: params.kind = InsetSpaceParams::THIN; break; - case 1: params.kind = InsetSpaceParams::MEDIUM; break; - case 2: params.kind = InsetSpaceParams::THICK; break; - case 3: params.kind = InsetSpaceParams::NEGTHIN; break; - case 4: params.kind = InsetSpaceParams::NEGMEDIUM; break; - case 5: params.kind = InsetSpaceParams::NEGTHICK; break; - case 6: params.kind = InsetSpaceParams::ENSKIP; break; - case 7: params.kind = InsetSpaceParams::QUAD; break; - case 8: params.kind = InsetSpaceParams::QQUAD; break; - case 9: - params.kind = InsetSpaceParams::CUSTOM; - params.length = GlueLength(widgetsToLength(value, unit)); - break; - } - return params; + InsetSpaceParams params(true); + switch (spacingCO->currentIndex()) { + case 0: params.kind = InsetSpaceParams::THIN; break; + case 1: params.kind = InsetSpaceParams::MEDIUM; break; + case 2: params.kind = InsetSpaceParams::THICK; break; + case 3: params.kind = InsetSpaceParams::NEGTHIN; break; + case 4: params.kind = InsetSpaceParams::NEGMEDIUM; break; + case 5: params.kind = InsetSpaceParams::NEGTHICK; break; + case 6: params.kind = InsetSpaceParams::ENSKIP; break; + case 7: params.kind = InsetSpaceParams::QUAD; break; + case 8: params.kind = InsetSpaceParams::QQUAD; break; + case 9: + params.kind = InsetSpaceParams::CUSTOM; + params.length = GlueLength(widgetsToLength(valueLE, unitCO)); + break; } + return from_ascii(InsetSpace::params2string(params)); +} + + +docstring GuiHSpace::dialogToParams() const +{ + if (math_mode_) + return dialogToMathParams(); - switch (spacing) { + InsetSpaceParams params(false); + + switch (spacingCO->currentIndex()) { case 0: - if (keep) + if (keepCB->isChecked()) params.kind = InsetSpaceParams::PROTECTED; else params.kind = InsetSpaceParams::NORMAL; @@ -293,7 +267,7 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing, params.kind = InsetSpaceParams::NEGTHIN; break; case 3: - if (keep) + if (keepCB->isChecked()) params.kind = InsetSpaceParams::ENSPACE; else params.kind = InsetSpaceParams::ENSKIP; @@ -305,88 +279,53 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing, params.kind = InsetSpaceParams::QQUAD; break; case 6: - if (fill == 1) + switch (fillPatternCO->currentIndex()) { + case 1: params.kind = InsetSpaceParams::DOTFILL; - else if (fill == 2) + break; + case 2: params.kind = InsetSpaceParams::HRULEFILL; - else if (fill == 3) + break; + case 3: params.kind = InsetSpaceParams::LEFTARROWFILL; - else if (fill == 4) + break; + case 4: params.kind = InsetSpaceParams::RIGHTARROWFILL; - else if (fill == 5) + break; + case 5: params.kind = InsetSpaceParams::UPBRACEFILL; - else if (fill == 6) + break; + case 6: params.kind = InsetSpaceParams::DOWNBRACEFILL; - else if (keep) - params.kind = InsetSpaceParams::HFILL_PROTECTED; - else - params.kind = InsetSpaceParams::HFILL; + break; + default: + if (keepCB->isChecked()) + params.kind = InsetSpaceParams::HFILL_PROTECTED; + else + params.kind = InsetSpaceParams::HFILL; + break; + } break; case 7: - if (keep) + if (keepCB->isChecked()) params.kind = InsetSpaceParams::CUSTOM_PROTECTED; else params.kind = InsetSpaceParams::CUSTOM; - params.length = GlueLength(widgetsToLength(value, unit)); + params.length = GlueLength(widgetsToLength(valueLE, unitCO)); break; } - return params; -} - - -void GuiHSpace::applyView() -{ - params_ = setHSpaceFromWidgets(spacingCO->currentIndex(), - valueLE, unitCO, keepCB->isChecked(), - fillPatternCO->currentIndex(), params_.math); -} - - -void GuiHSpace::updateContents() -{ - setWidgetsFromHSpace(params_, spacingCO, valueLE, unitCO, keepCB, - fillPatternCO); - enableWidgets(spacingCO->currentIndex()); + return from_ascii(InsetSpace::params2string(params)); } -bool GuiHSpace::initialiseParams(string const & data) +bool GuiHSpace::checkWidgets() const { - bool const math = params_.math; - InsetSpace::string2params(data, params_); - params_.math = math; - if (params_.math) - setMath(params_.kind == InsetSpaceParams::CUSTOM); - setButtonsValid(true); - return true; -} - - -void GuiHSpace::clearParams() -{ - params_ = InsetSpaceParams(params_.math); -} - - -void GuiHSpace::dispatchParams() -{ - dispatch(FuncRequest(getLfun(), InsetSpace::params2string(params_))); -} - - -bool GuiHSpace::isValid() -{ - return spacingCO->currentIndex() != (params_.math ? 9 : 7) + if (!InsetParamsWidget::checkWidgets()) + return false; + return spacingCO->currentIndex() != (math_mode_ ? 9 : 7) || !valueLE->text().isEmpty(); } - -Dialog * createGuiMathHSpace(GuiView & lv) { return new GuiHSpace(lv, true); } - - -Dialog * createGuiTextHSpace(GuiView & lv) { return new GuiHSpace(lv, false); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiHSpace.h b/src/frontends/qt4/GuiHSpace.h index 5b0bdece3b..20a98946e4 100644 --- a/src/frontends/qt4/GuiHSpace.h +++ b/src/frontends/qt4/GuiHSpace.h @@ -12,48 +12,38 @@ #ifndef GUIHSPACE_H #define GUIHSPACE_H -#include "GuiDialog.h" +#include "InsetParamsWidget.h" #include "ui_HSpaceUi.h" -#include "insets/InsetSpace.h" namespace lyx { namespace frontend { -class GuiHSpace : public GuiDialog, public Ui::HSpaceUi +class GuiHSpace : public InsetParamsWidget, public Ui::HSpaceUi { Q_OBJECT public: - GuiHSpace(GuiView & lv, bool math); + GuiHSpace(bool math_mode, QWidget * parent = 0); private Q_SLOTS: /// - void change_adaptor(); + void changedSlot(); /// - void enableWidgets(int); - /// - void patternChanged(); + void enableWidgets(); private: - /// - void setMath(bool custom); - /// Apply from dialog - void applyView(); - /// Update the dialog - void updateContents(); - /// - bool isValid(); - /// - bool initialiseParams(std::string const & data); - /// clean-up on hide. - void clearParams(); - /// clean-up on hide. - void dispatchParams(); - /// - bool isBufferDependent() const { return true; } - - /// - InsetSpaceParams params_; + /// \name InsetParamsWidget inherited methods + //@{ + InsetCode insetCode() const { return SPACE_CODE; } + FuncCode creationCode() const { return LFUN_INSET_INSERT; } + void paramsToDialog(Inset const *); + docstring dialogToParams() const; + bool checkWidgets() const; + //@} + /// + docstring dialogToMathParams() const; + /// + bool const math_mode_; }; } // namespace frontend diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 0c1100d9e4..78163517cc 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -3457,7 +3457,6 @@ Dialog * createGuiIndex(GuiView & lv); Dialog * createGuiLabel(GuiView & lv); Dialog * createGuiListings(GuiView & lv); Dialog * createGuiLog(GuiView & lv); -Dialog * createGuiMathHSpace(GuiView & lv); Dialog * createGuiMathMatrix(GuiView & lv); Dialog * createGuiNomenclature(GuiView & lv); Dialog * createGuiNote(GuiView & lv); @@ -3476,7 +3475,6 @@ Dialog * createGuiSpellchecker(GuiView & lv); Dialog * createGuiSymbols(GuiView & lv); Dialog * createGuiTabularCreate(GuiView & lv); Dialog * createGuiTexInfo(GuiView & lv); -Dialog * createGuiTextHSpace(GuiView & lv); Dialog * createGuiToc(GuiView & lv); Dialog * createGuiThesaurus(GuiView & lv); Dialog * createGuiHyperlink(GuiView & lv); @@ -3538,8 +3536,6 @@ Dialog * GuiView::build(string const & name) return createGuiLog(*this); if (name == "mathdelimiter") return createGuiDelimiter(*this); - if (name == "mathspace") - return createGuiMathHSpace(*this); if (name == "mathmatrix") return createGuiMathMatrix(*this); if (name == "nomenclature") @@ -3560,8 +3556,6 @@ Dialog * GuiView::build(string const & name) return createGuiRef(*this); if (name == "sendto") return createGuiSendTo(*this); - if (name == "space") - return createGuiTextHSpace(*this); if (name == "spellchecker") return createGuiSpellchecker(*this); if (name == "symbols") diff --git a/src/frontends/qt4/InsetParamsDialog.cpp b/src/frontends/qt4/InsetParamsDialog.cpp index 16f29ca8e0..aa5850677d 100644 --- a/src/frontends/qt4/InsetParamsDialog.cpp +++ b/src/frontends/qt4/InsetParamsDialog.cpp @@ -16,6 +16,7 @@ #include "GuiBranch.h" #include "GuiERT.h" #include "GuiInfo.h" +#include "GuiHSpace.h" #include "GuiTabular.h" #include "GuiVSpace.h" #include "FloatPlacement.h" @@ -214,6 +215,12 @@ Dialog * createDialog(GuiView & lv, InsetCode code) case INFO_CODE: widget = new GuiInfo; break; + case MATH_SPACE_CODE: + widget = new GuiHSpace(true); + break; + case SPACE_CODE: + widget = new GuiHSpace(false); + break; case TABULAR_CODE: widget = new GuiTabular; break; diff --git a/src/frontends/qt4/InsetParamsWidget.h b/src/frontends/qt4/InsetParamsWidget.h index d0fbd1157f..58c98a7831 100644 --- a/src/frontends/qt4/InsetParamsWidget.h +++ b/src/frontends/qt4/InsetParamsWidget.h @@ -67,7 +67,7 @@ public: virtual docstring dialogToParams() const = 0; /// \return true if all CheckedWidgets are in a valid state. - bool checkWidgets() const; + virtual bool checkWidgets() const; protected: /// Add a widget to the list of all widgets whose validity should diff --git a/src/frontends/qt4/ui/HSpaceUi.ui b/src/frontends/qt4/ui/HSpaceUi.ui index 5d6a7b5b8f..7d23827576 100644 --- a/src/frontends/qt4/ui/HSpaceUi.ui +++ b/src/frontends/qt4/ui/HSpaceUi.ui @@ -1,185 +1,142 @@ - + HSpaceUi - - + + 0 0 - 259 - 160 + 239 + 109 - + - + true - - + + 9 - + 6 - - - + + + Select a fill pattern style for HFills - + None - + ............... - + ________ - + <----------- - - -----------> + + -----------> - + \-----v-----/ - + /-----^-----\ - - - + + + &Spacing: - + spacingCO - - - + + + Supported spacing types - - - + + + &Value: - + valueLE - - - + + + false - - Custom value. Needs spacing type "Custom". + + Custom value. Needs spacing type "Custom". - - + + - - - + + + &Fill Pattern: - + fillPatternCO - - - + + + - + &Protect: - + keepCB - - - + + + Insert the spacing even after a line break - + - - - - 0 - - - 6 - - - - - &OK - - - false - - - true - - - - - - - &Apply - - - false - - - - - - - &Close - - - false - - - - - @@ -192,13 +149,10 @@ spacingCO valueLE - okPB - applyPB - closePB keepCB - qt_i18n.h + qt_i18n.h diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 119c1c4cd7..c615b78ab9 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -103,7 +103,7 @@ static void build_translator() insetnames[BRANCH_CODE] = InsetName("branch", _("Branch")); insetnames[BOX_CODE] = InsetName("box", _("Box")); insetnames[FLEX_CODE] = InsetName("flex"); - insetnames[SPACE_CODE] = InsetName("space"); + insetnames[SPACE_CODE] = InsetName("space", _("Horizontal Space")); insetnames[VSPACE_CODE] = InsetName("vspace", _("Vertical Space")); insetnames[MATH_MACROARG_CODE] = InsetName("mathmacroarg"); insetnames[LISTINGS_CODE] = InsetName("listings"); @@ -149,7 +149,7 @@ static void build_translator() insetnames[MATH_ROOT_CODE] = InsetName("mathroot"); insetnames[MATH_SCRIPT_CODE] = InsetName("mathscript"); insetnames[MATH_SIZE_CODE] = InsetName("mathsize"); - insetnames[MATH_SPACE_CODE] = InsetName("mathspace"); + insetnames[MATH_SPACE_CODE] = InsetName("mathspace", _("Horizontal Math Space")); insetnames[MATH_SPECIALCHAR_CODE] = InsetName("mathspecialchar"); insetnames[MATH_SPLIT_CODE] = InsetName("mathsplit"); insetnames[MATH_SQRT_CODE] = InsetName("mathsqrt"); @@ -298,6 +298,8 @@ bool Inset::showInsetDialog(BufferView * bv) const case BOX_CODE: case BRANCH_CODE: case INFO_CODE: + case MATH_SPACE_CODE: + case SPACE_CODE: case TABULAR_CODE: case VSPACE_CODE: bv->showDialog(insetName(code)); diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 5cd30542dd..3d9f0abef8 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -60,12 +60,6 @@ GlueLength InsetSpace::length() const } -InsetSpace::~InsetSpace() -{ - hideDialogs("space", this); -} - - docstring InsetSpace::toolTip(BufferView const &, int, int) const { docstring message; @@ -185,14 +179,6 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd, } -bool InsetSpace::showInsetDialog(BufferView * bv) const -{ - bv->showDialog("space", params2string(params()), - const_cast(this)); - return true; -} - - namespace { int const arrow_size = 8; } diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index 5aed4d50e7..d2d5d421df 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -23,8 +23,7 @@ namespace lyx { class LaTeXFeatures; -class InsetSpaceParams { -public: +struct InsetSpaceParams { /// The different kinds of spaces we support enum Kind { /// Normal space ('\ ') @@ -99,11 +98,9 @@ public: /// explicit InsetSpace(InsetSpaceParams const & par); /// - InsetSpaceParams params() const { return params_; } + InsetSpaceParams const & params() const { return params_; } /// InsetSpaceParams::Kind kind() const; - /// - ~InsetSpace(); /// static void string2params(std::string const &, InsetSpaceParams &); @@ -160,8 +157,6 @@ public: bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; private: - /// - bool showInsetDialog(BufferView * bv) const; /// InsetSpaceParams params_; }; diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 0a7810784a..d7ec9bd68c 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1191,11 +1191,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) if (name == "ref") { InsetMathRef tmp(buffer_, name); data = tmp.createDialogStr(to_utf8(name)); + cur.bv().showDialog(to_utf8(name), data); } else if (name == "mathspace") { - InsetMathSpace tmp; - data = tmp.createDialogStr(); + cur.bv().showDialog(to_utf8(name)); } - cur.bv().showDialog(to_utf8(name), data); break; } diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp index c771d2595b..bd426008cd 100644 --- a/src/mathed/InsetMathSpace.cpp +++ b/src/mathed/InsetMathSpace.cpp @@ -104,12 +104,6 @@ InsetMathSpace::InsetMathSpace(Length const & length) } -InsetMathSpace::~InsetMathSpace() -{ - hideDialogs("mathspace", this); -} - - Inset * InsetMathSpace::clone() const { return new InsetMathSpace(*this); @@ -230,13 +224,13 @@ void InsetMathSpace::write(WriteStream & os) const } -string const InsetMathSpace::createDialogStr() const +InsetSpaceParams InsetMathSpace::params() const { LASSERT(space_info[space_].visible, /**/); InsetSpaceParams isp(true); isp.kind = space_info[space_].kind; isp.length = GlueLength(length_); - return InsetSpace::params2string(isp); + return isp; } @@ -279,14 +273,9 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd) cur.undispatched(); break; - case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("mathspace", createDialogStr()); - break; - case LFUN_MOUSE_RELEASE: if (cmd.button() == mouse_button::button1) { - string const data = createDialogStr(); - cur.bv().showDialog("mathspace", data, this); + showInsetDialog(&cur.bv()); break; } cur.undispatched(); diff --git a/src/mathed/InsetMathSpace.h b/src/mathed/InsetMathSpace.h index 3e60b41c12..381562178c 100644 --- a/src/mathed/InsetMathSpace.h +++ b/src/mathed/InsetMathSpace.h @@ -18,6 +18,7 @@ namespace lyx { +struct InsetSpaceParams; /// Smart spaces class InsetMathSpace : public InsetMath { @@ -29,8 +30,6 @@ public: /// explicit InsetMathSpace(Length const & length); /// - ~InsetMathSpace(); - /// InsetMathSpace const * asSpaceInset() const { return this; } /// InsetMathSpace * asSpaceInset() { return this; } @@ -56,7 +55,7 @@ public: /// void write(WriteStream & os) const; /// generate something that will be understood by the Dialogs. - std::string const createDialogStr() const; + InsetSpaceParams params() const; /// bool hasSettings() const { return true; } /// -- 2.39.2