Here's the latest. Please test.

Richard

-- 
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Index: qt_helpers.C
===================================================================
--- qt_helpers.C	(revision 17717)
+++ qt_helpers.C	(working copy)
@@ -5,6 +5,7 @@
  *
  * \author Dekel Tsur
  * \author Jürgen Spitzmüller
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -24,6 +25,7 @@
 #include "debug.h"
 
 #include <QComboBox>
+#include <QCheckBox>
 #include <qlineedit.h>
 #include <qtextcodec.h>
 
@@ -92,6 +94,14 @@
 
 
 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
+	LyXLength const & len, LyXLength::UNIT defaultUnit) 
+{
+	combo->setCurrentItem(LyXLength(len).unit());
+	input->setText(toqstr(convert<string>(LyXLength(len).value())));
+}
+
+
+void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
 	string const & len, LyXLength::UNIT defaultUnit)
 {
 	if (len.empty()) {
@@ -103,12 +113,33 @@
 		combo->setCurrentItem(defaultUnit);
 		input->setText(toqstr(len));
 	} else {
-		combo->setCurrentItem(LyXLength(len).unit());
-		input->setText(toqstr(convert<string>(LyXLength(len).value())));
+		lengthToWidgets(input, combo, LyXLength(len), defaultUnit);
 	}
 }
 
 
+void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo, 
+	LyXLength const & len, LyXLength::UNIT defaultUnit)
+{
+	if (len.value() == 0) 
+		lengthToWidgets(input, combo, "auto", defaultUnit);
+	else
+		lengthToWidgets(input, combo, len, defaultUnit);
+}
+
+
+//NOTE "CB" here because we probably will want one of these
+//for labeled sets, as well.
+void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, 
+	LengthCombo * lengthCombo) 
+{
+	if (!checkBox->isChecked()) 
+		lengthToWidgets(lineEdit, lengthCombo, "auto", lengthCombo->currentLengthItem());
+	else if (lineEdit->text() == "auto")
+		lengthToWidgets(lineEdit, lengthCombo, string(""), lengthCombo->currentLengthItem());
+}
+
+
 QString const qt_(char const * str, const char *)
 {
 	return toqstr(_(str));
Index: checkedwidgets.C
===================================================================
--- checkedwidgets.C	(revision 17717)
+++ checkedwidgets.C	(working copy)
@@ -20,7 +20,7 @@
 namespace frontend {
 
 void addCheckedLineEdit(BCView & bcview,
-			QLineEdit * input, QLabel * label)
+			QLineEdit * input, QWidget * label)
 {
 	bcview.addCheckedWidget(new CheckedLineEdit(input, label));
 }
@@ -41,7 +41,7 @@
 }
 
 
-void setWidget(bool valid, QLineEdit * input, QLabel * label)
+void setWidget(bool valid, QLineEdit * input, QWidget * label)
 {
 	if (valid)
 		input->setPalette(QPalette());
@@ -60,7 +60,7 @@
 } // namespace anon
 
 
-CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QLabel * label)
+CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
 	: input_(input), label_(label)
 {}
 
Index: QGraphics.C
===================================================================
--- QGraphics.C	(revision 17717)
+++ QGraphics.C	(working copy)
@@ -6,6 +6,7 @@
  * \author John Levon
  * \author Edwin Leuven
  * \author Herbert Voß
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -90,8 +91,8 @@
 	bcview().addReadOnly(dialog_->getPB);
 
 	// initialize the length validator
-	addCheckedLineEdit(bcview(), dialog_->Width, dialog_->widthL);
-	addCheckedLineEdit(bcview(), dialog_->Height, dialog_->heightL);
+	addCheckedLineEdit(bcview(), dialog_->Width, dialog_->WidthCB);
+	addCheckedLineEdit(bcview(), dialog_->Height, dialog_->HeightCB);
 	addCheckedLineEdit(bcview(), dialog_->displayscale, dialog_->scaleLA);
 	addCheckedLineEdit(bcview(), dialog_->angle, dialog_->angleL);
 	addCheckedLineEdit(bcview(), dialog_->lbX, dialog_->xL);
@@ -225,20 +226,43 @@
 	dialog_->displayGB->setChecked(igp.display != graphics::NoDisplay);
 
 	// the output section (width/height)
+	
 	dialog_->Scale->setText(toqstr(igp.scale));
+	//igp.scale defaults to 100, so we treat it as empty
+	bool const scaleChecked = !igp.scale.empty() && igp.scale != "100";
+	dialog_->scaleCB->setChecked(scaleChecked);
+	dialog_->scaleCB->blockSignals(true);
+	dialog_->scaleCB->setChecked(scaleChecked);
+	dialog_->scaleCB->blockSignals(false);
+	dialog_->Scale->setEnabled(scaleChecked);
+	
+	lengthAutoToWidgets(dialog_->Width, dialog_->widthUnit, igp.width, 
+		unitDefault);
+	bool const widthChecked = !dialog_->Width->text().isEmpty() && 
+		dialog_->Width->text() != "auto";
+	dialog_->WidthCB->blockSignals(true);
+	dialog_->WidthCB->setChecked(widthChecked);
+	dialog_->WidthCB->blockSignals(false);
+	dialog_->Width->setEnabled(widthChecked);
+	dialog_->widthUnit->setEnabled(widthChecked);
+	
+	lengthAutoToWidgets(dialog_->Height, dialog_->heightUnit, igp.height, 
+		unitDefault);
+	bool const heightChecked = !dialog_->Height->text().isEmpty() 
+		&& dialog_->Height->text() != "auto";
+	dialog_->HeightCB->blockSignals(true);
+	dialog_->HeightCB->setChecked(heightChecked);
+	dialog_->HeightCB->blockSignals(false);
+	dialog_->Height->setEnabled(heightChecked);
+	dialog_->heightUnit->setEnabled(heightChecked);
+	
+	dialog_->scaleCB->setEnabled(!widthChecked && !heightChecked);
+	dialog_->WidthCB->setEnabled(!scaleChecked);
+	dialog_->HeightCB->setEnabled(!scaleChecked);
+	dialog_->aspectratio->setEnabled(widthChecked && heightChecked);
+	
+	dialog_->setAutoText();
 
-	lengthToWidgets(dialog_->Width, dialog_->widthUnit,
-		igp.width.asString(), unitDefault);
-
-	lengthToWidgets(dialog_->Height, dialog_->heightUnit,
-		igp.height.asString(), unitDefault);
-
-	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();
@@ -319,20 +343,28 @@
 
 	if (!dialog_->displayGB->isChecked())
 		igp.display = graphics::NoDisplay;
-
-	if (dialog_->scaleCB->isChecked()
-		&& !dialog_->Scale->text().isEmpty()) {
+	
+	//the graphics section
+	if (dialog_->scaleCB->isChecked()	&& !dialog_->Scale->text().isEmpty()) {
 		igp.scale = fromqstr(dialog_->Scale->text());
+		igp.width = LyXLength("0pt");
+		igp.height = LyXLength("0pt");
+		igp.keepAspectRatio = false;
 	} else {
 		igp.scale = string();
+		igp.width = dialog_->WidthCB->isChecked() ? 
+			//Note that this works even if dialog_->Width is "auto", since in
+			//that case we get "0pt".
+			LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit)): 
+			LyXLength("0pt");
+		igp.height = dialog_->HeightCB->isChecked() ? 
+			LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit)) :
+			LyXLength("0pt");
+		igp.keepAspectRatio = dialog_->aspectratio->isEnabled() &&
+			dialog_->aspectratio->isChecked() &&
+			igp.width.value() > 0 && igp.height.value() > 0;
 	}
 
-	igp.width = LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit));
-
-	igp.height = LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
-
-	igp.keepAspectRatio = dialog_->aspectratio->isChecked();
-
 	igp.noUnzip = dialog_->unzipCB->isChecked();
 
 	igp.lyxscale = convert<int>(fromqstr(dialog_->displayscale->text()));
Index: QGraphicsDialog.C
===================================================================
--- QGraphicsDialog.C	(revision 17717)
+++ QGraphicsDialog.C	(working copy)
@@ -6,6 +6,7 @@
  * \author John Levon
  * \author Herbert Voß
  * \author Abdelrazak Younes
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -41,6 +42,7 @@
 	: form_(form)
 {
 	setupUi(this);
+	//main buttons
 	connect(okPB, SIGNAL( clicked() ),
 		form, SLOT( slotOK() ) );
 	connect(applyPB, SIGNAL( clicked() ),
@@ -49,51 +51,47 @@
 		form, SLOT( slotClose() ) );
 	connect(restorePB, SIGNAL( clicked() ),
 		form, SLOT( slotRestore() ) );
+	
+	//graphics pane
 	connect(filename, SIGNAL( textChanged(const QString&) ),
 		this, SLOT( change_adaptor() ) );
-	connect(subcaption, SIGNAL( textChanged(const QString&) ),
+	connect(WidthCB, SIGNAL(  clicked() ),
 		this, SLOT( change_adaptor() ) );
-
-	// 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
-	connect(subfigure, SIGNAL( toggled(bool) ),
+	connect(HeightCB, SIGNAL(  clicked() ),
 		this, SLOT( change_adaptor() ) );
-	connect(displayGB, 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(aspectratio, SIGNAL( stateChanged(int) ),
+		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( clicked() ),
 		this, SLOT(change_adaptor()) );
 	connect(Scale, SIGNAL( textChanged(const QString&) ),
 		this, SLOT( change_adaptor() ) );
+	
+	filename->setValidator(new PathValidator(true, filename));
+	setFocusProxy(filename);
+	
+	QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
+	scaleValidator->setBottom(0);
+	scaleValidator->setDecimals(16); //I guess 16 will do
+	Scale->setValidator(scaleValidator);
+	Height->setValidator(unsignedLengthAutoValidator(Height));
+	Width->setValidator(unsignedLengthAutoValidator(Width));
+	angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
 
+	//clipping pane
+	connect(clip, SIGNAL( stateChanged(int) ),
+		this, SLOT( change_adaptor() ) );
 	connect(lbY, SIGNAL( textChanged(const QString&) ),
 		this, SLOT( change_bb() ) );
 	connect(lbYunit, SIGNAL( activated(int) ),
@@ -102,7 +100,6 @@
 		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) ),
@@ -111,20 +108,34 @@
 		this, SLOT( change_bb() ) );
 	connect(rtXunit, SIGNAL( activated(int) ),
 		this, SLOT( change_bb() ) );
-
-	angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
-
+	connect(getPB, SIGNAL( clicked() ),
+		this, SLOT( change_adaptor() ) );
+	
 	lbX->setValidator(new QDoubleValidator(lbX));
 	lbY->setValidator(new QDoubleValidator(lbY));
 	rtX->setValidator(new QDoubleValidator(rtX));
 	rtY->setValidator(new QDoubleValidator(rtY));
 
+	//extra options pane
+	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() ) );
+	// 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
+	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() ) );
 	displayscale->setValidator(new QIntValidator(displayscale));
-	Height->setValidator(unsignedLengthValidator(Height));
-	Width->setValidator(unsignedLengthValidator(Width));
-
-	filename->setValidator(new PathValidator(true, filename));
-	setFocusProxy(filename);
 }
 
 
@@ -183,25 +194,87 @@
 }
 
 
-void QGraphicsDialog::on_scaleCB_toggled(bool setscale)
+void QGraphicsDialog::setAutoText() {
+	if (scaleCB->isChecked()) return;
+	if (!Scale->isEnabled()) 
+		Scale->setText(QString("auto"));
+
+	setAutoTextCB(WidthCB, Width, widthUnit);
+	setAutoTextCB(HeightCB, Height, heightUnit);
+}
+
+
+void QGraphicsDialog::on_scaleCB_toggled(bool setScale)
 {
-	//FIXME: There is no scale text when the scale was "100" before keepaspectratio
-	//was checked and then scaleCB is checked again
-	//When somebody implements a void on toggling keepaspectration, this
-	//case should be handled there.
-	if (scaleCB->isChecked() && Scale->text() == "")
-		Scale->setText("100");
-	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);
+	Scale->setEnabled(setScale);
+	if (setScale) {
+		Scale->setText("");
+		Scale->setFocus(Qt::OtherFocusReason);
+	}
+	
+	WidthCB->setDisabled(setScale);
+	WidthCB->blockSignals(true);
+	WidthCB->setChecked(false);
+	WidthCB->blockSignals(false);
+	Width->setEnabled(false);
+	widthUnit->setEnabled(false);
+	
+	HeightCB->setDisabled(setScale);
+	HeightCB->blockSignals(true);
+	HeightCB->setChecked(false);
+	HeightCB->blockSignals(false);
+	Height->setEnabled(false);
+	heightUnit->setEnabled(false);
+	
+	aspectratio->setDisabled(true);
+	aspectratio->setChecked(true);
+	
+	setAutoText();
 }
 
+void QGraphicsDialog::on_WidthCB_toggled(bool setWidth)
+{
+	Width->setEnabled(setWidth);
+	widthUnit->setEnabled(setWidth);
+	if (setWidth)
+		Width->setFocus(Qt::OtherFocusReason);
+	
+	bool const setHeight = HeightCB->isChecked();
+	aspectratio->setEnabled(setWidth && setHeight);
+	aspectratio->blockSignals(true);
+	aspectratio->setChecked(!(setWidth && setHeight));
+	aspectratio->blockSignals(false);
+	
+	scaleCB->setEnabled(!setWidth && !setHeight);
+	//already will be unchecked, so don't need to do that
+	Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled() 
+			&& scaleCB->isChecked()); //should be false, but let's check
+	
+	setAutoText();
+}
+
+void QGraphicsDialog::on_HeightCB_toggled(bool setHeight)
+{
+	Height->setEnabled(setHeight);
+	heightUnit->setEnabled(setHeight);
+	if (setHeight)
+		Height->setFocus(Qt::OtherFocusReason);
+	
+	bool const setWidth = WidthCB->isChecked();
+	aspectratio->setEnabled(setWidth && setHeight);
+	aspectratio->blockSignals(true);
+	aspectratio->setChecked(!(setWidth && setHeight));
+	aspectratio->blockSignals(false);
+	
+	scaleCB->setEnabled(!setWidth && !setHeight);
+	//already unchecked
+	Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled() 
+		&& scaleCB->isChecked()); //should be false
+	
+	setAutoText();
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
Index: validators.C
===================================================================
--- validators.C	(revision 17717)
+++ validators.C	(working copy)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Angus Leeming
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -92,6 +93,45 @@
 }
 
 
+LengthAutoValidator::LengthAutoValidator(QWidget * parent)
+	: LengthValidator(parent)
+{}
+
+
+QValidator::State LengthAutoValidator::validate(QString & qtext, int & dummy) const
+{
+	string const text = fromqstr(qtext);
+	if (text == "auto")
+		return QValidator::Acceptable;
+	return LengthValidator::validate(qtext, dummy);
+}
+
+
+LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit * ed)
+{
+	LengthAutoValidator * v = new LengthAutoValidator(ed);
+	v->setBottom(LyXLength());
+	return v;
+}
+
+
+DoubleAutoValidator::DoubleAutoValidator(QWidget * parent) : 
+	QDoubleValidator(parent) {}
+
+
+DoubleAutoValidator::DoubleAutoValidator(double bottom,
+	double top, int decimals, QObject * parent) : 
+	QDoubleValidator(bottom, top, decimals, parent) {}
+
+
+QValidator::State DoubleAutoValidator::validate(QString & input, int & pos) const {
+	string const text = fromqstr(input);
+	if (text == "auto")
+		return QValidator::Acceptable;
+	return QDoubleValidator::validate(input, pos);
+}
+
+
 PathValidator::PathValidator(bool acceptable_if_empty,
 			     QWidget * parent)
 	: QValidator(parent),
Index: qt_helpers.h
===================================================================
--- qt_helpers.h	(revision 17717)
+++ qt_helpers.h	(working copy)
@@ -5,6 +5,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Dekel Tsur
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -17,11 +18,11 @@
 #include "support/qstring_helpers.h"
 
 #include <QString>
-
 #include <utility>
 
 class QComboBox;
 class QLineEdit;
+class QCheckBox;
 
 class LengthCombo;
 
@@ -36,10 +37,31 @@
 /// method to get a LyXLength from widgets (QComboBox)
 LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo);
 
+//FIXME It would be nice if defaultUnit were a default argument
 /// method to set widgets from a LyXLength
+void lengthToWidgets(QLineEdit * input, LengthCombo * combo, 
+	LyXLength const & len, LyXLength::UNIT default_unit);
+/// method to set widgets from a string
 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
 	std::string const & len, LyXLength::UNIT default_unit);
+/// method to set widgets from a LyXLength with optional "auto" if zero
+void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo, 
+	LyXLength const & len, LyXLength::UNIT defaultUnit);
 
+//FIXME setAutoTextCB should really take an argument, as indicated, that
+//determines what text is to be written for "auto". But making
+//that work involves more extensive revisions than we now want
+//to make, since "auto" also appears in update_contents() (see
+//QGraphics.C). 
+/**
+ * sets a checkbox-line edit-length combo group, using "text" if the
+ * checkbox is unchecked and clearing the line edit if it previously
+ * said "text".
+*/
+void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, 
+	LengthCombo * lengthCombo/*, string text = "auto"*/);
+
+
 /// format a string to the given width
 docstring const formatted(docstring const & text, int w = 80);
 
Index: checkedwidgets.h
===================================================================
--- checkedwidgets.h	(revision 17717)
+++ checkedwidgets.h	(working copy)
@@ -14,18 +14,20 @@
 
 #include "BCView.h"
 
-class QLabel;
+class QWidget;
 class QLineEdit;
 
 namespace lyx {
 namespace frontend {
 
+//FIXME If making it a QWidget is uncool, then we can
+//just make this a template...and the class, too...
 void addCheckedLineEdit(BCView & bcview,
-			QLineEdit * input, QLabel * label = 0);
+			QLineEdit * input, QWidget * label = 0);
 
 class CheckedLineEdit : public CheckedWidget {
 public:
-	CheckedLineEdit(QLineEdit * input, QLabel * label = 0);
+	CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
 
 private:
 	///
@@ -33,7 +35,7 @@
 
 	///
 	QLineEdit * input_;
-	QLabel * label_;
+	QWidget * label_;
 };
 
 } // namespace frontend
Index: QGraphicsDialog.h
===================================================================
--- QGraphicsDialog.h	(revision 17717)
+++ QGraphicsDialog.h	(working copy)
@@ -6,6 +6,7 @@
  *
  * \author John Levon
  * \author Herbert Voß
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -28,7 +29,7 @@
 	Q_OBJECT
 public:
 	QGraphicsDialog(QGraphics * form);
-
+	virtual void setAutoText();
 	virtual void show();
 protected Q_SLOTS:
 	virtual void change_adaptor();
@@ -38,6 +39,8 @@
 	virtual void on_editPB_clicked();
 	virtual void on_filename_textChanged(const QString &);
 	virtual void on_scaleCB_toggled(bool);
+	virtual void on_WidthCB_toggled(bool);
+	virtual void on_HeightCB_toggled(bool);
 protected:
 	virtual void closeEvent(QCloseEvent * e);
 private:
Index: validators.h
===================================================================
--- validators.h	(revision 17717)
+++ validators.h	(working copy)
@@ -5,6 +5,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Angus Leeming
+ * \author Richard Heck
  *
  * Full author contact details are available in file CREDITS.
  *
@@ -75,7 +76,44 @@
 /// @returns a new @c LengthValidator that does not accept negative lengths.
 LengthValidator * unsignedLengthValidator(QLineEdit *);
 
+//FIXME This should be generalized to take "text" as part of the
+//constructor and so to set what text we check for, rather than
+//hard-coding it as "auto". But see qt_helpers.h for reasons this
+//is not so trivial. (RGH)
+/** A class to ascertain whether the data passed to the @c validate()
+ *  member function can be interpretted as a LyXGlueLength or is "auto".
+ */
+class LengthAutoValidator : public LengthValidator
+{
+	Q_OBJECT
+	public:
+	/// Define a validator for widget @c parent.
+		LengthAutoValidator(QWidget * parent);
 
+	/** @returns QValidator::Acceptable if @c data is a LyXGlueLength
+		* or is "auto". If not, returns QValidator::Intermediate.
+	 */
+		QValidator::State validate(QString & data, int &) const;
+};
+
+/// @returns a new @c LengthAutoValidator that does not accept negative lengths.
+LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit *);
+
+//FIXME As above, this should really take a text argument.
+/**
+ * A class to determine whether the passed is a double
+ * or is "auto".
+ *
+ */
+class DoubleAutoValidator : public QDoubleValidator {
+	Q_OBJECT
+	public:
+		DoubleAutoValidator(QWidget * parent);
+		DoubleAutoValidator(double bottom, double top, int decimals, 
+			QObject * parent);
+		QValidator::State validate(QString & input, int & pos) const;
+};
+
 // Forward declarations
 class LyXRC;
 
Index: ui/QGraphicsUi.ui
===================================================================
--- ui/QGraphicsUi.ui	(revision 17717)
+++ ui/QGraphicsUi.ui	(working copy)
@@ -232,16 +232,16 @@
            </widget>
           </item>
           <item row="2" column="0" >
-           <widget class="QLabel" name="heightL" >
+           <widget class="QCheckBox" name="HeightCB" >
             <property name="enabled" >
              <bool>true</bool>
             </property>
+            <property name="toolTip" >
+             <string>Sets height of graphic. Leave unchecked to set automatically.</string>
+            </property>
             <property name="text" >
-             <string>&amp;Height:</string>
+             <string>Set &amp;height:</string>
             </property>
-            <property name="buddy" >
-             <cstring>Height</cstring>
-            </property>
            </widget>
           </item>
           <item row="0" column="0" >
@@ -252,16 +252,16 @@
            </widget>
           </item>
           <item row="1" column="0" >
-           <widget class="QLabel" name="widthL" >
+           <widget class="QCheckBox" name="WidthCB" >
             <property name="enabled" >
              <bool>true</bool>
             </property>
+            <property name="toolTip" >
+             <string>Sets width of graphic. Leave unchecked to set automatically.</string>
+            </property>
             <property name="text" >
-             <string>&amp;Width:</string>
+             <string>Set &amp;width:</string>
             </property>
-            <property name="buddy" >
-             <cstring>Width</cstring>
-            </property>
            </widget>
           </item>
           <item row="3" column="1" colspan="2" >
@@ -270,7 +270,7 @@
              <bool>true</bool>
             </property>
             <property name="toolTip" >
-             <string>Maintain aspect ratio with largest dimension</string>
+             <string>Scale image to maximum size not exceeding width and height</string>
             </property>
             <property name="text" >
              <string>&amp;Maintain aspect ratio</string>
@@ -448,7 +448,7 @@
      </widget>
      <widget class="QWidget" name="ExtraOptions" >
       <attribute name="title" >
-       <string>E&amp;xtra options</string>
+       <string>LaTe&amp;X and LyX options</string>
       </attribute>
       <layout class="QGridLayout" >
        <property name="margin" >
@@ -766,8 +766,10 @@
   <tabstop>editPB</tabstop>
   <tabstop>scaleCB</tabstop>
   <tabstop>Scale</tabstop>
+  <tabstop>WidthCB</tabstop>
   <tabstop>Width</tabstop>
   <tabstop>widthUnit</tabstop>
+  <tabstop>HeightCB</tabstop>
   <tabstop>Height</tabstop>
   <tabstop>heightUnit</tabstop>
   <tabstop>aspectratio</tabstop>
@@ -801,53 +803,5 @@
  </includes>
  <resources/>
  <connections>
-  <connection>
-   <sender>aspectratio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>heightL</receiver>
-   <slot>setDisabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>201</x>
-     <y>193</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>81</x>
-     <y>158</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>aspectratio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>Height</receiver>
-   <slot>setDisabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>315</x>
-     <y>193</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>275</x>
-     <y>169</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>aspectratio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>heightUnit</receiver>
-   <slot>setDisabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>337</x>
-     <y>193</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>337</x>
-     <y>167</y>
-    </hint>
-   </hints>
-  </connection>
  </connections>
 </ui>

Reply via email to