>> While you are at it, could you also change the control names:
>> Height -> heightLE
>> widht -> widthLE
>> aspectratio -> aspectratioCB
>
> Maybe we should device a general naming scheme.
>
> As Designer automatically created names look like 'pushButton',
> 'pushButton_2' etc. it is usually the least hassle to keep that
> as prefix.
>
> So this would be
>
> virtual void on_pushButtonGet_clicked();
But this would affect all our ui-files. I think for LyX 1.5 this is too much work and we should
postpone it to LyX 1.6.
Attached is the patch where I renamed Height -> heightED etc. in consistency to
http://www.lyx.org/trac/browser/lyx-devel/trunk/src/frontends/qt4/README
There are muc more UI-fields to rename but I don't want to do this in thins
patch to keep the overview.
Btw. I just saw that Richard updated our element naming scheme to clearify this:
http://www.lyx.org/trac/changeset/17644
@Richard: My last email wasn't clear enough I think. The problem with having the aspectratio also in
LyX's dialog is the following:
Assume you have a 2cm x 4cm image and want to have it in double size. So you would write in the
dialog the values 4cm x 8cm but as the smaller value is taken as border you get as result again 2cm
x4cm image. I hope my comment for the manual points this out.
regards Uwe
Index: lib/doc/EmbeddedObjects.lyx
===================================================================
--- lib/doc/EmbeddedObjects.lyx (revision 17676)
+++ lib/doc/EmbeddedObjects.lyx (working copy)
@@ -405,6 +405,22 @@
button.
The program can be set for every image format in the file format settings
in LyX's preferences.
+\newline
+When you use the option
+\family sans
+Maintain aspect ratio
+\family default
+ the width and heigth will have the same unit and value.
+ For the image treatment the smaller value of width and height will be used
+ as maximum, that means if you have for example an image with the size 10\InsetSpace \thinspace{}
+cmÃ20\InsetSpace \thinspace{}
+cm
+ (widthÃheight) and you specify 10\InsetSpace \thinspace{}
+cmÃ10\InsetSpace \thinspace{}
+cm as size in LyX, the image will
+ have the size 5\InsetSpace \thinspace{}
+cmÃ10\InsetSpace \thinspace{}
+cm in the output.
\end_layout
\begin_layout Description
Index: src/frontends/qt4/QGraphics.C
===================================================================
--- src/frontends/qt4/QGraphics.C (revision 17676)
+++ src/frontends/qt4/QGraphics.C (working copy)
@@ -79,7 +79,6 @@
bcview().addReadOnly(dialog_->filename);
bcview().addReadOnly(dialog_->browsePB);
bcview().addReadOnly(dialog_->unzipCB);
- bcview().addReadOnly(dialog_->filename);
bcview().addReadOnly(dialog_->bbFrame);
bcview().addReadOnly(dialog_->draftCB);
bcview().addReadOnly(dialog_->clip);
@@ -91,8 +90,8 @@
bcview().addReadOnly(dialog_->getPB);
// initialize the length validator
- addCheckedLineEdit(bcview(), dialog_->Width, dialog_->widthL);
- addCheckedLineEdit(bcview(), dialog_->Height, dialog_->heightL);
+ addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthL);
+ addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightL);
addCheckedLineEdit(bcview(), dialog_->displayscale, dialog_->scaleLA);
addCheckedLineEdit(bcview(), dialog_->angle, dialog_->angleL);
addCheckedLineEdit(bcview(), dialog_->lbX, dialog_->xL);
@@ -228,13 +227,13 @@
// the output section (width/height)
dialog_->Scale->setText(toqstr(igp.scale));
- lengthToWidgets(dialog_->Width, dialog_->widthUnit,
+ lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
igp.width.asString(), unitDefault);
- lengthToWidgets(dialog_->Height, dialog_->heightUnit,
+ lengthToWidgets(dialog_->heightED, dialog_->heightUnit,
igp.height.asString(), unitDefault);
- dialog_->aspectratio->setChecked(igp.keepAspectRatio);
+ dialog_->aspectratioCB->setChecked(igp.keepAspectRatio);
dialog_->scaleCB->setChecked(!igp.scale.empty() || igp.width.empty());
@@ -328,11 +327,11 @@
igp.scale = string();
}
- igp.width = LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit));
+ igp.width = LyXLength(widgetsToLength(dialog_->widthED, dialog_->widthUnit));
- igp.height = LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit));
+ igp.height = LyXLength(widgetsToLength(dialog_->heightED, dialog_->heightUnit));
- igp.keepAspectRatio = dialog_->aspectratio->isChecked();
+ igp.keepAspectRatio = dialog_->aspectratioCB->isChecked();
igp.noUnzip = dialog_->unzipCB->isChecked();
Index: src/frontends/qt4/QGraphicsDialog.C
===================================================================
--- src/frontends/qt4/QGraphicsDialog.C (revision 17676)
+++ src/frontends/qt4/QGraphicsDialog.C (working copy)
@@ -69,15 +69,15 @@
this, SLOT( change_adaptor() ) );
connect(displayscale, SIGNAL( textChanged(const QString&) ),
this, SLOT( change_adaptor() ) );
- connect(Width, SIGNAL( textChanged(const QString&) ),
+ connect(widthED, SIGNAL( textChanged(const QString&) ),
this, SLOT( change_adaptor() ) );
- connect(aspectratio, SIGNAL( stateChanged(int) ),
+ connect(aspectratioCB, 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&) ),
+ connect(heightED, SIGNAL( textChanged(const QString&) ),
this, SLOT( change_adaptor() ) );
connect(heightUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
this, SLOT( change_adaptor() ) );
@@ -120,9 +120,12 @@
rtY->setValidator(new QDoubleValidator(rtY));
displayscale->setValidator(new QIntValidator(displayscale));
- Height->setValidator(unsignedLengthValidator(Height));
- Width->setValidator(unsignedLengthValidator(Width));
+ //FIXME We should have a validator for Scale, too.
+ //It would have to inherit from QDoubleValidator
+ heightED->setValidator(unsignedLengthValidator(heightED));
+ widthED->setValidator(unsignedLengthValidator(widthED));
+
filename->setValidator(new PathValidator(true, filename));
setFocusProxy(filename);
}
@@ -182,18 +185,60 @@
editPB->setDisabled(filename.isEmpty());
}
+void QGraphicsDialog::on_heightED_textChanged(const QString &)
+{
+ //when aspectratioCB is checked, the unit of the height is used also for the width
+ //and the height value is used also for the width value
+ if (aspectratioCB->isChecked()) {
+ if (widthUnit->currentIndex() != heightUnit->currentIndex())
+ widthUnit->setCurrentIndex(heightUnit->currentIndex());
+ widthED->setText(heightED->text());
+ }
+}
+void QGraphicsDialog::on_widthED_textChanged(const QString &)
+{
+ //when aspectratioCB is checked, the unit of the width is used also for the height
+ //and the width value is used also for the height value
+ if (aspectratioCB->isChecked()) {
+ if (widthUnit->currentIndex() != heightUnit->currentIndex())
+ heightUnit->setCurrentIndex(widthUnit->currentIndex());
+ heightED->setText(widthED->text());
+ }
+}
+
+void QGraphicsDialog::on_aspectratioCB_toggled()
+{
+ //when aspectratioCB is checked, the unit of the width is used also for the height
+ //and the smaller value (but not zero) of width and height is used for width and height
+ if (aspectratioCB->isChecked()) {
+ int Hvalue = heightED->text().toInt();
+ int Wvalue = widthED->text().toInt();
+ if (widthUnit->currentIndex() != heightUnit->currentIndex())
+ heightUnit->setCurrentIndex(widthUnit->currentIndex());
+ if (Wvalue < Hvalue && Wvalue != 0)
+ heightED->setText(widthED->text());
+ if (Wvalue == 0)
+ widthED->setText(heightED->text());
+ if (Hvalue < Wvalue && Hvalue != 0)
+ widthED->setText(heightED->text());
+ if (Hvalue == 0)
+ heightED->setText(widthED->text());
+ }
+}
+
void QGraphicsDialog::on_scaleCB_toggled(bool setscale)
{
+ if (scaleCB->isChecked() && Scale->text() == "")
+ Scale->setText("100");
Scale->setEnabled(setscale);
widthL->setDisabled(setscale);
- Width->setDisabled(setscale);
+ widthED->setDisabled(setscale);
widthUnit->setDisabled(setscale);
- aspectratio->setDisabled(setscale);
- bool noheight = setscale || aspectratio->checkState()==Qt::Checked;
- heightL->setDisabled(noheight);
- Height->setDisabled(noheight);
- heightUnit->setDisabled(noheight);
+ aspectratioCB->setDisabled(setscale);
+ heightL->setDisabled(setscale);
+ heightED->setDisabled(setscale);
+ heightUnit->setDisabled(setscale);
}
} // namespace frontend
Index: src/frontends/qt4/QGraphicsDialog.h
===================================================================
--- src/frontends/qt4/QGraphicsDialog.h (revision 17676)
+++ src/frontends/qt4/QGraphicsDialog.h (working copy)
@@ -37,6 +37,9 @@
virtual void on_getPB_clicked();
virtual void on_editPB_clicked();
virtual void on_filename_textChanged(const QString &);
+ virtual void on_heightED_textChanged(const QString &);
+ virtual void on_widthED_textChanged(const QString &);
+ virtual void on_aspectratioCB_toggled();
virtual void on_scaleCB_toggled(bool);
protected:
virtual void closeEvent(QCloseEvent * e);
Index: src/frontends/qt4/ui/QGraphicsUi.ui
===================================================================
--- src/frontends/qt4/ui/QGraphicsUi.ui (revision 17676)
+++ src/frontends/qt4/ui/QGraphicsUi.ui (working copy)
@@ -232,19 +232,6 @@
</item>
</layout>
</widget>
- <widget class="QLineEdit" name="filename" >
- <property name="geometry" >
- <rect>
- <x>35</x>
- <y>12</y>
- <width>235</width>
- <height>18</height>
- </rect>
- </property>
- <property name="toolTip" >
- <string>File name of image</string>
- </property>
- </widget>
<widget class="QGroupBox" name="sizeGB" >
<property name="geometry" >
<rect>
@@ -274,7 +261,7 @@
<widget class="LengthCombo" name="heightUnit" />
</item>
<item row="1" column="1" >
- <widget class="QLineEdit" name="Width" >
+ <widget class="QLineEdit" name="widthED" >
<property name="enabled" >
<bool>true</bool>
</property>
@@ -308,7 +295,7 @@
<widget class="QLineEdit" name="Scale" />
</item>
<item row="2" column="1" >
- <widget class="QLineEdit" name="Height" >
+ <widget class="QLineEdit" name="heightED" >
<property name="enabled" >
<bool>true</bool>
</property>
@@ -334,7 +321,7 @@
<string>&Height:</string>
</property>
<property name="buddy" >
- <cstring>Height</cstring>
+ <cstring>heightED</cstring>
</property>
</widget>
</item>
@@ -354,12 +341,12 @@
<string>&Width:</string>
</property>
<property name="buddy" >
- <cstring>Width</cstring>
+ <cstring>widthED</cstring>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
- <widget class="QCheckBox" name="aspectratio" >
+ <widget class="QCheckBox" name="aspectratioCB" >
<property name="enabled" >
<bool>true</bool>
</property>
@@ -408,6 +395,19 @@
<bool>false</bool>
</property>
</widget>
+ <widget class="QLineEdit" name="filename" >
+ <property name="geometry" >
+ <rect>
+ <x>35</x>
+ <y>12</y>
+ <width>235</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="toolTip" >
+ <string>File name of image</string>
+ </property>
+ </widget>
</widget>
<widget class="QWidget" name="Clipping" >
<attribute name="title" >
@@ -800,11 +800,11 @@
<tabstop>editPB</tabstop>
<tabstop>scaleCB</tabstop>
<tabstop>Scale</tabstop>
- <tabstop>Width</tabstop>
+ <tabstop>widthED</tabstop>
<tabstop>widthUnit</tabstop>
- <tabstop>Height</tabstop>
+ <tabstop>heightED</tabstop>
<tabstop>heightUnit</tabstop>
- <tabstop>aspectratio</tabstop>
+ <tabstop>aspectratioCB</tabstop>
<tabstop>angle</tabstop>
<tabstop>origin</tabstop>
<tabstop>restorePB</tabstop>
@@ -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>