mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
* reorganisation of graphics dialog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15707 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d03061c171
commit
406c793cd8
@ -33,10 +33,10 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
#include <qlineedit.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@ -70,38 +70,20 @@ void QGraphics::build_dialog()
|
||||
bcview().setRestore(dialog_->restorePB);
|
||||
bcview().setCancel(dialog_->closePB);
|
||||
|
||||
bcview().addReadOnly(dialog_->rotateGB);
|
||||
bcview().addReadOnly(dialog_->latexoptions);
|
||||
bcview().addReadOnly(dialog_->subfigure);
|
||||
bcview().addReadOnly(dialog_->subcaption);
|
||||
bcview().addReadOnly(dialog_->filenameL);
|
||||
bcview().addReadOnly(dialog_->filename);
|
||||
bcview().addReadOnly(dialog_->browsePB);
|
||||
bcview().addReadOnly(dialog_->unzipCB);
|
||||
bcview().addReadOnly(dialog_->filename);
|
||||
bcview().addReadOnly(dialog_->lbX);
|
||||
bcview().addReadOnly(dialog_->lbY);
|
||||
bcview().addReadOnly(dialog_->rtX);
|
||||
bcview().addReadOnly(dialog_->rtY);
|
||||
bcview().addReadOnly(dialog_->lbXunit);
|
||||
bcview().addReadOnly(dialog_->lbYunit);
|
||||
bcview().addReadOnly(dialog_->rtXunit);
|
||||
bcview().addReadOnly(dialog_->rtYunit);
|
||||
bcview().addReadOnly(dialog_->bbFrame);
|
||||
bcview().addReadOnly(dialog_->draftCB);
|
||||
bcview().addReadOnly(dialog_->clip);
|
||||
bcview().addReadOnly(dialog_->unzipCB);
|
||||
bcview().addReadOnly(dialog_->subfigure);
|
||||
bcview().addReadOnly(dialog_->subcaption);
|
||||
bcview().addReadOnly(dialog_->showCB);
|
||||
bcview().addReadOnly(dialog_->Width);
|
||||
bcview().addReadOnly(dialog_->Height);
|
||||
bcview().addReadOnly(dialog_->displayCB);
|
||||
bcview().addReadOnly(dialog_->displayscale);
|
||||
bcview().addReadOnly(dialog_->widthUnit);
|
||||
bcview().addReadOnly(dialog_->heightUnit);
|
||||
bcview().addReadOnly(dialog_->aspectratio);
|
||||
bcview().addReadOnly(dialog_->angle);
|
||||
bcview().addReadOnly(dialog_->origin);
|
||||
bcview().addReadOnly(dialog_->displayGB);
|
||||
bcview().addReadOnly(dialog_->sizeGB);
|
||||
bcview().addReadOnly(dialog_->rotationGB);
|
||||
bcview().addReadOnly(dialog_->latexoptions);
|
||||
bcview().addReadOnly(dialog_->getPB);
|
||||
|
||||
@ -238,47 +220,25 @@ void QGraphics::update_contents()
|
||||
}
|
||||
dialog_->showCB->setCurrentIndex(item);
|
||||
dialog_->showCB->setEnabled(igp.display != graphics::NoDisplay && !readOnly());
|
||||
dialog_->displayCB->setChecked(igp.display != graphics::NoDisplay);
|
||||
dialog_->displayGB->setChecked(igp.display != graphics::NoDisplay);
|
||||
dialog_->displayscale->setEnabled(igp.display != graphics::NoDisplay && !readOnly());
|
||||
dialog_->displayscaleL->setEnabled(igp.display != graphics::NoDisplay && !readOnly());
|
||||
dialog_->displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
|
||||
|
||||
//// the output section (width/height)
|
||||
// set the length combo boxes
|
||||
// only the width has the possibility for scale%. The original
|
||||
// units are defined in lengthcommon.C
|
||||
// 1. the width (a listttype)
|
||||
dialog_->widthUnit->clear();
|
||||
dialog_->widthUnit->addItem(qt_("Scale%"));
|
||||
for (int i = 0; i < num_units; i++)
|
||||
dialog_->widthUnit->addItem(unit_name_gui[i]);
|
||||
// the output section (width/height)
|
||||
dialog_->Scale->setText(toqstr(igp.scale));
|
||||
|
||||
lengthToWidgets(dialog_->Width, dialog_->widthUnit,
|
||||
igp.width.asString(), unitDefault);
|
||||
|
||||
if (!igp.scale.empty()
|
||||
&& !float_equal(convert<double>(igp.scale), 0.0, 0.05)
|
||||
|| igp.width.empty()) {
|
||||
dialog_->Width->setText(toqstr(igp.scale));
|
||||
dialog_->widthUnit->setCurrentIndex(0);
|
||||
} else {
|
||||
// no scale means default width/height
|
||||
dialog_->Width->setText(toqstr(convert<string>(igp.width.value())));
|
||||
// the width cannot have a unitDefault, because
|
||||
// it is a "Scale%" or another user defined unit!
|
||||
// +1 instead of the "Scale%" option
|
||||
int unit_ = igp.width.unit();
|
||||
dialog_->widthUnit->setCurrentIndex(unit_ + 1);
|
||||
}
|
||||
// 2. the height (a lengthgcombo type)
|
||||
lengthToWidgets(dialog_->Height, dialog_->heightUnit,
|
||||
igp.height.asString(), unitDefault);
|
||||
|
||||
// enable height input in case of non "Scale%" as width-unit
|
||||
bool use_height = (dialog_->widthUnit->currentIndex() > 0);
|
||||
dialog_->heightL->setEnabled(use_height);
|
||||
dialog_->Height->setEnabled(use_height);
|
||||
dialog_->heightUnit->setEnabled(use_height);
|
||||
|
||||
dialog_->aspectratio->setChecked(igp.keepAspectRatio);
|
||||
|
||||
dialog_->scaleCB->setChecked(!igp.scale.empty() || igp.width.empty());
|
||||
|
||||
dialog_->Scale->setEnabled(!igp.scale.empty() || igp.width.empty());
|
||||
|
||||
dialog_->angle->setText(toqstr(igp.rotateAngle));
|
||||
|
||||
dialog_->origin->clear();
|
||||
@ -358,23 +318,19 @@ void QGraphics::apply()
|
||||
default:;
|
||||
}
|
||||
|
||||
if (!dialog_->displayCB->isChecked())
|
||||
if (!dialog_->displayGB->isChecked())
|
||||
igp.display = graphics::NoDisplay;
|
||||
|
||||
string value = fromqstr(dialog_->Width->text());
|
||||
if (dialog_->widthUnit->currentIndex() > 0 || isValidLength(value)) {
|
||||
// width/height combination
|
||||
igp.width =
|
||||
widgetsToLength(dialog_->Width, dialog_->widthUnit);
|
||||
igp.scale = string();
|
||||
if (dialog_->scaleCB->isChecked()
|
||||
&& !dialog_->Scale->text().isEmpty()) {
|
||||
igp.scale = fromqstr(dialog_->Scale->text());
|
||||
} else {
|
||||
// scaling instead of a width
|
||||
igp.scale = value;
|
||||
igp.width = LyXLength();
|
||||
igp.scale = string();
|
||||
}
|
||||
value = fromqstr(dialog_->Height->text());
|
||||
igp.height =
|
||||
LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
|
||||
|
||||
igp.width = LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit));
|
||||
|
||||
igp.height = LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
|
||||
|
||||
igp.keepAspectRatio = dialog_->aspectratio->isChecked();
|
||||
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "QGraphicsDialog.h"
|
||||
#include "QGraphics.h"
|
||||
//Added by qt3to4:
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "lengthcombo.h"
|
||||
#include "validators.h"
|
||||
@ -25,9 +23,10 @@
|
||||
|
||||
#include "controllers/ControlGraphics.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qvalidator.h>
|
||||
#include <QCloseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QValidator>
|
||||
|
||||
|
||||
using std::string;
|
||||
@ -48,41 +47,62 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form)
|
||||
form, SLOT(slotClose()));
|
||||
connect(restorePB, SIGNAL(clicked()),
|
||||
form, SLOT(slotRestore()));
|
||||
connect(editPB, SIGNAL(clicked()),
|
||||
this, SLOT(edit_clicked()));
|
||||
connect(filename, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(subcaption, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(subfigure, SIGNAL( toggled(bool) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(latexoptions, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(clip, SIGNAL( stateChanged(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(showCB, SIGNAL( currentIndexChanged(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(displayscale, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(Width, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(aspectratio, SIGNAL( stateChanged(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(draftCB, SIGNAL( stateChanged(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(unzipCB, SIGNAL( stateChanged(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(Height, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(heightUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(widthUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(angle, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(origin, SIGNAL( activated(int) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(getPB, SIGNAL( clicked() ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
connect(scaleCB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(change_adaptor()) );
|
||||
connect(Scale, SIGNAL( textChanged(const QString&) ),
|
||||
this, SLOT( change_adaptor() ) );
|
||||
|
||||
connect( subfigure, SIGNAL( toggled(bool) ), subcaption, SLOT( setEnabled(bool) ) );
|
||||
connect( browsePB, SIGNAL( clicked() ), this, SLOT( browse_clicked() ) );
|
||||
connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( filenameChanged(const QString&) ) );
|
||||
connect( subcaption, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( subfigure, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( latexoptions, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( clip, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( lbX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
|
||||
connect( showCB, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( displayscale, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( Width, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( widthUnit, SIGNAL( activated(int) ), this, SLOT( change_WUnit() ) );
|
||||
connect( aspectratio, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( displayCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( draftCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( unzipCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( displayCB, SIGNAL( toggled(bool) ), showCB, SLOT( setEnabled(bool) ) );
|
||||
connect( displayCB, SIGNAL( toggled(bool) ), displayscale, SLOT( setEnabled(bool) ) );
|
||||
connect( Height, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( heightUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) );
|
||||
connect( angle, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
|
||||
connect( origin, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
|
||||
connect( getPB, SIGNAL( clicked() ), this, SLOT( getBB_clicked() ) );
|
||||
connect( getPB, SIGNAL( clicked() ), this, SLOT( change_adaptor() ) );
|
||||
connect( lbY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
|
||||
connect( rtX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
|
||||
connect( rtY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
|
||||
connect( lbXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
|
||||
connect( lbYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
|
||||
connect( rtXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
|
||||
connect( rtYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
|
||||
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() ) );
|
||||
|
||||
angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
|
||||
|
||||
@ -121,16 +141,6 @@ void QGraphicsDialog::change_bb()
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::change_WUnit()
|
||||
{
|
||||
bool useHeight = (widthUnit->currentIndex() > 0);
|
||||
Height->setEnabled(useHeight);
|
||||
heightUnit->setEnabled(useHeight);
|
||||
heightL->setEnabled(useHeight);
|
||||
form_->changed();
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
form_->slotWMHide();
|
||||
@ -138,7 +148,7 @@ void QGraphicsDialog::closeEvent(QCloseEvent * e)
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::browse_clicked()
|
||||
void QGraphicsDialog::on_browsePB_clicked()
|
||||
{
|
||||
docstring const str =
|
||||
form_->controller().browse(qstring_to_ucs4(filename->text()));
|
||||
@ -147,22 +157,37 @@ void QGraphicsDialog::browse_clicked()
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::getBB_clicked()
|
||||
void QGraphicsDialog::on_getPB_clicked()
|
||||
{
|
||||
form_->getBB();
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::edit_clicked()
|
||||
void QGraphicsDialog::on_editPB_clicked()
|
||||
{
|
||||
form_->controller().editGraphics();
|
||||
}
|
||||
|
||||
void QGraphicsDialog::filenameChanged(const QString & filename)
|
||||
|
||||
void QGraphicsDialog::on_filename_textChanged(const QString & filename)
|
||||
{
|
||||
editPB->setDisabled(filename.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void QGraphicsDialog::on_scaleCB_toggled(bool setscale)
|
||||
{
|
||||
Scale->setEnabled(setscale);
|
||||
widthL->setDisabled(setscale);
|
||||
Width->setDisabled(setscale);
|
||||
widthUnit->setDisabled(setscale);
|
||||
aspectratio->setDisabled(setscale);
|
||||
bool noheight = setscale || aspectratio->checkState()==Qt::Checked;
|
||||
heightL->setDisabled(noheight);
|
||||
Height->setDisabled(noheight);
|
||||
heightUnit->setDisabled(noheight);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -33,11 +33,11 @@ public:
|
||||
protected Q_SLOTS:
|
||||
virtual void change_adaptor();
|
||||
virtual void change_bb();
|
||||
virtual void change_WUnit();
|
||||
virtual void browse_clicked();
|
||||
virtual void getBB_clicked();
|
||||
virtual void edit_clicked();
|
||||
virtual void filenameChanged(const QString &);
|
||||
virtual void on_browsePB_clicked();
|
||||
virtual void on_getPB_clicked();
|
||||
virtual void on_editPB_clicked();
|
||||
virtual void on_filename_textChanged(const QString &);
|
||||
virtual void on_scaleCB_toggled(bool);
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent * e);
|
||||
private:
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user