From: Juergen Spitzmueller Date: Sun, 4 Jan 2015 09:05:42 +0000 (+0100) Subject: Fix aspectratio UI X-Git-Tag: 2.2.0alpha1~1390 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3cd1d396ff37a1f1d93be5348b531757107e2560;p=features.git Fix aspectratio UI Fixes: #9357 --- diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index 3bc7b943be..04f768567f 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -127,8 +127,12 @@ GuiGraphics::GuiGraphics(GuiView & lv) this, SLOT(change_adaptor())); connect(HeightCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(Width, SIGNAL(textChanged(const QString &)), + this, SLOT(updateAspectRatioStatus())); connect(Width, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); + connect(Height, SIGNAL(textChanged(const QString &)), + this, SLOT(updateAspectRatioStatus())); connect(Height, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), @@ -399,15 +403,13 @@ void GuiGraphics::on_scaleCB_toggled(bool setScale) Height->setEnabled(false); heightUnit->setEnabled(false); - aspectratio->setDisabled(true); - aspectratio->setChecked(true); - rotateOrderCB->setEnabled((WidthCB->isChecked() || HeightCB->isChecked() || scaleCB->isChecked()) && (angle->text() != "0")); setAutoText(); + updateAspectRatioStatus(); } @@ -419,11 +421,6 @@ void GuiGraphics::on_WidthCB_toggled(bool 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() @@ -433,6 +430,7 @@ void GuiGraphics::on_WidthCB_toggled(bool setWidth) (angle->text() != "0")); setAutoText(); + updateAspectRatioStatus(); } @@ -444,11 +442,6 @@ void GuiGraphics::on_HeightCB_toggled(bool 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() @@ -458,6 +451,41 @@ void GuiGraphics::on_HeightCB_toggled(bool setHeight) (angle->text() != "0")); setAutoText(); + updateAspectRatioStatus(); +} + + +void GuiGraphics::updateAspectRatioStatus() +{ + // keepaspectratio only makes sense if both a width _and_ a + // height are given, since its function is (see graphics manual): + // "If set to true then specifying both 'width' and 'height' + // (or 'totalheight') does not distort the figure but scales + // such that neither of the specified dimensions is _exceeded_." + aspectratio->setEnabled( + WidthCB->isChecked() && !Width->text().isEmpty() + && Width->text() != qt_(autostr) + && HeightCB->isChecked() && !Height->text().isEmpty() + && Height->text() != qt_(autostr) + ); + if (!aspectratio->isEnabled()) + aspectratio->setChecked(false); +} + + +void GuiGraphics::on_aspectratio_toggled(bool aspectratio) +{ + if (aspectratio) { + WidthCB->setText(qt_("Set max. &width:")); + HeightCB->setText(qt_("Set max. &height:")); + Width->setToolTip(qt_("Maximal width of image in output")); + Height->setToolTip(qt_("Maximal height of image in output")); + } else { + WidthCB->setText(qt_("Set &width:")); + HeightCB->setText(qt_("Set &height:")); + Width->setToolTip(qt_("Width of image in output")); + Height->setToolTip(qt_("Height of image in output")); + } } @@ -614,9 +642,9 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp) scaleCB->setEnabled(!widthChecked && !heightChecked); WidthCB->setEnabled(!scaleChecked); HeightCB->setEnabled(!scaleChecked); - aspectratio->setEnabled(widthChecked && heightChecked); setAutoText(); + updateAspectRatioStatus(); doubleToWidget(angle, igp.rotateAngle); rotateOrderCB->setChecked(igp.scaleBeforeRotation); @@ -701,9 +729,7 @@ void GuiGraphics::applyView() igp.height = HeightCB->isChecked() ? Length(widgetsToLength(Height, heightUnit)) : Length("0pt"); - igp.keepAspectRatio = aspectratio->isEnabled() && - aspectratio->isChecked() && - igp.width.value() > 0 && igp.height.value() > 0; + igp.keepAspectRatio = aspectratio->isChecked(); } igp.noUnzip = unzipCB->isChecked(); diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h index 7d32ce26d6..6446949daf 100644 --- a/src/frontends/qt4/GuiGraphics.h +++ b/src/frontends/qt4/GuiGraphics.h @@ -46,6 +46,8 @@ private Q_SLOTS: void on_scaleCB_toggled(bool); void on_WidthCB_toggled(bool); void on_HeightCB_toggled(bool); + void updateAspectRatioStatus(); + void on_aspectratio_toggled(bool); void on_angle_textChanged(const QString &); private: