mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Migrate ERT dialog to InsetDialog.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33354 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ede4c8c370
commit
116ef17ce9
@ -13,6 +13,9 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "GuiERT.h"
|
#include "GuiERT.h"
|
||||||
|
|
||||||
|
#include "insets/InsetERT.h"
|
||||||
|
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
@ -26,64 +29,41 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GuiERT::GuiERT(GuiView & lv)
|
GuiERT::GuiERT(GuiView & lv)
|
||||||
: GuiDialog(lv, "ert", qt_("TeX Code Settings")), status_(InsetCollapsable::Collapsed)
|
: InsetDialog(lv, ERT_CODE, LFUN_INSET_INSERT, "ert", "TeX Code Settings")
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
connect(collapsedRB, SIGNAL(clicked()), this, SLOT(applyView()));
|
||||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
connect(openRB, SIGNAL(clicked()), this, SLOT(applyView()));
|
||||||
connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
||||||
connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
|
||||||
|
|
||||||
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
||||||
bc().setOK(okPB);
|
|
||||||
bc().setCancel(closePB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiERT::change_adaptor()
|
void GuiERT::enableView(bool enable)
|
||||||
{
|
{
|
||||||
changed();
|
collapsedRB->setEnabled(enable);
|
||||||
|
openRB->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiERT::applyView()
|
docstring GuiERT::dialogToParams() const
|
||||||
{
|
{
|
||||||
if (openRB->isChecked())
|
InsetCollapsable::CollapseStatus status = openRB->isChecked()
|
||||||
status_ = InsetCollapsable::Open;
|
? InsetCollapsable::Open : InsetCollapsable::Collapsed;
|
||||||
else
|
return from_ascii(InsetERT::params2string(status));
|
||||||
status_ = InsetCollapsable::Collapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiERT::updateContents()
|
void GuiERT::paramsToDialog(Inset const * inset)
|
||||||
{
|
{
|
||||||
switch (status_) {
|
InsetERT const * ert = static_cast<InsetERT const *>(inset);
|
||||||
|
InsetCollapsable::CollapseStatus status = ert->status(*bufferview());
|
||||||
|
switch (status) {
|
||||||
case InsetCollapsable::Open: openRB->setChecked(true); break;
|
case InsetCollapsable::Open: openRB->setChecked(true); break;
|
||||||
case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
|
case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GuiERT::initialiseParams(string const & data)
|
|
||||||
{
|
|
||||||
status_ = InsetERT::string2params(data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiERT::clearParams()
|
|
||||||
{
|
|
||||||
status_ = InsetCollapsable::Collapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiERT::dispatchParams()
|
|
||||||
{
|
|
||||||
dispatch(FuncRequest(getLfun(), InsetERT::params2string(status_)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Dialog * createGuiERT(GuiView & lv) { return new GuiERT(lv); }
|
Dialog * createGuiERT(GuiView & lv) { return new GuiERT(lv); }
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,43 +12,30 @@
|
|||||||
#ifndef GUIERT_H
|
#ifndef GUIERT_H
|
||||||
#define GUIERT_H
|
#define GUIERT_H
|
||||||
|
|
||||||
#include "GuiDialog.h"
|
#include "InsetDialog.h"
|
||||||
#include "ui_ERTUi.h"
|
#include "ui_ERTUi.h"
|
||||||
#include "insets/InsetERT.h" // InsetERT::ERTStatus
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiERT : public GuiDialog, public Ui::ERTUi
|
class GuiERT : public InsetDialog, public Ui::ERTUi
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiERT(GuiView & lv);
|
GuiERT(GuiView & lv);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private:
|
||||||
void change_adaptor();
|
/// \name Dialog inerited methods
|
||||||
|
//@{
|
||||||
|
void enableView(bool enable);
|
||||||
|
//@}
|
||||||
|
|
||||||
private:
|
/// \name InsetDialog inherited methods
|
||||||
/// Apply changes
|
//@{
|
||||||
void applyView();
|
void paramsToDialog(Inset const *);
|
||||||
/// update
|
docstring dialogToParams() const;
|
||||||
void updateContents();
|
//@}
|
||||||
///
|
|
||||||
InsetCollapsable::CollapseStatus status() const { return status_; }
|
|
||||||
///
|
|
||||||
void setStatus(InsetCollapsable::CollapseStatus status) { status_ = status; }
|
|
||||||
///
|
|
||||||
bool initialiseParams(std::string const & data);
|
|
||||||
/// clean-up on hide.
|
|
||||||
void clearParams();
|
|
||||||
/// clean-up on hide.
|
|
||||||
void dispatchParams();
|
|
||||||
///
|
|
||||||
bool isBufferDependent() const { return true; }
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
InsetCollapsable::CollapseStatus status_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -70,7 +70,10 @@ void InsetDialog::on_closePB_clicked()
|
|||||||
|
|
||||||
void InsetDialog::on_newPB_clicked()
|
void InsetDialog::on_newPB_clicked()
|
||||||
{
|
{
|
||||||
docstring const argument = dialogToParams();
|
docstring argument;
|
||||||
|
if (d->creation_code_ == LFUN_INSET_INSERT)
|
||||||
|
argument = from_ascii(insetName(d->inset_code_)) + " ";
|
||||||
|
argument += dialogToParams();
|
||||||
dispatch(FuncRequest(d->creation_code_, argument));
|
dispatch(FuncRequest(d->creation_code_, argument));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user