* 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:
Edwin Leuven 2006-11-03 11:24:27 +00:00
parent d03061c171
commit 406c793cd8
4 changed files with 656 additions and 802 deletions

View File

@ -33,10 +33,10 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include <qlineedit.h> #include <QLineEdit>
#include <qpushbutton.h> #include <QPushButton>
#include <qcheckbox.h> #include <QCheckBox>
#include <qlabel.h> #include <QLabel>
#include <cmath> #include <cmath>
@ -70,38 +70,20 @@ void QGraphics::build_dialog()
bcview().setRestore(dialog_->restorePB); bcview().setRestore(dialog_->restorePB);
bcview().setCancel(dialog_->closePB); bcview().setCancel(dialog_->closePB);
bcview().addReadOnly(dialog_->rotateGB);
bcview().addReadOnly(dialog_->latexoptions); bcview().addReadOnly(dialog_->latexoptions);
bcview().addReadOnly(dialog_->subfigure); bcview().addReadOnly(dialog_->subfigure);
bcview().addReadOnly(dialog_->subcaption);
bcview().addReadOnly(dialog_->filenameL); bcview().addReadOnly(dialog_->filenameL);
bcview().addReadOnly(dialog_->filename); bcview().addReadOnly(dialog_->filename);
bcview().addReadOnly(dialog_->browsePB); bcview().addReadOnly(dialog_->browsePB);
bcview().addReadOnly(dialog_->unzipCB); bcview().addReadOnly(dialog_->unzipCB);
bcview().addReadOnly(dialog_->filename); bcview().addReadOnly(dialog_->filename);
bcview().addReadOnly(dialog_->lbX); bcview().addReadOnly(dialog_->bbFrame);
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_->draftCB); bcview().addReadOnly(dialog_->draftCB);
bcview().addReadOnly(dialog_->clip); bcview().addReadOnly(dialog_->clip);
bcview().addReadOnly(dialog_->unzipCB); bcview().addReadOnly(dialog_->unzipCB);
bcview().addReadOnly(dialog_->subfigure); bcview().addReadOnly(dialog_->displayGB);
bcview().addReadOnly(dialog_->subcaption); bcview().addReadOnly(dialog_->sizeGB);
bcview().addReadOnly(dialog_->showCB); bcview().addReadOnly(dialog_->rotationGB);
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_->latexoptions); bcview().addReadOnly(dialog_->latexoptions);
bcview().addReadOnly(dialog_->getPB); bcview().addReadOnly(dialog_->getPB);
@ -238,47 +220,25 @@ void QGraphics::update_contents()
} }
dialog_->showCB->setCurrentIndex(item); dialog_->showCB->setCurrentIndex(item);
dialog_->showCB->setEnabled(igp.display != graphics::NoDisplay && !readOnly()); 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_->displayscale->setEnabled(igp.display != graphics::NoDisplay && !readOnly());
dialog_->displayscaleL->setEnabled(igp.display != graphics::NoDisplay && !readOnly());
dialog_->displayscale->setText(toqstr(convert<string>(igp.lyxscale))); dialog_->displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
//// the output section (width/height) // the output section (width/height)
// set the length combo boxes dialog_->Scale->setText(toqstr(igp.scale));
// only the width has the possibility for scale%. The original
// units are defined in lengthcommon.C lengthToWidgets(dialog_->Width, dialog_->widthUnit,
// 1. the width (a listttype) igp.width.asString(), unitDefault);
dialog_->widthUnit->clear();
dialog_->widthUnit->addItem(qt_("Scale%"));
for (int i = 0; i < num_units; i++)
dialog_->widthUnit->addItem(unit_name_gui[i]);
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, lengthToWidgets(dialog_->Height, dialog_->heightUnit,
igp.height.asString(), unitDefault); 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_->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_->angle->setText(toqstr(igp.rotateAngle));
dialog_->origin->clear(); dialog_->origin->clear();
@ -358,23 +318,19 @@ void QGraphics::apply()
default:; default:;
} }
if (!dialog_->displayCB->isChecked()) if (!dialog_->displayGB->isChecked())
igp.display = graphics::NoDisplay; igp.display = graphics::NoDisplay;
string value = fromqstr(dialog_->Width->text()); if (dialog_->scaleCB->isChecked()
if (dialog_->widthUnit->currentIndex() > 0 || isValidLength(value)) { && !dialog_->Scale->text().isEmpty()) {
// width/height combination igp.scale = fromqstr(dialog_->Scale->text());
igp.width =
widgetsToLength(dialog_->Width, dialog_->widthUnit);
igp.scale = string();
} else { } else {
// scaling instead of a width igp.scale = string();
igp.scale = value;
igp.width = LyXLength();
} }
value = fromqstr(dialog_->Height->text());
igp.height = igp.width = LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit));
LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
igp.height = LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
igp.keepAspectRatio = dialog_->aspectratio->isChecked(); igp.keepAspectRatio = dialog_->aspectratio->isChecked();

View File

@ -14,8 +14,6 @@
#include "QGraphicsDialog.h" #include "QGraphicsDialog.h"
#include "QGraphics.h" #include "QGraphics.h"
//Added by qt3to4:
#include <QCloseEvent>
#include "lengthcombo.h" #include "lengthcombo.h"
#include "validators.h" #include "validators.h"
@ -25,9 +23,10 @@
#include "controllers/ControlGraphics.h" #include "controllers/ControlGraphics.h"
#include <qpushbutton.h> #include <QCloseEvent>
#include <qlineedit.h> #include <QPushButton>
#include <qvalidator.h> #include <QLineEdit>
#include <QValidator>
using std::string; using std::string;
@ -48,41 +47,62 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form)
form, SLOT(slotClose())); form, SLOT(slotClose()));
connect(restorePB, SIGNAL(clicked()), connect(restorePB, SIGNAL(clicked()),
form, SLOT(slotRestore())); form, SLOT(slotRestore()));
connect(editPB, SIGNAL(clicked()), connect(filename, SIGNAL( textChanged(const QString&) ),
this, SLOT(edit_clicked())); 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(lbY, SIGNAL( textChanged(const QString&) ),
connect( browsePB, SIGNAL( clicked() ), this, SLOT( browse_clicked() ) ); this, SLOT( change_bb() ) );
connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); connect(lbYunit, SIGNAL( activated(int) ),
connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( filenameChanged(const QString&) ) ); this, SLOT( change_bb() ) );
connect( subcaption, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); connect(rtY, SIGNAL( textChanged(const QString&) ),
connect( subfigure, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); this, SLOT( change_bb() ) );
connect( latexoptions, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); connect(rtYunit, SIGNAL( activated(int) ),
connect( clip, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); this, SLOT( change_bb() ) );
connect( lbX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
connect( showCB, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) ); connect(lbX, SIGNAL( textChanged(const QString&) ),
connect( displayscale, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); this, SLOT( change_bb() ) );
connect( Width, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); connect(lbXunit, SIGNAL( activated(int) ),
connect( widthUnit, SIGNAL( activated(int) ), this, SLOT( change_WUnit() ) ); this, SLOT( change_bb() ) );
connect( aspectratio, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); connect(rtX, SIGNAL( textChanged(const QString&) ),
connect( displayCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); this, SLOT( change_bb() ) );
connect( draftCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); connect(rtXunit, SIGNAL( activated(int) ),
connect( unzipCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); this, SLOT( change_bb() ) );
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() ) );
angle->setValidator(new QDoubleValidator(-360, 360, 2, angle)); 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) void QGraphicsDialog::closeEvent(QCloseEvent * e)
{ {
form_->slotWMHide(); form_->slotWMHide();
@ -138,7 +148,7 @@ void QGraphicsDialog::closeEvent(QCloseEvent * e)
} }
void QGraphicsDialog::browse_clicked() void QGraphicsDialog::on_browsePB_clicked()
{ {
docstring const str = docstring const str =
form_->controller().browse(qstring_to_ucs4(filename->text())); 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(); form_->getBB();
} }
void QGraphicsDialog::edit_clicked() void QGraphicsDialog::on_editPB_clicked()
{ {
form_->controller().editGraphics(); form_->controller().editGraphics();
} }
void QGraphicsDialog::filenameChanged(const QString & filename)
void QGraphicsDialog::on_filename_textChanged(const QString & filename)
{ {
editPB->setDisabled(filename.isEmpty()); 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 frontend
} // namespace lyx } // namespace lyx

View File

@ -33,11 +33,11 @@ public:
protected Q_SLOTS: protected Q_SLOTS:
virtual void change_adaptor(); virtual void change_adaptor();
virtual void change_bb(); virtual void change_bb();
virtual void change_WUnit(); virtual void on_browsePB_clicked();
virtual void browse_clicked(); virtual void on_getPB_clicked();
virtual void getBB_clicked(); virtual void on_editPB_clicked();
virtual void edit_clicked(); virtual void on_filename_textChanged(const QString &);
virtual void filenameChanged(const QString &); virtual void on_scaleCB_toggled(bool);
protected: protected:
virtual void closeEvent(QCloseEvent * e); virtual void closeEvent(QCloseEvent * e);
private: private:

File diff suppressed because it is too large Load Diff