mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +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 "GuiERT.h"
|
||||
|
||||
#include "insets/InsetERT.h"
|
||||
|
||||
#include "FuncRequest.h"
|
||||
|
||||
#include "support/gettext.h"
|
||||
@ -26,64 +29,41 @@ namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
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);
|
||||
|
||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
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);
|
||||
connect(collapsedRB, SIGNAL(clicked()), this, SLOT(applyView()));
|
||||
connect(openRB, SIGNAL(clicked()), this, SLOT(applyView()));
|
||||
}
|
||||
|
||||
|
||||
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())
|
||||
status_ = InsetCollapsable::Open;
|
||||
else
|
||||
status_ = InsetCollapsable::Collapsed;
|
||||
InsetCollapsable::CollapseStatus status = openRB->isChecked()
|
||||
? InsetCollapsable::Open : InsetCollapsable::Collapsed;
|
||||
return from_ascii(InsetERT::params2string(status));
|
||||
}
|
||||
|
||||
|
||||
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::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); }
|
||||
|
||||
|
||||
|
@ -12,43 +12,30 @@
|
||||
#ifndef GUIERT_H
|
||||
#define GUIERT_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "InsetDialog.h"
|
||||
#include "ui_ERTUi.h"
|
||||
#include "insets/InsetERT.h" // InsetERT::ERTStatus
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiERT : public GuiDialog, public Ui::ERTUi
|
||||
class GuiERT : public InsetDialog, public Ui::ERTUi
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiERT(GuiView & lv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void change_adaptor();
|
||||
private:
|
||||
/// \name Dialog inerited methods
|
||||
//@{
|
||||
void enableView(bool enable);
|
||||
//@}
|
||||
|
||||
private:
|
||||
/// Apply changes
|
||||
void applyView();
|
||||
/// update
|
||||
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_;
|
||||
/// \name InsetDialog inherited methods
|
||||
//@{
|
||||
void paramsToDialog(Inset const *);
|
||||
docstring dialogToParams() const;
|
||||
//@}
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -70,7 +70,10 @@ void InsetDialog::on_closePB_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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user