2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
|
* \file QGraphicsDialog.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
|
|
|
|
* \author Abdelrazak Younes
|
2007-04-05 14:58:15 +00:00
|
|
|
|
* \author Richard Heck
|
2006-03-05 17:24:44 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "QGraphicsDialog.h"
|
|
|
|
|
#include "QGraphics.h"
|
|
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "LengthCombo.h"
|
|
|
|
|
#include "Validator.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
|
#include "controllers/ControlGraphics.h"
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetGraphicsParams.h"
|
2007-01-08 13:22:50 +00:00
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QValidator>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QGraphicsDialog::QGraphicsDialog(QGraphics * form)
|
|
|
|
|
: form_(form)
|
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2007-04-05 14:58:15 +00:00
|
|
|
|
//main buttons
|
2007-04-25 16:39:21 +00:00
|
|
|
|
connect(okPB, SIGNAL(clicked()),
|
|
|
|
|
form, SLOT(slotOK()));
|
|
|
|
|
connect(applyPB, SIGNAL(clicked()),
|
|
|
|
|
form, SLOT(slotApply()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
|
form, SLOT(slotClose()));
|
|
|
|
|
connect(restorePB, SIGNAL(clicked()),
|
|
|
|
|
form, SLOT(slotRestore()));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
//graphics pane
|
2007-04-26 07:12:31 +00:00
|
|
|
|
connect(filename, SIGNAL(textChanged(const QString &)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(WidthCB, SIGNAL( clicked()),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(HeightCB, SIGNAL( clicked()),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-26 07:12:31 +00:00
|
|
|
|
connect(Width, SIGNAL(textChanged(const QString &)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-26 07:12:31 +00:00
|
|
|
|
connect(Height, SIGNAL(textChanged(const QString &)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(aspectratio, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-26 07:12:31 +00:00
|
|
|
|
connect(angle, SIGNAL(textChanged(const QString &)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(origin, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(scaleCB, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-26 07:12:31 +00:00
|
|
|
|
connect(Scale, SIGNAL(textChanged(const QString &)),
|
2007-04-25 16:39:21 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-06-25 13:49:51 +00:00
|
|
|
|
connect(rotateOrderCB, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
filename->setValidator(new PathValidator(true, filename));
|
|
|
|
|
setFocusProxy(filename);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
|
|
|
|
|
scaleValidator->setBottom(0);
|
|
|
|
|
scaleValidator->setDecimals(256); //I guess that will do
|
|
|
|
|
Scale->setValidator(scaleValidator);
|
|
|
|
|
Height->setValidator(unsignedLengthAutoValidator(Height));
|
|
|
|
|
Width->setValidator(unsignedLengthAutoValidator(Width));
|
|
|
|
|
angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
|
2006-11-03 11:24:27 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
//clipping pane
|
2007-04-25 16:39:21 +00:00
|
|
|
|
connect(clip, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(lbY, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(lbYunit, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(rtY, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(rtYunit, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(lbX, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(lbXunit, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(rtX, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(rtXunit, SIGNAL(activated(int)),
|
|
|
|
|
this, SLOT(change_bb()));
|
|
|
|
|
connect(getPB, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-01-13 10:33:04 +00:00
|
|
|
|
lbX->setValidator(new QDoubleValidator(lbX));
|
|
|
|
|
lbY->setValidator(new QDoubleValidator(lbY));
|
|
|
|
|
rtX->setValidator(new QDoubleValidator(rtX));
|
|
|
|
|
rtY->setValidator(new QDoubleValidator(rtY));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
//extra options pane
|
2007-04-25 16:39:21 +00:00
|
|
|
|
connect(latexoptions, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(draftCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(unzipCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-05 14:58:15 +00:00
|
|
|
|
// FIXME: we should connect to clicked() when we move to Qt 4.2 because
|
|
|
|
|
// the toggled(bool) signal is also trigged when we update the widgets
|
|
|
|
|
// (rgh-4/07) this isn't as much or a problem as it was, because we're now
|
|
|
|
|
// using blockSignals() to keep from triggering that signal when we call
|
|
|
|
|
// setChecked(). Note, too, that clicked() would get called whenever it
|
|
|
|
|
// is clicked, even right clicked (I think), not just whenever it is
|
|
|
|
|
// toggled.
|
2007-04-25 16:39:21 +00:00
|
|
|
|
connect(subfigure, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(subcaption, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(displayGB, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(showCB, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(displayscale, SIGNAL(textChanged(const QString&)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
displayscale->setValidator(new QIntValidator(displayscale));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::show()
|
|
|
|
|
{
|
|
|
|
|
QDialog::show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::change_adaptor()
|
|
|
|
|
{
|
|
|
|
|
form_->changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::change_bb()
|
|
|
|
|
{
|
|
|
|
|
form_->controller().bbChanged = true;
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::GRAPHICS)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
<< "[controller().bb_Changed set to true]\n";
|
|
|
|
|
form_->changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::closeEvent(QCloseEvent * e)
|
|
|
|
|
{
|
|
|
|
|
form_->slotWMHide();
|
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
void QGraphicsDialog::on_browsePB_clicked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-10-09 16:33:20 +00:00
|
|
|
|
docstring const str =
|
|
|
|
|
form_->controller().browse(qstring_to_ucs4(filename->text()));
|
2007-05-11 14:25:25 +00:00
|
|
|
|
if(!str.empty()){
|
|
|
|
|
filename->setText(toqstr(str));
|
|
|
|
|
form_->changed();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
void QGraphicsDialog::on_getPB_clicked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
form_->getBB();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
void QGraphicsDialog::on_editPB_clicked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
form_->controller().editGraphics();
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::on_filename_textChanged(const QString & filename)
|
2006-04-06 21:04:27 +00:00
|
|
|
|
{
|
|
|
|
|
editPB->setDisabled(filename.isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-03 11:24:27 +00:00
|
|
|
|
|
2007-06-25 13:49:51 +00:00
|
|
|
|
void QGraphicsDialog::setAutoText()
|
|
|
|
|
{
|
2007-04-05 14:58:15 +00:00
|
|
|
|
if (scaleCB->isChecked()) return;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
if (!Scale->isEnabled() && Scale->text() != "100")
|
2007-04-05 14:58:15 +00:00
|
|
|
|
Scale->setText(QString("auto"));
|
|
|
|
|
|
|
|
|
|
setAutoTextCB(WidthCB, Width, widthUnit);
|
|
|
|
|
setAutoTextCB(HeightCB, Height, heightUnit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::on_scaleCB_toggled(bool setScale)
|
|
|
|
|
{
|
|
|
|
|
Scale->setEnabled(setScale);
|
|
|
|
|
if (setScale) {
|
2007-04-06 12:38:23 +00:00
|
|
|
|
Scale->setText("100");
|
2007-04-05 14:58:15 +00:00
|
|
|
|
Scale->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
}
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
WidthCB->setDisabled(setScale);
|
|
|
|
|
WidthCB->blockSignals(true);
|
|
|
|
|
WidthCB->setChecked(false);
|
|
|
|
|
WidthCB->blockSignals(false);
|
|
|
|
|
Width->setEnabled(false);
|
|
|
|
|
widthUnit->setEnabled(false);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
HeightCB->setDisabled(setScale);
|
|
|
|
|
HeightCB->blockSignals(true);
|
|
|
|
|
HeightCB->setChecked(false);
|
|
|
|
|
HeightCB->blockSignals(false);
|
|
|
|
|
Height->setEnabled(false);
|
|
|
|
|
heightUnit->setEnabled(false);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
aspectratio->setDisabled(true);
|
|
|
|
|
aspectratio->setChecked(true);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-06-25 13:49:51 +00:00
|
|
|
|
rotateOrderCB->setEnabled((WidthCB->isChecked() ||
|
|
|
|
|
HeightCB->isChecked() ||
|
|
|
|
|
scaleCB->isChecked()) &&
|
|
|
|
|
(angle->text() != "0"));
|
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
setAutoText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QGraphicsDialog::on_WidthCB_toggled(bool setWidth)
|
2006-11-03 11:24:27 +00:00
|
|
|
|
{
|
2007-04-05 14:58:15 +00:00
|
|
|
|
Width->setEnabled(setWidth);
|
|
|
|
|
widthUnit->setEnabled(setWidth);
|
|
|
|
|
if (setWidth)
|
|
|
|
|
Width->setFocus(Qt::OtherFocusReason);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
bool const setHeight = HeightCB->isChecked();
|
|
|
|
|
aspectratio->setEnabled(setWidth && setHeight);
|
|
|
|
|
aspectratio->blockSignals(true);
|
|
|
|
|
aspectratio->setChecked(!(setWidth && setHeight));
|
|
|
|
|
aspectratio->blockSignals(false);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
scaleCB->setEnabled(!setWidth && !setHeight);
|
|
|
|
|
//already will be unchecked, so don't need to do that
|
2007-05-28 22:27:45 +00:00
|
|
|
|
Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
|
2007-04-05 14:58:15 +00:00
|
|
|
|
&& scaleCB->isChecked()); //should be false, but let's check
|
2007-06-25 13:49:51 +00:00
|
|
|
|
rotateOrderCB->setEnabled((setWidth || setHeight ||
|
|
|
|
|
scaleCB->isChecked()) &&
|
|
|
|
|
(angle->text() != "0"));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
setAutoText();
|
2006-11-03 11:24:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
void QGraphicsDialog::on_HeightCB_toggled(bool setHeight)
|
|
|
|
|
{
|
|
|
|
|
Height->setEnabled(setHeight);
|
|
|
|
|
heightUnit->setEnabled(setHeight);
|
|
|
|
|
if (setHeight)
|
|
|
|
|
Height->setFocus(Qt::OtherFocusReason);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
bool const setWidth = WidthCB->isChecked();
|
|
|
|
|
aspectratio->setEnabled(setWidth && setHeight);
|
|
|
|
|
aspectratio->blockSignals(true);
|
|
|
|
|
aspectratio->setChecked(!(setWidth && setHeight));
|
|
|
|
|
aspectratio->blockSignals(false);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
scaleCB->setEnabled(!setWidth && !setHeight);
|
|
|
|
|
//already unchecked
|
2007-05-28 22:27:45 +00:00
|
|
|
|
Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
|
2007-04-05 14:58:15 +00:00
|
|
|
|
&& scaleCB->isChecked()); //should be false
|
2007-06-25 13:49:51 +00:00
|
|
|
|
rotateOrderCB->setEnabled((setWidth || setHeight ||
|
|
|
|
|
scaleCB->isChecked()) &&
|
|
|
|
|
(angle->text() != "0"));
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-04-05 14:58:15 +00:00
|
|
|
|
setAutoText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-25 13:49:51 +00:00
|
|
|
|
void QGraphicsDialog::on_angle_textChanged(const QString & filename)
|
|
|
|
|
{
|
|
|
|
|
rotateOrderCB->setEnabled((WidthCB->isChecked() ||
|
|
|
|
|
HeightCB->isChecked() ||
|
|
|
|
|
scaleCB->isChecked()) &&
|
|
|
|
|
(filename != "0"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
|
|
#include "QGraphicsDialog_moc.cpp"
|