Attached is what is hopefully the penultimate version of this patch.
Please note that the diff was run from src/frontends/qt4/.

The changes at the beginning of QGraphicsDialog.C are less extensive
than they appear. I had to re-arrange this so I could make sense of it.
The only real changes are added connections for the new width and height
checkboxes and the aspectratio checkbox, and adding a validator for the
Scale field. And the changes to MarginsUi.ui are not so extensive
either, though QtDesigner seems to save the XML in a pretty random
order, so it's hard to see that. As Enrico pointed out, there is
something wrong with this file that is causing the dialog not to report
a preferred size. We'll get that fixed before final update.

There is some duplication of code. But the only sensible way around that
involves more work than it seems wise to do right now.

Someone had earlier suggested cleaning up some of the naming-scheme
stuff here. I'll do that after this is done, substantively speaking.

Associated changes to documentation are done but will be sent separately.

Comments welcome. It'd also be helpful if I could get testing on other
platforms. I'm on Linux myself with QT 4.2.3.

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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ 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 17710)
+++ ui/QGraphicsUi.ui	(working copy)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>467</width>
-    <height>347</height>
+    <width>505</width>
+    <height>344</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -28,8 +28,8 @@
     <rect>
      <x>10</x>
      <y>310</y>
-     <width>441</width>
-     <height>27</height>
+     <width>481</width>
+     <height>31</height>
     </rect>
    </property>
    <layout class="QHBoxLayout" >
@@ -127,7 +127,7 @@
     <rect>
      <x>9</x>
      <y>9</y>
-     <width>449</width>
+     <width>482</width>
      <height>296</height>
     </rect>
    </property>
@@ -141,101 +141,45 @@
     <attribute name="title" >
      <string>&amp;Graphics</string>
     </attribute>
-    <widget class="QLabel" name="filenameL" >
+    <widget class="QPushButton" name="browsePB" >
      <property name="geometry" >
       <rect>
-       <x>9</x>
-       <y>9</y>
-       <width>20</width>
-       <height>25</height>
+       <x>306</x>
+       <y>10</y>
+       <width>75</width>
+       <height>23</height>
       </rect>
      </property>
      <property name="toolTip" >
-      <string>File name of image</string>
+      <string>Select an image file</string>
      </property>
      <property name="text" >
-      <string>&amp;File:</string>
+      <string>&amp;Browse...</string>
      </property>
-     <property name="buddy" >
-      <cstring>filename</cstring>
-     </property>
     </widget>
-    <widget class="QGroupBox" name="rotationGB" >
+    <widget class="QPushButton" name="editPB" >
      <property name="geometry" >
       <rect>
-       <x>35</x>
-       <y>178</y>
-       <width>399</width>
-       <height>82</height>
+       <x>387</x>
+       <y>10</y>
+       <width>75</width>
+       <height>23</height>
       </rect>
      </property>
-     <property name="title" >
-      <string>Rotate Graphics</string>
+     <property name="text" >
+      <string>&amp;Edit</string>
      </property>
-     <property name="flat" >
-      <bool>true</bool>
+     <property name="autoDefault" >
+      <bool>false</bool>
      </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>9</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="angleL" >
-        <property name="toolTip" >
-         <string>Angle to rotate image by</string>
-        </property>
-        <property name="text" >
-         <string>A&amp;ngle (Degrees):</string>
-        </property>
-        <property name="buddy" >
-         <cstring>angle</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1" >
-       <widget class="QLineEdit" name="angle" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>3</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="toolTip" >
-         <string>Angle to rotate image by</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="2" >
-       <widget class="QLabel" name="originL" >
-        <property name="toolTip" >
-         <string>The origin of the rotation</string>
-        </property>
-        <property name="text" >
-         <string>Or&amp;igin:</string>
-        </property>
-        <property name="buddy" >
-         <cstring>origin</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="3" >
-       <widget class="QComboBox" name="origin" >
-        <property name="toolTip" >
-         <string>The origin of the rotation</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
+     <property name="default" >
+      <bool>false</bool>
+     </property>
     </widget>
     <widget class="QLineEdit" name="filename" >
      <property name="geometry" >
       <rect>
-       <x>35</x>
+       <x>59</x>
        <y>12</y>
        <width>235</width>
        <height>18</height>
@@ -245,12 +189,31 @@
       <string>File name of image</string>
      </property>
     </widget>
+    <widget class="QLabel" name="filenameL" >
+     <property name="geometry" >
+      <rect>
+       <x>9</x>
+       <y>9</y>
+       <width>41</width>
+       <height>25</height>
+      </rect>
+     </property>
+     <property name="toolTip" >
+      <string>File name of image</string>
+     </property>
+     <property name="text" >
+      <string>&amp;File:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>filename</cstring>
+     </property>
+    </widget>
     <widget class="QGroupBox" name="sizeGB" >
      <property name="geometry" >
       <rect>
-       <x>35</x>
+       <x>15</x>
        <y>40</y>
-       <width>399</width>
+       <width>457</width>
        <height>132</height>
       </rect>
      </property>
@@ -326,16 +289,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>Leave unchecked to set height automatically</string>
+        </property>
         <property name="text" >
-         <string>&amp;Height:</string>
+         <string>&amp;Set height:</string>
         </property>
-        <property name="buddy" >
-         <cstring>Height</cstring>
-        </property>
        </widget>
       </item>
       <item row="0" column="0" >
@@ -346,16 +309,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>Leave unchecked to set width automatically</string>
+        </property>
         <property name="text" >
-         <string>&amp;Width:</string>
+         <string>&amp;Set width:</string>
         </property>
-        <property name="buddy" >
-         <cstring>Width</cstring>
-        </property>
        </widget>
       </item>
       <item row="3" column="1" colspan="2" >
@@ -373,41 +336,78 @@
       </item>
      </layout>
     </widget>
-    <widget class="QPushButton" name="browsePB" >
+    <widget class="QGroupBox" name="rotationGB" >
      <property name="geometry" >
       <rect>
-       <x>277</x>
-       <y>10</y>
-       <width>75</width>
-       <height>23</height>
+       <x>15</x>
+       <y>178</y>
+       <width>457</width>
+       <height>82</height>
       </rect>
      </property>
-     <property name="toolTip" >
-      <string>Select an image file</string>
+     <property name="title" >
+      <string>Rotate Graphics</string>
      </property>
-     <property name="text" >
-      <string>&amp;Browse...</string>
+     <property name="flat" >
+      <bool>true</bool>
      </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="angleL" >
+        <property name="toolTip" >
+         <string>Angle to rotate image by</string>
+        </property>
+        <property name="text" >
+         <string>A&amp;ngle (Degrees):</string>
+        </property>
+        <property name="buddy" >
+         <cstring>angle</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QLineEdit" name="angle" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>3</hsizetype>
+          <vsizetype>0</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="toolTip" >
+         <string>Angle to rotate image by</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" >
+       <widget class="QLabel" name="originL" >
+        <property name="toolTip" >
+         <string>The origin of the rotation</string>
+        </property>
+        <property name="text" >
+         <string>Or&amp;igin:</string>
+        </property>
+        <property name="buddy" >
+         <cstring>origin</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3" >
+       <widget class="QComboBox" name="origin" >
+        <property name="toolTip" >
+         <string>The origin of the rotation</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
-    <widget class="QPushButton" name="editPB" >
-     <property name="geometry" >
-      <rect>
-       <x>358</x>
-       <y>10</y>
-       <width>75</width>
-       <height>23</height>
-      </rect>
-     </property>
-     <property name="text" >
-      <string>&amp;Edit</string>
-     </property>
-     <property name="autoDefault" >
-      <bool>false</bool>
-     </property>
-     <property name="default" >
-      <bool>false</bool>
-     </property>
-    </widget>
    </widget>
    <widget class="QWidget" name="Clipping" >
     <attribute name="title" >
@@ -834,54 +834,5 @@
   <include location="local" >qt_helpers.h</include>
  </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>
+ <connections/>
 </ui>

Reply via email to