mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-23 08:39:07 +00:00
34492a9d03
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20216 a592a061-630c-0410-9148-cb99ea01b6c8
145 lines
2.9 KiB
C++
145 lines
2.9 KiB
C++
/**
|
|
* \file GuiWrap.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Jürgen Spitzmüller
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "GuiWrap.h"
|
|
|
|
#include "ControlWrap.h"
|
|
#include "LengthCombo.h"
|
|
#include "qt_helpers.h"
|
|
|
|
#include "insets/InsetWrap.h"
|
|
|
|
#include "support/convert.h"
|
|
#include "support/lstrings.h"
|
|
|
|
#include <QLineEdit>
|
|
#include <QCloseEvent>
|
|
#include <QPushButton>
|
|
|
|
using std::string;
|
|
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
GuiWrapDialog::GuiWrapDialog(LyXView & lv)
|
|
: GuiDialog(lv, "wrap")
|
|
{
|
|
setupUi(this);
|
|
setViewTitle(_("Wrap Float Settings"));
|
|
setController(new ControlWrap(*this));
|
|
|
|
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
connect(widthED, SIGNAL(textChanged(const QString &)),
|
|
this, SLOT(change_adaptor()));
|
|
connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
|
this, SLOT(change_adaptor()));
|
|
connect(valignCO, SIGNAL(highlighted(const QString &)),
|
|
this, SLOT(change_adaptor()));
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
bc().setRestore(restorePB);
|
|
bc().setOK(okPB);
|
|
bc().setApply(applyPB);
|
|
bc().setCancel(closePB);
|
|
|
|
bc().addReadOnly(widthED);
|
|
bc().addReadOnly(unitsLC);
|
|
bc().addReadOnly(valignCO);
|
|
}
|
|
|
|
|
|
ControlWrap & GuiWrapDialog::controller() const
|
|
{
|
|
return static_cast<ControlWrap &>(GuiDialog::controller());
|
|
}
|
|
|
|
|
|
void GuiWrapDialog::closeEvent(QCloseEvent * e)
|
|
{
|
|
slotClose();
|
|
e->accept();
|
|
}
|
|
|
|
|
|
void GuiWrapDialog::change_adaptor()
|
|
{
|
|
changed();
|
|
}
|
|
|
|
|
|
void GuiWrapDialog::applyView()
|
|
{
|
|
double const value = widthED->text().toDouble();
|
|
Length::UNIT unit = unitsLC->currentLengthItem();
|
|
if (widthED->text().isEmpty())
|
|
unit = Length::UNIT_NONE;
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
params.width = Length(value, unit);
|
|
|
|
switch (valignCO->currentIndex()) {
|
|
case 0:
|
|
params.placement = "o";
|
|
break;
|
|
case 1:
|
|
params.placement = "i";
|
|
break;
|
|
case 2:
|
|
params.placement = "l";
|
|
break;
|
|
case 3:
|
|
params.placement = "r";
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
static string const numtostr(double val)
|
|
{
|
|
string a = convert<string>(val);
|
|
return a;
|
|
//0pt is a legal width now, it yields a
|
|
//wrapfloat just wide enough for the contents.
|
|
}
|
|
|
|
|
|
void GuiWrapDialog::update_contents()
|
|
{
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
Length len(params.width);
|
|
widthED->setText(toqstr(numtostr(len.value())));
|
|
unitsLC->setCurrentItem(len.unit());
|
|
|
|
int item = 0;
|
|
if (params.placement == "i")
|
|
item = 1;
|
|
else if (params.placement == "l")
|
|
item = 2;
|
|
else if (params.placement == "r")
|
|
item = 3;
|
|
|
|
valignCO->setCurrentIndex(item);
|
|
}
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
|
|
#include "GuiWrap_moc.cpp"
|