mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 15:01:58 +00:00
* GuiExternal.{cpp,h}:
* ExternalUi.ui: - use LengthCombo for width unit. - use reliable item data, instead of doing manual recounts. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28164 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
82883a05f4
commit
5707a39041
@ -203,16 +203,14 @@ GuiExternal::GuiExternal(GuiView & lv)
|
||||
for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
|
||||
originCO->addItem(qt_(origin_gui_strs[i]));
|
||||
|
||||
// Fill the width combo
|
||||
widthUnitCO->addItem(qt_("Scale%"));
|
||||
for (int i = 0; i < num_units; i++)
|
||||
widthUnitCO->addItem(qt_(unit_name_gui[i]));
|
||||
// add scale item
|
||||
widthUnitCO->insertItem(0, qt_("Scale%"), "scale");
|
||||
}
|
||||
|
||||
|
||||
bool GuiExternal::activateAspectratio() const
|
||||
{
|
||||
if (widthUnitCO->currentIndex() == 0)
|
||||
if (usingScale())
|
||||
return false;
|
||||
|
||||
string const wstr = fromqstr(widthED->text());
|
||||
@ -238,6 +236,13 @@ bool GuiExternal::activateAspectratio() const
|
||||
}
|
||||
|
||||
|
||||
bool GuiExternal::usingScale() const
|
||||
{
|
||||
return (widthUnitCO->itemData(
|
||||
widthUnitCO->currentIndex()).toString() == "scale");
|
||||
}
|
||||
|
||||
|
||||
void GuiExternal::bbChanged()
|
||||
{
|
||||
bbChanged_ = true;
|
||||
@ -333,15 +338,13 @@ void GuiExternal::templateChanged()
|
||||
|
||||
void GuiExternal::widthUnitChanged()
|
||||
{
|
||||
bool useHeight = (widthUnitCO->currentIndex() > 0);
|
||||
|
||||
if (useHeight)
|
||||
widthED->setValidator(unsignedLengthValidator(widthED));
|
||||
else
|
||||
if (usingScale())
|
||||
widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
|
||||
else
|
||||
widthED->setValidator(unsignedLengthValidator(widthED));
|
||||
|
||||
heightED->setEnabled(useHeight);
|
||||
heightUnitCO->setEnabled(useHeight);
|
||||
heightED->setEnabled(!usingScale());
|
||||
heightUnitCO->setEnabled(!usingScale());
|
||||
changed();
|
||||
}
|
||||
|
||||
@ -380,7 +383,7 @@ static void getRotation(external::RotationData & data,
|
||||
}
|
||||
|
||||
|
||||
static void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
|
||||
static void setSize(QLineEdit & widthED, LengthCombo & widthUnitCO,
|
||||
QLineEdit & heightED, LengthCombo & heightUnitCO,
|
||||
QCheckBox & aspectratioCB,
|
||||
external::ResizeData const & data)
|
||||
@ -395,14 +398,10 @@ static void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
|
||||
|
||||
if (using_scale) {
|
||||
widthED.setText(toqstr(scale));
|
||||
widthUnitCO.setCurrentIndex(0);
|
||||
} else {
|
||||
widthED.setText(QString::number(data.width.value()));
|
||||
// Because 'Scale' is position 0...
|
||||
// Note also that width cannot be zero here, so
|
||||
// we don't need to worry about the default unit.
|
||||
widthUnitCO.setCurrentIndex(data.width.unit() + 1);
|
||||
}
|
||||
widthUnitCO.setCurrentItem("scale");
|
||||
} else
|
||||
lengthToWidgets(&widthED, &widthUnitCO,
|
||||
data.width.asString(), defaultUnit());
|
||||
|
||||
string const h = data.height.zero() ? string() : data.height.asString();
|
||||
Length::UNIT default_unit = data.width.zero() ?
|
||||
@ -423,33 +422,19 @@ static void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
|
||||
static void getSize(external::ResizeData & data,
|
||||
QLineEdit const & widthED, QComboBox const & widthUnitCO,
|
||||
QLineEdit const & heightED, LengthCombo const & heightUnitCO,
|
||||
QCheckBox const & aspectratioCB)
|
||||
QCheckBox const & aspectratioCB, bool const scaling)
|
||||
{
|
||||
string const width = fromqstr(widthED.text());
|
||||
|
||||
if (widthUnitCO.currentIndex() > 0) {
|
||||
// Subtract one, because scale is 0.
|
||||
int const unit = widthUnitCO.currentIndex() - 1;
|
||||
|
||||
Length w;
|
||||
if (isValidLength(width, &w))
|
||||
data.width = w;
|
||||
else if (isStrDbl(width))
|
||||
data.width = Length(convert<double>(width),
|
||||
static_cast<Length::UNIT>(unit));
|
||||
else
|
||||
data.width = Length();
|
||||
|
||||
data.scale = string();
|
||||
|
||||
} else {
|
||||
if (scaling) {
|
||||
// scaling instead of a width
|
||||
data.scale = width;
|
||||
data.width = Length();
|
||||
} else {
|
||||
data.width = Length(widgetsToLength(&widthED, &widthUnitCO));
|
||||
data.scale = string();
|
||||
}
|
||||
|
||||
data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
|
||||
|
||||
data.keepAspectRatio = aspectratioCB.isChecked();
|
||||
}
|
||||
|
||||
@ -488,8 +473,6 @@ static void getCrop(external::ClipData & data,
|
||||
|
||||
void GuiExternal::updateContents()
|
||||
{
|
||||
tab->setCurrentIndex(0);
|
||||
|
||||
string const name =
|
||||
params_.filename.outputFilename(fromqstr(bufferFilepath()));
|
||||
fileED->setText(toqstr(name));
|
||||
@ -613,7 +596,7 @@ void GuiExternal::applyView()
|
||||
|
||||
if (scaleGB->isEnabled())
|
||||
getSize(params_.resizedata, *widthED, *widthUnitCO,
|
||||
*heightED, *heightUnitCO, *aspectratioCB);
|
||||
*heightED, *heightUnitCO, *aspectratioCB, usingScale());
|
||||
|
||||
if (cropGB->isEnabled())
|
||||
getCrop(params_.clipdata, *clipCB, *xlED, *ybED,
|
||||
|
@ -54,6 +54,8 @@ private:
|
||||
void updateContents();
|
||||
/// Helper function called when the template is changed.
|
||||
void updateTemplate();
|
||||
///
|
||||
bool usingScale() const;
|
||||
|
||||
///
|
||||
bool initialiseParams(std::string const & data);
|
||||
|
@ -28,17 +28,9 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="filetab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>F&ile</string>
|
||||
</attribute>
|
||||
@ -109,7 +101,7 @@
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -120,7 +112,9 @@
|
||||
<item row="0" column="0" >
|
||||
<widget class="QComboBox" name="externalCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -136,18 +130,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="lyxviewtab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>LaTe&X and LyX options</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="optionsGB" >
|
||||
<property name="title" >
|
||||
@ -214,7 +206,13 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<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="scaleLA" >
|
||||
<property name="toolTip" >
|
||||
@ -234,7 +232,9 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -245,11 +245,11 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<spacer name="horizontalSpacer" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
@ -265,7 +265,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>196</height>
|
||||
@ -276,14 +276,6 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="sizetab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>Si&ze and Rotation</string>
|
||||
</attribute>
|
||||
@ -317,7 +309,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -336,7 +328,9 @@ p, li { white-space: pre-wrap; }
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="angleED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -406,7 +400,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="LengthCombo" name="heightUnitCO" />
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="widthUnitCO" />
|
||||
<widget class="LengthCombo" name="widthUnitCO" />
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="heightED" >
|
||||
@ -547,7 +541,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>43</width>
|
||||
<height>18</height>
|
||||
@ -577,12 +571,12 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
@ -591,7 +585,7 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -635,8 +629,6 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>tab</zorder>
|
||||
<zorder>displayscaleLA</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user